From a4b220d6c31c97f6504023f0b52527825a4cd897 Mon Sep 17 00:00:00 2001 From: snipe Date: Sat, 19 Jul 2014 17:28:51 -0400 Subject: [PATCH] Fixed #191 - allow admins to assign a user during asset creation --- app/controllers/admin/AssetsController.php | 10 ++++++++-- app/lang/en/admin/hardware/form.php | 1 + app/views/backend/hardware/edit.blade.php | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/AssetsController.php b/app/controllers/admin/AssetsController.php index 3f7f804580ed..867422987360 100644 --- a/app/controllers/admin/AssetsController.php +++ b/app/controllers/admin/AssetsController.php @@ -151,11 +151,12 @@ public function getCreate() // Grab the dropdown list of models $model_list = array('' => '') + Model::orderBy('name', 'asc')->lists('name', 'id'); $supplier_list = array('' => '') + Supplier::orderBy('name', 'asc')->lists('name', 'id'); + $assigned_to = array('' => 'Select a User') + DB::table('users')->select(DB::raw('concat (first_name," ",last_name) as full_name, id'))->whereNull('deleted_at')->lists('full_name', 'id'); // Grab the dropdown list of status $statuslabel_list = array('' => Lang::get('general.pending')) + array('0' => Lang::get('general.ready_to_deploy')) + Statuslabel::orderBy('name', 'asc')->lists('name', 'id'); - return View::make('backend/hardware/edit')->with('supplier_list',$supplier_list)->with('model_list',$model_list)->with('statuslabel_list',$statuslabel_list)->with('asset',new Asset); + return View::make('backend/hardware/edit')->with('supplier_list',$supplier_list)->with('model_list',$model_list)->with('statuslabel_list',$statuslabel_list)->with('assigned_to',$assigned_to)->with('asset',new Asset); } @@ -201,6 +202,12 @@ public function postCreate() $asset->purchase_date = e(Input::get('purchase_date')); } + if (e(Input::get('assigned_to')) == '') { + $asset->assigned_to = 0; + } else { + $asset->assigned_to = e(Input::get('assigned_to')); + } + // Save the asset data $asset->name = e(Input::get('name')); $asset->serial = e(Input::get('serial')); @@ -210,7 +217,6 @@ public function postCreate() $asset->asset_tag = e(Input::get('asset_tag')); $asset->supplier_id = e(Input::get('supplier_id')); $asset->user_id = Sentry::getId(); - $asset->assigned_to = '0'; $asset->archived = '0'; $asset->physical = '1'; $asset->depreciate = '0'; diff --git a/app/lang/en/admin/hardware/form.php b/app/lang/en/admin/hardware/form.php index 2c6edd3bb4a1..7bb6d63c69c8 100644 --- a/app/lang/en/admin/hardware/form.php +++ b/app/lang/en/admin/hardware/form.php @@ -12,6 +12,7 @@ 'eol_date' => 'EOL Date', 'eol_rate' => 'EOL Rate', 'fully_depreciated' => 'Fully Depreciated', + 'help_checkout' => 'If you wish to assign this asset immediately, you should select "Ready to Deploy" from the status list above, or unexpected things may happen. ', 'manufacturer' => 'Manufacturer', 'model' => 'Model', 'months' => 'months', diff --git a/app/views/backend/hardware/edit.blade.php b/app/views/backend/hardware/edit.blade.php index 6c49fac55fda..93acce94fadb 100755 --- a/app/views/backend/hardware/edit.blade.php +++ b/app/views/backend/hardware/edit.blade.php @@ -144,6 +144,19 @@ + @if (!$asset->id) + +
+ +
+ {{ Form::select('assigned_to', $assigned_to , Input::old('assigned_to', $asset->assigned_to), array('class'=>'select2', 'style'=>'min-width:350px')) }} +

@lang('admin/hardware/form.help_checkout')

+ {{ $errors->first('assigned_to', ' :message') }} +
+
+ @endif +
@@ -155,6 +168,7 @@
+