Merge branch 'develop'

This commit is contained in:
snipe 2017-10-18 01:23:01 -07:00
commit b846bb20c6
17 changed files with 183 additions and 107 deletions

View file

@ -97,7 +97,8 @@ LOGIN_LOCKOUT_DURATION=60
# --------------------------------------------
# OPTIONAL: MISC
# --------------------------------------------
APP_LOG=single
APP_LOG=daily
APP_LOG_MAX_FILES=10
APP_LOCKED=false
FILESYSTEM_DISK=local
APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1

View file

@ -146,39 +146,40 @@ class AssetsController extends Controller
$assets->withTrashed()->Deleted();
break;
case 'Pending':
$assets->join('status_labels',function ($join) {
$join->on('status_labels.id', "=", "assets.status_id")
->where('status_labels.deployable','=',0)
->where('status_labels.pending','=',1)
->where('status_labels.archived', '=', 0);
$assets->join('status_labels AS status_alias',function ($join) {
$join->on('status_alias.id', "=", "assets.status_id")
->where('status_alias.deployable','=',0)
->where('status_alias.pending','=',1)
->where('status_alias.archived', '=', 0);
});
break;
case 'RTD':
$assets->join('status_labels',function ($join) {
$join->on('status_labels.id', "=", "assets.status_id")
->where('status_labels.deployable','=',1)
->where('status_labels.pending','=',0)
->where('status_labels.archived', '=', 0);
$assets->whereNull('assets.assigned_to')
->join('status_labels AS status_alias',function ($join) {
$join->on('status_alias.id', "=", "assets.status_id")
->where('status_alias.deployable','=',1)
->where('status_alias.pending','=',0)
->where('status_alias.archived', '=', 0);
});
break;
case 'Undeployable':
$assets->Undeployable();
break;
case 'Archived':
$assets->join('status_labels',function ($join) {
$join->on('status_labels.id', "=", "assets.status_id")
->where('status_labels.deployable','=',0)
->where('status_labels.pending','=',0)
->where('status_labels.archived', '=', 1);
$assets->join('status_labels AS status_alias',function ($join) {
$join->on('status_alias.id', "=", "assets.status_id")
->where('status_alias.deployable','=',0)
->where('status_alias.pending','=',0)
->where('status_alias.archived', '=', 1);
});
break;
case 'Requestable':
$assets->where('assets.requestable', '=', 1)
->join('status_labels',function ($join) {
$join->on('status_labels.id', "=", "assets.status_id")
->where('status_labels.deployable','=',1)
->where('status_labels.pending','=',0)
->where('status_labels.archived', '=', 0);
->join('status_labels AS status_alias',function ($join) {
$join->on('status_alias.id', "=", "assets.status_id")
->where('status_alias.deployable','=',1)
->where('status_alias.pending','=',0)
->where('status_alias.archived', '=', 0);
});
break;
@ -188,9 +189,9 @@ class AssetsController extends Controller
break;
default:
// terrible workaround for complex-query Laravel bug in fulltext
$assets->join('status_labels',function ($join) {
$join->on('status_labels.id', "=", "assets.status_id")
->where('status_labels.archived', '=', 0);
$assets->join('status_labels AS status_alias',function ($join) {
$join->on('status_alias.id', "=", "assets.status_id")
->where('status_alias.archived', '=', 0);
});
}

View file

@ -57,7 +57,6 @@ class UsersController extends Controller
$users = $users->GetDeleted();
}
if ($request->has('company_id')) {
$users = $users->where('company_id', '=', $request->input('company_id'));
}
@ -65,6 +64,10 @@ class UsersController extends Controller
if ($request->has('location_id')) {
$users = $users->where('location_id', '=', $request->input('location_id'));
}
if ($request->has('group_id')) {
$users = $users->ByGroup($request->has('group_id'));
}
if ($request->has('department_id')) {
$users = $users->where('department_id','=',$request->input('department_id'));

View file

@ -87,10 +87,15 @@ class GroupsController extends Controller
public function edit($id = null)
{
$group = Group::find($id);
$permissions = config('permissions');
$groupPermissions = $group->decodePermissions();
$selected_array = Helper::selectedPermissionsArray($permissions, $groupPermissions);
return view('groups.edit', compact('group', 'permissions', 'selected_array', 'groupPermissions'));
if ($group) {
$permissions = config('permissions');
$groupPermissions = $group->decodePermissions();
$selected_array = Helper::selectedPermissionsArray($permissions, $groupPermissions);
return view('groups.edit', compact('group', 'permissions', 'selected_array', 'groupPermissions'));
}
return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', compact('id')));
}
/**
@ -142,4 +147,24 @@ class GroupsController extends Controller
return redirect()->route('groups.index')->with('error', trans('general.feature_disabled'));
}
/**
* Returns a view that invokes the ajax tables which actually contains
* the content for the group detail page.
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $locationId
* @since [v4.0.11]
* @return \Illuminate\Contracts\View\View
*/
public function show($id)
{
$group = Group::find($id);
if ($group) {
return view('groups/view', compact('group'));
}
return redirect()->route('groups.index')->with('error', trans('admin/groups/message.group_not_found', compact('id')));
}
}

View file

@ -781,14 +781,11 @@ class Asset extends Depreciable
$query->where('locations.name', 'LIKE', '%'.$search.'%');
});
})->orWhere(function ($query) use ($search) {
$query->whereHas('assignedTo', function ($query) use ($search) {
$query->where('users.first_name', 'LIKE', '%'.$search.'%')
->orWhere('users.last_name', 'LIKE', '%'.$search.'%')
->orWhere('users.username', 'LIKE', '%'.$search.'%')
->orWhere('locations.name', 'LIKE', '%'.$search.'%')
->orWhere('assigned_assets.name', 'LIKE', '%'.$search.'%');
});
})->orWhere('assets.name', 'LIKE', '%'.$search.'%')
->orWhere('assets.asset_tag', 'LIKE', '%'.$search.'%')
->orWhere('assets.serial', 'LIKE', '%'.$search.'%')

View file

@ -378,6 +378,14 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
return json_decode($this->permissions, true);
}
public function scopeByGroup($query, $id) {
return $query->whereHas('groups', function ($query) use ($id) {
$query->where('id', '=', $id);
});
}
/**
* Query builder scope to search on text
*

View file

@ -98,8 +98,8 @@ class AppServiceProvider extends ServiceProvider
if (config('app.debug')) {
$log_level = 'debug';
} else {
if (config('log-level')) {
$log_level = config('log-level');
if (config('app.log_level')) {
$log_level = config('app.log_level');
} else {
$log_level = 'error';
}

View file

@ -121,8 +121,41 @@ return [
|
*/
'log' => env('APP_LOG', 'single'),
'log-level' => env('APP_LOG_LEVEL', 'error'),
'log' => env('APP_LOG', 'daily'),
/*
|--------------------------------------------------------------------------
| Logging Max Files
|--------------------------------------------------------------------------
|
| When using the daily log mode, Laravel will only retain 5
| days of log files by default.
|
| To change this, set the APP_LOG_MAX_FILES option in your .env.
|
*/
'log_max_files' => env('APP_LOG_MAX_FILES', 5),
/*
|--------------------------------------------------------------------------
| Logging Detail
|--------------------------------------------------------------------------
|
| By default, Laravel writes all log levels to storage. However, in your
| production environment, you may wish to configure the minimum severity that
| should be logged by editing your APP_LOG_LEVEL env config.
|
| Laravel will log all levels greater than or equal to the specified severity.
| For example, a default log_level of error will log error, critical, alert,
| and emergency messages.
|
| APP_LOG_LEVEL options are:
| "debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"
|
*/
'log_level' => env('APP_LOG_LEVEL', 'error'),
/*

View file

@ -1,7 +1,7 @@
<?php
return array (
'app_version' => 'v4.0.11',
'build_version' => '264',
'hash_version' => 'gc776fa4',
'full_hash' => 'v4.0.11-264-gc776fa4',
'app_version' => 'v4.0.12',
'build_version' => '272',
'hash_version' => 'gea63ced',
'full_hash' => 'v4.0.12-272-gea63ced',
);

View file

@ -60,7 +60,9 @@
<td><a href="{{ $asset->present()->viewUrl() }}">{{ $asset->serial }}</a></td>
<td>
{!! $asset->assetLoc->present()->nameUrl() !!}
@if ($asset->assetloc)
{!! $asset->assetloc->present()->nameUrl() !!}
@endif
</td>
@if ($asset->assigned_to != '' && $asset->assigned_to > 0)
<td>Checked out</td>

View file

@ -230,7 +230,7 @@ View Assets for {{ $user->present()->fullName() }}
id="table"
data-cookie="false"
data-cookie-id-table="userHistoryTable-{{ config('version.hash_version') }}"
data-url="{{route('api.activity.index', ['user_id' => $user->id, 'order' => 'desc']) }}">
data-url="{{route('api.activity.index', ['target_id' => $user->id, 'target_type' => 'User', 'order' => 'desc']) }}">
<thead>
<tr>
<th data-field="icon" style="width: 40px;" class="hidden-xs" data-formatter="iconFormatter"></th>

View file

@ -31,7 +31,7 @@
<thead>
<tr>
<th data-switchable="true" data-sortable="false" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
<th data-switchable="true" data-sortable="true" data-field="name" data-visible="true">{{ trans('admin/groups/table.name') }}</th>
<th data-switchable="true" data-sortable="true" data-field="name" data-formatter="groupsAdminLinkFormatter" data-visible="true">{{ trans('admin/groups/table.name') }}</th>
<th data-switchable="true" data-sortable="false" data-field="users_count" data-visible="true">{{ trans('admin/groups/table.users') }}</th>
<th data-switchable="true" data-sortable="true" data-field="created_at" data-visible="true" data-formatter="dateDisplayFormatter">{{ trans('general.created_at') }}</th>
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="actions" data-formatter="groupsActionsFormatter">{{ trans('table.actions') }}</th>

View file

@ -2,56 +2,63 @@
{{-- Page title --}}
@section('title')
{{ trans('admin/groups/table.view') }} -
{{ $group->name }}
@parent
{{ $group->name }}
@parent
@stop
@section('header_right')
<a href="{{ route('groups.edit', ['group' => $group->id]) }}" class="btn btn-sm btn-primary pull-right">{{ trans('admin/groups/titles.update') }} </a>
<a href="{{ route('groups.index') }}" class="btn btn-default pull-right">{{ trans('general.back') }}</a>
@stop
{{-- Page content --}}
@section('content')
<div class="row header">
<div class="col-md-12">
<a href="{{ route('update/group', $group->id) }}" class="btn-flat white pull-right">
{{ trans('admin/groups/table.update') }}
</a>
<a href="{{ url('admin/groups') }}" class="btn-flat gray pull-right" style="margin-right:5px;">
<i class="fa fa-arrow-left icon-white"></i> {{ trans('general.back') }}
</a>
<h3 class="name"> {{ trans('admin/groups/titles.group_management') }} - {{ $group->name }}</h3>
</div>
</div>
<div class="row">
<div class="col-md-9">
<div class="box box-default">
<div class="box-body">
<div class="row">
<div class="col-md-12">
<div class="table table-responsive">
<table
name="groups_users"
id="table-users"
class="table table-striped snipe-table"
data-url="{{ route('api.users.index',['group_id'=> $group->id]) }}"
data-cookie="true"
data-click-to-select="true"
data-cookie-id-table="groups_usersDetailTable">
<thead>
<div class="user-profile">
<div class="row profile">
<div class="col-md-12 bio">
@if (count($users) > 0)
<table id="example">
<thead>
<tr role="row">
<th class="col-md-3">{{ trans('admin/groups/table.name') }}</th>
</tr>
</thead>
<tbody>
@foreach ($users as $user)
<tr>
<td>
<a href="{{ route('users.show', $user->id) }}">{{ $user->first_name }} {{ $user->last_name }}</a>
</td>
</tr>
@endforeach
</tbody>
</table>
@else
<div class="col-md-12">
<div class="alert alert-info alert-block">
<i class="fa fa-info-circle"></i>
{{ trans('general.no_results') }}
</table>
</div>
</div>
</div>
</div>
</div>
@endif
</div>
</div> <!--.col-md-12-->
</div> <!--.user-profile-->
<div class="col-md-3">
<ul class="list-unstyled">
@foreach ($group->decodePermissions() as $permission_name => $permission)
<li>{!! ($permission == '1') ? '<i class="fa fa-check text-success"></i>' : '<i class="fa fa-times text-danger"></i>' !!} {{ e(str_replace('.', ': ', ucwords($permission_name))) }} </li>
@endforeach
</ul>
</div>
</div>
@stop
@section('moar_scripts')
@include ('partials.bootstrap-table', [
'exportFile' => 'groups-export',
'search' => true,
'columns' => \App\Presenters\UserPresenter::dataTableLayout()
])
@stop

View file

@ -332,6 +332,21 @@ $('.snipe-table').bootstrapTable({
}
}
function groupsFormatter(value) {
if (value) {
var groups = '';
for (var index in value.rows) {
groups += '<a href="{{ url('/') }}/admin/groups/' + value.rows[index].id + '" class="label label-default"> ' + value.rows[index].name + '</a> ';
}
return groups;
}
}
function groupsAdminLinkFormatter(value, row) {
return '<a href="{{ url('/') }}/admin/groups/' + row.id + '"> ' + value + '</a>';
}
function trueFalseFormatter(value, row) {
if ((value) && ((value == 'true') || (value == '1'))) {
return '<i class="fa fa-check text-success"></i>';

View file

@ -86,20 +86,5 @@
'columns' => \App\Presenters\UserPresenter::dataTableLayout()
])
<script nonce="{{ csrf_token() }}">
function groupsFormatter(value) {
if (value) {
var groups = '';
for (var index in value.rows) {
groups += '<a href="#" class="label label-default"> ' + value.rows[index].name + '</a> ';
}
return groups;
}
}
</script>
@stop

View file

@ -536,7 +536,6 @@ $(function () {
$('.progress-checkmark').fadeIn('fast').html('<i class="fa fa-check fa-3x icon-white" style="color: green"></i>');
$.each(data.result.file, function (index, file) {
$('<tr><td>' + file.notes + '</td><<td>' + file.name + '</td><td>Just now</td><td>' + file.filesize + '</td><td><a class="btn btn-info btn-sm hidden-print" href="import/process/' + file.name + '"><i class="fa fa-spinner process"></i> Process</a></td></tr>').prependTo("#upload-table > tbody");
//$('<tr><td>').text(file.name).appendTo(document.body);
});
}
$('#progress').removeClass('active');

View file

@ -190,7 +190,10 @@ Route::group([ 'prefix' => 'admin','middleware' => ['authorize:superuser']], fun
Route::get('requests', [ 'as' => 'requests', 'middleware' => 'authorize:admin', 'uses' => 'ViewAssetsController@getRequestedIndex']);
Route::resource('groups', 'GroupsController', [
'middleware' => ['auth'],
'parameters' => ['group' => 'group_id']
]);
Route::get('/', ['as' => 'settings.index', 'uses' => 'SettingsController@index' ]);
@ -198,10 +201,7 @@ Route::group([ 'prefix' => 'admin','middleware' => ['authorize:superuser']], fun
});
Route::resource('groups', 'GroupsController', [
'middleware' => ['auth'],
'parameters' => ['group' => 'group_id']
]);
/*
|--------------------------------------------------------------------------