Skip to content

Commit

Permalink
Fixes #17
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Nov 25, 2013
1 parent 2353eda commit 2b088a3
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/admin/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public function postCreate()
$asset->notes = e(Input::get('notes'));
$asset->asset_tag = e(Input::get('asset_tag'));
$asset->status_id = e(Input::get('status_id'));
$asset->warrantee_months = e(Input::get('warrantee_months'));
$asset->user_id = Sentry::getId();
$asset->physical = '1';

Expand Down Expand Up @@ -191,6 +192,7 @@ public function postEdit($assetId = null)
'asset_tag' => 'required|min:3',
'model_id' => 'required',
'serial' => 'required|min:3',
'warrantee_months' => 'integer|min:1',
);

// Create a new validator instance from our validation rules
Expand All @@ -213,6 +215,7 @@ public function postEdit($assetId = null)
$asset->order_number = e(Input::get('order_number'));
$asset->asset_tag = e(Input::get('asset_tag'));
$asset->status_id = e(Input::get('status_id'));
$asset->warrantee_months = e(Input::get('warrantee_months'));
$asset->notes = e(Input::get('notes'));
$asset->physical = '1';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use Illuminate\Database\Migrations\Migration;

class AddWarranteeToAssetsTable extends Migration {

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
Schema::table('assets', function($table)
{
$table->integer('warrantee_months')->nullable();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
Schema::table('assets', function($table)
{
$table->dropColumn('warrantee_months');
});
}

}
12 changes: 12 additions & 0 deletions app/models/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Asset extends Elegant {
'asset_tag' => 'required|min:3|unique:assets',
'model_id' => 'required',
'serial' => 'required|min:3',
'warrantee_months' => 'integer|min:1',
);


Expand Down Expand Up @@ -104,4 +105,15 @@ public function assetstatus()
}


public function warrantee_expires()
{


$date = date_create($this->purchase_date);
date_add($date, date_interval_create_from_date_string($this->warrantee_months.' months'));
return date_format($date, 'Y-m-d');

}


}
9 changes: 9 additions & 0 deletions app/views/backend/assets/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@
</div>
</div>

<!-- Warrantee -->
<div class="control-group {{ $errors->has('warrantee_months') ? 'error' : '' }}">
<label class="control-label" for="serial">Warrantee</label>
<div class="controls">
<input class="span1" type="text" name="warrantee_months" id="warrantee_months" value="{{ Input::old('warrantee_months', $asset->warrantee_months) }}" /> months
{{ $errors->first('warrantee_months', '<span class="help-inline">:message</span>') }}
</div>
</div>

<!-- Depreciation -->
<div class="control-group {{ $errors->has('depreciation_id') ? 'error' : '' }}">
<label class="control-label" for="parent">Depreciation</label>
Expand Down
19 changes: 19 additions & 0 deletions app/views/backend/assets/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,25 @@
<!-- side address column -->
<div class="span3 address pull-right">

<h6><br>More Info:</h6>
<ul>

@if ($asset->purchase_date)
<li>Purchase Date: {{ $asset->purchase_date }} </li>
@endif
@if ($asset->purchase_cost)
<li>Purchase Cost: ${{ number_format($asset->purchase_cost) }} </li>
@endif
@if ($asset->order_number)
<li>Order #: {{ $asset->order_number }} </li>
@endif
@if ($asset->warrantee_months)
<li>Warrantee: {{ $asset->warrantee_months }} months</li>
<li>Expires: {{ $asset->warrantee_expires() }}</li>
@endif
</ul>


@if ((isset($asset->assigned_to ) && ($asset->assigned_to > 0)))
<h6><br>Checked Out To:</h6>
<ul>
Expand Down

0 comments on commit 2b088a3

Please sign in to comment.