snipe-it/resources/views/models/custom_fields_form_bulk_edit.blade.php

124 lines
6.6 KiB
PHP
Raw Normal View History

2023-04-03 15:54:31 -07:00
@php
2023-04-17 11:57:48 -07:00
//set array up before loop so it doesn't get wiped at every iteration
2023-04-05 13:16:46 -07:00
$fields = [];
2023-04-03 15:54:31 -07:00
@endphp
@foreach($models as $model)
@if (($model) && ($model->fieldset))
@foreach($model->fieldset->fields AS $field)
2023-04-17 11:57:48 -07:00
@php
//prevents some duplicate queries - open to a better way of skipping dupes in output
//its ugly, but if we'd rather deal with duplicate queries we can get rid of this.
if (in_array($field->db_column_name(), $fields)) {
$duplicate = true;
continue;
} else {
$duplicate = false;
}
$fields[] = $field->db_column_name();
@endphp
2023-04-03 15:54:31 -07:00
<div class="form-group{{ $errors->has($field->db_column_name()) ? ' has-error' : '' }}">
<label for="{{ $field->db_column_name() }}" class="col-md-3 control-label">{{ $field->name }} </label>
<div class="col-md-7 col-sm-12{{ ($field->pivot->required=='1') ? ' required' : '' }}">
@if ($field->element!='text')
<!-- Listbox -->
@if ($field->element=='listbox')
2023-04-05 13:16:46 -07:00
{{ Form::select($field->db_column_name(), $field->formatFieldValuesAsArray(),
2023-04-03 15:54:31 -07:00
Request::old($field->db_column_name(),(isset($item) ? Helper::gracefulDecrypt($field, htmlspecialchars($item->{$field->db_column_name()}, ENT_QUOTES)) : $field->defaultValue($model->id))), ['class'=>'format select2 form-control']) }}
@elseif ($field->element=='textarea')
2023-06-28 10:59:54 -07:00
@if($field->is_unique)
2023-06-28 11:08:34 -07:00
<input type="text" class="form-control" disabled value="{{ trans('/admin/hardware/form.bulk_update_custom_field_unique') }}">
2023-06-28 10:59:54 -07:00
@endif
@if(!$field->is_unique)
2023-06-28 11:00:59 -07:00
<textarea class="col-md-6 form-control" id="{{ $field->db_column_name() }}" name="{{ $field->db_column_name() }}">{{ Request::old($field->db_column_name(),(isset($item) ? Helper::gracefulDecrypt($field, $item->{$field->db_column_name()}) : $field->defaultValue($model->id))) }}</textarea>
@endif
2023-04-03 15:54:31 -07:00
@elseif ($field->element=='checkbox')
<!-- Checkboxes -->
@foreach ($field->formatFieldValuesAsArray() as $key => $value)
<div>
<label>
<input type="checkbox" value="{{ $value }}" name="{{ $field->db_column_name() }}[]" class="minimal" {{ isset($item) ? (in_array($value, array_map('trim', explode(',', $item->{$field->db_column_name()}))) ? ' checked="checked"' : '') : (Request::old($field->db_column_name()) != '' ? ' checked="checked"' : (in_array($key, array_map('trim', explode(',', $field->defaultValue($model->id)))) ? ' checked="checked"' : '')) }}>
{{ $value }}
</label>
</div>
@endforeach
2023-04-05 13:16:46 -07:00
@elseif ($field->element=='radio')
@foreach ($field->formatFieldValuesAsArray() as $value)
2023-04-03 15:54:31 -07:00
<div>
<label>
<input type="radio" value="{{ $value }}" name="{{ $field->db_column_name() }}" class="minimal" {{ isset($item) ? ($item->{$field->db_column_name()} == $value ? ' checked="checked"' : '') : (Request::old($field->db_column_name()) != '' ? ' checked="checked"' : (in_array($value, explode(', ', $field->defaultValue($model->id))) ? ' checked="checked"' : '')) }}>
{{ $value }}
</label>
</div>
2023-04-05 13:16:46 -07:00
@endforeach
2023-04-03 15:54:31 -07:00
2023-04-05 13:16:46 -07:00
@endif
2023-04-03 15:54:31 -07:00
2023-04-05 13:16:46 -07:00
@else
2023-04-03 15:54:31 -07:00
<!-- Date field -->
2023-04-05 13:16:46 -07:00
@if ($field->format=='DATE')
2023-04-03 15:54:31 -07:00
2023-04-05 13:16:46 -07:00
<div class="input-group col-md-5" style="padding-left: 0px;">
<div class="input-group date" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-autoclose="true" data-date-clear-btn="true">
<input type="text" class="form-control" placeholder="{{ trans('general.select_date') }}" name="{{ $field->db_column_name() }}" id="{{ $field->db_column_name() }}" readonly value="{{ old($field->db_column_name(),(isset($item) ? Helper::gracefulDecrypt($field, $item->{$field->db_column_name()}) : $field->defaultValue($model->id))) }}" style="background-color:inherit">
<span class="input-group-addon"><i class="fas fa-calendar" aria-hidden="true"></i></span>
</div>
</div>
2023-04-03 15:54:31 -07:00
@else
2023-06-28 10:57:23 -07:00
2023-04-03 15:54:31 -07:00
@if (($field->field_encrypted=='0') || (Gate::allows('admin')))
2023-06-28 11:00:59 -07:00
@if ($field->is_unique)
2023-06-28 11:08:34 -07:00
<input type="text" class="form-control" disabled value="{{trans('/admin/hardware/form.bulk_update_custom_field_unique')}}">
2023-06-28 11:00:59 -07:00
@endif
@if(!$field->is_unique)
<input type="text" value="{{ Request::old($field->db_column_name(),(isset($item) ? Helper::gracefulDecrypt($field, $item->{$field->db_column_name()}) : $field->defaultValue($model->id))) }}" id="{{ $field->db_column_name() }}" class="form-control" name="{{ $field->db_column_name() }}" placeholder="Enter {{ strtolower($field->format) }} text">
@endif
@else
<input type="text" value="{{ strtoupper(trans('admin/custom_fields/general.encrypted')) }}" class="form-control disabled" disabled>
2023-04-03 15:54:31 -07:00
@endif
2023-06-28 10:57:23 -07:00
2023-04-03 15:54:31 -07:00
@endif
@endif
@if ($field->help_text!='')
<p class="help-block">{{ $field->help_text }}</p>
@endif
2023-06-28 08:17:28 -07:00
<p>{{ trans('admin/hardware/form.bulk_update_model_prefix') }}
@foreach($field->assetModels() as $assetModel)
@if(in_array($assetModel->name, $modelNames))
2023-04-05 13:16:46 -07:00
{{$assetModel->name}}{{($loop->last) ? '' : ', '}}
@endif
@endforeach
2023-04-05 13:16:46 -07:00
</p>
2023-04-03 15:54:31 -07:00
<?php
$errormessage=$errors->first($field->db_column_name());
if ($errormessage) {
$errormessage=preg_replace('/ snipeit /', '', $errormessage);
print('<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> '.$errormessage.'</span>');
}
?>
</div>
@if ($field->field_encrypted)
<div class="col-md-1 col-sm-1 text-left">
<i class="fas fa-lock" data-toggle="tooltip" data-placement="top" title="{{ trans('admin/custom_fields/general.value_encrypted') }}"></i>
</div>
@endif
</div>
@endforeach
@endif
@endforeach