From be0fdb3d90f7a4a3bb2d34c728c115c4b87869da Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 9 Apr 2025 16:52:16 -0400 Subject: [PATCH 01/21] beginning of audit on checkin/out --- .../lang/en-US/admin/settings/general.php | 2 ++ resources/views/hardware/checkin.blade.php | 32 +++++++++++++++++++ resources/views/settings/general.blade.php | 17 ++++++++++ 3 files changed, 51 insertions(+) diff --git a/resources/lang/en-US/admin/settings/general.php b/resources/lang/en-US/admin/settings/general.php index ffe20383ae0..ad42deb4f9d 100644 --- a/resources/lang/en-US/admin/settings/general.php +++ b/resources/lang/en-US/admin/settings/general.php @@ -283,6 +283,8 @@ 'require_accept_signature_help_text' => 'Enabling this feature will require users to physically sign off on accepting an asset.', 'require_checkinout_notes' => 'Require Notes on Checkin/Checkout', 'require_checkinout_notes_help_text' => 'Enabling this feature will require the note fields to be populated when checking in or checking out an asset.', + 'audit_on_checkinout' => 'Put Audit on Checkin/Checkout', + 'audit_on_checkinout_help_text' => 'Enabling this feature will add audit information to checking in or checking out an asset.', 'left' => 'left', 'right' => 'right', 'top' => 'top', diff --git a/resources/views/hardware/checkin.blade.php b/resources/views/hardware/checkin.blade.php index fbf2aa75ce9..c2ef1bbed95 100755 --- a/resources/views/hardware/checkin.blade.php +++ b/resources/views/hardware/checkin.blade.php @@ -144,10 +144,42 @@ 'show_display_checkin_fields' => 'true' ]) + @if($snipeSettings->audit_on_checkinout){ + +
+ +
+ +

+ @if ($asset->last_audit_date) + {{ Helper::getFormattedDateObject($asset->last_audit_date, 'datetime', false) }} + @else + {{ trans('admin/settings/general.none') }} + @endif +

+
+
+ +
+ +
+
+ + +
+ {!! $errors->first('next_audit_date', '') !!} +

{!! trans('general.next_audit_date_help') !!}

+
+
+} @endif diff --git a/resources/views/settings/general.blade.php b/resources/views/settings/general.blade.php index b4fa3cc5c31..4a62bf93c21 100644 --- a/resources/views/settings/general.blade.php +++ b/resources/views/settings/general.blade.php @@ -253,6 +253,23 @@ + +
+
+ +
+
+ +

{{ trans('admin/settings/general.audit_on_checkinout_help_text') }}

+
+
+ +
From 26aa3ee4bf8b900abf3578dd6a2c374f6924b302 Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 9 Apr 2025 17:24:39 -0400 Subject: [PATCH 02/21] less overthinking --- resources/views/hardware/checkin.blade.php | 38 ---------------------- 1 file changed, 38 deletions(-) diff --git a/resources/views/hardware/checkin.blade.php b/resources/views/hardware/checkin.blade.php index c2ef1bbed95..38d76582a65 100755 --- a/resources/views/hardware/checkin.blade.php +++ b/resources/views/hardware/checkin.blade.php @@ -144,44 +144,6 @@ 'show_display_checkin_fields' => 'true' ]) - @if($snipeSettings->audit_on_checkinout){ - -
- -
- -

- @if ($asset->last_audit_date) - {{ Helper::getFormattedDateObject($asset->last_audit_date, 'datetime', false) }} - @else - {{ trans('admin/settings/general.none') }} - @endif -

-
-
- - - -
- -
-
- - -
- {!! $errors->first('next_audit_date', '') !!} -

{!! trans('general.next_audit_date_help') !!}

-
-
- - -} @endif - -
+ + +
+
+ +
+
+ +

{{ trans('admin/settings/general.audit_on_checkinout_help_text') . " " . trans('general.checkin') . "." }}

+
+
+ + diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.php index b237a2d004f..93f7ba313e2 100755 --- a/resources/views/hardware/checkout.blade.php +++ b/resources/views/hardware/checkout.blade.php @@ -161,6 +161,23 @@ + +
+
+ +
+
+ +

{{ trans('admin/settings/general.audit_on_checkinout_help_text') . " " . trans('general.checkout') . "." }}

+
+
+ + @if ($asset->requireAcceptance() || $asset->getEula() || ($snipeSettings->webhook_endpoint!=''))
diff --git a/resources/views/settings/general.blade.php b/resources/views/settings/general.blade.php index 4a62bf93c21..edd7c515af2 100644 --- a/resources/views/settings/general.blade.php +++ b/resources/views/settings/general.blade.php @@ -253,24 +253,6 @@
- -
-
- -
-
- -

{{ trans('admin/settings/general.audit_on_checkinout_help_text') }}

-
-
- - -
From 02357a8fe75b3226a4594b4cb872fafde6c14612 Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 9 Apr 2025 19:23:27 -0400 Subject: [PATCH 04/21] operational stuffhoohasdss --- app/Http/Controllers/Assets/AssetCheckinController.php | 9 ++++++++- app/Http/Controllers/Assets/AssetCheckoutController.php | 7 +++++++ resources/views/hardware/checkin.blade.php | 4 +++- resources/views/hardware/checkout.blade.php | 3 +++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.php index 4452bfa51d2..2cb8e38aa6a 100644 --- a/app/Http/Controllers/Assets/AssetCheckinController.php +++ b/app/Http/Controllers/Assets/AssetCheckinController.php @@ -5,6 +5,7 @@ use App\Events\CheckoutableCheckedIn; use App\Helpers\Helper; use App\Http\Controllers\Controller; +use App\Http\Controllers\Assets\AssetsController; use App\Http\Requests\AssetCheckinRequest; use App\Http\Traits\MigratesLegacyAssetLocations; use App\Models\Asset; @@ -75,6 +76,10 @@ public function store(AssetCheckinRequest $request, $assetId = null, $backto = n $this->authorize('checkin', $asset); + if($request->filled('audit_on_checkinout') == "1") { + $this->authorize('audit', Asset::class); + } + if ($asset->assignedType() == Asset::USER) { $user = $asset->assignedTo; } @@ -133,7 +138,9 @@ function (Builder $query) use ($asset) { $asset->customFieldsForCheckinCheckout('display_checkin'); if ($asset->save()) { - + if($request->filled('audit_on_checkinout') == "1") { + $asset->logAudit($request->input('note'),$request->input('location_id')); + } event(new CheckoutableCheckedIn($asset, $target, auth()->user(), $request->input('note'), $checkin_at, $originalValues)); return redirect()->to(Helper::getRedirectOption($request, $asset->id, 'Assets'))->with('success', trans('admin/hardware/message.checkin.success')); } diff --git a/app/Http/Controllers/Assets/AssetCheckoutController.php b/app/Http/Controllers/Assets/AssetCheckoutController.php index 4d8c9ffda26..4b4523959a1 100644 --- a/app/Http/Controllers/Assets/AssetCheckoutController.php +++ b/app/Http/Controllers/Assets/AssetCheckoutController.php @@ -71,6 +71,10 @@ public function store(AssetCheckoutRequest $request, $assetId) : RedirectRespons $admin = auth()->user(); + if($request->filled('audit_on_checkinout') == "1") { + $this->authorize('audit', Asset::class); + } + $target = $this->determineCheckoutTarget(); $asset = $this->updateAssetLocation($asset, $target); @@ -114,6 +118,9 @@ public function store(AssetCheckoutRequest $request, $assetId) : RedirectRespons session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]); if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, $request->get('note'), $request->get('name'))) { + if($request->filled('audit_on_checkinout') == "1") { + $asset->logAudit($request->input('note'),$request->input('location_id')); + } return redirect()->to(Helper::getRedirectOption($request, $asset->id, 'Assets')) ->with('success', trans('admin/hardware/message.checkout.success')); } diff --git a/resources/views/hardware/checkin.blade.php b/resources/views/hardware/checkin.blade.php index 930fd60368a..34c9d845edd 100755 --- a/resources/views/hardware/checkin.blade.php +++ b/resources/views/hardware/checkin.blade.php @@ -156,7 +156,8 @@
- + @can("audit") +
+ @endcan
diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.php index 93f7ba313e2..df1f5513123 100755 --- a/resources/views/hardware/checkout.blade.php +++ b/resources/views/hardware/checkout.blade.php @@ -161,6 +161,8 @@ + + @can("audit",$asset)
@@ -177,6 +179,7 @@
+ @endcan @if ($asset->requireAcceptance() || $asset->getEula() || ($snipeSettings->webhook_endpoint!=''))
From 1943bcd7623af98374a863b7950df00bc07efddb Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 9 Apr 2025 19:27:32 -0400 Subject: [PATCH 05/21] removing unneededdnessnesneed --- app/Http/Controllers/Assets/AssetCheckinController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.php index 2cb8e38aa6a..6b6d77faa68 100644 --- a/app/Http/Controllers/Assets/AssetCheckinController.php +++ b/app/Http/Controllers/Assets/AssetCheckinController.php @@ -5,7 +5,6 @@ use App\Events\CheckoutableCheckedIn; use App\Helpers\Helper; use App\Http\Controllers\Controller; -use App\Http\Controllers\Assets\AssetsController; use App\Http\Requests\AssetCheckinRequest; use App\Http\Traits\MigratesLegacyAssetLocations; use App\Models\Asset; From 6617fa938ab16e5f9c3c1b6d11edb28c38d0b137 Mon Sep 17 00:00:00 2001 From: akemidx Date: Thu, 10 Apr 2025 17:47:01 -0400 Subject: [PATCH 06/21] requested variable changes --- resources/lang/en-US/admin/settings/general.php | 4 ++-- resources/views/hardware/checkin.blade.php | 16 ++++++---------- resources/views/hardware/checkout.blade.php | 14 +++++--------- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/resources/lang/en-US/admin/settings/general.php b/resources/lang/en-US/admin/settings/general.php index 3b6caef6a7b..f587b7d4d8c 100644 --- a/resources/lang/en-US/admin/settings/general.php +++ b/resources/lang/en-US/admin/settings/general.php @@ -283,8 +283,8 @@ 'require_accept_signature_help_text' => 'Enabling this feature will require users to physically sign off on accepting an asset.', 'require_checkinout_notes' => 'Require Notes on Checkin/Checkout', 'require_checkinout_notes_help_text' => 'Enabling this feature will require the note fields to be populated when checking in or checking out an asset.', - 'audit_on_checkinout' => 'Log an audit', - 'audit_on_checkinout_help_text' => 'Enabling this feature will also log an audit in addition to this', + 'log_audit' => 'Mark as audited', + 'log_audit_help_text' => 'Check this box to also log an audit in addition to this', 'left' => 'left', 'right' => 'right', 'top' => 'top', diff --git a/resources/views/hardware/checkin.blade.php b/resources/views/hardware/checkin.blade.php index 34c9d845edd..96463ae6c44 100755 --- a/resources/views/hardware/checkin.blade.php +++ b/resources/views/hardware/checkin.blade.php @@ -156,20 +156,16 @@
- @can("audit") - + @can('audit', \App\Models\Asset::class) +
-
- -
+
-

{{ trans('admin/settings/general.audit_on_checkinout_help_text') . " " . trans('general.checkin') . "." }}

+

{{ trans('admin/settings/general.log_audit_help_text') . " " . trans('general.checkin') . "." }}

diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.php index df1f5513123..aea67342dc6 100755 --- a/resources/views/hardware/checkout.blade.php +++ b/resources/views/hardware/checkout.blade.php @@ -162,20 +162,16 @@ - @can("audit",$asset) + @can('audit', \App\Models\Asset::class)
-
- -
+
-

{{ trans('admin/settings/general.audit_on_checkinout_help_text') . " " . trans('general.checkout') . "." }}

+

{{ trans('admin/settings/general.log_audit_help_text') . " " . trans('general.checkout') . "." }}

From cc686b1511181e830fed887daafee674705e488a Mon Sep 17 00:00:00 2001 From: akemidx Date: Thu, 10 Apr 2025 18:19:17 -0400 Subject: [PATCH 07/21] forgot the other bits --- app/Http/Controllers/Assets/AssetCheckinController.php | 4 ++-- app/Http/Controllers/Assets/AssetCheckoutController.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.php index 6b6d77faa68..5090e079f65 100644 --- a/app/Http/Controllers/Assets/AssetCheckinController.php +++ b/app/Http/Controllers/Assets/AssetCheckinController.php @@ -75,7 +75,7 @@ public function store(AssetCheckinRequest $request, $assetId = null, $backto = n $this->authorize('checkin', $asset); - if($request->filled('audit_on_checkinout') == "1") { + if($request->filled('log_audit') == "1") { $this->authorize('audit', Asset::class); } @@ -137,7 +137,7 @@ function (Builder $query) use ($asset) { $asset->customFieldsForCheckinCheckout('display_checkin'); if ($asset->save()) { - if($request->filled('audit_on_checkinout') == "1") { + if($request->filled('log_audit') == "1") { $asset->logAudit($request->input('note'),$request->input('location_id')); } event(new CheckoutableCheckedIn($asset, $target, auth()->user(), $request->input('note'), $checkin_at, $originalValues)); diff --git a/app/Http/Controllers/Assets/AssetCheckoutController.php b/app/Http/Controllers/Assets/AssetCheckoutController.php index 4b4523959a1..43f92ae48d0 100644 --- a/app/Http/Controllers/Assets/AssetCheckoutController.php +++ b/app/Http/Controllers/Assets/AssetCheckoutController.php @@ -71,7 +71,7 @@ public function store(AssetCheckoutRequest $request, $assetId) : RedirectRespons $admin = auth()->user(); - if($request->filled('audit_on_checkinout') == "1") { + if($request->filled('log_audit') == "1") { $this->authorize('audit', Asset::class); } @@ -118,7 +118,7 @@ public function store(AssetCheckoutRequest $request, $assetId) : RedirectRespons session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]); if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, $request->get('note'), $request->get('name'))) { - if($request->filled('audit_on_checkinout') == "1") { + if($request->filled('log_audit') == "1") { $asset->logAudit($request->input('note'),$request->input('location_id')); } return redirect()->to(Helper::getRedirectOption($request, $asset->id, 'Assets')) From 2b54fbb0743f1bfda1d2322a9be654978e0decc5 Mon Sep 17 00:00:00 2001 From: akemidx Date: Tue, 15 Apr 2025 17:15:45 -0400 Subject: [PATCH 08/21] trying to avoid a 403 when checking if the log_audit is chosen --- app/Http/Controllers/Assets/AssetCheckinController.php | 7 +++++-- app/Http/Controllers/Assets/AssetCheckoutController.php | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.php index 5090e079f65..ce332887c62 100644 --- a/app/Http/Controllers/Assets/AssetCheckinController.php +++ b/app/Http/Controllers/Assets/AssetCheckinController.php @@ -14,6 +14,7 @@ use Illuminate\Support\Facades\Log; use \Illuminate\Contracts\View\View; use \Illuminate\Http\RedirectResponse; +use Gate; class AssetCheckinController extends Controller { @@ -75,8 +76,10 @@ public function store(AssetCheckinRequest $request, $assetId = null, $backto = n $this->authorize('checkin', $asset); - if($request->filled('log_audit') == "1") { - $this->authorize('audit', Asset::class); + if(Gate::allows('audit',$asset)) { + if ($request->filled('log_audit') == "1") { + $this->authorize('audit', Asset::class); + } } if ($asset->assignedType() == Asset::USER) { diff --git a/app/Http/Controllers/Assets/AssetCheckoutController.php b/app/Http/Controllers/Assets/AssetCheckoutController.php index 43f92ae48d0..57876602399 100644 --- a/app/Http/Controllers/Assets/AssetCheckoutController.php +++ b/app/Http/Controllers/Assets/AssetCheckoutController.php @@ -12,6 +12,7 @@ use Illuminate\Support\Facades\Session; use \Illuminate\Contracts\View\View; use \Illuminate\Http\RedirectResponse; +use Gate; class AssetCheckoutController extends Controller { @@ -71,8 +72,10 @@ public function store(AssetCheckoutRequest $request, $assetId) : RedirectRespons $admin = auth()->user(); - if($request->filled('log_audit') == "1") { - $this->authorize('audit', Asset::class); + if(Gate::allows('audit',$asset)) { + if ($request->filled('log_audit') == "1") { + $this->authorize('audit', Asset::class); + } } $target = $this->determineCheckoutTarget(); From 802f03ec214128d9e56421f73a60c953b46b125f Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 16 Apr 2025 17:09:40 -0400 Subject: [PATCH 09/21] fixing white space --- resources/views/settings/general.blade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/views/settings/general.blade.php b/resources/views/settings/general.blade.php index edd7c515af2..b4fa3cc5c31 100644 --- a/resources/views/settings/general.blade.php +++ b/resources/views/settings/general.blade.php @@ -253,6 +253,7 @@ +
From 6f2d31497c56d8db9fdd6ec248f9e9ba05496f81 Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 16 Apr 2025 17:21:17 -0400 Subject: [PATCH 10/21] changing Gate location --- .../Controllers/Assets/AssetCheckinController.php | 12 ++++++------ .../Controllers/Assets/AssetCheckoutController.php | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.php index ce332887c62..b4a3acb1e27 100644 --- a/app/Http/Controllers/Assets/AssetCheckinController.php +++ b/app/Http/Controllers/Assets/AssetCheckinController.php @@ -76,10 +76,8 @@ public function store(AssetCheckinRequest $request, $assetId = null, $backto = n $this->authorize('checkin', $asset); - if(Gate::allows('audit',$asset)) { - if ($request->filled('log_audit') == "1") { - $this->authorize('audit', Asset::class); - } + if ($request->filled('log_audit') == "1") { + $this->authorize('audit', Asset::class); } if ($asset->assignedType() == Asset::USER) { @@ -140,8 +138,10 @@ function (Builder $query) use ($asset) { $asset->customFieldsForCheckinCheckout('display_checkin'); if ($asset->save()) { - if($request->filled('log_audit') == "1") { - $asset->logAudit($request->input('note'),$request->input('location_id')); + if(Gate::allows('audit',$asset)) { + if ($request->filled('log_audit') == "1") { + $asset->logAudit($request->input('note'), $request->input('location_id')); + } } event(new CheckoutableCheckedIn($asset, $target, auth()->user(), $request->input('note'), $checkin_at, $originalValues)); return redirect()->to(Helper::getRedirectOption($request, $asset->id, 'Assets'))->with('success', trans('admin/hardware/message.checkin.success')); diff --git a/app/Http/Controllers/Assets/AssetCheckoutController.php b/app/Http/Controllers/Assets/AssetCheckoutController.php index 57876602399..c4890a45298 100644 --- a/app/Http/Controllers/Assets/AssetCheckoutController.php +++ b/app/Http/Controllers/Assets/AssetCheckoutController.php @@ -121,8 +121,10 @@ public function store(AssetCheckoutRequest $request, $assetId) : RedirectRespons session()->put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]); if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, $request->get('note'), $request->get('name'))) { - if($request->filled('log_audit') == "1") { - $asset->logAudit($request->input('note'),$request->input('location_id')); + if(Gate::allows('audit',$asset)) { + if ($request->filled('log_audit') == "1") { + $asset->logAudit($request->input('note'), $request->input('location_id')); + } } return redirect()->to(Helper::getRedirectOption($request, $asset->id, 'Assets')) ->with('success', trans('admin/hardware/message.checkout.success')); From 4cad217a5fc2f8aa93cb3108d4dd06649b6cc732 Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 16 Apr 2025 17:58:24 -0400 Subject: [PATCH 11/21] js script --- resources/views/hardware/checkout.blade.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.php index aea67342dc6..77ff7be09f1 100755 --- a/resources/views/hardware/checkout.blade.php +++ b/resources/views/hardware/checkout.blade.php @@ -238,6 +238,18 @@ @section('moar_scripts') @include('partials/assets-assigned') + + + - - - - @stop diff --git a/resources/views/settings/general.blade.php b/resources/views/settings/general.blade.php index 3d2657826f6..0350c7ca9de 100644 --- a/resources/views/settings/general.blade.php +++ b/resources/views/settings/general.blade.php @@ -231,24 +231,6 @@
- -
-
- -
-
- -

{{ trans('admin/settings/general.audit_on_checkinout_help_text') }}

-
-
- - -
From 5967b8be59e0f3c560b7abf5498e2ba02f1038d3 Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 9 Apr 2025 19:23:27 -0400 Subject: [PATCH 16/21] rebase --- app/Http/Controllers/Assets/AssetCheckinController.php | 8 ++++++++ app/Http/Controllers/Assets/AssetCheckoutController.php | 4 ++++ resources/views/hardware/checkin.blade.php | 4 +++- resources/views/hardware/checkout.blade.php | 3 +++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.php index d41acf6596d..7407247fc39 100644 --- a/app/Http/Controllers/Assets/AssetCheckinController.php +++ b/app/Http/Controllers/Assets/AssetCheckinController.php @@ -5,6 +5,7 @@ use App\Events\CheckoutableCheckedIn; use App\Helpers\Helper; use App\Http\Controllers\Controller; +use App\Http\Controllers\Assets\AssetsController; use App\Http\Requests\AssetCheckinRequest; use App\Http\Traits\MigratesLegacyAssetLocations; use App\Models\Asset; @@ -89,6 +90,13 @@ public function store(AssetCheckinRequest $request, $assetId = null, $backto = n $this->authorize('checkin', $asset); + if($request->filled('audit_on_checkinout') == "1") { + $this->authorize('audit', Asset::class); + } + + if ($asset->assignedType() == Asset::USER) { + $user = $asset->assignedTo; + } session()->put('checkedInFrom', $asset->assignedTo->id); session()->put('checkout_to_type', match ($asset->assigned_type) { 'App\Models\User' => 'user', diff --git a/app/Http/Controllers/Assets/AssetCheckoutController.php b/app/Http/Controllers/Assets/AssetCheckoutController.php index 16579d5b754..9e8d72efc0c 100644 --- a/app/Http/Controllers/Assets/AssetCheckoutController.php +++ b/app/Http/Controllers/Assets/AssetCheckoutController.php @@ -81,6 +81,10 @@ public function store(AssetCheckoutRequest $request, $assetId) : RedirectRespons $admin = auth()->user(); + if($request->filled('audit_on_checkinout') == "1") { + $this->authorize('audit', Asset::class); + } + $target = $this->determineCheckoutTarget(); $asset = $this->updateAssetLocation($asset, $target); diff --git a/resources/views/hardware/checkin.blade.php b/resources/views/hardware/checkin.blade.php index 6beb21656f7..647d5b29c55 100755 --- a/resources/views/hardware/checkin.blade.php +++ b/resources/views/hardware/checkin.blade.php @@ -194,7 +194,8 @@
- + @can("audit") +
+ @endcan
diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.php index e3d3b05273b..ac6f550bd40 100755 --- a/resources/views/hardware/checkout.blade.php +++ b/resources/views/hardware/checkout.blade.php @@ -161,6 +161,8 @@ + + @can("audit",$asset)
@@ -177,6 +179,7 @@
+ @endcan @if ($asset->requireAcceptance() || $asset->getEula() || ($snipeSettings->webhook_endpoint!=''))
From af6cdcefa8e27d3c5a9823799e9b80ad1e03b2f0 Mon Sep 17 00:00:00 2001 From: akemidx Date: Thu, 10 Apr 2025 17:47:01 -0400 Subject: [PATCH 17/21] requested variable changes --- resources/lang/en-US/admin/settings/general.php | 4 ++-- resources/views/hardware/checkin.blade.php | 16 ++++++---------- resources/views/hardware/checkout.blade.php | 14 +++++--------- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/resources/lang/en-US/admin/settings/general.php b/resources/lang/en-US/admin/settings/general.php index 94b641c1638..8eb6248e6f8 100644 --- a/resources/lang/en-US/admin/settings/general.php +++ b/resources/lang/en-US/admin/settings/general.php @@ -291,8 +291,8 @@ 'require_accept_signature_help_text' => 'Enabling this feature will require users to physically sign off on accepting an asset.', 'require_checkinout_notes' => 'Require Notes on Checkin/Checkout', 'require_checkinout_notes_help_text' => 'Enabling this feature will require the note fields to be populated when checking in or checking out an asset.', - 'audit_on_checkinout' => 'Log an audit', - 'audit_on_checkinout_help_text' => 'Enabling this feature will also log an audit in addition to this', + 'log_audit' => 'Mark as audited', + 'log_audit_help_text' => 'Check this box to also log an audit in addition to this', 'left' => 'left', 'right' => 'right', 'top' => 'top', diff --git a/resources/views/hardware/checkin.blade.php b/resources/views/hardware/checkin.blade.php index 647d5b29c55..f98ad45a560 100755 --- a/resources/views/hardware/checkin.blade.php +++ b/resources/views/hardware/checkin.blade.php @@ -194,20 +194,16 @@
- @can("audit") - + @can('audit', \App\Models\Asset::class) +
-
- -
+
-

{{ trans('admin/settings/general.audit_on_checkinout_help_text') . " " . trans('general.checkin') . "." }}

+

{{ trans('admin/settings/general.log_audit_help_text') . " " . trans('general.checkin') . "." }}

diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.php index ac6f550bd40..555b4ce4954 100755 --- a/resources/views/hardware/checkout.blade.php +++ b/resources/views/hardware/checkout.blade.php @@ -162,20 +162,16 @@ - @can("audit",$asset) + @can('audit', \App\Models\Asset::class)
-
- -
+
-

{{ trans('admin/settings/general.audit_on_checkinout_help_text') . " " . trans('general.checkout') . "." }}

+

{{ trans('admin/settings/general.log_audit_help_text') . " " . trans('general.checkout') . "." }}

From 24fb9ff8ac313647bb394c63253de76b3deacf0b Mon Sep 17 00:00:00 2001 From: akemidx Date: Tue, 15 Apr 2025 17:15:45 -0400 Subject: [PATCH 18/21] rebase --- app/Http/Controllers/Assets/AssetCheckinController.php | 6 ++++-- app/Http/Controllers/Assets/AssetCheckoutController.php | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.php index 7407247fc39..fae1933a81c 100644 --- a/app/Http/Controllers/Assets/AssetCheckinController.php +++ b/app/Http/Controllers/Assets/AssetCheckinController.php @@ -90,8 +90,10 @@ public function store(AssetCheckinRequest $request, $assetId = null, $backto = n $this->authorize('checkin', $asset); - if($request->filled('audit_on_checkinout') == "1") { - $this->authorize('audit', Asset::class); + if(Gate::allows('audit',$asset)) { + if ($request->filled('log_audit') == "1") { + $this->authorize('audit', Asset::class); + } } if ($asset->assignedType() == Asset::USER) { diff --git a/app/Http/Controllers/Assets/AssetCheckoutController.php b/app/Http/Controllers/Assets/AssetCheckoutController.php index 9e8d72efc0c..173bfee6bf0 100644 --- a/app/Http/Controllers/Assets/AssetCheckoutController.php +++ b/app/Http/Controllers/Assets/AssetCheckoutController.php @@ -45,7 +45,7 @@ public function create(Asset $asset) : View | RedirectResponse return redirect()->route('hardware.edit', $asset)->withErrors($asset->getErrors()); } - + if ($asset->availableForCheckout()) { return view('hardware/checkout', compact('asset')) ->with('statusLabel_list', Helper::deployableStatusLabelList()) @@ -81,8 +81,10 @@ public function store(AssetCheckoutRequest $request, $assetId) : RedirectRespons $admin = auth()->user(); - if($request->filled('audit_on_checkinout') == "1") { - $this->authorize('audit', Asset::class); + if(Gate::allows('audit',$asset)) { + if ($request->filled('log_audit') == "1") { + $this->authorize('audit', Asset::class); + } } $target = $this->determineCheckoutTarget(); From 9c6eeab01bf711ccc2ee1a242051783a559170cb Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 16 Apr 2025 17:09:40 -0400 Subject: [PATCH 19/21] fixing white space --- resources/views/settings/general.blade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/views/settings/general.blade.php b/resources/views/settings/general.blade.php index 0350c7ca9de..1d621d8d591 100644 --- a/resources/views/settings/general.blade.php +++ b/resources/views/settings/general.blade.php @@ -231,6 +231,7 @@ +
From e77e57e3d996d44453365a0daf9fed1c4cf99085 Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 16 Apr 2025 17:21:17 -0400 Subject: [PATCH 20/21] changing Gate location --- app/Http/Controllers/Assets/AssetCheckinController.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.php index fae1933a81c..f1285201dfa 100644 --- a/app/Http/Controllers/Assets/AssetCheckinController.php +++ b/app/Http/Controllers/Assets/AssetCheckinController.php @@ -90,10 +90,8 @@ public function store(AssetCheckinRequest $request, $assetId = null, $backto = n $this->authorize('checkin', $asset); - if(Gate::allows('audit',$asset)) { - if ($request->filled('log_audit') == "1") { - $this->authorize('audit', Asset::class); - } + if ($request->filled('log_audit') == "1") { + $this->authorize('audit', Asset::class); } if ($asset->assignedType() == Asset::USER) { From 1095da0d5bcd9fa0ddd2c48249529fd6459d53f1 Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 16 Apr 2025 17:58:24 -0400 Subject: [PATCH 21/21] rebase --- resources/views/hardware/checkout.blade.php | 25 ++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.php index 555b4ce4954..a37e60ab818 100755 --- a/resources/views/hardware/checkout.blade.php +++ b/resources/views/hardware/checkout.blade.php @@ -152,7 +152,7 @@ {!! $errors->first('note', '') !!}
- + @include("models/custom_fields_form", [ 'model' => $asset->model, @@ -238,4 +238,27 @@ @section('moar_scripts') @include('partials/assets-assigned') + + + @stop