diff --git a/app/Http/Controllers/Account/AcceptanceController.php b/app/Http/Controllers/Account/AcceptanceController.php index 030e069bd2b3..b33d83cdd0b0 100644 --- a/app/Http/Controllers/Account/AcceptanceController.php +++ b/app/Http/Controllers/Account/AcceptanceController.php @@ -223,6 +223,7 @@ public function store(Request $request, $id) 'item_model' => $display_model, 'item_serial' => $item->serial, 'eula' => $item->getEula(), + 'note' => $request->input('note'), 'check_out_date' => Carbon::parse($acceptance->created_at)->format('Y-m-d'), 'accepted_date' => Carbon::parse($acceptance->accepted_at)->format('Y-m-d'), 'assigned_to' => $assigned_to, @@ -238,7 +239,7 @@ public function store(Request $request, $id) Storage::put('private_uploads/eula-pdfs/' .$pdf_filename, $pdf->output()); } - $acceptance->accept($sig_filename, $item->getEula(), $pdf_filename); + $acceptance->accept($sig_filename, $item->getEula(), $pdf_filename, $request->input('note')); $acceptance->notify(new AcceptanceAssetAcceptedNotification($data)); event(new CheckoutAccepted($acceptance)); @@ -306,10 +307,12 @@ public function store(Request $request, $id) $assigned_to = User::find($acceptance->assigned_to_id)->present()->fullName; break; } + $data = [ 'item_tag' => $item->asset_tag, 'item_model' => $display_model, 'item_serial' => $item->serial, + 'note' => $request->input('note'), 'declined_date' => Carbon::parse($acceptance->declined_at)->format('Y-m-d'), 'signature' => ($sig_filename) ? storage_path() . '/private_uploads/signatures/' . $sig_filename : null, 'assigned_to' => $assigned_to, @@ -323,7 +326,7 @@ public function store(Request $request, $id) Storage::put('private_uploads/eula-pdfs/' .$pdf_filename, $pdf->output()); } - $acceptance->decline($sig_filename); + $acceptance->decline($sig_filename, $request->input('note')); $acceptance->notify(new AcceptanceAssetDeclinedNotification($data)); event(new CheckoutDeclined($acceptance)); $return_msg = trans('admin/users/message.declined'); diff --git a/app/Listeners/LogListener.php b/app/Listeners/LogListener.php index 4b584c668bcb..0345ac13413e 100644 --- a/app/Listeners/LogListener.php +++ b/app/Listeners/LogListener.php @@ -62,6 +62,7 @@ public function onCheckoutAccepted(CheckoutAccepted $event) $logaction->target()->associate($event->acceptance->assignedTo); $logaction->accept_signature = $event->acceptance->signature_filename; $logaction->filename = $event->acceptance->stored_eula_file; + $logaction->note = $event->acceptance->note; $logaction->action_type = 'accepted'; // TODO: log the actual license seat that was checked out @@ -78,6 +79,7 @@ public function onCheckoutDeclined(CheckoutDeclined $event) $logaction->item()->associate($event->acceptance->checkoutable); $logaction->target()->associate($event->acceptance->assignedTo); $logaction->accept_signature = $event->acceptance->signature_filename; + $logaction->note = $event->acceptance->note; $logaction->action_type = 'declined'; // TODO: log the actual license seat that was checked out diff --git a/app/Models/CheckoutAcceptance.php b/app/Models/CheckoutAcceptance.php index 4a4360c40a00..9c501aaf63c5 100644 --- a/app/Models/CheckoutAcceptance.php +++ b/app/Models/CheckoutAcceptance.php @@ -80,12 +80,13 @@ public function isCheckedOutTo(User $user) * * @param string $signature_filename */ - public function accept($signature_filename, $eula = null, $filename = null) + public function accept($signature_filename, $eula = null, $filename = null, $note = null) { $this->accepted_at = now(); $this->signature_filename = $signature_filename; $this->stored_eula = $eula; $this->stored_eula_file = $filename; + $this->note = $note; $this->save(); /** @@ -99,9 +100,10 @@ public function accept($signature_filename, $eula = null, $filename = null) * * @param string $signature_filename */ - public function decline($signature_filename) + public function decline($signature_filename, $note = null) { $this->declined_at = now(); + $this->note = $note; $this->signature_filename = $signature_filename; $this->save(); diff --git a/app/Notifications/AcceptanceAssetAcceptedNotification.php b/app/Notifications/AcceptanceAssetAcceptedNotification.php index ca016acd346d..db1555b57426 100644 --- a/app/Notifications/AcceptanceAssetAcceptedNotification.php +++ b/app/Notifications/AcceptanceAssetAcceptedNotification.php @@ -26,6 +26,7 @@ public function __construct($params) $this->item_serial = $params['item_serial']; $this->accepted_date = Helper::getFormattedDateObject($params['accepted_date'], 'date', false); $this->assigned_to = $params['assigned_to']; + $this->note = $params['note']; $this->company_name = $params['company_name']; $this->settings = Setting::getSettings(); @@ -64,6 +65,7 @@ public function toMail() 'item_tag' => $this->item_tag, 'item_model' => $this->item_model, 'item_serial' => $this->item_serial, + 'note' => $this->note, 'accepted_date' => $this->accepted_date, 'assigned_to' => $this->assigned_to, 'company_name' => $this->company_name, diff --git a/app/Notifications/AcceptanceAssetDeclinedNotification.php b/app/Notifications/AcceptanceAssetDeclinedNotification.php index 11b022e09590..abdfbbf0c090 100644 --- a/app/Notifications/AcceptanceAssetDeclinedNotification.php +++ b/app/Notifications/AcceptanceAssetDeclinedNotification.php @@ -25,6 +25,7 @@ public function __construct($params) $this->item_model = $params['item_model']; $this->item_serial = $params['item_serial']; $this->declined_date = Helper::getFormattedDateObject($params['declined_date'], 'date', false); + $this->note = $params['note']; $this->assigned_to = $params['assigned_to']; $this->company_name = $params['company_name']; $this->settings = Setting::getSettings(); @@ -62,6 +63,7 @@ public function toMail($notifiable) 'item_tag' => $this->item_tag, 'item_model' => $this->item_model, 'item_serial' => $this->item_serial, + 'note' => $this->note, 'declined_date' => $this->declined_date, 'assigned_to' => $this->assigned_to, 'company_name' => $this->company_name, diff --git a/database/migrations/2024_03_18_164714_add_note_to_checkout_acceptance_table.php b/database/migrations/2024_03_18_164714_add_note_to_checkout_acceptance_table.php new file mode 100644 index 000000000000..75d251b60dfa --- /dev/null +++ b/database/migrations/2024_03_18_164714_add_note_to_checkout_acceptance_table.php @@ -0,0 +1,32 @@ +text('note')->after('signature_filename')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('checkout_acceptances', function (Blueprint $table) { + $table->dropColumn('note'); + }); + } +} diff --git a/resources/lang/en-US/admin/settings/general.php b/resources/lang/en-US/admin/settings/general.php index 33cfd7b416fb..b78942c5dafe 100644 --- a/resources/lang/en-US/admin/settings/general.php +++ b/resources/lang/en-US/admin/settings/general.php @@ -49,6 +49,7 @@ 'default_eula_text' => 'Default EULA', 'default_language' => 'Default Language', 'default_eula_help_text' => 'You can also associate custom EULAs to specific asset categories.', + 'acceptance_note' => 'Add a note for your decision (Optional)', 'display_asset_name' => 'Display Asset Name', 'display_checkout_date' => 'Display Checkout Date', 'display_eol' => 'Display EOL in table view', diff --git a/resources/lang/en-US/general.php b/resources/lang/en-US/general.php index d879ef7db36e..5321ed0cf7bb 100644 --- a/resources/lang/en-US/general.php +++ b/resources/lang/en-US/general.php @@ -293,6 +293,7 @@ 'user' => 'User', 'accepted' => 'accepted', 'declined' => 'declined', + 'declined_note' => 'Declined Notes', 'unassigned' => 'Unassigned', 'unaccepted_asset_report' => 'Unaccepted Assets', 'users' => 'Users', diff --git a/resources/views/account/accept/create.blade.php b/resources/views/account/accept/create.blade.php index c05bc3a89239..407d89161686 100644 --- a/resources/views/account/accept/create.blade.php +++ b/resources/views/account/accept/create.blade.php @@ -64,6 +64,15 @@ +
+
+
+ +
+
+ +
+
@if ($snipeSettings->require_accept_signature=='1')
@@ -94,6 +103,7 @@ @section('moar_scripts') @stop \ No newline at end of file diff --git a/resources/views/notifications/markdown/asset-acceptance.blade.php b/resources/views/notifications/markdown/asset-acceptance.blade.php index 50191d4a3722..93292375a549 100644 --- a/resources/views/notifications/markdown/asset-acceptance.blade.php +++ b/resources/views/notifications/markdown/asset-acceptance.blade.php @@ -13,6 +13,9 @@ @if (isset($declined_date)) | **{{ ucfirst(trans('general.declined')) }}** | {{ $declined_date }} | @endif +@if (isset($note)) +| **{{ trans('general.notes') }}** | {{ $note }} | +@endif @if ((isset($item_tag)) && ($item_tag!='')) | **{{ trans('mail.asset_tag') }}** | {{ $item_tag }} | @endif