@php($unique_element = "update")
<!-- Modal ADD Branch -->
<div class="modal fade" id="md_update_subhead" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  {{ Form::open(array('route' => 'subhead.update', 'class' => 'cls_form','id'=>'form_update_subhead')) }}
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Update SubHead</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true"></span>
        </button>
      </div>
      <div class="modal-body">
        <div class = "card">
          <div class = "card-header">
          <div class = "col-md-5">
    <strong class="strong-margin">ACCOUNT INFORMATION</strong>
     </div>
              <div class = "col-md-6">


     </div>
             <div class = "col-md-1">
           <img src = "{{asset('assets/images/icons/accountinformation.png')}}"/>


     </div>
          </div>
          <div class = "card-body form-fieldset">
                  <div class="row">
              {{-- @if($head->nature === "Current Assets") --}}
                <div class="col-sm-12">
                  <label class="label-color"> Type: <i style = "color:red;">*</i></label>
                <small class="form-errors pull-right req" value="*">{{ $errors->first('type',":message") }}</small>

                <div class="input-group mb-3">

                  <select onchange="verifyBank(event,this,'{{$unique_element}}')" name="type" class="form-control form-control-sm cls_selection">
                  @foreach(EF::getAccountsTypeList() as $rows)

                    @if($rows === "Cash" || $rows === "Bank" || $rows === "General")
                       <option @if($subhead->type === $rows) selected @endif value="{{$rows}}">{{$rows}}</option>
                     @endif

                  @endforeach
                  </select>

                </div>
            </div>
            {{-- @else
              <input type="hidden" name="type" value="General">
            @endif --}}

        <div class="col-sm-12 {{$unique_element}}_subhead_bank_section" @if($subhead->type != "Bank") style="display: none;" @endif>
            <label class="label-color">Select Bank: <i style = "color:red;"></i></label>
              <small class="form-errors pull-right req" value="">{{ $errors->first('bank',":message") }}</small>

            <div class="input-group mb-3">
              <select onchange="setBank(event,this,'{{$unique_element}}')" class="form-control-sm form-control {{$unique_element}}_bank_list" name="bank" >
                  <option selected="true" value="{{Crypt::encrypt(0)}}">Select Bank</option>
                  @foreach($bank_list as $rows)
                    <option @if($subhead->bank_id === $rows->id) selected @endif  value="{{Crypt::encrypt($rows->id)}}">{{ucwords($rows->branch_code)}} | {{ucwords($rows->bank_name)}} | {{ucwords($rows->location)}}</option>
                  @endforeach
              </select>



             <div id="view_add_button" class="input-group-prepend">
              </div>
            </div>
          </div>

            <div class="col-sm-6">
                <label class="label-color"> Code: <i style = "color:red;">*</i></label>
            <small class="form-errors pull-right req" value="*">{{ $errors->first('code',":message") }}</small>
            <div class="input-group mb-3">

              {{Form::Text('code',$subhead->code, ['class' => 'form-control form-control-sm', 'placeholder' => 'Code #' , 'aria-label' => 'Default', 'aria-describedby' => 'inputGroup-sizing-default', 'readonly' => 'series'])}}
            </div>
          </div>

          @php($flag = false)

          @if($subhead->bank_id > 0)
            @php($flag = true)
          @endif

          <div class="col-sm-6">
              <label class="label-color"> Name: <i style = "color:red;">*</i> </label>
            <small class="form-errors pull-right req" value="*">{{ $errors->first('name',":message") }}</small>

            <div class="input-group mb-3">

              {{Form::Text('name',$subhead->name, ['class' => 'form-control form-control-sm cls_required  '.$unique_element.'_subhead_name ', 'placeholder' => 'Name' , 'aria-label' => 'Default', 'aria-describedby' => 'inputGroup-sizing-default', 'id' => 'bank', 'readonly' => $flag])}}
            </div>
           </div>

        <div class="col-sm-6">
            <label class="label-color"> Opening Balance: <i style = "color:red;"></i> </label>
          <small class="form-errors pull-right req" value="">{{ $errors->first('openining_balance',":message") }}</small>

          <div class="input-group mb-3">

          <input value="{{$subhead->opening_balance}}"onkeyup="numberInWordsValue(this,'{{$unique_element}}_opening_balance_in_words'); checkOpeningBalanceAccount(this,'{{$unique_element}}');" type="number" name="opening_balance" class="{{$unique_element}}_opening_balance form-control form-control-sm" placeholder="Opening Balance">
          </div>
        </div>

        <div class="col-sm-6">

            <label class="label-color"> Opening Balance In Words: <i style = "color:red;"></i> </label>

          <div class="input-group mb-3">

          <input value="{{EF::numberToWords($subhead->opening_balance)}}" readonly="" type="text"  class=" form-control form-control-sm {{$unique_element}}_opening_balance_in_words" placeholder="Opening Balance In Words">
          </div>
        </div>

         @php($nature = EF::getNatureList())
        @php($name  = 'debit_account')
        @php($label = 'Select Debit Account')


        @if(in_array($head->nature,[$nature[0],$nature[1],$nature[3],$nature[4]]))
          @php($name  = 'credit_account')
          @php($label = 'Select Credit Account')
        @endif

        <div class="col-sm-12 account_{{$unique_element}}" style="height: 150px; @if($subhead->opening_balance <= 0) display: none; @endif">

          <label class="label-color">{{$label}}: <i style = "color:red;"></i> </label>

          <div class="input-group mb-3">
            <select  name="{{$name}}" class="fstdropdown-select form-control form-control-sm ">
              <option value="{{Crypt::encrypt(0)}}">{{$label}}</option>
              @foreach($subhead_list as $rows)
                @if($subhead->id != $rows->id)
                  <option @if($subhead->opening_balance_id == $rows->id) selected @endif value="{{Crypt::encrypt($rows->id)}}">{{$rows->head->code}}-{{$rows->head->name}} | {{$rows->code}}-{{$rows->name}}</option>
                @endif
              @endforeach
            </select>
           </div>
        </div>

        <input type="hidden" name="head_id" value="{{Crypt::encrypt($head_id)}}">


       </div>
          </div>
        </div>

      </div>
      <div class="modal-footer">
        <input type="hidden" name="subhead_id" value="{{Crypt::encrypt($subhead->id)}}">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button onclick="updateSubhead(event,this);" type="submit" class="btn btn-primary " content="update subhead">Update SubHead</button>
      </div>
    </div>
  </div>
  {{ Form::close() }}
</div>
<!-- END MODAL ADD BRANCH -->
<script type="text/javascript">
  setFstDropdown();
</script>
