From 0fd99d410e090a9697b698b5422026549ab6d7af Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 18 Mar 2024 09:36:09 -0700 Subject: [PATCH 01/13] adds a text field and jquery to show/hide text field --- .../views/account/accept/create.blade.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/resources/views/account/accept/create.blade.php b/resources/views/account/accept/create.blade.php index c05bc3a892..1dc146c769 100644 --- a/resources/views/account/accept/create.blade.php +++ b/resources/views/account/accept/create.blade.php @@ -64,6 +64,14 @@ +
+
+ {{ Form::label('decline_msg', trans('admin/settings/general.decling_msg')) }} +
+
+ +
+
@if ($snipeSettings->require_accept_signature=='1')
@@ -130,6 +138,20 @@ $('#signature_output').val(signaturePad.toDataURL()); } }); + $(document).ready(function(){ + // Initially hide the div + $('#decline_msg').hide(); + + $('input[id="declined"]').change(function(){ + + if($(this).is(':checked')){ + $('#decline_msg').show(); + } + else { + $('#decline_msg').hide(); + } + }); + }); @stop \ No newline at end of file From 4588393b76602bdd90f8a68a888bc75096a1da23 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 18 Mar 2024 10:25:55 -0700 Subject: [PATCH 02/13] adds declined msg to mail notif, updates lang files and checkout acceptance controller --- .../Account/AcceptanceController.php | 2 ++ app/Models/CheckoutAcceptance.php | 3 +- .../AcceptanceAssetDeclinedNotification.php | 2 ++ ...cline_msg_to_checkout_acceptance_table.php | 32 +++++++++++++++++++ .../lang/en-US/admin/settings/general.php | 1 + resources/lang/en-US/general.php | 1 + .../views/account/accept/create.blade.php | 21 +++++++----- .../markdown/asset-acceptance.blade.php | 3 ++ 8 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 database/migrations/2024_03_18_164714_add_decline_msg_to_checkout_acceptance_table.php diff --git a/app/Http/Controllers/Account/AcceptanceController.php b/app/Http/Controllers/Account/AcceptanceController.php index 030e069bd2..16a3bb292f 100644 --- a/app/Http/Controllers/Account/AcceptanceController.php +++ b/app/Http/Controllers/Account/AcceptanceController.php @@ -306,10 +306,12 @@ class AcceptanceController extends Controller $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, + 'declined_msg' => $request->input('declined_msg'), '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, diff --git a/app/Models/CheckoutAcceptance.php b/app/Models/CheckoutAcceptance.php index 4a4360c40a..d0532bc704 100644 --- a/app/Models/CheckoutAcceptance.php +++ b/app/Models/CheckoutAcceptance.php @@ -99,9 +99,10 @@ class CheckoutAcceptance extends Model * * @param string $signature_filename */ - public function decline($signature_filename) + public function decline($signature_filename, $declined_msg = null) { $this->declined_at = now(); + $this->declined_msg = $declined_msg; $this->signature_filename = $signature_filename; $this->save(); diff --git a/app/Notifications/AcceptanceAssetDeclinedNotification.php b/app/Notifications/AcceptanceAssetDeclinedNotification.php index 11b022e095..2dd2854506 100644 --- a/app/Notifications/AcceptanceAssetDeclinedNotification.php +++ b/app/Notifications/AcceptanceAssetDeclinedNotification.php @@ -25,6 +25,7 @@ class AcceptanceAssetDeclinedNotification extends Notification $this->item_model = $params['item_model']; $this->item_serial = $params['item_serial']; $this->declined_date = Helper::getFormattedDateObject($params['declined_date'], 'date', false); + $this->declined_msg = $params['declined_msg']; $this->assigned_to = $params['assigned_to']; $this->company_name = $params['company_name']; $this->settings = Setting::getSettings(); @@ -62,6 +63,7 @@ class AcceptanceAssetDeclinedNotification extends Notification 'item_tag' => $this->item_tag, 'item_model' => $this->item_model, 'item_serial' => $this->item_serial, + 'declined_msg' => $this->declined_msg, '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_decline_msg_to_checkout_acceptance_table.php b/database/migrations/2024_03_18_164714_add_decline_msg_to_checkout_acceptance_table.php new file mode 100644 index 0000000000..3b37b5998f --- /dev/null +++ b/database/migrations/2024_03_18_164714_add_decline_msg_to_checkout_acceptance_table.php @@ -0,0 +1,32 @@ +string('declined_msg')->after('signature_filename'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('checkout_acceptances', function (Blueprint $table) { + $table->dropColumn('declined_msg'); + }); + } +} diff --git a/resources/lang/en-US/admin/settings/general.php b/resources/lang/en-US/admin/settings/general.php index 33cfd7b416..1100bde6bd 100644 --- a/resources/lang/en-US/admin/settings/general.php +++ b/resources/lang/en-US/admin/settings/general.php @@ -49,6 +49,7 @@ return [ 'default_eula_text' => 'Default EULA', 'default_language' => 'Default Language', 'default_eula_help_text' => 'You can also associate custom EULAs to specific asset categories.', + 'decline_msg' => 'Add details to why you cant accept this (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 d879ef7db3..3498af23b5 100644 --- a/resources/lang/en-US/general.php +++ b/resources/lang/en-US/general.php @@ -293,6 +293,7 @@ return [ 'user' => 'User', 'accepted' => 'accepted', 'declined' => 'declined', + 'declined_notes' => '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 1dc146c769..425cc77513 100644 --- a/resources/views/account/accept/create.blade.php +++ b/resources/views/account/accept/create.blade.php @@ -64,12 +64,13 @@
-
-
- {{ Form::label('decline_msg', trans('admin/settings/general.decling_msg')) }} +
+
+
+
-
- +
+
@@ -140,15 +141,19 @@ }); $(document).ready(function(){ // Initially hide the div - $('#decline_msg').hide(); + $('#declined_msg').hide(); + $('#declined_msg_label').hide(); + $('input[id="declined"]').change(function(){ if($(this).is(':checked')){ - $('#decline_msg').show(); + $('#declined_msg_label').show(); + $('#declined_msg').show(); } else { - $('#decline_msg').hide(); + $('#declined_msg_label').hide(); + $('#declined_msg').hide(); } }); }); diff --git a/resources/views/notifications/markdown/asset-acceptance.blade.php b/resources/views/notifications/markdown/asset-acceptance.blade.php index 50191d4a37..2f073fe8d7 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($declined_msg)) +| **{{ trans('mail.declined_note') }}** | {{ $declined_msg }} | +@endif @if ((isset($item_tag)) && ($item_tag!='')) | **{{ trans('mail.asset_tag') }}** | {{ $item_tag }} | @endif From 57f5d4a570575c57984c90a56ed9c3cde6457c6d Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 18 Mar 2024 10:45:47 -0700 Subject: [PATCH 03/13] deleted_msg saves to db --- app/Http/Controllers/Account/AcceptanceController.php | 2 +- resources/lang/en-US/general.php | 2 +- .../views/notifications/markdown/asset-acceptance.blade.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Account/AcceptanceController.php b/app/Http/Controllers/Account/AcceptanceController.php index 16a3bb292f..8339df8fef 100644 --- a/app/Http/Controllers/Account/AcceptanceController.php +++ b/app/Http/Controllers/Account/AcceptanceController.php @@ -325,7 +325,7 @@ class AcceptanceController extends Controller Storage::put('private_uploads/eula-pdfs/' .$pdf_filename, $pdf->output()); } - $acceptance->decline($sig_filename); + $acceptance->decline($sig_filename, $request->input('declined_msg')); $acceptance->notify(new AcceptanceAssetDeclinedNotification($data)); event(new CheckoutDeclined($acceptance)); $return_msg = trans('admin/users/message.declined'); diff --git a/resources/lang/en-US/general.php b/resources/lang/en-US/general.php index 3498af23b5..5131452e89 100644 --- a/resources/lang/en-US/general.php +++ b/resources/lang/en-US/general.php @@ -293,7 +293,7 @@ return [ 'user' => 'User', 'accepted' => 'accepted', 'declined' => 'declined', - 'declined_notes' => 'Declined Notes', + 'declined_note' => 'Declined Notes', 'unassigned' => 'Unassigned', 'unaccepted_asset_report' => 'Unaccepted Assets', 'users' => 'Users', diff --git a/resources/views/notifications/markdown/asset-acceptance.blade.php b/resources/views/notifications/markdown/asset-acceptance.blade.php index 2f073fe8d7..ab767c821c 100644 --- a/resources/views/notifications/markdown/asset-acceptance.blade.php +++ b/resources/views/notifications/markdown/asset-acceptance.blade.php @@ -14,7 +14,7 @@ | **{{ ucfirst(trans('general.declined')) }}** | {{ $declined_date }} | @endif @if (isset($declined_msg)) -| **{{ trans('mail.declined_note') }}** | {{ $declined_msg }} | +| **{{ trans('general.declined_note') }}** | {{ $declined_msg }} | @endif @if ((isset($item_tag)) && ($item_tag!='')) | **{{ trans('mail.asset_tag') }}** | {{ $item_tag }} | From 01afa9a749efaf3d4ca4ab97c5ad5cc5b5dbf1c9 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 18 Mar 2024 10:50:15 -0700 Subject: [PATCH 04/13] declined notes are reflected in the action logs --- app/Listeners/LogListener.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Listeners/LogListener.php b/app/Listeners/LogListener.php index 4b584c668b..2fcd0a9d36 100644 --- a/app/Listeners/LogListener.php +++ b/app/Listeners/LogListener.php @@ -78,6 +78,7 @@ class LogListener $logaction->item()->associate($event->acceptance->checkoutable); $logaction->target()->associate($event->acceptance->assignedTo); $logaction->accept_signature = $event->acceptance->signature_filename; + $logaction->note = $event->acceptance->declined_msg; $logaction->action_type = 'declined'; // TODO: log the actual license seat that was checked out From 8b52d5da85639dd097f66c711235113d5747522e Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 18 Mar 2024 12:36:54 -0700 Subject: [PATCH 05/13] fixed typos, reordered jquery, fixed migrations --- ...cline_msg_to_checkout_acceptance_table.php | 2 +- .../lang/en-US/admin/settings/general.php | 2 +- .../views/account/accept/create.blade.php | 35 ++++++++++--------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/database/migrations/2024_03_18_164714_add_decline_msg_to_checkout_acceptance_table.php b/database/migrations/2024_03_18_164714_add_decline_msg_to_checkout_acceptance_table.php index 3b37b5998f..a1f49f33e1 100644 --- a/database/migrations/2024_03_18_164714_add_decline_msg_to_checkout_acceptance_table.php +++ b/database/migrations/2024_03_18_164714_add_decline_msg_to_checkout_acceptance_table.php @@ -14,7 +14,7 @@ class AddDeclineMsgToCheckoutAcceptanceTable extends Migration public function up() { Schema::table('checkout_acceptances', function (Blueprint $table) { - $table->string('declined_msg')->after('signature_filename'); + $table->string('declined_msg')->after('signature_filename')->nullable(); }); } diff --git a/resources/lang/en-US/admin/settings/general.php b/resources/lang/en-US/admin/settings/general.php index 1100bde6bd..ddf5dc4eab 100644 --- a/resources/lang/en-US/admin/settings/general.php +++ b/resources/lang/en-US/admin/settings/general.php @@ -49,7 +49,7 @@ return [ 'default_eula_text' => 'Default EULA', 'default_language' => 'Default Language', 'default_eula_help_text' => 'You can also associate custom EULAs to specific asset categories.', - 'decline_msg' => 'Add details to why you cant accept this (Optional)', + 'decline_msg' => 'Add details to why you can\'t accept this (Optional)', 'display_asset_name' => 'Display Asset Name', 'display_checkout_date' => 'Display Checkout Date', 'display_eol' => 'Display EOL in table view', diff --git a/resources/views/account/accept/create.blade.php b/resources/views/account/accept/create.blade.php index 425cc77513..5501474bfa 100644 --- a/resources/views/account/accept/create.blade.php +++ b/resources/views/account/accept/create.blade.php @@ -103,6 +103,24 @@ @section('moar_scripts') @stop \ No newline at end of file From b9986033cca5d2d6ce4eae9308a0402900998c29 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 18 Mar 2024 16:03:40 -0700 Subject: [PATCH 06/13] removed abbr. of variable, changed variable types in migration --- .../Account/AcceptanceController.php | 4 ++-- app/Listeners/LogListener.php | 2 +- app/Models/CheckoutAcceptance.php | 4 ++-- .../AcceptanceAssetDeclinedNotification.php | 4 ++-- ...ecline_msg_to_checkout_acceptance_table.php | 4 ++-- .../lang/en-US/admin/settings/general.php | 2 +- resources/lang/en-US/general.php | 2 +- .../views/account/accept/create.blade.php | 18 +++++++++--------- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/Http/Controllers/Account/AcceptanceController.php b/app/Http/Controllers/Account/AcceptanceController.php index 8339df8fef..9a59858ccd 100644 --- a/app/Http/Controllers/Account/AcceptanceController.php +++ b/app/Http/Controllers/Account/AcceptanceController.php @@ -311,7 +311,7 @@ class AcceptanceController extends Controller 'item_tag' => $item->asset_tag, 'item_model' => $display_model, 'item_serial' => $item->serial, - 'declined_msg' => $request->input('declined_msg'), + 'declined_message' => $request->input('declined_message'), '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, @@ -325,7 +325,7 @@ class AcceptanceController extends Controller Storage::put('private_uploads/eula-pdfs/' .$pdf_filename, $pdf->output()); } - $acceptance->decline($sig_filename, $request->input('declined_msg')); + $acceptance->decline($sig_filename, $request->input('declined_message')); $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 2fcd0a9d36..3cb0929ebb 100644 --- a/app/Listeners/LogListener.php +++ b/app/Listeners/LogListener.php @@ -78,7 +78,7 @@ class LogListener $logaction->item()->associate($event->acceptance->checkoutable); $logaction->target()->associate($event->acceptance->assignedTo); $logaction->accept_signature = $event->acceptance->signature_filename; - $logaction->note = $event->acceptance->declined_msg; + $logaction->note = $event->acceptance->declined_message; $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 d0532bc704..0a9db7d74c 100644 --- a/app/Models/CheckoutAcceptance.php +++ b/app/Models/CheckoutAcceptance.php @@ -99,10 +99,10 @@ class CheckoutAcceptance extends Model * * @param string $signature_filename */ - public function decline($signature_filename, $declined_msg = null) + public function decline($signature_filename, $declined_message = null) { $this->declined_at = now(); - $this->declined_msg = $declined_msg; + $this->declined_message = $declined_message; $this->signature_filename = $signature_filename; $this->save(); diff --git a/app/Notifications/AcceptanceAssetDeclinedNotification.php b/app/Notifications/AcceptanceAssetDeclinedNotification.php index 2dd2854506..37f9f9763d 100644 --- a/app/Notifications/AcceptanceAssetDeclinedNotification.php +++ b/app/Notifications/AcceptanceAssetDeclinedNotification.php @@ -25,7 +25,7 @@ class AcceptanceAssetDeclinedNotification extends Notification $this->item_model = $params['item_model']; $this->item_serial = $params['item_serial']; $this->declined_date = Helper::getFormattedDateObject($params['declined_date'], 'date', false); - $this->declined_msg = $params['declined_msg']; + $this->declined_message = $params['declined_message']; $this->assigned_to = $params['assigned_to']; $this->company_name = $params['company_name']; $this->settings = Setting::getSettings(); @@ -63,7 +63,7 @@ class AcceptanceAssetDeclinedNotification extends Notification 'item_tag' => $this->item_tag, 'item_model' => $this->item_model, 'item_serial' => $this->item_serial, - 'declined_msg' => $this->declined_msg, + 'declined_message' => $this->declined_message, '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_decline_msg_to_checkout_acceptance_table.php b/database/migrations/2024_03_18_164714_add_decline_msg_to_checkout_acceptance_table.php index a1f49f33e1..dd47d172be 100644 --- a/database/migrations/2024_03_18_164714_add_decline_msg_to_checkout_acceptance_table.php +++ b/database/migrations/2024_03_18_164714_add_decline_msg_to_checkout_acceptance_table.php @@ -14,7 +14,7 @@ class AddDeclineMsgToCheckoutAcceptanceTable extends Migration public function up() { Schema::table('checkout_acceptances', function (Blueprint $table) { - $table->string('declined_msg')->after('signature_filename')->nullable(); + $table->text('declined_message')->after('signature_filename')->nullable(); }); } @@ -26,7 +26,7 @@ class AddDeclineMsgToCheckoutAcceptanceTable extends Migration public function down() { Schema::table('checkout_acceptances', function (Blueprint $table) { - $table->dropColumn('declined_msg'); + $table->dropColumn('declined_message'); }); } } diff --git a/resources/lang/en-US/admin/settings/general.php b/resources/lang/en-US/admin/settings/general.php index ddf5dc4eab..2cab57ffb2 100644 --- a/resources/lang/en-US/admin/settings/general.php +++ b/resources/lang/en-US/admin/settings/general.php @@ -49,7 +49,7 @@ return [ 'default_eula_text' => 'Default EULA', 'default_language' => 'Default Language', 'default_eula_help_text' => 'You can also associate custom EULAs to specific asset categories.', - 'decline_msg' => 'Add details to why you can\'t accept this (Optional)', + 'decline_message' => 'Add details to why you can\'t accept this (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 5131452e89..5321ed0cf7 100644 --- a/resources/lang/en-US/general.php +++ b/resources/lang/en-US/general.php @@ -293,7 +293,7 @@ return [ 'user' => 'User', 'accepted' => 'accepted', 'declined' => 'declined', - 'declined_note' => 'Declined Notes', + '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 5501474bfa..47190bb8e5 100644 --- a/resources/views/account/accept/create.blade.php +++ b/resources/views/account/accept/create.blade.php @@ -67,10 +67,10 @@

- +
- +
@@ -104,20 +104,20 @@