{{-- Payer create/edit modal form. --}}
@php $isEdit = $payer->exists; @endphp
<div class="modal-dialog" role="document">
  <div class="modal-content">
    <form class="medbill-form"
        action="{{ $isEdit ? route('medbill.payers.update', $payer->id) : route('medbill.payers.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 ? __('medbilling::lang.edit_payer') : __('medbilling::lang.add_payer') }}</h4>
      </div>
      <div class="modal-body">
        <div class="row">
          <div class="col-md-8 form-group">
            <label>@lang('medbilling::lang.payer_name') *</label>
            <input type="text" name="name" class="form-control" required value="{{ $payer->name }}">
          </div>
          <div class="col-md-4 form-group">
            <label>@lang('medbilling::lang.payer_code')</label>
            <input type="text" name="code" class="form-control" value="{{ $payer->code }}">
          </div>
        </div>
        <div class="row">
          <div class="col-md-6 form-group">
            <label>@lang('medbilling::lang.payer_type') *</label>
            <select name="payer_type" class="form-control" required>
              @foreach($payerTypes as $type)
                <option value="{{ $type }}" @selected($payer->payer_type === $type)>@lang('medbilling::lang.payer_type_' . $type)</option>
              @endforeach
            </select>
          </div>
          <div class="col-md-6 form-group">
            <label>@lang('medbilling::lang.claim_submission') *</label>
            <select name="claim_submission" class="form-control" required>
              @foreach($submissions as $sub)
                <option value="{{ $sub }}" @selected($payer->claim_submission === $sub)>@lang('medbilling::lang.submission_' . $sub)</option>
              @endforeach
            </select>
          </div>
        </div>
        <div class="row">
          <div class="col-md-6 form-group">
            <label>@lang('medbilling::lang.default_price_group')</label>
            <select name="default_price_group_id" class="form-control">
              <option value="">@lang('medbilling::lang.none')</option>
              @foreach($priceGroups as $id => $name)
                <option value="{{ $id }}" @selected((int) $payer->default_price_group_id === (int) $id)>{{ $name }}</option>
              @endforeach
            </select>
          </div>
          <div class="col-md-6 form-group">
            <label>@lang('medbilling::lang.settlement_terms_days')</label>
            <input type="number" name="settlement_terms_days" class="form-control" min="0" value="{{ $payer->settlement_terms_days }}">
          </div>
        </div>
        <div class="row">
          <div class="col-md-4 form-group">
            <label>@lang('medbilling::lang.contact_phone')</label>
            <input type="text" name="contact_phone" class="form-control" value="{{ data_get($payer->contact, 'phone') }}">
          </div>
          <div class="col-md-4 form-group">
            <label>@lang('medbilling::lang.contact_email')</label>
            <input type="text" name="contact_email" class="form-control" value="{{ data_get($payer->contact, 'email') }}">
          </div>
          <div class="col-md-4 form-group">
            <label>@lang('medbilling::lang.contact_address')</label>
            <input type="text" name="contact_address" class="form-control" value="{{ data_get($payer->contact, 'address') }}">
          </div>
        </div>
        <div class="row">
          <div class="col-md-6">
            <label class="checkbox-inline">
              <input type="checkbox" name="pre_auth_required_default" value="1" @checked($payer->pre_auth_required_default)>
              @lang('medbilling::lang.pre_auth_required_default')
            </label>
          </div>
          <div class="col-md-6">
            <label class="checkbox-inline">
              <input type="checkbox" name="is_active" value="1" @checked(! $isEdit || $payer->is_active)>
              @lang('medbilling::lang.active')
            </label>
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">@lang('medbilling::lang.cancel')</button>
        <button type="submit" class="btn btn-primary">@lang('medbilling::lang.save')</button>
      </div>
    </form>
  </div>
</div>
