mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Associate serials with multiple asset creation
This commit is contained in:
parent
476b58632b
commit
ecb8204c3c
|
@ -117,12 +117,17 @@ class AssetsController extends Controller
|
|||
$asset_tags = $request->input('asset_tags');
|
||||
|
||||
$success = false;
|
||||
$serials = $request->input('serials');
|
||||
|
||||
for ($a = 1; $a <= count($asset_tags); $a++) {
|
||||
|
||||
$asset = new Asset();
|
||||
$asset->model()->associate(AssetModel::find($request->input('model_id')));
|
||||
$asset->name = $request->input('name');
|
||||
$asset->serial = $request->input('serial');
|
||||
// Check for a corresponding serial
|
||||
if (($serials) && (array_key_exists($a, $serials))) {
|
||||
$asset->serial = $serials[$a];
|
||||
}
|
||||
$asset->company_id = Company::getIdForCurrentUser($request->input('company_id'));
|
||||
$asset->model_id = $request->input('model_id');
|
||||
$asset->order_number = $request->input('order_number');
|
||||
|
|
|
@ -34,9 +34,9 @@
|
|||
<button class="add_field_button btn btn-default btn-sm"><i class="fa fa-plus"></i></button>
|
||||
</div>
|
||||
@endif
|
||||
{!! $errors->first('asset_tag', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
{!! $errors->first('asset_tags', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
</div>
|
||||
@include ('partials.forms.edit.serial', ['translated_serial' => trans('admin/hardware/form.serial')])
|
||||
@include ('partials.forms.edit.serial', ['fieldname'=> 'serials[1]', 'translated_serial' => trans('admin/hardware/form.serial')])
|
||||
|
||||
<div class="input_fields_wrap">
|
||||
</div>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<!-- Serial -->
|
||||
<div class="form-group {{ $errors->has('serial') ? ' has-error' : '' }}">
|
||||
<label for="serial" class="col-md-3 control-label">{{ trans('admin/hardware/form.serial') }} </label>
|
||||
<label for="{{ $fieldname }}" class="col-md-3 control-label">{{ trans('admin/hardware/form.serial') }} </label>
|
||||
<div class="col-md-7 col-sm-12{{ (\App\Helpers\Helper::checkIfRequired($item, 'serial')) ? ' required' : '' }}">
|
||||
<input class="form-control" type="text" name="serial" id="serial" value="{{ Input::old('serial', $item->serial) }}" />
|
||||
<input class="form-control" type="text" name="{{ $fieldname }}" id="serial" value="{{ Input::old('serial', $item->serial) }}" />
|
||||
{!! $errors->first('serial', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in a new issue