Merge pull request #78 from peelman/ExpandManufacturer

Expand Manufacturer
This commit is contained in:
snipe
2013-11-27 09:05:10 -08:00
4 changed files with 37 additions and 7 deletions
+17 -7
View File
@@ -9,6 +9,7 @@ use Setting;
use Sentry;
use DB;
use Depreciation;
use Manufacturer;
use Str;
use Validator;
use View;
@@ -38,8 +39,14 @@ class ModelsController extends AdminController {
{
// Show the page
$depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id');
$manufacturer_list = array('' => 'Select One') + Manufacturer::lists('name', 'id');
$category_list = array('' => '') + DB::table('categories')->lists('name', 'id');
return View::make('backend/models/edit')->with('category_list',$category_list)->with('depreciation_list',$depreciation_list)->with('model',new Model);
$view = View::make('backend/models/edit');
$view->with('category_list',$category_list);
$view->with('depreciation_list',$depreciation_list);
$view->with('manufacturer_list',$manufacturer_list);
$view->with('model',new Model);
return $view;
}
@@ -65,6 +72,7 @@ class ModelsController extends AdminController {
$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();
@@ -99,13 +107,18 @@ 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 model management page
return Redirect::to('assets/models')->with('error', Lang::get('admin/models/message.does_not_exist'));
}
$depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id');
$manufacturer_list = array('' => 'Select One') + Manufacturer::lists('name', 'id');
$category_list = array('' => '') + DB::table('categories')->lists('name', 'id');
return View::make('backend/models/edit', compact('model'))->with('category_list',$category_list)->with('depreciation_list',$depreciation_list);
$view = View::make('backend/models/edit', compact('model'));
$view->with('category_list',$category_list);
$view->with('depreciation_list',$depreciation_list);
$view->with('manufacturer_list',$manufacturer_list);
return $view;
}
@@ -135,6 +148,7 @@ class ModelsController extends AdminController {
$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'));
@@ -183,9 +197,6 @@ class ModelsController extends AdminController {
// Redirect to the models management page
return Redirect::to('assets/models')->with('success', Lang::get('admin/models/message.delete.success'));
}
}
@@ -213,5 +224,4 @@ class ModelsController extends AdminController {
}
}
+4
View File
@@ -145,5 +145,9 @@ class Asset extends Elegant {
return $this->belongsTo('Depreciation','id');
}
public function model()
{
return $this->belongsTo('Model','model_id');
}
}
+8
View File
@@ -105,6 +105,14 @@ View Asset {{ $asset->asset_tag }} ::
<h6><br>More Info:</h6>
<ul>
@if ($asset->model->manufacturer)
<li>Manufacturer: {{ $asset->model->manufacturer->name }} </li>
<li>Model: {{ $asset->model->name }} / {{ $asset->model->modelno }}</li>
@endif
@if ($asset->purchase_date)
<li>Purchased On: {{ $asset->purchase_date }} </li>
@endif
@if ($asset->purchase_date)
<li>Purchased On: {{ $asset->purchase_date }} </li>
+8
View File
@@ -50,6 +50,14 @@
</div>
</div>
<!-- Manufacturer -->
<div class="control-group {{ $errors->has('manufacturer_id') ? 'error' : '' }}">
<label class="control-label" for="parent">Manufacturer</label>
<div class="controls">
{{ Form::select('manufacturer_id', $manufacturer_list , Input::old('manufacturer_id', $model->manufacturer_id), array('class'=>'select2', 'style'=>'width:250px')) }}
{{ $errors->first('manufacturer_id', '<span class="help-inline">:message</span>') }}
</div>
</div>
<!-- Depreciation -->
<div class="control-group {{ $errors->has('depreciation_id') ? 'error' : '' }}">