diff --git a/app/models/Asset.php b/app/models/Asset.php index a3f58192ad..308dc64bbf 100644 --- a/app/models/Asset.php +++ b/app/models/Asset.php @@ -117,12 +117,27 @@ class Asset extends Elegant { public function months_until_depreciated() { - $date = date_create($this->purchase_date); - date_add($date, date_interval_create_from_date_string($this->depreciation()->months.' months')); - return date_format($date, 'Y-m-d'); + $today = date("Y-m-d"); + + // @link http://www.php.net/manual/en/class.datetime.php + $d1 = new DateTime($today); + $d2 = new DateTime($this->depreciated_date()); + + // @link http://www.php.net/manual/en/class.dateinterval.php + $interval = $d1->diff($d2); + return $interval; } + + public function depreciated_date() + { + $date = date_create($this->purchase_date); + date_add($date, date_interval_create_from_date_string($this->depreciation->months.' months')); + return date_format($date, 'Y-m-d'); + } + + public function depreciation() { return $this->belongsTo('Depreciation','id'); diff --git a/app/views/backend/assets/view.blade.php b/app/views/backend/assets/view.blade.php index d69dbe1d81..f37e018e24 100644 --- a/app/views/backend/assets/view.blade.php +++ b/app/views/backend/assets/view.blade.php @@ -102,8 +102,9 @@ View Asset {{ $asset->asset_tag }} :: @@ -144,6 +147,8 @@ View Asset {{ $asset->asset_tag }} :: + + @if (isset($asset->assigneduser->email))

  • {{ $asset->assigneduser->email }}
  • @endif