From 0ee5dea1a1a785ec4c0b864869f77ce8abbce1cb Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 28 Jul 2016 06:43:31 -0700 Subject: [PATCH 1/6] Fixes #2344 --- resources/views/licenses/view.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/licenses/view.blade.php b/resources/views/licenses/view.blade.php index f5fc595d37..5ce12542a1 100755 --- a/resources/views/licenses/view.blade.php +++ b/resources/views/licenses/view.blade.php @@ -261,7 +261,7 @@ {{ trans('admin/licenses/form.notes') }}: - {{ nl2br(e($license->notes)) }} + {!! nl2br(e($license->notes)) !!} @endif From 214a7d548d7b59f1c23df58bc26b171e3832a86e Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 28 Jul 2016 06:44:59 -0700 Subject: [PATCH 2/6] Bumped version --- config/version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/version.php b/config/version.php index 49137d890b..22a77bffb1 100644 --- a/config/version.php +++ b/config/version.php @@ -1,5 +1,5 @@ 'v3.0', - 'hash_version' => 'v3.0-55-g3fd5fb8', + 'hash_version' => 'v3.0-62-g0ee5dea', ); \ No newline at end of file From f53c5706f6a5f5bb0572d35d5bcba206ab2b336f Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 28 Jul 2016 07:36:58 -0700 Subject: [PATCH 3/6] Fixes #2341 --- app/Http/Controllers/AssetsController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.php index b6cd4d6f82..11bea8f0c0 100755 --- a/app/Http/Controllers/AssetsController.php +++ b/app/Http/Controllers/AssetsController.php @@ -624,7 +624,12 @@ class AssetsController extends Controller // Was the asset updated? if ($asset->save()) { - $checkout_at = e(Input::get('checkin_at')); + if ($request->input('checkout_at')== Carbon::now()->format('Y-m-d')) { + $checkout_at = Carbon::now(); + } else { + $checkout_at = Carbon::now()->format('Y-m-d h:i:s'); + } + //$checkout_at = e(Input::get('checkin_at')); $logaction = $asset->createLogRecord('checkin', $asset, $admin, $user, null, e(Input::get('note')), $checkout_at); From fbd0059bbbcf0567b5a6d6dd07829f1568dfb91a Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 28 Jul 2016 08:07:14 -0700 Subject: [PATCH 4/6] Fixes #2317 --- app/Http/Controllers/ComponentsController.php | 2 +- app/Models/Asset.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ComponentsController.php b/app/Http/Controllers/ComponentsController.php index 9be7282706..977bf7d190 100644 --- a/app/Http/Controllers/ComponentsController.php +++ b/app/Http/Controllers/ComponentsController.php @@ -503,7 +503,7 @@ class ComponentsController extends Controller foreach ($component->assets as $component_assignment) { $rows[] = array( - 'name' => (string)link_to('/hardware/'.$component_assignment->id.'/view', e($component_assignment->name)), + 'name' => (string)link_to('/hardware/'.$component_assignment->id.'/view', e($component_assignment->showAssetName())), 'qty' => e($component_assignment->pivot->assigned_qty), 'created_at' => ($component_assignment->created_at->format('Y-m-d H:i:s')=='-0001-11-30 00:00:00') ? '' : $component_assignment->created_at->format('Y-m-d H:i:s'), ); diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 12f82cfce6..c88c27956f 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -376,7 +376,7 @@ class Asset extends Depreciable { if ($this->name == '') { - return $this->model->name; + return $this->model->name.' ('.$this->asset_tag.')'; } else { return $this->name; } From 3e5d2b53853ecf5d16fd300227b95b6576db9e6e Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 28 Jul 2016 08:10:15 -0700 Subject: [PATCH 5/6] Ability to remove field from fieldset --- .../Controllers/CustomFieldsController.php | 21 +++++++++++++++++++ app/Http/routes.php | 1 + resources/views/custom_fields/show.blade.php | 9 +++++++- resources/views/hardware/edit.blade.php | 2 +- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/CustomFieldsController.php b/app/Http/Controllers/CustomFieldsController.php index 12f44e9939..d2d911bb2a 100644 --- a/app/Http/Controllers/CustomFieldsController.php +++ b/app/Http/Controllers/CustomFieldsController.php @@ -147,6 +147,25 @@ class CustomFieldsController extends Controller } } + + /** + * Detach a custom field from a fieldset. + * + * @author [A. Gianotto] [] + * @since [v3.0] + * @return Redirect + */ + public function deleteFieldFromFieldset($field_id, $fieldset_id) + { + $field = CustomField::find($field_id); + + if ($field->fieldset()->detach($fieldset_id)) { + return redirect()->route("admin.custom_fields.index")->with("success", trans('admin/custom_fields/message.field.delete.success')); + } + + return redirect()->back()->withErrors(['message' => "Field is in-use"]); + } + /** * Delete a custom field. * @@ -158,6 +177,8 @@ class CustomFieldsController extends Controller { $field=CustomField::find($field_id); + + if ($field->fieldset->count()>0) { return redirect()->back()->withErrors(['message' => "Field is in-use"]); } else { diff --git a/app/Http/routes.php b/app/Http/routes.php index f0ac9f2267..c010d4bcd8 100755 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -638,6 +638,7 @@ Route::group([ 'prefix' => 'admin','middleware' => ['web','auth']], function () Route::get('custom_fields/create-field', ['uses' =>'CustomFieldsController@createField','as' => 'admin.custom_fields.create-field']); Route::post('custom_fields/create-field', ['uses' => 'CustomFieldsController@storeField','as' => 'admin.custom_fields.store-field']); Route::post('custom_fields/{id}/associate', ['uses' => 'CustomFieldsController@associate','as' => 'admin.custom_fields.associate']); + Route::get('custom_fields/{field_id}/{fieldset_id}/disassociate', ['uses' => 'CustomFieldsController@deleteFieldFromFieldset','as' => 'admin.custom_fields.disassociate']); Route::match(['DELETE'], 'custom_fields/delete-field/{id}', ['uses' => 'CustomFieldsController@deleteField','as' => 'admin.custom_fields.delete-field']); Route::resource('custom_fields', 'CustomFieldsController'); diff --git a/resources/views/custom_fields/show.blade.php b/resources/views/custom_fields/show.blade.php index eff90959e1..e32a76fed2 100644 --- a/resources/views/custom_fields/show.blade.php +++ b/resources/views/custom_fields/show.blade.php @@ -6,6 +6,11 @@ @parent @stop +@section('header_right') + + {{ trans('general.back') }} +@stop + @section('content') @@ -32,10 +37,11 @@ {{ trans('admin/custom_fields/general.order') }} - {{ trans('admin/custom_fields/general.field_name') }} + {{ trans('admin/custom_fields/general.field_name') }} {{ trans('admin/custom_fields/general.field_format') }} {{ trans('admin/custom_fields/general.field_element') }} {{ trans('admin/custom_fields/general.required') }} + @@ -66,6 +72,7 @@ {{$field->format}} {{$field->element}} {{$field->pivot->required ? "REQUIRED" : "OPTIONAL"}} + Remove @endforeach diff --git a/resources/views/hardware/edit.blade.php b/resources/views/hardware/edit.blade.php index 4b0b5504a4..58b17d2109 100755 --- a/resources/views/hardware/edit.blade.php +++ b/resources/views/hardware/edit.blade.php @@ -12,7 +12,7 @@ @section('header_right') - {{ trans('general.back') }} + {{ trans('general.back') }} @stop From f31637adb454d69905ae3042c13b27c10c3d326f Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 28 Jul 2016 08:39:28 -0700 Subject: [PATCH 6/6] Fixes #2346 --- app/Http/Controllers/UsersController.php | 41 ++++++++++++--------- app/Http/routes.php | 32 +++++++++-------- resources/views/users/view.blade.php | 46 +++++++++++++++++++----- 3 files changed, 79 insertions(+), 40 deletions(-) diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php index e9868fa5b4..6a1ab6fc7c 100755 --- a/app/Http/Controllers/UsersController.php +++ b/app/Http/Controllers/UsersController.php @@ -33,6 +33,7 @@ use Symfony\Component\HttpFoundation\JsonResponse; use URL; use View; use Illuminate\Http\Request; +use Gate; /** * This controller handles all actions related to Users for @@ -853,7 +854,7 @@ class UsersController extends Controller * @see UsersController::getIndex() method that consumed this JSON response * @return string JSON */ - public function getDatatable($status = null) + public function getDatatable(Request $request, $status = null) { if (Input::has('offset')) { @@ -922,24 +923,30 @@ class UsersController extends Controller $group_names .= '' . $group->name . ' '; } + if (Gate::allows('users:edit')) { + if (!is_null($user->deleted_at)) { - if (!is_null($user->deleted_at)) { - - $actions .= ' '; - } else { - - if ($user->accountStatus() == 'suspended') { - $actions .= ' '; - } - - $actions .= ' '; - - $actions .= ''; - - if ((Auth::user()->id !== $user->id) && (!config('app.lock_passwords'))) { - $actions .= ' '; + $actions .= ' '; } else { - $actions .= ' '; + + if ($user->accountStatus() == 'suspended') { + $actions .= ' '; + } + + $actions .= ' '; + + $actions .= ''; + + if ((Auth::user()->id !== $user->id) && (!config('app.lock_passwords'))) { + $actions .= ' '; + } else { + $actions .= ' '; + } } } $actions .= ''; diff --git a/app/Http/routes.php b/app/Http/routes.php index c010d4bcd8..6679ec8287 100755 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -645,21 +645,21 @@ Route::group([ 'prefix' => 'admin','middleware' => ['web','auth']], function () # User Management Route::group([ 'prefix' => 'users', 'middleware' => ['web','auth','authorize:users.view']], function () { - Route::get('ldap', ['as' => 'ldap/user', 'uses' => 'UsersController@getLDAP' ]); + Route::get('ldap', ['as' => 'ldap/user', 'uses' => 'UsersController@getLDAP', 'middleware' => ['authorize:users.edit'] ]); Route::post('ldap', 'UsersController@postLDAP'); - Route::get('create', [ 'as' => 'create/user', 'uses' => 'UsersController@getCreate' ]); - Route::post('create', 'UsersController@postCreate'); - Route::get('import', [ 'as' => 'import/user', 'uses' => 'UsersController@getImport' ]); - Route::post('import', 'UsersController@postImport'); - Route::get('{userId}/edit', [ 'as' => 'update/user', 'uses' => 'UsersController@getEdit' ]); - Route::post('{userId}/edit', 'UsersController@postEdit'); - Route::get('{userId}/clone', [ 'as' => 'clone/user', 'uses' => 'UsersController@getClone' ]); - Route::post('{userId}/clone', 'UsersController@postCreate'); - Route::get('{userId}/delete', [ 'as' => 'delete/user', 'uses' => 'UsersController@getDelete' ]); - Route::get('{userId}/restore', [ 'as' => 'restore/user', 'uses' => 'UsersController@getRestore' ]); - Route::get('{userId}/view', [ 'as' => 'view/user', 'uses' => 'UsersController@getView' ]); - Route::get('{userId}/unsuspend', [ 'as' => 'unsuspend/user', 'uses' => 'UsersController@getUnsuspend' ]); + Route::get('create', [ 'as' => 'create/user', 'uses' => 'UsersController@getCreate', 'middleware' => ['authorize:users.edit'] ]); + Route::post('create', [ 'uses' => 'UsersController@postCreate', 'middleware' => ['authorize:users.edit'] ]); + Route::get('import', [ 'as' => 'import/user', 'uses' => 'UsersController@getImport', 'middleware' => ['authorize:users.edit'] ]); + Route::post('import', [ 'uses' => 'UsersController@postImport', 'middleware' => ['authorize:users.edit'] ]); + Route::get('{userId}/edit', [ 'as' => 'update/user', 'uses' => 'UsersController@getEdit', 'middleware' => ['authorize:users.edit'] ]); + Route::post('{userId}/edit', [ 'uses' => 'UsersController@postEdit', 'middleware' => ['authorize:users.edit'] ]); + Route::get('{userId}/clone', [ 'as' => 'clone/user', 'uses' => 'UsersController@getClone', 'middleware' => ['authorize:users.edit'] ]); + Route::post('{userId}/clone', [ 'uses' => 'UsersController@postCreate', 'middleware' => ['authorize:users.edit'] ]); + Route::get('{userId}/delete', [ 'as' => 'delete/user', 'uses' => 'UsersController@getDelete', 'middleware' => ['authorize:users.edit'] ]); + Route::get('{userId}/restore', [ 'as' => 'restore/user', 'uses' => 'UsersController@getRestore', 'middleware' => ['authorize:users.edit'] ]); + Route::get('{userId}/view', [ 'as' => 'view/user', 'uses' => 'UsersController@getView' , 'middleware' => ['authorize:users.view'] ]); + Route::get('{userId}/unsuspend', [ 'as' => 'unsuspend/user', 'uses' => 'UsersController@getUnsuspend', 'middleware' => ['authorize:users.edit'] ]); Route::get( '{userId}/deletefile/{fileId}', [ 'as' => 'delete/userfile', 'uses' => 'UsersController@getDeleteFile' ] @@ -673,14 +673,16 @@ Route::group([ 'prefix' => 'admin','middleware' => ['web','auth']], function () 'bulkedit', [ 'as' => 'users/bulkedit', - 'uses' => 'UsersController@postBulkEdit' + 'uses' => 'UsersController@postBulkEdit', + 'middleware' => ['authorize:users.edit'], ] ); Route::post( 'bulksave', [ 'as' => 'users/bulksave', - 'uses' => 'UsersController@postBulkSave' + 'uses' => 'UsersController@postBulkSave', + 'middleware' => ['authorize:users.edit'], ] ); diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php index 56b7c59581..c832048098 100755 --- a/resources/views/users/view.blade.php +++ b/resources/views/users/view.blade.php @@ -23,7 +23,9 @@
  • + @can('users.edit') + @endcan
    @@ -44,7 +47,10 @@
    - This user has been marked as deleted. Click here to restore them. + This user has been marked as deleted. + @can('users.edit') + Click here to restore them. + @endcan
    @endif @@ -126,13 +132,16 @@
    + @can('users.edit') + @if ((Auth::user()->id !== $user->id) && (!config('app.lock_passwords'))) @if ($user->deleted_at=='') @@ -154,7 +163,7 @@ @endif @endif - + @endcan
    @@ -182,10 +191,18 @@ @if ($asset->physical=='1') {{ $asset->model->name }} @endif - {{ $asset->asset_tag }} + + @can('assets.view') + {{ $asset->asset_tag }} + @endcan + {{ $asset->name }} - Checkin + + @can('assets.edit') + Checkin + @endcan + @endforeach @@ -205,9 +222,15 @@ @foreach ($user->licenses as $license) - {{ $license->name }} + + {{ $license->name }} + + {{ mb_strimwidth($license->serial, 0, 50, "...") }} - Checkin + + @can('licenses.edit') + Checkin + @endcan @endforeach @@ -228,7 +251,10 @@ @foreach ($user->accessories as $accessory) {{ $accessory->name }} - Checkin + + @can('accessories.edit') + Checkin + @endcan @endforeach @@ -264,13 +290,15 @@
    - + @can('users.edit') + Select File... + @endcan
    @@ -325,7 +353,9 @@ @endif + @can('users.edit') + @endcan @endforeach