Fixed component checkout bug

This commit is contained in:
snipe 2018-03-28 18:53:18 -07:00
parent 69478aea58
commit 983786c29f
3 changed files with 18 additions and 9 deletions

View file

@ -24,7 +24,7 @@ use App\Notifications\CheckoutAssetNotification;
class Asset extends Depreciable
{
protected $presenter = 'App\Presenters\AssetPresenter';
use Loggable, Requestable, Presentable, Notifiable, SoftDeletes, ValidatingTrait, UniqueUndeletedTrait;
use Loggable, Requestable, Presentable, SoftDeletes, ValidatingTrait, UniqueUndeletedTrait;
const LOCATION = 'location';
const ASSET = 'asset';

View file

@ -19,6 +19,14 @@ class Component extends SnipeModel
protected $dates = ['deleted_at', 'purchase_date'];
protected $table = 'components';
/**
* Set static properties to determine which checkout/checkin handlers we should use
*/
public static $checkoutClass = null;
public static $checkinClass = null;
/**
* Category validation rules
*/

View file

@ -73,16 +73,16 @@ trait Loggable
'settings' => $settings,
];
// Send to the admin, if settings dictate
$recipient = new \App\Models\Recipients\AdminRecipient();
$checkoutClass = null;
if (method_exists($target, 'notify')) {
$target->notify(new static::$checkoutClass($params));
}
if ($settings->admin_cc_email!='') {
// Send to the admin, if settings dictate
$recipient = new \App\Models\Recipients\AdminRecipient();
if (($settings->admin_cc_email!='') && (static::$checkoutClass!='')) {
$recipient->notify(new static::$checkoutClass($params));
}
@ -140,8 +140,6 @@ trait Loggable
'settings' => $settings,
];
// Send to the admin, if settings dictate
$recipient = new \App\Models\Recipients\AdminRecipient();
$checkoutClass = null;
@ -149,7 +147,10 @@ trait Loggable
$target->notify(new static::$checkinClass($params));
}
if ($settings->admin_cc_email!='') {
// Send to the admin, if settings dictate
$recipient = new \App\Models\Recipients\AdminRecipient();
if (($settings->admin_cc_email!='') && (static::$checkoutClass!='')) {
$recipient->notify(new static::$checkinClass($params));
}