Skip to content

Commit

Permalink
Fixed #191 - allow admins to assign a user during asset creation
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Jul 19, 2014
1 parent a8c2955 commit a4b220d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/controllers/admin/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

Expand Down Expand Up @@ -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'));
Expand All @@ -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';
Expand Down
1 change: 1 addition & 0 deletions app/lang/en/admin/hardware/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
14 changes: 14 additions & 0 deletions app/views/backend/hardware/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,19 @@
</div>
</div>

@if (!$asset->id)
<!-- Assigned To -->
<div class="form-group {{ $errors->has('assigned_to') ? ' has-error' : '' }}">
<label for="parent" class="col-md-2 control-label">@lang('admin/hardware/form.checkout_to')
</label>
<div class="col-md-7">
{{ Form::select('assigned_to', $assigned_to , Input::old('assigned_to', $asset->assigned_to), array('class'=>'select2', 'style'=>'min-width:350px')) }}
<p class="help-block">@lang('admin/hardware/form.help_checkout')</p>
{{ $errors->first('assigned_to', '<span class="alert-msg"><i class="icon-remove-sign"></i> :message</span>') }}
</div>
</div>
@endif

<!-- Requestable -->
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
Expand All @@ -155,6 +168,7 @@
</div>
</div>


<!-- Form actions -->
<div class="form-group">
<label class="col-md-2 control-label"></label>
Expand Down

0 comments on commit a4b220d

Please sign in to comment.