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();
$this->authorize('view', $asset);
if (isset($asset->id)) {
if (isset($asset)) {
if ($asset->assetloc) {
if (!is_null($asset->assetloc)) {
$use_currency = $asset->assetloc->currency;
} else {

View file

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

View file

@ -15,14 +15,21 @@ class AssetObserver
* @param Asset $asset
* @return void
*/
public function updated(Asset $asset)
public function updating(Asset $asset)
{
$logAction = new Actionlog();
$logAction->item_type = Asset::class;
$logAction->item_id = $asset->id;
$logAction->created_at = date("Y-m-d H:i:s");
$logAction->user_id = Auth::id();
$logAction->logaction('update');
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->item_type = Asset::class;
$logAction->item_id = $asset->id;
$logAction->created_at = date("Y-m-d H:i:s");
$logAction->user_id = Auth::id();
$logAction->logaction('update');
}
}