mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 06:04:08 -08:00
adds Asset Check Out Notification
This commit is contained in:
parent
befab608f2
commit
f049cf5b06
|
@ -44,7 +44,8 @@ class CheckinAssetNotification extends Notification
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function via()
|
public function via()
|
||||||
{ if (Setting::getSettings()->webhook_selected == 'microsoft'){
|
{
|
||||||
|
if (Setting::getSettings()->webhook_selected == 'microsoft'){
|
||||||
|
|
||||||
return [MicrosoftTeamsChannel::class];
|
return [MicrosoftTeamsChannel::class];
|
||||||
}
|
}
|
||||||
|
@ -94,27 +95,18 @@ class CheckinAssetNotification extends Notification
|
||||||
$admin = $this->admin;
|
$admin = $this->admin;
|
||||||
$item = $this->item;
|
$item = $this->item;
|
||||||
$note = $this->note;
|
$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()
|
return MicrosoftTeamsMessage::create()
|
||||||
->to($this->settings->webhook_endpoint)
|
->to($this->settings->webhook_endpoint)
|
||||||
->type('success')
|
->type('success')
|
||||||
->addStartGroupToSection('header')
|
->addStartGroupToSection('activityTitle')
|
||||||
->title("Asset Checked in")
|
->title("Asset Checked in")
|
||||||
|
->addStartGroupToSection('activityText')
|
||||||
->fact(htmlspecialchars_decode($item->present()->name), '', 'header')
|
->fact(htmlspecialchars_decode($item->present()->name), '', 'header')
|
||||||
->fact('Checked into ', $item->location->name)
|
->fact('Checked into ', $item->location->name)
|
||||||
->fact(trans('mail.Asset_Checkin_Notification')." by ", $admin->present()->fullName())
|
->fact(trans('mail.Asset_Checkin_Notification')." by ", $admin->present()->fullName())
|
||||||
->fact('Asset Status', $item->assetstatus->name)
|
->fact('Asset Status', $item->assetstatus->name)
|
||||||
->fact('Notes', $note ?: 'No notes');
|
->fact('Notes', $note ?: 'No notes');
|
||||||
// ->image($item->getImageUrl(), $item->model()->name, 'header');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,6 +10,8 @@ use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Messages\SlackMessage;
|
use Illuminate\Notifications\Messages\SlackMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsChannel;
|
||||||
|
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsMessage;
|
||||||
|
|
||||||
class CheckoutAssetNotification extends Notification
|
class CheckoutAssetNotification extends Notification
|
||||||
{
|
{
|
||||||
|
@ -51,6 +53,10 @@ class CheckoutAssetNotification extends Notification
|
||||||
*/
|
*/
|
||||||
public function via()
|
public function via()
|
||||||
{
|
{
|
||||||
|
if (Setting::getSettings()->webhook_selected == 'microsoft'){
|
||||||
|
|
||||||
|
return [MicrosoftTeamsChannel::class];
|
||||||
|
}
|
||||||
$notifyBy = [];
|
$notifyBy = [];
|
||||||
|
|
||||||
if ((Setting::getSettings()) && (Setting::getSettings()->webhook_endpoint != '')) {
|
if ((Setting::getSettings()) && (Setting::getSettings()->webhook_endpoint != '')) {
|
||||||
|
@ -117,6 +123,24 @@ class CheckoutAssetNotification extends Notification
|
||||||
->content($note);
|
->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.
|
* Get the mail representation of the notification.
|
||||||
|
|
Loading…
Reference in a new issue