From 4588393b76602bdd90f8a68a888bc75096a1da23 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 18 Mar 2024 10:25:55 -0700 Subject: [PATCH] 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