Merge branch 'refs/heads/develop'

This commit is contained in:
snipe
2013-12-10 13:01:05 -05:00
13 changed files with 182 additions and 71 deletions
+15 -13
View File
@@ -69,12 +69,13 @@ class ModelsController extends AdminController {
{
// Save the model data
$model->name = e(Input::get('name'));
$model->modelno = e(Input::get('modelno'));
$model->depreciation_id = e(Input::get('depreciation_id'));
$model->manufacturer_id = e(Input::get('manufacturer_id'));
$model->category_id = e(Input::get('category_id'));
$model->user_id = Sentry::getId();
$model->name = e(Input::get('name'));
$model->modelno = e(Input::get('modelno'));
$model->depreciation_id = e(Input::get('depreciation_id'));
$model->manufacturer_id = e(Input::get('manufacturer_id'));
$model->category_id = e(Input::get('category_id'));
$model->user_id = Sentry::getId();
$model->eol = e(Input::get('eol'));
// Was it created?
@@ -133,7 +134,7 @@ class ModelsController extends AdminController {
// Check if the model exists
if (is_null($model = Model::find($modelId)))
{
// Redirect to the blogs management page
// Redirect to the models management page
return Redirect::to('admin/models')->with('error', Lang::get('admin/models/message.does_not_exist'));
}
@@ -145,18 +146,19 @@ class ModelsController extends AdminController {
{
// Update the model data
$model->name = e(Input::get('name'));
$model->modelno = e(Input::get('modelno'));
$model->depreciation_id = e(Input::get('depreciation_id'));
$model->manufacturer_id = e(Input::get('manufacturer_id'));
$model->category_id = e(Input::get('category_id'));
$model->name = e(Input::get('name'));
$model->modelno = e(Input::get('modelno'));
$model->depreciation_id = e(Input::get('depreciation_id'));
$model->manufacturer_id = e(Input::get('manufacturer_id'));
$model->category_id = e(Input::get('category_id'));
$model->eol = e(Input::get('eol'));
// Was it created?
if($model->save())
{
// Redirect to the new model page
return Redirect::to("hardware/models/$modelId/edit")->with('success', Lang::get('admin/models/message.update.success'));
return Redirect::to("hardware/models")->with('success', Lang::get('admin/models/message.update.success'));
}
}
else
@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
class AddEolOnModelsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('models', function($table)
{
$table->integer('eol')->nullable()->default(NULL);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('models', function($table)
{
$table->dropColumn('old');
});
}
}
+54 -48
View File
@@ -12,71 +12,77 @@ class ModelsSeeder extends Seeder {
$date = new DateTime;
$models[] = array(
'name' => 'MacBook Pro (13-inch, Mid 2012)',
'manufacturer_id' => '1',
'category_id' => '1',
'modelno' => 'MacBookPro9,2',
'created_at' => $date->modify('-10 day'),
'updated_at' => $date->modify('-3 day'),
'depreciation_id' => 1,
'user_id' => 1,
'name' => 'MacBook Pro (13-inch, Mid 2012)',
'manufacturer_id' => '1',
'category_id' => '1',
'modelno' => 'MacBookPro9,2',
'created_at' => $date->modify('-10 day'),
'updated_at' => $date->modify('-3 day'),
'depreciation_id' => 1,
'user_id' => 1,
'eol' => '36',
);
$models[] = array(
'name' => 'MacBook Pro (Retina, 13-inch, Late 2012)',
'manufacturer_id' => '1',
'category_id' => '1',
'modelno' => 'MacBookPro10,2',
'created_at' => $date->modify('-4 day'),
'updated_at' => $date->modify('-1 day'),
'depreciation_id' => 1,
'user_id' => 1,
'name' => 'MacBook Pro (Retina, 13-inch, Late 2012)',
'manufacturer_id' => '1',
'category_id' => '1',
'modelno' => 'MacBookPro10,2',
'created_at' => $date->modify('-4 day'),
'updated_at' => $date->modify('-1 day'),
'depreciation_id' => 1,
'user_id' => 1,
'eol' => '36',
);
$models[] = array(
'name' => 'MacBook Pro (Retina, 13-inch, Early 2013)',
'manufacturer_id' => '2',
'category_id' => '1',
'modelno' => 'MacBookPro10,2',
'created_at' => $date->modify('-2 day'),
'updated_at' => $date,
'depreciation_id' => 1,
'user_id' => 1,
'name' => 'MacBook Pro (Retina, 13-inch, Early 2013)',
'manufacturer_id' => '2',
'category_id' => '1',
'modelno' => 'MacBookPro10,2',
'created_at' => $date->modify('-2 day'),
'updated_at' => $date,
'depreciation_id' => 1,
'user_id' => 1,
'eol' => '36',
);
$models[] = array(
'name' => 'MacBook Pro (Retina, 13-inch, Late 2013)',
'manufacturer_id' => '2',
'category_id' => '1',
'modelno' => 'MacBookPro11,1',
'created_at' => $date->modify('-2 day'),
'updated_at' => $date,
'depreciation_id' => 1,
'user_id' => 1,
'name' => 'MacBook Pro (Retina, 13-inch, Late 2013)',
'manufacturer_id' => '2',
'category_id' => '1',
'modelno' => 'MacBookPro11,1',
'created_at' => $date->modify('-2 day'),
'updated_at' => $date,
'depreciation_id' => 1,
'user_id' => 1,
'eol' => '24',
);
$models[] = array(
'name' => 'Inspiron 15 Non-Touch',
'manufacturer_id' => '4',
'category_id' => '1',
'modelno' => 'FNCWC16B',
'created_at' => $date->modify('-2 day'),
'updated_at' => $date,
'depreciation_id' => 1,
'user_id' => 1,
'name' => 'Inspiron 15 Non-Touch',
'manufacturer_id' => '4',
'category_id' => '1',
'modelno' => 'FNCWC16B',
'created_at' => $date->modify('-2 day'),
'updated_at' => $date,
'depreciation_id' => 1,
'user_id' => 1,
'eol' => '36',
);
$models[] = array(
'name' => '22-inch T897',
'manufacturer_id' => '4',
'category_id' => '5',
'modelno' => '78FNCWC16B',
'created_at' => $date->modify('-2 day'),
'updated_at' => $date,
'depreciation_id' => 1,
'user_id' => 1,
'name' => '22-inch T897',
'manufacturer_id' => '4',
'category_id' => '5',
'modelno' => '78FNCWC16B',
'created_at' => $date->modify('-2 day'),
'updated_at' => $date,
'depreciation_id' => 1,
'user_id' => 1,
'eol' => '60',
);
+1
View File
@@ -13,5 +13,6 @@ return array(
'checkoutto' => 'Checked Out',
'change' => 'In/Out',
'location' => 'Location',
'eol' => 'EOL',
);
+1
View File
@@ -6,5 +6,6 @@ return array(
'modelnumber' => 'Model No.',
'created_at' => 'Created at',
'numassets' => 'Assets',
'eol' => 'EOL',
);
+24
View File
@@ -149,4 +149,28 @@ class Asset extends Elegant {
return $this->belongsTo('Model','model_id');
}
public function months_until_eol()
{
$today = date("Y-m-d");
$d1 = new DateTime($today);
$d2 = new DateTime($this->eol_date());
if ($this->eol_date() > $today)
{
$interval = $d2->diff($d1);
} else {
$interval = NULL;
}
return $interval;
}
public function eol_date()
{
$date = date_create($this->purchase_date);
date_add($date, date_interval_create_from_date_string($this->model->eol.' months'));
return date_format($date, 'Y-m-d');
}
}
+4 -5
View File
@@ -4,10 +4,11 @@ class Model extends Elegant {
// Declare the rules for the form validation
protected $rules = array(
'name' => 'required|alpha_space|min:3',
'modelno' => 'alpha_space|min:1',
'category_id' => 'required|integer',
'name' => 'required|alpha_space|min:3',
'modelno' => 'alpha_space|min:1',
'category_id' => 'required|integer',
'manufacturer_id' => 'required|integer',
'eol' => 'integer',
);
public function assets()
@@ -35,6 +36,4 @@ class Model extends Elegant {
return $this->belongsTo('Manufacturer','manufacturer_id');
}
}
+1 -1
View File
@@ -2,5 +2,5 @@
Validator::extend('alpha_space', function($attribute,$value,$parameters)
{
return preg_match("/^[-+:?#~'\/()_,!. a-zA-Z0-9]+$/",$value);
return preg_match("/^[-+:?#~'\/\(\)_,!. a-zA-Z0-9]+$/",$value);
});
+8 -2
View File
@@ -54,7 +54,7 @@ Assets ::
<table id="example">
<thead>
<tr role="row">
<th class="col-md-2" bSortable="true">@lang('admin/hardware/table.asset_tag')</th>
<th class="col-md-1" bSortable="true">@lang('admin/hardware/table.asset_tag')</th>
<th class="col-md-3" bSortable="true">@lang('admin/hardware/table.title')</th>
<th class="col-md-2" bSortable="true">@lang('admin/hardware/table.serial')</th>
@if (Input::get('Pending') || Input::get('Undeployable') || Input::get('RTD'))
@@ -63,7 +63,7 @@ Assets ::
<th class="col-md-2" bSortable="true">@lang('admin/hardware/table.checkoutto')</th>
<th class="col-md-2" bSortable="true">@lang('admin/hardware/table.location')</th>
@endif
<th class="col-md-2">@lang('admin/hardware/table.eol')</th>
<th class="col-md-1">@lang('admin/hardware/table.change')</th>
<th class="col-md-2 actions" bSortable="false">@lang('table.actions')</th>
</tr>
@@ -108,6 +108,12 @@ Assets ::
@endif
<td>
@if ($asset->model->eol)
{{ $asset->eol_date() }}
@endif
</td>
<td>
@if ($asset->status_id < 1 )
@if ($asset->assigned_to != 0)
+10
View File
@@ -74,6 +74,16 @@ View Asset {{ $asset->asset_tag }} ::
{{ $asset->months_until_depreciated()->y }} years</div>
@endif
@if ($asset->model->eol)
<div class="col-md-6"><strong>EOL Rate: </strong> {{ $asset->model->eol }} months </div>
<div class="col-md-6"><strong>EOL Date: </strong> {{ $asset->eol_date() }}
@if ($asset->months_until_eol())
({{ $asset->months_until_eol()->y }} years,
{{ $asset->months_until_eol()->m }} months)
@endif
</div>
@endif
</div>
+13
View File
@@ -78,6 +78,19 @@
</div>
</div>
<!-- EOL -->
<div class="form-group {{ $errors->has('eol') ? ' has-error' : '' }}">
<label for="eol" class="col-md-2 control-label">EOL</label>
<div class="col-md-2">
<div class="input-group">
<input class="col-md-1 form-control" type="text" name="eol" id="eol" value="{{ Input::old('eol', $model->eol) }}" /> <span class="input-group-addon">months</span>
{{ $errors->first('eol', '<span class="alert-msg"><i class="icon-remove-sign"></i> :message</span>') }}
</div>
</div>
</div>
<!-- Form actions -->
<div class="form-group">
<label class="col-md-2 control-label"></label>
+13 -2
View File
@@ -25,18 +25,18 @@ Asset Models ::
<th class="col-md-1">@lang('admin/models/table.numassets')</th>
<th class="col-md-2">Depreciation</th>
<th class="col-md-2">Category</th>
<th class="col-md-2">EOL</th>
<th class="col-md-2 actions">@lang('table.actions')</th>
</tr>
</thead>
<tbody>
@foreach ($models as $model)
<tr>
<td><a href="{{ route('update/model', $model->id) }}">{{{ $model->name }}}</a></td>
<td><a href="{{ route('view/model', $model->id) }}">{{{ $model->name }}}</a></td>
<td>{{ $model->modelno }}</td>
<td><a href="{{ route('view/model', $model->id) }}">{{ ($model->assets->count()) }}</a></td>
<td>
@if (($model->depreciation) && ($model->depreciation->id > 0))
{{ $model->depreciation->name }}
({{ $model->depreciation->months }} months)
@@ -50,6 +50,17 @@ Asset Models ::
{{ $model->category->name }}
@endif
</td>
<td>
@if ($model->eol)
{{ $model->eol }} months
@else
--
@endif
</td>
<td>
<a href="{{ route('update/model', $model->id) }}" class="btn btn-warning"><i class="icon-pencil icon-white"></i></a>
<a data-html="false" class="btn delete-asset btn-danger" data-toggle="modal" href="{{ route('delete/model', $model->id) }}" data-content="Are you sure you wish to delete this model?" data-title="Delete {{ htmlspecialchars($model->name) }}?" onClick="return false;"><i class="icon-trash icon-white"></i></a>
+4
View File
@@ -90,6 +90,10 @@ View Model {{ $model->model_tag }} ::
<li>Depreciation: {{ $model->depreciation->name }} ({{ $model->depreciation->months }} months)</li>
@endif
@if ($model->eol)
<li>EOL: {{ $model->eol }} months</li>
@endif
</ul>