From dac877f18432eb7f3fc68b60bf7cc148ddf1c412 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 1 Mar 2023 13:51:35 -0800 Subject: [PATCH 1/8] Added location clone Signed-off-by: snipe --- app/Http/Controllers/LocationsController.php | 29 +++++++++++++++++++ .../Transformers/LocationsTransformer.php | 3 +- routes/web.php | 20 +++++++++---- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/LocationsController.php b/app/Http/Controllers/LocationsController.php index 9524abf6ee..25a500b567 100755 --- a/app/Http/Controllers/LocationsController.php +++ b/app/Http/Controllers/LocationsController.php @@ -227,6 +227,35 @@ class LocationsController extends Controller } + + /** + * Returns a view that presents a form to clone a location. + * + * @author [A. Gianotto] [] + * @param int $licenseId + * @since [v6.0.14] + * @return View + */ + public function getClone($licenseId = null) + { + // Check if the asset exists + if (is_null($location_to_clone = Location::find($licenseId))) { + // Redirect to the asset management page + return redirect()->route('licenses.index')->with('error', trans('admin/locations/message.does_not_exist')); + } + + $this->authorize('create', $location_to_clone); + + $location = clone $location_to_clone; + $location->id = null; + $location->name = null; + $location->image = null; + + return view('locations/edit') + ->with('item', $location); + } + + public function print_all_assigned($id) { if ($location = Location::where('id', $id)->first()) { diff --git a/app/Http/Transformers/LocationsTransformer.php b/app/Http/Transformers/LocationsTransformer.php index a55c41b350..22eade5d6e 100644 --- a/app/Http/Transformers/LocationsTransformer.php +++ b/app/Http/Transformers/LocationsTransformer.php @@ -4,7 +4,7 @@ namespace App\Http\Transformers; use App\Helpers\Helper; use App\Models\Location; -use Gate; +use Illuminate\Support\Facades\Gate; use Illuminate\Database\Eloquent\Collection; use Illuminate\Support\Facades\Storage; @@ -63,6 +63,7 @@ class LocationsTransformer $permissions_array['available_actions'] = [ 'update' => Gate::allows('update', Location::class) ? true : false, 'delete' => $location->isDeletable(), + 'clone' => (Gate::allows('create', Location::class) && ($location->deleted_at == '')), ]; $array += $permissions_array; diff --git a/routes/web.php b/routes/web.php index 4c52918f8e..18b7f9a990 100644 --- a/routes/web.php +++ b/routes/web.php @@ -40,12 +40,9 @@ Route::group(['middleware' => 'auth'], function () { 'parameters' => ['category' => 'category_id'], ]); - /* - * Locations - */ - Route::resource('locations', LocationsController::class, [ - 'parameters' => ['location' => 'location_id'], - ]); + Route::get('locations/{locationId}/clone', + [LocationsController::class, 'getClone'] + )->name('clone/license'); Route::get( 'locations/{locationId}/printassigned', @@ -57,6 +54,17 @@ Route::group(['middleware' => 'auth'], function () { [LocationsController::class, 'print_all_assigned'] )->name('locations.print_all_assigned'); + /* + * Locations + */ + Route::resource('locations', LocationsController::class, [ + 'parameters' => ['location' => 'location_id'], + ]); + + + + + /* * Manufacturers */ From 473553c464fa61f008206aa33085d058d4c2bc64 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 1 Mar 2023 14:01:40 -0800 Subject: [PATCH 2/8] Moved gate Signed-off-by: snipe --- app/Http/Controllers/LocationsController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/LocationsController.php b/app/Http/Controllers/LocationsController.php index 25a500b567..adbe173c66 100755 --- a/app/Http/Controllers/LocationsController.php +++ b/app/Http/Controllers/LocationsController.php @@ -236,16 +236,16 @@ class LocationsController extends Controller * @since [v6.0.14] * @return View */ - public function getClone($licenseId = null) + public function getClone($locationId = null) { + $this->authorize('create', Location::class); + // Check if the asset exists - if (is_null($location_to_clone = Location::find($licenseId))) { + if (is_null($location_to_clone = Location::find($locationId))) { // Redirect to the asset management page return redirect()->route('licenses.index')->with('error', trans('admin/locations/message.does_not_exist')); } - $this->authorize('create', $location_to_clone); - $location = clone $location_to_clone; $location->id = null; $location->name = null; From 84a14918bb519afac3e7550a7b447792f9de119e Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 1 Mar 2023 14:03:33 -0800 Subject: [PATCH 3/8] Updated comments Signed-off-by: snipe --- app/Http/Controllers/LocationsController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/LocationsController.php b/app/Http/Controllers/LocationsController.php index adbe173c66..73066365db 100755 --- a/app/Http/Controllers/LocationsController.php +++ b/app/Http/Controllers/LocationsController.php @@ -232,7 +232,7 @@ class LocationsController extends Controller * Returns a view that presents a form to clone a location. * * @author [A. Gianotto] [] - * @param int $licenseId + * @param int $locationId * @since [v6.0.14] * @return View */ @@ -247,6 +247,8 @@ class LocationsController extends Controller } $location = clone $location_to_clone; + + // unset these values $location->id = null; $location->name = null; $location->image = null; From 9b522006f353426966843514d807d205a69038aa Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 1 Mar 2023 14:05:53 -0800 Subject: [PATCH 4/8] Usew route group for locations Signed-off-by: snipe --- routes/web.php | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/routes/web.php b/routes/web.php index 18b7f9a990..cc358c910f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -40,23 +40,29 @@ Route::group(['middleware' => 'auth'], function () { 'parameters' => ['category' => 'category_id'], ]); - Route::get('locations/{locationId}/clone', - [LocationsController::class, 'getClone'] - )->name('clone/license'); - Route::get( - 'locations/{locationId}/printassigned', - [LocationsController::class, 'print_assigned'] - )->name('locations.print_assigned'); - - Route::get( - 'locations/{locationId}/printallassigned', - [LocationsController::class, 'print_all_assigned'] - )->name('locations.print_all_assigned'); /* - * Locations - */ + * Locations + */ + + Route::group(['prefix' => 'locations', 'middleware' => ['auth']], function () { + + Route::get('{locationId}/clone', + [LocationsController::class, 'getClone'] + )->name('clone/license'); + + Route::get( + '{locationId}/printassigned', + [LocationsController::class, 'print_assigned'] + )->name('locations.print_assigned'); + + Route::get( + '{locationId}/printallassigned', + [LocationsController::class, 'print_all_assigned'] + )->name('locations.print_all_assigned'); + }); + Route::resource('locations', LocationsController::class, [ 'parameters' => ['location' => 'location_id'], ]); From b8231f420b11d96998ca629374fa445ed633e834 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 1 Mar 2023 14:12:33 -0800 Subject: [PATCH 5/8] Remove name from blanking paroperties Signed-off-by: snipe --- app/Http/Controllers/LocationsController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Http/Controllers/LocationsController.php b/app/Http/Controllers/LocationsController.php index 73066365db..39b73a9797 100755 --- a/app/Http/Controllers/LocationsController.php +++ b/app/Http/Controllers/LocationsController.php @@ -250,7 +250,6 @@ class LocationsController extends Controller // unset these values $location->id = null; - $location->name = null; $location->image = null; return view('locations/edit') From 778787db3c69a6c59ce63dff8526281b0548222b Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 1 Mar 2023 15:36:01 -0800 Subject: [PATCH 6/8] Rip out jquery for location parent Signed-off-by: snipe --- resources/views/locations/edit.blade.php | 47 ------------------------ 1 file changed, 47 deletions(-) diff --git a/resources/views/locations/edit.blade.php b/resources/views/locations/edit.blade.php index 0c93c83a81..10d0f59bb0 100755 --- a/resources/views/locations/edit.blade.php +++ b/resources/views/locations/edit.blade.php @@ -65,50 +65,3 @@ @include ('partials.forms.edit.image-upload') @stop -@if (!$item->id) -@section('moar_scripts') - -@stop -@endif From 8a5d426ccd7579155935a38c7eaa2463e77d7264 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Thu, 2 Mar 2023 19:33:32 -0600 Subject: [PATCH 7/8] Use correct LicenseSeat property --- app/Http/Controllers/Licenses/LicenseCheckinController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Licenses/LicenseCheckinController.php b/app/Http/Controllers/Licenses/LicenseCheckinController.php index a34de73d77..257722b005 100644 --- a/app/Http/Controllers/Licenses/LicenseCheckinController.php +++ b/app/Http/Controllers/Licenses/LicenseCheckinController.php @@ -61,7 +61,7 @@ class LicenseCheckinController extends Controller $license = License::find($licenseSeat->license_id); // LicenseSeat is not assigned, it can't be checked in - if (is_null($licenseSeat->assignedTo) && is_null($licenseSeat->asset_id)) { + if (is_null($licenseSeat->assigned_to) && is_null($licenseSeat->asset_id)) { return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkin.error')); } From 0b3becee7aa402c46318675364d606cba5717c17 Mon Sep 17 00:00:00 2001 From: Achmad Fienan Rahardianto Date: Sat, 4 Mar 2023 11:27:00 +0700 Subject: [PATCH 8/8] enable sortable for ID column --- resources/views/groups/index.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/groups/index.blade.php b/resources/views/groups/index.blade.php index ffc193c7cf..4958e3a4d0 100755 --- a/resources/views/groups/index.blade.php +++ b/resources/views/groups/index.blade.php @@ -41,7 +41,7 @@ - {{ trans('general.id') }} + {{ trans('general.id') }} {{ trans('admin/groups/table.name') }} {{ trans('admin/groups/table.users') }} {{ trans('general.created_at') }}