{{-- Dependent create/edit modal form. --}}
@php $isEdit = $dependent->exists; @endphp
<div class="modal-dialog" role="document">
  <div class="modal-content">
    <form class="mportal-form"
        action="{{ $isEdit ? route('mportal.dependents.update', $dependent->id) : route('mportal.dependents.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 ? __('medportal::lang.edit_dependent') : __('medportal::lang.add_dependent') }}</h4>
      </div>
      <div class="modal-body">
        <div class="form-group">
          <label>@lang('medportal::lang.guardian') *</label>
          <select name="guardian_contact_id" class="form-control" required {{ $isEdit ? 'disabled' : '' }}>
            <option value="">@lang('medportal::lang.none')</option>
            @foreach($guardians as $id => $name)
              <option value="{{ $id }}" @selected((int) $dependent->guardian_contact_id === (int) $id)>{{ $name }}</option>
            @endforeach
          </select>
          @if($isEdit)<input type="hidden" name="guardian_contact_id" value="{{ $dependent->guardian_contact_id }}">@endif
        </div>
        <div class="form-group">
          <label>@lang('medportal::lang.dependent_patient') *</label>
          <select name="dependent_patient_id" class="form-control" required {{ $isEdit ? 'disabled' : '' }}>
            <option value="">@lang('medportal::lang.select_patient')</option>
            @foreach($patients as $id => $name)
              <option value="{{ $id }}" @selected((int) $dependent->dependent_patient_id === (int) $id)>{{ $name }}</option>
            @endforeach
          </select>
          @if($isEdit)<input type="hidden" name="dependent_patient_id" value="{{ $dependent->dependent_patient_id }}">@endif
        </div>
        <div class="form-group">
          <label>@lang('medportal::lang.relationship') *</label>
          <select name="relationship" class="form-control" required>
            @foreach($relationships as $rel)
              <option value="{{ $rel }}" @selected($dependent->relationship === $rel)>@lang('medportal::lang.rel_' . $rel)</option>
            @endforeach
          </select>
        </div>
        <div class="row">
          <div class="col-md-6">
            <label class="checkbox-inline">
              <input type="checkbox" name="can_book" value="1" @checked(! $isEdit || $dependent->can_book)> @lang('medportal::lang.can_book')
            </label>
          </div>
          <div class="col-md-6">
            <label class="checkbox-inline">
              <input type="checkbox" name="can_view_records" value="1" @checked(! $isEdit || $dependent->can_view_records)> @lang('medportal::lang.can_view_records')
            </label>
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">@lang('medportal::lang.cancel')</button>
        <button type="submit" class="btn btn-primary">@lang('medportal::lang.save')</button>
      </div>
    </form>
  </div>
</div>
