Fixes #4011 - do not send email to user on license checkout

This commit is contained in:
snipe 2017-09-29 02:00:49 -07:00
parent 7fe2a1f802
commit faf3802971
2 changed files with 29 additions and 26 deletions

View file

@ -279,7 +279,7 @@ class LicensesController extends Controller
// Declare the rules for the form validation // Declare the rules for the form validation
$rules = [ $rules = [
'note' => 'string', 'note' => 'string|nullable',
'asset_id' => 'required_without:assigned_to', 'asset_id' => 'required_without:assigned_to',
]; ];

View file

@ -44,7 +44,9 @@ class CheckoutNotification extends Notification
} }
$item = $this->params['item']; $item = $this->params['item'];
$notifyBy[]='mail'; if (class_basename(get_class($this->params['item']))!='License') {
$notifyBy[] = 'mail';
}
// if ((method_exists($item, 'requireAcceptance') && ($item->requireAcceptance()=='1')) // if ((method_exists($item, 'requireAcceptance') && ($item->requireAcceptance()=='1'))
// || (method_exists($item, 'getEula') && ($item->getEula())) // || (method_exists($item, 'getEula') && ($item->getEula()))
// ) { // ) {
@ -81,30 +83,31 @@ class CheckoutNotification extends Notification
*/ */
public function toMail($notifiable) public function toMail($notifiable)
{ {
//TODO: Expand for non assets.
$item = $this->params['item']; //TODO: Expand for non assets.
$admin_user = $this->params['admin']; $item = $this->params['item'];
$target = $this->params['target']; $admin_user = $this->params['admin'];
$data = [ $target = $this->params['target'];
'eula' => method_exists($item, 'getEula') ? $item->getEula() : '', $data = [
'first_name' => $target->present()->fullName(), 'eula' => method_exists($item, 'getEula') ? $item->getEula() : '',
'item_name' => $item->present()->name(), 'first_name' => $target->present()->fullName(),
'checkout_date' => $item->last_checkout, 'item_name' => $item->present()->name(),
'expected_checkin' => $item->expected_checkin, 'checkout_date' => $item->last_checkout,
'item_tag' => $item->asset_tag, 'expected_checkin' => $item->expected_checkin,
'note' => $this->params['note'], 'item_tag' => $item->asset_tag,
'item_serial' => $item->serial, 'note' => $this->params['note'],
'require_acceptance' => method_exists($item, 'requireAcceptance') ? $item->requireAcceptance() : '', 'item_serial' => $item->serial,
'log_id' => $this->params['log_id'], 'require_acceptance' => method_exists($item, 'requireAcceptance') ? $item->requireAcceptance() : '',
]; 'log_id' => $this->params['log_id'],
return (new MailMessage) ];
->view('emails.accept-asset', $data)
->subject(trans('mail.Confirm_asset_delivery')); return (new MailMessage)
// \Mail::send('emails.accept-asset', $data, function ($m) use ($target) { ->view('emails.accept-asset', $data)
// $m->to($target->email, $target->first_name . ' ' . $target->last_name); ->subject(trans('mail.Confirm_asset_delivery'));
// $m->replyTo(config('mail.reply_to.address'), config('mail.reply_to.name'));
// $m->subject(trans('mail.Confirm_asset_delivery'));
// });
} }
/** /**