@extends('layouts.admin')
@section('content')

<div class="card">
    <div class="card-header">
        {{ trans('global.edit') }} {{ trans('cruds.serviceComplaint.title_singular') }}
    </div>

    <div class="card-body">
        <form method="POST" action="{{ route("admin.service-complaints.update", [$serviceComplaint->id]) }}" enctype="multipart/form-data">
            @method('PUT')
            @csrf
            <div class="form-group">
                <label class="required" for="client_id">{{ trans('cruds.serviceComplaint.fields.client') }}</label>
                <select class="form-control select2 {{ $errors->has('client') ? 'is-invalid' : '' }}" name="client_id" id="client_id" required disabled>
                    @foreach($clients as $id => $entry)
                        <option value="{{ $id }}" {{ (old('client_id') ? old('client_id') : $serviceComplaint->client->id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                <input type="hidden" name="client_id" value="{{ old('client_id') ? old('client_id') : $serviceComplaint->client->id ?? '' }}">
                @if($errors->has('client'))
                    <div class="invalid-feedback">
                        {{ $errors->first('client') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.serviceComplaint.fields.client_helper') }}</span>
            </div>
            <div class="form-group">
                <label class="required" for="location_id">{{ trans('cruds.serviceComplaint.fields.location') }}</label>
                <select class="form-control select2 {{ $errors->has('location') ? 'is-invalid' : '' }}" name="location_id" id="location_id" required disabled>
                    @foreach($locations as $id => $entry)
                        <option value="{{ $id }}" {{ (old('location_id') ? old('location_id') : $serviceComplaint->location->id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                <input type="hidden" name="location_id" value="{{ old('location_id') ? old('location_id') : $serviceComplaint->location->id ?? '' }}">

                @if($errors->has('location'))
                    <div class="invalid-feedback">
                        {{ $errors->first('location') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.serviceComplaint.fields.location_helper') }}</span>
            </div>

            <div class="form-group">
                <label for="asset_id">{{ trans('cruds.serviceComplaint.fields.asset') }}</label>
                <select class="form-control select2 {{ $errors->has('asset') ? 'is-invalid' : '' }}" name="asset_id" id="asset_id">
                    @foreach($assets as $id => $entry)
                        <option value="{{ $id }}" {{ (old('asset_id') ? old('asset_id') : $serviceComplaint->asset_id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                @if($errors->has('asset'))
                    <div class="invalid-feedback">
                        {{ $errors->first('asset') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.serviceComplaint.fields.asset_helper') }}</span>
            </div>

            <div class="form-group">
                <label class="required" for="service_type_id">{{ trans('cruds.serviceComplaint.fields.service_type') }}</label>
                <select class="form-control select2 {{ $errors->has('service_type') ? 'is-invalid' : '' }}" name="service_type_id" id="service_type_id" required>
                    @foreach($service_types as $id => $entry)
                        <option value="{{ $id }}" {{ (old('service_type_id') ? old('service_type_id') : $serviceComplaint->service_type->id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                @if($errors->has('service_type'))
                    <div class="invalid-feedback">
                        {{ $errors->first('service_type') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.serviceComplaint.fields.service_type_helper') }}</span>
            </div>
            <div class="form-group">
                <label class="required" for="visit_type_id">{{ trans('cruds.serviceComplaint.fields.visit_type') }}</label>
                <select class="form-control select2 {{ $errors->has('visit_type') ? 'is-invalid' : '' }}" name="visit_type_id" id="visit_type_id" required>
                    @foreach($visit_types as $id => $entry)
                        <option value="{{ $id }}" {{ (old('visit_type_id') ? old('visit_type_id') : $serviceComplaint->visit_type->id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                @if($errors->has('visit_type'))
                    <div class="invalid-feedback">
                        {{ $errors->first('visit_type') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.serviceComplaint.fields.visit_type_helper') }}</span>
            </div>
            <div class="form-group">
                <label class="required" for="status_id">{{ trans('cruds.serviceComplaint.fields.status') }}</label>
                <select class="form-control select2 {{ $errors->has('status') ? 'is-invalid' : '' }}" name="status_id" id="status_id" required>
                    @foreach($statuses as $id => $entry)
                        <option value="{{ $id }}" {{ (old('status_id') ? old('status_id') : $serviceComplaint->status->id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                @if($errors->has('status'))
                    <div class="invalid-feedback">
                        {{ $errors->first('status') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.serviceComplaint.fields.status_helper') }}</span>
            </div>
            <div class="form-group">
                <label class="required" for="enginner_assigned_id">{{ trans('cruds.serviceComplaint.fields.enginner_assigned') }}</label>
                <select class="form-control select2 {{ $errors->has('enginner_assigned') ? 'is-invalid' : '' }}" name="enginner_assigned_id" id="enginner_assigned_id" required>
                    @foreach($enginner_assigneds as $id => $entry)
                        <option value="{{ $id }}" {{ (old('enginner_assigned_id') ? old('enginner_assigned_id') : $serviceComplaint->enginner_assigned->id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                @if($errors->has('enginner_assigned'))
                    <div class="invalid-feedback">
                        {{ $errors->first('enginner_assigned') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.serviceComplaint.fields.enginner_assigned_helper') }}</span>
            </div>
            <div class="form-group">
                <label class="required" for="supervisor_assigned_id">{{ trans('cruds.serviceComplaint.fields.supervisor_assigned') }}</label>
                <select class="form-control select2 {{ $errors->has('supervisor_assigned') ? 'is-invalid' : '' }}" name="supervisor_assigned_id" id="supervisor_assigned_id" required>
                    @foreach($supervisor_assigneds as $id => $entry)
                        <option value="{{ $id }}" {{ (old('supervisor_assigned_id') ? old('supervisor_assigned_id') : $serviceComplaint->supervisor_assigned->id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                @if($errors->has('supervisor_assigned'))
                    <div class="invalid-feedback">
                        {{ $errors->first('supervisor_assigned') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.serviceComplaint.fields.supervisor_assigned_helper') }}</span>
            </div>
            <div class="form-group">
                <label class="required" for="service_date">{{ trans('cruds.serviceComplaint.fields.service_date') }}</label>
                <input class="form-control date {{ $errors->has('service_date') ? 'is-invalid' : '' }}" type="text" name="service_date" id="service_date" value="{{ old('service_date', $serviceComplaint->service_date) }}" required>
                @if($errors->has('service_date'))
                    <div class="invalid-feedback">
                        {{ $errors->first('service_date') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.serviceComplaint.fields.service_date_helper') }}</span>
            </div>
            <div class="form-group">
                <label class="required" for="complaint">{{ trans('cruds.serviceComplaint.fields.complaint') }}</label>
                <input class="form-control {{ $errors->has('complaint') ? 'is-invalid' : '' }}" type="text" name="complaint" id="complaint" value="{{ old('complaint', $serviceComplaint->complaint) }}" required>
                @if($errors->has('complaint'))
                    <div class="invalid-feedback">
                        {{ $errors->first('complaint') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.serviceComplaint.fields.complaint_helper') }}</span>
            </div>
            <div class="form-group">
                <label for="team_id">{{ trans('cruds.serviceComplaint.fields.team') }}</label>
                <select class="form-control select2 {{ $errors->has('team') ? 'is-invalid' : '' }}" name="team_id" id="team_id">
                    @foreach($teams as $id => $entry)
                        <option value="{{ $id }}" {{ (old('team_id') ? old('team_id') : $serviceComplaint->team->id ?? '') == $id ? 'selected' : '' }}>{{ $entry }}</option>
                    @endforeach
                </select>
                @if($errors->has('team'))
                    <div class="invalid-feedback">
                        {{ $errors->first('team') }}
                    </div>
                @endif
                <span class="help-block">{{ trans('cruds.serviceComplaint.fields.team_helper') }}</span>
            </div>
            <div class="form-group">
                <button class="btn btn-danger btn-lg btn-block" type="submit">
                    {{ trans('global.save') }}
                </button>
            </div>
        </form>
    </div>
</div>



@endsection