{{-- Ward create/edit modal form. --}}
@php $isEdit = $ward->exists; @endphp
<div class="modal-dialog" role="document">
  <div class="modal-content">
    <form class="medward-form"
        action="{{ $isEdit ? route('medward.wards.update', $ward->id) : route('medward.wards.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 ? __('medward::lang.edit_ward') : __('medward::lang.add_ward') }}</h4>
      </div>
      <div class="modal-body">
        <div class="row">
          <div class="col-md-8 form-group">
            <label>@lang('medward::lang.ward_name') *</label>
            <input type="text" name="name" class="form-control" required value="{{ $ward->name }}">
          </div>
          <div class="col-md-4 form-group">
            <label>@lang('medward::lang.ward_code')</label>
            <input type="text" name="code" class="form-control" value="{{ $ward->code }}">
          </div>
        </div>
        <div class="row">
          <div class="col-md-6 form-group">
            <label>@lang('medward::lang.ward_type') *</label>
            <select name="ward_type" class="form-control" required>
              @foreach($wardTypes as $type)
                <option value="{{ $type }}" @selected($ward->ward_type === $type)>@lang('medward::lang.ward_type_' . $type)</option>
              @endforeach
            </select>
          </div>
          <div class="col-md-6 form-group">
            <label>@lang('medward::lang.floor')</label>
            <input type="text" name="floor" class="form-control" value="{{ $ward->floor }}">
          </div>
        </div>
        <div class="row">
          <div class="col-md-6 form-group">
            <label>@lang('medward::lang.department')</label>
            <select name="dept_id" class="form-control">
              <option value="">@lang('medward::lang.none')</option>
              @foreach($departments as $id => $name)
                <option value="{{ $id }}" @selected((int) $ward->dept_id === (int) $id)>{{ $name }}</option>
              @endforeach
            </select>
          </div>
          <div class="col-md-6 form-group">
            <label>@lang('medward::lang.in_charge')</label>
            <input type="number" name="in_charge_user_id" class="form-control" value="{{ $ward->in_charge_user_id }}">
          </div>
        </div>
        <div class="form-group">
          <label>@lang('medward::lang.notes')</label>
          <textarea name="notes" class="form-control" rows="2">{{ $ward->notes }}</textarea>
        </div>
        <div class="checkbox">
          <label>
            <input type="checkbox" name="is_active" value="1" @checked(! $isEdit || $ward->is_active)>
            @lang('medward::lang.active')
          </label>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">@lang('medward::lang.cancel')</button>
        <button type="submit" class="btn btn-primary">@lang('medward::lang.save')</button>
      </div>
    </form>
  </div>
</div>
