Merge pull request #11 from Godmartinz/license_checkable

adds consumable checkout  ms notification
This commit is contained in:
Godfrey Martinez 2024-01-23 11:22:02 -08:00 committed by GitHub
commit b797795d37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 0 deletions

View file

@ -9,6 +9,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 CheckoutConsumableNotification extends Notification
{
@ -43,6 +45,11 @@ class CheckoutConsumableNotification extends Notification
{
$notifyBy = [];
if (Setting::getSettings()->webhook_selected == 'microsoft'){
$notifyBy[] = MicrosoftTeamsChannel::class;
}
if (Setting::getSettings()->webhook_endpoint != '') {
$notifyBy[] = 'slack';
}
@ -102,6 +109,25 @@ class CheckoutConsumableNotification extends Notification
->content($note);
});
}
public function toMicrosoftTeams()
{
$target = $this->target;
$admin = $this->admin;
$item = $this->item;
$note = $this->note;
return MicrosoftTeamsMessage::create()
->to($this->settings->webhook_endpoint)
->type('success')
->addStartGroupToSection('activityTitle')
->title("Consumable Checked Out")
->addStartGroupToSection('activityText')
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle')
->fact(trans('mail.Consumable_checkout_notification')." by ", $admin->present()->fullName())
->fact('Checked out to', $target->present()->fullName())
->fact('Number Remaining', $item->numRemaining())
->fact('Notes', $note ?: 'No notes');
}
/**
* Get the mail representation of the notification.

View file

@ -12,6 +12,7 @@ return [
'Confirm_asset_delivery' => 'Asset delivery confirmation',
'Confirm_consumable_delivery' => 'Consumable delivery confirmation',
'Confirm_license_delivery' => 'License delivery confirmation',
'Consumable_checkout_notification' => 'Consumable checked out',
'Days' => 'Days',
'Expected_Checkin_Date' => 'An asset checked out to you is due to be checked back in on :date',
'Expected_Checkin_Notification' => 'Reminder: :name checkin deadline approaching',