Skip to content

Commit

Permalink
Fixes #55
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Nov 26, 2013
1 parent 5bf38b1 commit e6fc195
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
19 changes: 17 additions & 2 deletions app/models/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,27 @@ public function warrantee_expires()
public function months_until_depreciated()
{

$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'));
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');
Expand Down
7 changes: 6 additions & 1 deletion app/views/backend/assets/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@
<ul>

@if ($asset->purchase_date)
<li>Purchase Date: {{ $asset->purchase_date }} </li>
<li>Purchased On: {{ $asset->purchase_date }} </li>
@endif

@if ($asset->purchase_cost)
<li>Purchase Cost: ${{ number_format($asset->purchase_cost) }} </li>
@endif
Expand All @@ -117,6 +118,8 @@

@if ($asset->depreciation)
<li>Depreciation: {{ $asset->depreciation->name }} ({{ $asset->depreciation->months }} months)</li>
<li>Depreciates On: {{ $asset->depreciated_date() }} </li>
<li>Fully Depreciated: {{ $asset->months_until_depreciated()->m }} months, {{ $asset->months_until_depreciated()->y }} years</li>
@endif

</ul>
Expand Down Expand Up @@ -144,6 +147,8 @@





@if (isset($asset->assigneduser->email))
<li><br /><i class="icon-envelope-alt"></i> <a href="mailto:{{ $asset->assigneduser->email }}">{{ $asset->assigneduser->email }}</a></li>
@endif
Expand Down

0 comments on commit e6fc195

Please sign in to comment.