Merge branch 'refs/heads/develop'
This commit is contained in:
@@ -189,10 +189,10 @@ class AssetsController extends AdminController {
|
||||
|
||||
// Declare the rules for the form validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:3',
|
||||
'asset_tag' => 'required|min:3',
|
||||
'name' => 'required|alpha_dash|min:3',
|
||||
'asset_tag' => 'required|alpha_dash|min:3',
|
||||
'model_id' => 'required',
|
||||
'serial' => 'required|min:3',
|
||||
'serial' => 'required|alpha_dash|min:3',
|
||||
'warranty_months' => 'integer|min:1',
|
||||
);
|
||||
|
||||
|
||||
+25
-2
@@ -8,9 +8,8 @@ class Asset extends Elegant {
|
||||
'name' => 'required|alpha_dash|min:3',
|
||||
'asset_tag' => 'required|min:3|unique:assets',
|
||||
'model_id' => 'required',
|
||||
'serial' => 'required|min:3',
|
||||
'serial' => 'required|alpha_dash|min:3',
|
||||
'warranty_months' => 'integer|min:1',
|
||||
'purchase_cost' => 'integer|min:1',
|
||||
);
|
||||
|
||||
|
||||
@@ -115,6 +114,30 @@ class Asset extends Elegant {
|
||||
|
||||
}
|
||||
|
||||
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'));
|
||||
return date_format($date, 'Y-m-d');
|
||||
}
|
||||
|
||||
|
||||
public function depreciation()
|
||||
{
|
||||
return $this->belongsTo('Depreciation','id');
|
||||
|
||||
@@ -102,8 +102,9 @@ View Asset {{ $asset->asset_tag }} ::
|
||||
<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
|
||||
@@ -117,6 +118,8 @@ View Asset {{ $asset->asset_tag }} ::
|
||||
|
||||
@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>
|
||||
@@ -144,6 +147,8 @@ View Asset {{ $asset->asset_tag }} ::
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@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
|
||||
|
||||
Reference in New Issue
Block a user