mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
adds google notifs to license seats check in and out
This commit is contained in:
parent
e074ca0bf9
commit
2406d2cfdb
|
@ -160,7 +160,6 @@ class CheckinAccessoryNotification extends Notification
|
|||
trans('mail.checked_into').': '.$item->location->name ? $item->location->name : '',
|
||||
trans('admin/consumables/general.remaining').': '.$item->numRemaining(),
|
||||
trans('admin/hardware/form.notes').": ".$note ?: '',
|
||||
|
||||
)
|
||||
->onClick(route('accessories.show', $item->id))
|
||||
)
|
||||
|
|
|
@ -9,6 +9,11 @@ use Illuminate\Bus\Queueable;
|
|||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use NotificationChannels\GoogleChat\Card;
|
||||
use NotificationChannels\GoogleChat\GoogleChatChannel;
|
||||
use NotificationChannels\GoogleChat\GoogleChatMessage;
|
||||
use NotificationChannels\GoogleChat\Section;
|
||||
use NotificationChannels\GoogleChat\Widgets\KeyValue;
|
||||
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsChannel;
|
||||
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsMessage;
|
||||
|
||||
|
@ -43,6 +48,10 @@ class CheckinLicenseSeatNotification extends Notification
|
|||
{
|
||||
$notifyBy = [];
|
||||
|
||||
if (Setting::getSettings()->webhook_selected == 'google'){
|
||||
|
||||
$notifyBy[] = GoogleChatChannel::class;
|
||||
}
|
||||
if (Setting::getSettings()->webhook_selected == 'microsoft'){
|
||||
|
||||
$notifyBy[] = MicrosoftTeamsChannel::class;
|
||||
|
@ -113,6 +122,34 @@ class CheckinLicenseSeatNotification extends Notification
|
|||
->fact(trans('admin/consumables/general.remaining'), $item->availCount()->count())
|
||||
->fact(trans('mail.notes'), $note ?: '');
|
||||
}
|
||||
public function toGoogleChat()
|
||||
{
|
||||
$target = $this->target;
|
||||
$item = $this->item;
|
||||
$note = $this->note;
|
||||
|
||||
return GoogleChatMessage::create()
|
||||
->to($this->settings->webhook_endpoint)
|
||||
->card(
|
||||
Card::create()
|
||||
->header(
|
||||
'<strong>'.trans('mail.License_Checkin_Notification').'</strong>' ?: '',
|
||||
htmlspecialchars_decode($item->present()->name) ?: '',
|
||||
)
|
||||
->section(
|
||||
Section::create(
|
||||
KeyValue::create(
|
||||
trans('mail.checkedin_from') ?: '',
|
||||
$target->present()->fullName() ?: '',
|
||||
trans('admin/consumables/general.remaining').': '.$item->availCount()->count(),
|
||||
)
|
||||
->onClick(route('licenses.show', $item->id))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
|
|
|
@ -9,6 +9,11 @@ use Illuminate\Bus\Queueable;
|
|||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use NotificationChannels\GoogleChat\Card;
|
||||
use NotificationChannels\GoogleChat\GoogleChatChannel;
|
||||
use NotificationChannels\GoogleChat\GoogleChatMessage;
|
||||
use NotificationChannels\GoogleChat\Section;
|
||||
use NotificationChannels\GoogleChat\Widgets\KeyValue;
|
||||
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsChannel;
|
||||
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsMessage;
|
||||
|
||||
|
@ -43,9 +48,12 @@ class CheckoutLicenseSeatNotification extends Notification
|
|||
*/
|
||||
public function via()
|
||||
{
|
||||
|
||||
$notifyBy = [];
|
||||
|
||||
if (Setting::getSettings()->webhook_selected == 'google'){
|
||||
|
||||
$notifyBy[] = GoogleChatChannel::class;
|
||||
}
|
||||
if (Setting::getSettings()->webhook_selected == 'microsoft'){
|
||||
|
||||
$notifyBy[] = MicrosoftTeamsChannel::class;
|
||||
|
@ -129,6 +137,33 @@ class CheckoutLicenseSeatNotification extends Notification
|
|||
->fact(trans('admin/consumables/general.remaining'), $item->availCount()->count())
|
||||
->fact(trans('mail.notes'), $note ?: '');
|
||||
}
|
||||
public function toGoogleChat()
|
||||
{
|
||||
$target = $this->target;
|
||||
$item = $this->item;
|
||||
$note = $this->note;
|
||||
|
||||
return GoogleChatMessage::create()
|
||||
->to($this->settings->webhook_endpoint)
|
||||
->card(
|
||||
Card::create()
|
||||
->header(
|
||||
'<strong>'.trans('mail.License_Checkout_Notification').'</strong>' ?: '',
|
||||
htmlspecialchars_decode($item->present()->name) ?: '',
|
||||
)
|
||||
->section(
|
||||
Section::create(
|
||||
KeyValue::create(
|
||||
trans('mail.assigned_to') ?: '',
|
||||
$target->present()->name ?: '',
|
||||
trans('admin/consumables/general.remaining').': '.$item->availCount()->count(),
|
||||
)
|
||||
->onClick(route('users.show', $target->id))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
|
|
|
@ -42,6 +42,7 @@ return [
|
|||
'checkin_date' => 'Checkin Date:',
|
||||
'checkout_date' => 'Checkout Date:',
|
||||
'checkedout_from' => 'Checked out from',
|
||||
'checkedin_from' => 'Checked in from',
|
||||
'checked_into' => 'Checked into',
|
||||
'click_on_the_link_accessory' => 'Please click on the link at the bottom to confirm that you have received the accessory.',
|
||||
'click_on_the_link_asset' => 'Please click on the link at the bottom to confirm that you have received the asset.',
|
||||
|
|
Loading…
Reference in a new issue