Only add an update log message if the asset isn’t being checked in or out

This commit is contained in:
snipe 2017-07-08 03:38:39 -07:00
parent b02148f59e
commit 932e25ca9b
3 changed files with 18 additions and 9 deletions

View file

@ -587,9 +587,9 @@ class AssetsController extends Controller
$settings = Setting::getSettings(); $settings = Setting::getSettings();
$this->authorize('view', $asset); $this->authorize('view', $asset);
if (isset($asset->id)) { if (isset($asset)) {
if ($asset->assetloc) { if (!is_null($asset->assetloc)) {
$use_currency = $asset->assetloc->currency; $use_currency = $asset->assetloc->currency;
} else { } else {

View file

@ -278,6 +278,8 @@ class Asset extends Depreciable
return $this->assignedTo->assetloc(); // Recurse until we have a final location return $this->assignedTo->assetloc(); // Recurse until we have a final location
} elseif ($this->assignedType() == self::LOCATION) { } elseif ($this->assignedType() == self::LOCATION) {
return $this->assignedTo(); return $this->assignedTo();
} elseif (!$this->assignedTo) {
return $this->defaultLoc();
} elseif ($this->assignedType() == self::USER) { } elseif ($this->assignedType() == self::USER) {
return $this->assignedTo->userLoc(); return $this->assignedTo->userLoc();
} }

View file

@ -15,7 +15,12 @@ class AssetObserver
* @param Asset $asset * @param Asset $asset
* @return void * @return void
*/ */
public function updated(Asset $asset) public function updating(Asset $asset)
{
if (($asset->getAttributes()['assigned_to'] == $asset->getOriginal()['assigned_to'])
&& ($asset->getAttributes()['last_checkout'] == $asset->getOriginal()['last_checkout'])
&& ($asset->getAttributes()['status_id'] == $asset->getOriginal()['status_id']))
{ {
$logAction = new Actionlog(); $logAction = new Actionlog();
$logAction->item_type = Asset::class; $logAction->item_type = Asset::class;
@ -25,6 +30,8 @@ class AssetObserver
$logAction->logaction('update'); $logAction->logaction('update');
} }
}
/** /**
* Listen to the Asset created event, and increment * Listen to the Asset created event, and increment