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

View file

@ -44,7 +44,8 @@ class CheckinAssetNotification extends Notification
* @return array
*/
public function via()
{ if (Setting::getSettings()->webhook_selected == 'microsoft'){
{
if (Setting::getSettings()->webhook_selected == 'microsoft'){
return [MicrosoftTeamsChannel::class];
}
@ -94,27 +95,18 @@ class CheckinAssetNotification extends Notification
$admin = $this->admin;
$item = $this->item;
$note = $this->note;
$button = [
trans('general.administrator') => '<'.$admin->present()->viewUrl().'|'.$admin->present()->fullName().'>',
trans('general.status') => $item->assetstatus->name,
trans('general.location') => ($item->location) ? $item->location->name : '',
];
return MicrosoftTeamsMessage::create()
->to($this->settings->webhook_endpoint)
->type('success')
->addStartGroupToSection('header')
->addStartGroupToSection('activityTitle')
->title("Asset Checked in")
->addStartGroupToSection('activityText')
->fact(htmlspecialchars_decode($item->present()->name), '', 'header')
->fact('Checked into ', $item->location->name)
->fact(trans('mail.Asset_Checkin_Notification')." by ", $admin->present()->fullName())
->fact('Asset Status', $item->assetstatus->name)
->fact('Notes', $note ?: 'No notes');
// ->image($item->getImageUrl(), $item->model()->name, 'header');
}
/**

View file

@ -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.