From b5a0da03a8a50ab1b0b729563d1b9eff1daaeebf Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 10:06:36 -0500 Subject: [PATCH 1/8] Add manufacturer to edit form --- app/controllers/admin/ModelsController.php | 1 + app/views/backend/models/edit.blade.php | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index 1dea8dd9f9..0b841a9ed2 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -38,6 +38,7 @@ class ModelsController extends AdminController { { // Show the page $depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); + $manufacturer_list = array('' => 'N/A') + 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); } diff --git a/app/views/backend/models/edit.blade.php b/app/views/backend/models/edit.blade.php index 7288d48cc7..e5456361de 100755 --- a/app/views/backend/models/edit.blade.php +++ b/app/views/backend/models/edit.blade.php @@ -50,6 +50,14 @@ + +
+ +
+ {{ Form::select('manufacturer_id', $manufacturer_list , Input::old('manufacturer_id', $model->manufacturer_id), array('class'=>'select2', 'style'=>'width:250px')) }} + {{ $errors->first('manufacturer_id', ':message') }} +
+
From c2d889de12a9290bda02526d6c0ee6695d799739 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 10:18:15 -0500 Subject: [PATCH 2/8] Add necessary use statements, clean up the run-on return statement that was forming... --- app/controllers/admin/ModelsController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index 0b841a9ed2..627937e49f 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -9,6 +9,7 @@ use Setting; use Sentry; use DB; use Depreciation; +use Manufacturer; use Str; use Validator; use View; @@ -40,7 +41,12 @@ class ModelsController extends AdminController { $depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); $manufacturer_list = array('' => 'N/A') + 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; } From 996458dde3b38645e63bee132f0b86ae1ce03579 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 10:18:43 -0500 Subject: [PATCH 3/8] missing semicolon --- app/controllers/admin/ModelsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index 627937e49f..f4dd64f505 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -41,7 +41,7 @@ class ModelsController extends AdminController { $depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); $manufacturer_list = array('' => 'N/A') + Manufacturer::lists('name', 'id'); $category_list = array('' => '') + DB::table('categories')->lists('name', 'id'); - $view = View::make('backend/models/edit') + $view = View::make('backend/models/edit'); $view->with('category_list',$category_list); $view->with('depreciation_list',$depreciation_list); $view->with('manufacturer_list',$manufacturer_list); From 6f59617546bda2a923bc1e900e03147a214eb6cd Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 10:23:11 -0500 Subject: [PATCH 4/8] Add to controller's edit method too... --- app/controllers/admin/ModelsController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index f4dd64f505..50810dfa10 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -111,8 +111,14 @@ class ModelsController extends AdminController { } $depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); + $manufacturer_list = array('' => 'N/A') + 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); + $view->with('model',new Model); + return $view; } From b7579a14206a83f93003143e4dfa48cd662b1905 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 10:25:25 -0500 Subject: [PATCH 5/8] Copy/Paste Error --- app/controllers/admin/ModelsController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index 50810dfa10..f40d48e2af 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -117,7 +117,6 @@ class ModelsController extends AdminController { $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; } From 9f19792985992a256ddb824f18342029381d8b5c Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 10:32:50 -0500 Subject: [PATCH 6/8] Save manufacturer ID --- app/controllers/admin/ModelsController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index f40d48e2af..790bf4f987 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -72,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(); @@ -106,7 +107,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 model management page return Redirect::to('assets/models')->with('error', Lang::get('admin/models/message.does_not_exist')); } @@ -147,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')); From d6ba98252d5f9e7f3ae50be61a8a4448d37f3ea3 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 11:37:02 -0500 Subject: [PATCH 7/8] Change N/A to Select One --- app/controllers/admin/ModelsController.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index 790bf4f987..038c104bfc 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -39,7 +39,7 @@ class ModelsController extends AdminController { { // Show the page $depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); - $manufacturer_list = array('' => 'N/A') + Manufacturer::lists('name', 'id'); + $manufacturer_list = array('' => 'Select One') + Manufacturer::lists('name', 'id'); $category_list = array('' => '') + DB::table('categories')->lists('name', 'id'); $view = View::make('backend/models/edit'); $view->with('category_list',$category_list); @@ -112,7 +112,7 @@ class ModelsController extends AdminController { } $depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); - $manufacturer_list = array('' => 'N/A') + Manufacturer::lists('name', 'id'); + $manufacturer_list = array('' => 'Select One') + Manufacturer::lists('name', 'id'); $category_list = array('' => '') + DB::table('categories')->lists('name', 'id'); $view = View::make('backend/models/edit', compact('model')); $view->with('category_list',$category_list); @@ -197,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')); } - - - } @@ -227,5 +224,4 @@ class ModelsController extends AdminController { } - } From 301ef3fddb77111274feb2d0fb1f3d02e595d08c Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 27 Nov 2013 11:37:22 -0500 Subject: [PATCH 8/8] Add Manufacturer and Model info to asset page --- app/models/Asset.php | 4 ++++ app/views/backend/assets/view.blade.php | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/app/models/Asset.php b/app/models/Asset.php index 8d90d42702..2b8b1ac562 100644 --- a/app/models/Asset.php +++ b/app/models/Asset.php @@ -145,5 +145,9 @@ class Asset extends Elegant { return $this->belongsTo('Depreciation','id'); } + public function model() + { + return $this->belongsTo('Model','model_id'); + } } diff --git a/app/views/backend/assets/view.blade.php b/app/views/backend/assets/view.blade.php index b6aafe1a20..d11b90dfbd 100644 --- a/app/views/backend/assets/view.blade.php +++ b/app/views/backend/assets/view.blade.php @@ -105,6 +105,14 @@ View Asset {{ $asset->asset_tag }} ::

More Info:
    + @if ($asset->model->manufacturer) +
  • Manufacturer: {{ $asset->model->manufacturer->name }}
  • +
  • Model: {{ $asset->model->name }} / {{ $asset->model->modelno }}
  • + @endif + + @if ($asset->purchase_date) +
  • Purchased On: {{ $asset->purchase_date }}
  • + @endif @if ($asset->purchase_date)
  • Purchased On: {{ $asset->purchase_date }}