From a929b635ffc7c4262653585d7336b71a577ccbbc Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 27 Oct 2016 15:33:48 -0700 Subject: [PATCH] Fixes #2809 - adds serial number to components --- app/Http/Controllers/ComponentsController.php | 5 ++- app/Models/Component.php | 1 + ..._10_27_151715_add_serial_to_components.php | 33 +++++++++++++++++++ resources/views/components/edit.blade.php | 11 +++++++ resources/views/components/index.blade.php | 1 + resources/views/components/view.blade.php | 6 ++++ 6 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2016_10_27_151715_add_serial_to_components.php diff --git a/app/Http/Controllers/ComponentsController.php b/app/Http/Controllers/ComponentsController.php index 406ca1673c..998558d4c5 100644 --- a/app/Http/Controllers/ComponentsController.php +++ b/app/Http/Controllers/ComponentsController.php @@ -89,6 +89,7 @@ class ComponentsController extends Controller $component->company_id = Company::getIdForCurrentUser(Input::get('company_id')); $component->order_number = e(Input::get('order_number')); $component->min_amt = e(Input::get('min_amt')); + $component->serial_number = e(Input::get('serial_number')); if (e(Input::get('purchase_date')) == '') { $component->purchase_date = null; @@ -174,6 +175,7 @@ class ComponentsController extends Controller $component->company_id = Company::getIdForCurrentUser(Input::get('company_id')); $component->order_number = e(Input::get('order_number')); $component->min_amt = e(Input::get('min_amt')); + $component->serial_number = e(Input::get('serial_number')); if (e(Input::get('purchase_date')) == '') { $component->purchase_date = null; @@ -422,7 +424,7 @@ class ComponentsController extends Controller $limit = 50; } - $allowed_columns = ['id','name','min_amt','order_number','purchase_date','purchase_cost','companyName','category','total_qty']; + $allowed_columns = ['id','name','min_amt','order_number','serial_number','purchase_date','purchase_cost','companyName','category','total_qty']; $order = Input::get('order') === 'asc' ? 'asc' : 'desc'; $sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at'; @@ -470,6 +472,7 @@ class ComponentsController extends Controller 'checkbox' =>'
', 'id' => $component->id, 'name' => (string)link_to('admin/components/'.$component->id.'/view', e($component->name)), + 'serial_number' => $component->serial_number, 'location' => ($component->location) ? e($component->location->name) : '', 'total_qty' => e($component->total_qty), 'min_amt' => e($component->min_amt), diff --git a/app/Models/Component.php b/app/Models/Component.php index a13b164181..c73c9d53e1 100644 --- a/app/Models/Component.php +++ b/app/Models/Component.php @@ -141,6 +141,7 @@ class Component extends Model }); })->orWhere('components.name', 'LIKE', '%'.$search.'%') ->orWhere('components.order_number', 'LIKE', '%'.$search.'%') + ->orWhere('components.serial_number', 'LIKE', '%'.$search.'%') ->orWhere('components.purchase_cost', 'LIKE', '%'.$search.'%') ->orWhere('components.purchase_date', 'LIKE', '%'.$search.'%'); } diff --git a/database/migrations/2016_10_27_151715_add_serial_to_components.php b/database/migrations/2016_10_27_151715_add_serial_to_components.php new file mode 100644 index 0000000000..94c6dfc6a9 --- /dev/null +++ b/database/migrations/2016_10_27_151715_add_serial_to_components.php @@ -0,0 +1,33 @@ +string('serial_number')->nullable()->default(null); + }); + + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('components', function ($table) { + $table->dropColumn('serial_number'); + }); + + } +} diff --git a/resources/views/components/edit.blade.php b/resources/views/components/edit.blade.php index 9e20716f51..93db1ee199 100644 --- a/resources/views/components/edit.blade.php +++ b/resources/views/components/edit.blade.php @@ -96,6 +96,17 @@ + +
+ + {{ Form::label('name', trans('admin/hardware/form.serial'), array('class' => 'col-md-3 control-label')) }} + +
+ + {!! $errors->first('serial_number', ' :message') !!} +
+
+ @if (\App\Models\Company::isCurrentUserAuthorized()) diff --git a/resources/views/components/index.blade.php b/resources/views/components/index.blade.php index 266617389b..aa1e161a4f 100644 --- a/resources/views/components/index.blade.php +++ b/resources/views/components/index.blade.php @@ -52,6 +52,7 @@ {{ trans('general.id') }} {{ trans('admin/companies/table.title') }} {{ trans('admin/components/table.title') }} + {{ trans('admin/hardware/form.serial') }} {{ trans('general.location') }} {{ trans('general.category') }} {{ trans('admin/components/general.total') }} diff --git a/resources/views/components/view.blade.php b/resources/views/components/view.blade.php index e84fb34f32..2b432eeca9 100644 --- a/resources/views/components/view.blade.php +++ b/resources/views/components/view.blade.php @@ -74,6 +74,12 @@
+ + @if ($component->serial_number!='') +
{{ trans('admin/hardware/form.serial') }}: + {{ $component->serial_number }}
+ @endif + @if ($component->purchase_date)
{{ trans('admin/components/general.date') }}: {{ $component->purchase_date }}