<?php

use App\Models\BankAccount;

$user_id = auth()->id();
$nama_rek = BankAccount::where('user_id', $user_id)->value('nama_rek');
?>

<!-- deposite popup -->
<div class="md-content">

  <form id="bank_register_popup" novalidate="novalidate">
    @csrf
    <div class="md-body">
      <!-- //Silahkan  tambahkan   data bank anda -->
      <div class="md_title">
        Please add your bank data
      </div>
      <div class="row " id="acc_type_btn_group">

        <div class="col-md-12 col-xs-12 ">
          <div class="font-weight-bold">
            Jenis akun baru
          </div>
        </div>
        <div class="col-md-12 col-xs-12">
          <div class="row">

            <div class="col-xs-6 radio_2">
              <input class=" " name="acc_type" id="radioBank" checked="" type="radio" value="5">
              <label class=" " for="radioBank">

                <span class="radio-title">
                  Bank
                </span>
                <span class="marked">
                  <i class="icon-checkmark"></i>
                </span>
              </label>
            </div>

            <div class="col-xs-6 radio_2">
              <input class=" " name="acc_type" id="radioEwallet7" type="radio" value="7">
              <label class="" for="radioEwallet7">

                <span class="radio-title">
                  E-wallet
                </span>
                <span class="marked">
                  <i class="icon-checkmark"></i>
                </span>
              </label>
            </div>
          </div>
        </div>

      </div>
      <div class="form-group newbank_show" style="">
        <label>Bank</label>
        <select class="form-control  " data-type="bank" data-plugin="bank_list" name="new_bank" id="new_bank">
          <option selected="" value="">Please select a bank</option>
          <option value="BCA" data-bcode="BCA">
            BCA </option>
          <option value="BRI" data-bcode="BRI">
            BRI </option>
          <option value="MANDIRI" data-bcode="MDR">
            MANDIRI </option>
          <option value="BNI" data-bcode="BNI">
            BNI </option>
          <option value="CIMB" data-bcode="CIMBN">
            CIMB </option>
          <option value="DANAMON" data-bcode="DMN">
            DANAMON </option>
          <option value="OCBC" data-bcode="OCBCN">
            OCBC </option>
          <option value="NEO" data-bcode="NEO">
            NEO </option>
          <option value="BANK JAGO" data-bcode="ARIN">
            BANK JAGO </option>
          <option value="CIMB NIAGA" data-bcode="CIMBN">
            CIMB NIAGA </option>
          <option value="BLU BCA" data-bcode="BLA">
            BLU BCA </option>
          <option value="SEA BANK" data-bcode="SEABANK">
            SEA BANK </option>
          <option value="BANK JENIUS" data-bcode="BTPN">
            BANK JENIUS </option>
          <option value="BSI" data-bcode="BSI">
            BSI </option>
          <option value="BCA SYARIAH" data-bcode="BCAS">
            BCA SYARIAH </option>
          <option value="BANK BTN" data-bcode="BTN">
            BANK BTN </option>

        </select>
      </div>
      <div class="form-group newfundmethod_show" id="" style="display:none;">
        <label> E-wallet<span class="text-danger">*</span></label>
        <select class="form-control  " data-type="bank" data-plugin="bank_list" name="new_bank" id="new_bank">
          <option selected="" value="">Silahkan pilih</option>
          <option value="DANA">
            DANA</option>
          <option value="GOPAY">
            GOPAY</option>
          <option value="OVO">
            OVO</option>
          <option value="LINK AJA">
            LINK AJA</option>
          <option value="SAKUKU">
            SAKUKU</option>

        </select>
      </div>
     
      <div class="form-group">
        <label class="lable_name">BANK ACCOUNT NUMBER</label>
        <input type="text" name="acc_no" id="acc_no" class="form-control" placeholder="BANK ACCOUNT NUMBER" minlength="8" maxlength="20" required="">
      </div>

       <div class="form-group locked">
        <label>NAME OF ACCOUNT OWNER</label>
        <input type="text" value="{{ $nama_rek }}" name="nama_rek" readonly="" class="form-control " placeholder="PLEASE LOG IN THE NAME OF THE ACCOUNT OWNER" required="">
        <span class="input-group-addon transparent pass_lock"><i class="icon-lock"></i></span>
      </div>
    

    </div>
    <div class="md-footer deposit_footer">
      <div class="form_button">
        <button type="button" class="btn btn-primary" id="bank_deposit_confirm">Cancel</button>
        <button type="submit" class="btn btn-secondary">Kirim</button>
      </div>
    </div>
   
  </form>
</div>

<script>
        $(document).ready(function () {
             //alert("hi");
             
            function setNewAccType(){
              var selVal= $('#bank_register_popup input[type=radio][name=acc_type]:checked').val() ;
              $("#acc_no").val(null);
              $('#method').val(selVal);
               if(selVal == 5){
               
                  $('#acc_no').attr('placeholder','BANK ACCOUNT NUMBER' );
                  $('.lable_name').text("BANK ACCOUNT NUMBER");
                  $('.newfundmethod_show select[name=new_bank]').prop('disabled', 'disabled');
                  $('.newfundmethod_show select[name=new_bank]').val('');
                  $('.newfundmethod_show input[name=acc_no]').val('');
                  $('.newfundmethod_show').hide();

                  $('.newbank_show select[name=new_bank]').prop('disabled',  false); 
                  $('.newbank_show').show(); 
                  $("#acc_no").attr("minlength", window.accLength);                

               }

               else  if(selVal == 7){
                  $('#acc_no').attr('placeholder','NOMOR' );
                  $('.lable_name').text("NOMOR");
                  $('.newbank_show select[name=new_bank]').prop('disabled', 'disabled');
                  $('.newbank_show select[name=new_bank]').val('');
                  $('.newbank_show input[name=acc_no]').val('');
                  $('.newbank_show').hide();
                  $('.newfundmethod_show select[name=new_bank]').prop('disabled',  false); 
                  $('.newfundmethod_show').show();
                  $("#acc_no").attr("minlength", '1');
                $("#acc_no").attr("maxlength", "20");
                
               }
            }
            $('#bank_register_popup input[type=radio][name=acc_type]').change(function(){          
              setNewAccType();

            });
            setNewAccType();
        });
     
    </script>