A free open source IT asset/license management system
adds reminder notification constructor and updates markdown
Godfrey Md3ab152d3009
diff --git a/app/Console/Commands/SendAcceptanceReminder.php b/app/Console/Commands/SendAcceptanceReminder.phpindex ac46c87ede..dd9e59f611 100644--- a/app/Console/Commands/SendAcceptanceReminder.php+++ b/app/Console/Commands/SendAcceptanceReminder.php@@ -8,6 +8,7 @@ use App\Models\Setting;use App\Models\User;use App\Notifications\CheckoutAssetNotification;use App\Notifications\CurrentInventory;+use App\Notifications\UnacceptedAssetReminderNotification;use Illuminate\Console\Command;use Illuminate\Support\Facades\Notification;@@ -52,7 +53,7 @@ class SendAcceptanceReminder extends Command->get();$count = 0;- $unacceptedAssets = $pending+ $unacceptedAssetGroups = $pending->filter(function($acceptance) {return $acceptance->checkoutable_type == 'App\Models\Asset';})@@ -62,26 +63,30 @@ class SendAcceptanceReminder extends Command->groupBy(function($item) {return $item['acceptance']->assignedTo ? $item['acceptance']->assignedTo->id : '';});+$no_mail_address = [];- foreach($unacceptedAssets as $unacceptedAsset) {- if ($unacceptedAsset['acceptance']->assignedTo->email == ''){- $no_mail_address[] = $unacceptedAsset['checkoutable']->assignedTo->present()->fullName;- }- if ($unacceptedAsset['acceptance']->assignedTo) {-- if (!$unacceptedAsset['acceptance']->assignedTo->locale) {- Notification::locale(Setting::getSettings()->locale)->send(- $unacceptedAsset['acceptance']->assignedTo,- new CheckoutAssetNotification($unacceptedAsset['assetItem'], $unacceptedAsset['acceptance']->assignedTo, $unacceptedAsset['assetItem']->adminuser, $unacceptedAsset['acceptance'], '')- );- } else {- Notification::send(- $unacceptedAsset['acceptance']->assignedTo,- new CheckoutAssetNotification($unacceptedAsset['assetItem'], $unacceptedAsset['acceptance']->assignedTo, $unacceptedAsset['assetItem']->adminuser, $unacceptedAsset['acceptance'], '')- );+ foreach($unacceptedAssetGroups as $unacceptedAssetGroup) {+ $item_count = $unacceptedAssetGroup->count();+ foreach ($unacceptedAssetGroup as $unacceptedAsset) {+// if ($unacceptedAsset['acceptance']->assignedTo->email == ''){+// $no_mail_address[] = $unacceptedAsset['checkoutable']->assignedTo->present()->fullName;+// }+ if ($unacceptedAsset['acceptance']->assignedTo) {++ if (!$unacceptedAsset['acceptance']->assignedTo->locale) {+ Notification::locale(Setting::getSettings()->locale)->send(+ $unacceptedAsset['acceptance']->assignedTo,+ new UnacceptedAssetReminderNotification($unacceptedAsset['assetItem'], $count)+ );+ } else {+ Notification::send(+ $unacceptedAsset['acceptance']->assignedTo,+ new UnacceptedAssetReminderNotification($unacceptedAsset, $item_count)+ );+ }+ $count++;}- $count++;}}diff --git a/app/Notifications/UnacceptedAssetReminderNotification.php b/app/Notifications/UnacceptedAssetReminderNotification.phpnew file mode 100644index 0000000000..4751168195--- /dev/null+++ b/app/Notifications/UnacceptedAssetReminderNotification.php@@ -0,0 +1,69 @@+<?php++namespace App\Notifications;++use App\Models\Asset;+use App\Models\User;+use Illuminate\Bus\Queueable;+use Illuminate\Contracts\Queue\ShouldQueue;+use Illuminate\Notifications\Messages\MailMessage;+use Illuminate\Notifications\Notification;++class UnacceptedAssetReminderNotification extends Notification+{+ use Queueable;++ /**+ * Create a new notification instance.+ *+ * @return void+ */+ public function __construct($checkout_info, $count)+ {+ $this->count = $count;+ $this->target = $checkout_info['acceptance']->assignedTo;+ }++ /**+ * Get the notification's delivery channels.+ *+ * @param mixed $notifiable+ * @return array+ */+ public function via()+ {+ return ['mail'];+ }++ /**+ * Get the mail representation of the notification.+ *+ * @param mixed $notifiable+ * @return \Illuminate\Notifications\Messages\MailMessage+ */+ public function toMail()+ {+ $message = (new MailMessage)->markdown('notifications.markdown.asset-reminder',+ [+ 'count' => $this->count,+ 'assigned_to' => $this->target->present()->fullName,+ 'link' => route('account.accept')+ ])+ ->subject(trans('mail.unaccepted_asset_reminder'));++ return $message;+ }++ /**+ * Get the array representation of the notification.+ *+ * @param mixed $notifiable+ * @return array+ */+ public function toArray($notifiable)+ {+ return [+ //+ ];+ }+}diff --git a/resources/lang/en-US/mail.php b/resources/lang/en-US/mail.phpindex 759ff0f5e8..affc305df6 100644--- a/resources/lang/en-US/mail.php+++ b/resources/lang/en-US/mail.php@@ -56,6 +56,7 @@ return ['i_have_read' => 'I have read and agree to the terms of use, and have received this item.','inventory_report' => 'Inventory Report','item' => 'Item:',+ 'item_checked_reminder' => 'This is a reminder that you currently have :count items checked out to you that you have not accepted or declined. Please <a href=":link">click here</a> to review your items.','license_expiring_alert' => 'There is :count license expiring in the next :threshold days.|There are :count licenses expiring in the next :threshold days.','link_to_update_password' => 'Please click on the following link to update your :web password:','login' => 'Login:',@@ -86,6 +87,7 @@ return ['upcoming-audits' => 'There is :count asset that is coming up for audit within :threshold days.|There are :count assets that are coming up for audit within :threshold days.','user' => 'User','username' => 'Username',+ 'unaccepted_asset_reminder' => 'You have Unnaccepted Assets.','welcome' => 'Welcome :name','welcome_to' => 'Welcome to :web!','your_assets' => 'View Your Assets',diff --git a/resources/views/notifications/markdown/asset-reminder.blade.php b/resources/views/notifications/markdown/asset-reminder.blade.phpindex 204793fe05..876e9c6c96 100644--- a/resources/views/notifications/markdown/asset-reminder.blade.php+++ b/resources/views/notifications/markdown/asset-reminder.blade.php@@ -1,31 +1,7 @@@component('mail::message')- # {{ trans('mail.hello') }},+ # {{ trans('mail.hello') }} {{ $assigned_to}},- {{ $intro_text }}.-- @component('mail::table')- | | |- | ------------- | ------------- |- | **{{ trans('mail.user') }}** | {{ $assigned_to }} |- @if (isset($accepted_date))- | **{{ ucfirst(trans('general.accepted')) }}** | {{ $accepted_date }} |- @endif- @if (isset($declined_date))- | **{{ ucfirst(trans('general.declined')) }}** | {{ $declined_date }} |- @endif- @if ((isset($item_tag)) && ($item_tag!=''))- | **{{ trans('mail.asset_tag') }}** | {{ $item_tag }} |- @endif- @if ((isset($item_model)) && ($item_model!=''))- | **{{ trans('mail.asset_name') }}** | {{ $item_model }} |- @endif- @if (isset($item->model))- | **{{ trans('general.asset_model') }}** | {{ $item->model->name }} |- @endif- @if (isset($item_serial))- | **{{ trans('mail.serial') }}** | {{ $item_serial }} |- @endif- @endcomponent+ {{ trans('mail.item_checked_reminder', ['link' => $link, 'count' => $count]) }}{{ trans('mail.best_regards') }}