{{-- Shift-template create/edit modal form. --}}
@php $isEdit = $template->exists; @endphp
<div class="modal-dialog" role="document">
  <div class="modal-content">
    <form class="medwf-form"
        action="{{ $isEdit ? route('medwf.templates.update', $template->id) : route('medwf.templates.store') }}"
        method="POST">
      {{ csrf_field() }}
      @if($isEdit) {{ method_field('PUT') }} @endif
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">{{ $isEdit ? __('medworkforce::lang.edit_template') : __('medworkforce::lang.add_template') }}</h4>
      </div>
      <div class="modal-body">
        <div class="row">
          <div class="col-md-8 form-group">
            <label>@lang('medworkforce::lang.template_name') *</label>
            <input type="text" name="name" class="form-control" required
                   placeholder="{{ __('medworkforce::lang.template_hint') }}" value="{{ $template->name }}">
          </div>
          <div class="col-md-4 form-group">
            <label>@lang('medworkforce::lang.color')</label>
            <input type="color" name="color" class="form-control" value="{{ $template->color ?: '#3c8dbc' }}">
          </div>
        </div>
        <div class="row">
          <div class="col-md-4 form-group">
            <label>@lang('medworkforce::lang.start_time') *</label>
            <input type="time" name="start_time" class="form-control" required value="{{ substr((string) $template->start_time, 0, 5) }}">
          </div>
          <div class="col-md-4 form-group">
            <label>@lang('medworkforce::lang.end_time') *</label>
            <input type="time" name="end_time" class="form-control" required value="{{ substr((string) $template->end_time, 0, 5) }}">
          </div>
          <div class="col-md-4 form-group">
            <label>@lang('medworkforce::lang.break_minutes')</label>
            <input type="number" name="break_minutes" class="form-control" min="0" value="{{ $template->break_minutes ?? 0 }}">
          </div>
        </div>
        <div class="row">
          <div class="col-md-6 form-group">
            <label>@lang('medworkforce::lang.department')</label>
            <select name="department_id" class="form-control">
              <option value="">@lang('medworkforce::lang.none')</option>
              @foreach($departments as $id => $name)
                <option value="{{ $id }}" @selected((int) $template->department_id === (int) $id)>{{ $name }}</option>
              @endforeach
            </select>
          </div>
          <div class="col-md-6 form-group">
            <label>@lang('medworkforce::lang.location')</label>
            <select name="business_location_id" class="form-control">
              <option value="">@lang('medworkforce::lang.none')</option>
              @foreach($locations as $id => $name)
                <option value="{{ $id }}" @selected((int) $template->business_location_id === (int) $id)>{{ $name }}</option>
              @endforeach
            </select>
          </div>
        </div>
        <div class="row">
          <div class="col-md-6">
            <label class="checkbox-inline">
              <input type="checkbox" name="night_allowance" value="1" @checked($template->night_allowance)>
              @lang('medworkforce::lang.night_allowance')
            </label>
          </div>
          <div class="col-md-6">
            <label class="checkbox-inline">
              <input type="checkbox" name="is_active" value="1" @checked(! $isEdit || $template->is_active)>
              @lang('medworkforce::lang.active')
            </label>
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">@lang('medworkforce::lang.cancel')</button>
        <button type="submit" class="btn btn-primary">@lang('medworkforce::lang.save')</button>
      </div>
    </form>
  </div>
</div>
