adds Asset Check Out Notification

This commit is contained in:
Godfrey M
2024-01-22 10:57:22 -08:00
parent befab608f2
commit f049cf5b06
2 changed files with 28 additions and 12 deletions
@@ -10,6 +10,8 @@ use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage;
use Illuminate\Notifications\Notification;
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsChannel;
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsMessage;
class CheckoutAssetNotification extends Notification
{
@@ -51,6 +53,10 @@ class CheckoutAssetNotification extends Notification
*/
public function via()
{
if (Setting::getSettings()->webhook_selected == 'microsoft'){
return [MicrosoftTeamsChannel::class];
}
$notifyBy = [];
if ((Setting::getSettings()) && (Setting::getSettings()->webhook_endpoint != '')) {
@@ -117,6 +123,24 @@ class CheckoutAssetNotification extends Notification
->content($note);
});
}
public function toMicrosoftTeams()
{
$admin = $this->admin;
$item = $this->item;
$note = $this->note;
return MicrosoftTeamsMessage::create()
->to($this->settings->webhook_endpoint)
->type('success')
->addStartGroupToSection('activityTitle')
->title("Asset Checked Out")
->addStartGroupToSection('activityText')
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle')
->fact('Checked out from ', $item->location->name)
->fact(trans('mail.Asset_Checkout_Notification')." by ", $admin->present()->fullName())
->fact('Asset Status', $item->assetstatus->name)
->fact('Notes', $note ?: 'No notes');
}
/**
* Get the mail representation of the notification.