<table width="100%" class="table m-table nowrap table-header-fixed table-striped table-bordered table-hover table-header-fixed" id="loans_view_table">
  <thead>
    <tr class="">
      <th>Sl No</th>
      <th>ID</th>
      <th>Title</th>
      <th>Description</th>
      <th>Loan Date</th>
      <th><?php if($page_name=='loans_receivable'){ ?>Borrower <?php }elseif($page_name=='loans_payable'){?> Provider <?php }else{?> Borrower/Provider<?php } ?></th>
      <th>Total Loan Amount</th>
      <th>Op Balance <?php if($page_name=='loans_receivable'){ ?>Receivable <?php }else{?> Payable <?php } ?></th>
      <th>Op Payable Balance</th>
      <th><?php if($page_name=='loans_receivable'){ ?>Debited From <?php }elseif($page_name=='loans_payable'){?> Credited To <?php }else{?> Debited From/Credited To<?php } ?> Acc</th>
      <th>Total <?php if($page_name=='loans_receivable'){ ?>Received <?php }elseif($page_name=='loans_payable'){?> Paid <?php }else{?> Received/Paid<?php } ?></th>
      <th>Balance <?php if($page_name=='loans_receivable'){ ?>Receivable <?php }elseif($page_name=='loans_payable'){?> Payable <?php }else{?> Receivable/Payable<?php } ?></th>
      <th>Loan Purpose</th>
      <th>Creation</th>
      <th>Actions</th>
      <th>Credit/Debit Acc</th>
      <th>Work id</th>
      <th>Provider id</th>
      <th>Approval Status</th>
      <th>Approval Status 2</th>
    </tr>
  </thead>
  <tbody>
  </tbody>
</table>


<div class="modal fade" tabindex="-1" id="loan_add_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog " role="document" style="max-width: 800px">
    <div class="modal-content">
      <div class="modal-header" style="background-color: #36a3f7;border-radius: 4px">
        <h5 class="modal-title" id="exampleModalLabel" style="color: #ffffff" >
          Add New <?php if($page_name=='loans_receivable'){ ?>Receivable <?php }else{?> Payable <?php } ?>Loan
        </h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">
            &times;
          </span>
        </button>
      </div>
      <form autocomplete="off" id="form_loan_add" data-modal-id="loan_add_modal" method="post" action="<?php echo base_url().'loans/create_loan'?>" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
        <div class="modal-body">
          <div class="m-form__content">
            <div class="m-alert m-alert--icon alert alert-warning m--hide" role="alert" id="form_loan_add_msg">
              <div class="m-alert__icon">
                <i class="la la-warning"></i>
              </div>
              <div class="m-alert__text">
                Oh snap! Change a few things up and try submitting again.
              </div>
              <div class="m-alert__close">
                <button type="button" class="close" data-close="alert" aria-label="Close"></button>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-lg-5">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Title
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <!-- <div class="input-group-prepend">
                  <span class="input-group-text" id="basic-addon1">
                  <i class="la la-tag"></i>
                </span>
              </div> -->
              <input required type="text" name="title" placeholder="Title.." class="form-control form_loan_add_fields m-input"  aria-describedby="basic-addon1">
            </div>
            <span class="m-form__help"></span>
          </div>
        </div>
        <div class="col-lg-4">
          <div class="form-group m-form__group" >
            <label for="user_name">
              Loan Amount
            </label>
            <div class="input-group m-input-group m-input-group--pill m-input-group--air">
              <div class="input-group-prepend">
                <span class="input-group-text" id="basic-addon1">
                  <?php echo $this->config->item('Currency_currency_format'); ?>
                </span>
              </div>
              <input required type="text" name="loan_amount" id="loan_amount_add"  class="form-control form_loan_add_fields m-input" placeholder="Loan Amount" aria-describedby="basic-addon1">
            </div>
            <span class="m-form__help"></span>
          </div>
        </div>
        <div class="col-lg-3">
          <div class="form-group m-form__group" >
            <label for="user_name">
              Loan Date
            </label>
            <div class="input-group m-input-group m-input-group--pill m-input-group--air">
              <input required type="text" name="loan_date" id="loan_date_add" data-date-format="dd-mm-yyyy" placeholder="Loan Date.." class="form-control form_loan_add_fields m-input"  aria-describedby="basic-addon1">
            </div>
            <span class="m-form__help"></span>
          </div>
        </div>
        <div class="col-lg-12">
          <div class="form-group m-form__group" >
            <label for="user_name">
              Description
            </label>
            <div class="input-group m-input-group--air m-input-group--pill">
              <textarea name="description" class="form-control form_loan_add_fields m-input " placeholder="Description about Loan" ></textarea>
            </div>
          </div>
          <span class="m-form__help"></span>
        </div>
        <div class="col-lg-6">
          <div class="form-group m-form__group" >
            <label for="user_name">
              <?php if($page_name=='loans_receivable'){ ?>
                Released From Account (Debited Acc)
              <?php }else{?>
                Received To Account (Credited Acc)
              <?php } ?>
            </label>
            <div class="m-select2 m-select2--air m-select2--pill">
              <select required id="loan_received_acc_add" name="credit_acc" style="width: 100%" class="form-control m-input form_loan_add_select"  aria-describedby="basic-addon1">
                <?php
                foreach($this->config->item('account_heads') as $row):
                  $selected="";
                  if($row->acc_head_id==1){
                    $selected="selected";
                  }
                  ?>
                  <option <?php echo $selected?> value="<?php echo $row->acc_head_id?>"><?php echo $row->acc_head_name?></option>
                  <?php
                endforeach;
                ?>
              </select>
            </div>
            <span class="m-form__help"></span>
          </div>
        </div>
        <!-- <div class="col-lg-6">
        <div class="form-group m-form__group" >
        <label for="user_name">
        Current Payable Balance
      </label>
      <div class="input-group m-input-group--air m-input-group--pill">
      <div class="input-group-prepend">
      <span class="input-group-text">
      <?php echo $this->config->item('Currency_currency_format'); ?>
    </span>
  </div>
  <input  required type="text" name="payable_balance" class="form-control form_loan_add_fields m-input " placeholder="Payable Balance" >
</div>
</div>
<span class="m-form__help"></span>
</div> -->

<div class="col-lg-6">
  <div class="form-group m-form__group" >
    <label for="user_name">
      <?php if($page_name=='loans_receivable'){
        $loan_type='receivable';?>
        Borrower
      <?php }else{
        $loan_type='payable';?>
        Provider
      <?php } ?>
    </label>
    <div class="input-group m-input-group m-input-group--pill">
      <div class="input-group-prepend" id='suppler_add_btn'>
        <a href="#supplier_add_modal"   data-toggle="modal" data-target="#provider_add_modal" class="btn btn-focus">
          <i class="fa fa-plus-circle"></i>
        </a>
      </div>
      <select style="width: 80%" class="form-control m-select2 m-select2-general" required id="provider_add" name="provider" data-placeholder="Select Provider">

      </select>
    </div>
    <span class="m-form__help"></span>
  </div>
</div>
<?php if($page_name=='loans_payable'){ ?>
  <div class="col-lg-4">
    <div class="form-group m-form__group" style="  !important">
      <label for="user_name">
        Loan Purpose
      </label>
      <div class="m-select2 m-select2--air m-select2--pill">
        <select  style="width: 100%" class="form-control m-select2 form_loan_add_select" id="work_id_loan_add"  name="work_id" data-placeholder="Select Purpose">
          <option selected value="0">For Whole Business</option>
          <?php
          foreach($work_contracts as $row): ?>
          <option data-work-status="<?php echo $row->work_status?>" value="<?php echo $row->work_id?>">For Project : <?php echo $row->work_name?></option>
          <?php
        endforeach;
        ?>
      </select>
    </div>
    <span class="m-form__help"></span>
  </div>
</div>
<?php } ?>
<div class="col-lg-4">
  <div class="form-group m-form__group" >
    <label for="user_name">
      <?php if($page_name=='loans_receivable'){ ;?>
        OP/Outstand Balance Receivable
      <?php }else{ ?>
        OP/Outstand Balance Payable
      <?php } ?>
    </label>
    <div class="input-group m-input-group m-input-group--pill m-input-group--air">
      <div class="input-group-prepend">
        <span class="input-group-text" id="basic-addon1">
          <?php echo $this->config->item('Currency_currency_format'); ?>
        </span>
      </div>
      <input required type="text" name="op_balance" id="op_balance_add" value="0" class="form-control form_loan_add_fields m-input" placeholder="OP/Outstanding Balance" aria-describedby="basic-addon1">
    </div>
    <span class="m-form__help">* OP Balance At the time of Data Creation
      <br/>* OP Balance Will Not <?php if($page_name=='loans_receivable'){ ;?>
      Debit From
    <?php }else{ ?>
    Credit To
  <?php } ?> Account</span>
  </div>
</div>
<div class="col-lg-4">
  <div class="form-group m-form__group" >
    <label for="user_name">
      <?php if($page_name=='loans_receivable'){ ;?>
        Total Balance Receivable
      <?php }else{ ?>
        Total Balance Payable
      <?php } ?>
    </label>
    <div class="input-group m-input-group m-input-group--pill m-input-group--air">
      <div class="input-group-prepend">
        <span class="input-group-text" id="basic-addon1">
          <?php echo $this->config->item('Currency_currency_format'); ?>
        </span>
      </div>
      <input readonly type="text" name="total_balance" id="total_balance_add" value="0" class="form-control form_loan_add_fields m-input" placeholder="Total Balance" aria-describedby="basic-addon1">
    </div>
    <span class="m-form__help"></span>
  </div>
</div>
<input type="hidden" name="loan_type" value="<?php echo $loan_type ?>" >
<input type="hidden" name="redirect_url" value="<?php echo base_url(uri_string())?>" >
</div>
</div>
<div class="modal-footer">
  <button type="button" class="btn btn-secondary" data-dismiss="modal">
    Close
  </button>
  <button type="submit" class="btn form_submit_btn btn-primary">
    Submit
  </button>
</div>
</form>
</div>
</div>
</div>
<div class="modal fade" tabindex="-1" id="loan_edit_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog " role="document" style="max-width: 800px">
    <div class="modal-content">
      <div class="modal-header" style="background-color: #36a3f7;border-radius: 4px">
        <h5 class="modal-title" id="exampleModalLabel" style="color: #ffffff" >
          Edit Loan Details
        </h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">
            &times;
          </span>
        </button>
      </div>
      <form autocomplete="off" id="form_loan_edit" data-modal-id="loan_edit_modal" method="post" action="<?php echo base_url().'loans/update_loan'?>" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
        <div class="modal-body">
          <div class="m-form__content">
            <div class="m-alert m-alert--icon alert alert-warning m--hide" role="alert" id="form_loan_edit_msg">
              <div class="m-alert__icon">
                <i class="la la-warning"></i>
              </div>
              <div class="m-alert__text">
                Oh snap! Change a few things up and try submitting again.
              </div>
              <div class="m-alert__close">
                <button type="button" class="close" data-close="alert" aria-label="Close"></button>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-lg-5">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Title
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <div class="input-group-prepend">
                    <span class="input-group-text" id="basic-addon1">
                      <i class="la la-tag"></i>
                    </span>
                  </div>
                  <input required type="text" name="title" id="title_edit" placeholder="Title.." class="form-control form_loan_edit_fields m-input"  aria-describedby="basic-addon1">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Loan Amount
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <div class="input-group-prepend">
                    <span class="input-group-text" id="basic-addon1">
                      <?php echo $this->config->item('Currency_currency_format'); ?>
                    </span>
                  </div>
                  <input required type="text" name="loan_amount" id="loan_amount_edit"  class="form-control form_loan_edit_fields m-input" placeholder="Loan Amount" aria-describedby="basic-addon1">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-3">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Loan Date
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <input required type="text" name="loan_date" id="loan_date_edit" data-date-format="dd-mm-yyyy" placeholder="Loan Date.." class="form-control form_loan_edit_fields m-input"  aria-describedby="basic-addon1">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-12">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Description
                </label>
                <div class="input-group m-input-group--air m-input-group--pill">
                  <textarea name="description" id="description_edit" class="form-control form_loan_edit_fields m-input " placeholder="Description about Loan" ></textarea>
                </div>
              </div>
              <span class="m-form__help"></span>
            </div>
            <div class="col-lg-6">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  <?php if($page_name=='loans_receivable'){ ?>
                    Released From Account (Debited Acc)
                  <?php }else{?>
                    Received To Account (Credited Acc)
                  <?php } ?>
                </label>
                <div class="m-select2 m-select2--air m-select2--pill">
                  <select required id="loan_received_acc_edit" name="credit_acc" style="width: 100%" class="form-control m-input form_loan_edit_select"  aria-describedby="basic-addon1">
                    <?php
                    foreach($this->config->item('account_heads') as $row):
                      $selected="";
                      if($row->acc_head_id==1){
                        $selected="selected";
                      }
                      ?>
                      <option <?php echo $selected?> value="<?php echo $row->acc_head_id?>"><?php echo $row->acc_head_name?></option>
                      <?php
                    endforeach;
                    ?>
                  </select>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <!-- <div class="col-lg-6">
            <div class="form-group m-form__group" >
            <label for="user_name">
            Current Payable Balance
          </label>
          <div class="input-group m-input-group--air m-input-group--pill">
          <div class="input-group-prepend">
          <span class="input-group-text">
          <?php echo $this->config->item('Currency_currency_format'); ?>
        </span>
      </div>
      <input  required type="text" name="payable_balance" id="payable_balance_edit" class="form-control form_loan_edit_fields m-input " placeholder="Payable Balance" >
    </div>
  </div>
  <span class="m-form__help"></span>
</div> -->

<div class="col-lg-6">
  <div class="form-group m-form__group" >
    <label for="user_name">
      <?php if($page_name=='loans_receivable'){
        $loan_type='receivable';?>
        Borrower
      <?php }else{
        $loan_type='payable';?>
        Provider
      <?php } ?>
    </label>
    <div class="input-group m-input-group m-input-group--pill">
      <div class="input-group-prepend" id='suppler_add_btn'>
        <a href="#supplier_add_modal"   data-toggle="modal" data-target="#provider_add_modal" class="btn btn-focus">
          <i class="fa fa-plus-circle"></i>
        </a>
      </div>
      <select style="width: 80%" class="form-control m-select2 m-select2-general" required id="provider_edit" name="provider" data-placeholder="Select Provider">

      </select>
    </div>
    <span class="m-form__help"></span>
  </div>
</div>
<?php if($page_name=='loans_payable'){ ?>
  <div class="col-lg-4">
    <div class="form-group m-form__group" style="  !important">
      <label for="user_name">
        Loan Purpose
      </label>
      <div class="m-select2 m-select2--air m-select2--pill">
        <select  style="width: 100%" class="form-control m-select2 form_loan_edit_select" id="work_id_loan_edit"  name="work_id" data-placeholder="Select Purpose">
          <option selected value="0">For Whole Business</option>
          <?php
          foreach($work_contracts as $row): ?>
          <option data-work-status="<?php echo $row->work_status?>" value="<?php echo $row->work_id?>">For Project : <?php echo $row->work_name?></option>
          <?php
        endforeach;
        ?>
      </select>
    </div>
    <span class="m-form__help"></span>
  </div>
</div>
<?php } ?>
<div class="col-lg-4">
  <div class="form-group m-form__group" >
    <label for="user_name">
      <?php if($page_name=='loans_receivable'){ ;?>
        OP/Outstand Balance Receivable
      <?php }else{ ?>
        OP/Outstand Balance Payable
      <?php } ?>
    </label>
    <div class="input-group m-input-group m-input-group--pill m-input-group--air">
      <div class="input-group-prepend">
        <span class="input-group-text" id="basic-addon1">
          <?php echo $this->config->item('Currency_currency_format'); ?>
        </span>
      </div>
      <input required type="text" name="op_balance" id="op_balance_edit" value="0" class="form-control form_loan_add_fields m-input" placeholder="OP/Outstanding Balance" aria-describedby="basic-addon1">
    </div>
    <span class="m-form__help">* OP Balance At the time of Data Creation
      <br/>* OP Balance Will Not <?php if($page_name=='loans_receivable'){ ;?>
      Debit From
    <?php }else{ ?>
    Credit To
  <?php } ?> Account</span>
  </div>
</div>
<div class="col-lg-4">
  <div class="form-group m-form__group" >
    <label for="user_name">
      <?php if($page_name=='loans_receivable'){ ;?>
        Total Balance Receivable
      <?php }else{ ?>
        Total Balance Payable
      <?php } ?>
    </label>
    <div class="input-group m-input-group m-input-group--pill m-input-group--air">
      <div class="input-group-prepend">
        <span class="input-group-text" id="basic-addon1">
          <?php echo $this->config->item('Currency_currency_format'); ?>
        </span>
      </div>
      <input readonly type="text" name="total_balance" id="total_balance_edit" value="0" class="form-control form_loan_add_fields m-input" placeholder="Total Balance" aria-describedby="basic-addon1">
    </div>
    <span class="m-form__help"></span>
  </div>
</div>
<input type="hidden" name="loan_id" id="loan_id_edit" >
<input type="hidden" name="loan_type" value="<?php echo $loan_type ?>" >
<input type="hidden" name="redirect_url" value="<?php echo base_url(uri_string())?>" >
</div>
</div>
<div class="modal-footer">
  <button type="button" class="btn btn-secondary" data-dismiss="modal">
    Close
  </button>
  <button type="submit" class="btn form_submit_btn btn-primary">
    Submit
  </button>
</div>
</form>
</div>
</div>
</div>
<div class="modal fade" tabindex="-1" id="loan_delete_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog " role="document" >
    <form autocomplete="off" id="form_loan_delete" data-modal-id="loan_delete_modal"  method="post" action="<?php echo base_url().'loans/delete_loan'?>" class="form-horizontal">
      <div class="modal-content">
        <div class="alert alert-danger" role="alert" style="margin-bottom: 0px">
          <button type="button" class="close" data-dismiss="modal"></button>
          <br/>
          <h4 class="alert-heading">Warning! Please Confirm Your Action</h4>
          <br/>
          <p> Are You Sure to Delete this Data ?. All the Associated Data will Lost. </p>
          <p>
            <button class="btn btn-danger form_submit_btn" type="submit" name="submit">Confirm & Delete</button>
            <button type="button" class="btn btn-primary modal-dismiss" data-dismiss="modal">Cancel</button>
          </p>
          <input type="hidden"  name="loan_id" id="loan_id_delete">
          <input type="hidden" name="redirect_url" value="<?php echo base_url(uri_string())?>" >
        </div>
      </div>
    </form>
  </div>
</div>
<div class="modal fade" tabindex="-1" id="provider_add_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog " role="document" style="max-width: 800px">
    <div class="modal-content">
      <div class="modal-header" style="background-color: #36a3f7;border-radius: 4px">
        <h5 class="modal-title" id="exampleModalLabel" style="color: #ffffff" >
          Create New Loan Provider/Borrower
        </h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">
            &times;
          </span>
        </button>
      </div>
      <form autocomplete="off" id="form_provider_add" data-form-type="provider_create" data-modal-id="provider_add_modal" method="post" action="<?php echo base_url().'loans/create_provider'?>" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
        <div class="modal-body">
          <div class="m-form__content">
            <div class="m-alert m-alert--icon alert alert-warning m--hide" role="alert" id="form_provider_add_msg">
              <div class="m-alert__icon">
                <i class="la la-warning"></i>
              </div>
              <div class="m-alert__text">
                Oh snap! Change a few things up and try submitting again.
              </div>
              <div class="m-alert__close">
                <button type="button" class="close" data-close="alert" aria-label="Close"></button>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-lg-12">
              <div class="form-group m-form__group">
                <label for="user_name">
                  Loan Provider/Borrower Name
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <div class="input-group-prepend">
                    <span class="input-group-text" id="basic-addon1">
                      <i class="la la-tag"></i>
                    </span>
                  </div>
                  <input required type="text" name="name"  class="form-control m-input form_provider_add_fields" placeholder="Provider/Borrower Name" aria-describedby="basic-addon1">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">
            Close
          </button>
          <button type="submit" class="btn btn-primary form_submit_btn">
            Submit
          </button>
        </div>
      </form>
    </div>
  </div>
</div>


<div class="modal fade" tabindex="-1" id="loan_receipt_add_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog " role="document" style="max-width: 800px">
    <div class="modal-content">
      <div class="modal-header" style="background-color: #36a3f7;border-radius: 4px">
        <h5 class="modal-title" id="exampleModalLabel" style="color: #ffffff" >
          New Loan Receipt
        </h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">
            &times;
          </span>
        </button>
      </div>
      <form autocomplete="off" data-form-type="loan_receipt" id="form_loan_receipt_add" data-modal-id="loan_receipt_add_modal" method="post" action="<?php echo base_url().'accounts/create_transaction'?>" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
        <div class="modal-body">
          <div class="m-form__content">
            <div class="m-alert m-alert--icon alert alert-warning m--hide" role="alert" id="form_loan_receipt_add_msg">
              <div class="m-alert__icon">
                <i class="la la-warning"></i>
              </div>
              <div class="m-alert__text">
                Oh snap! Change a few things up and try submitting again.
              </div>
              <div class="m-alert__close">
                <button type="button" class="close" data-close="alert" aria-label="Close"></button>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-lg-6">
              <div class="form-group m-form__group">
                <label for="user_name">
                  Loan Title
                </label>
                <div class="m-input-icon m-input-icon--right">
                  <input disabled="" type="text" id="loan_title_add_receipt" class="form-control m-input m-input--pill m-input--air form_bill_payment_add_fields" aria-describedby="basic-addon1">
                  <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-edit"></i></span></span>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-6">
              <div class="form-group m-form__group">
                <label for="user_name">
                  Loan Provider
                </label>
                <div class="m-input-icon m-input-icon--right">
                  <input disabled="" type="text" id="loan_provider_add_receipt" class="form-control m-input m-input--pill m-input--air form_bill_payment_add_fields" aria-describedby="basic-addon1">
                  <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-user"></i></span></span>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Received Amount
                </label>
                <div class="m-input-icon m-input-icon--right">
                  <input required type="text" name="received_amount"  class="form-control form_loan_receipt_add_fields m-input m-input--pill m-input--air" placeholder="Received Amount" aria-describedby="basic-addon1">
                  <span class="m-input-icon__icon m-input-icon__icon--right"><span><?php echo $this->config->item('Currency_currency_format'); ?></span></span>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Received Date
                </label>
                <div class="m-input-icon m-input-icon--right">
                  <input  data-date-format="dd-mm-yyyy" id="loan_receipt_received_date_add" required type="text" name="received_date" class="form-control form_loan_receipt_add_fields m-input m-input--pill m-input--air" placeholder="Received Date" >
                  <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-calendar"></i></span></span>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Received To Acc
                </label>
                <div class="m-select2 m-select2--air m-select2--pill">
                  <select required id="loan_receipt_acc_add" name="credit_acc" style="width: 100%" class="form-control m-input"  aria-describedby="basic-addon1">
                    <?php
                    foreach($this->config->item('account_heads') as $row):
                      $selected="";
                      if($row->acc_head_id==1){
                        $selected="selected";
                      }
                      ?>
                      <option <?php echo $selected?> value="<?php echo $row->acc_head_id?>"><?php echo $row->acc_head_name?></option>
                      <?php
                    endforeach;
                    ?>
                  </select>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-12">
              <div class="form-group m-form__group" style="  !important">
                <label for="user_name">
                  Remarks
                </label>
                <div class="m-input-icon m-input-icon--right">
                  <input type="text" name="tr_remarks"  class="form-control form_loan_receipt_add_fields m-input m-input--pill m-input--air" placeholder="Remarks" aria-describedby="basic-addon1">
                  <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-edit"></i></span></span>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <input type="hidden" name="tr_type" value="loan_receipt_transaction" >
            <input type="hidden" name="reference_id" id="reference_id_add_loan_receipt">
            <input type="hidden" name="reference_type" value="loan">
            <input type="hidden" name="redirect_url" value="<?php echo base_url(uri_string())?>" >
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">
            Close
          </button>
          <button type="submit" class="btn form_submit_btn btn-primary">
            Submit
          </button>
        </div>
      </form>
    </div>
  </div>
</div>
<div class="modal fade" tabindex="-1" id="loan_receipt_edit_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog " role="document" style="max-width: 800px">
    <div class="modal-content">
      <div class="modal-header" style="background-color: #00c5dc;border-radius: 4px">
        <h5 class="modal-title" id="exampleModalLabel" style="color: #ffffff" >
          Edit Loan Receipt
        </h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">
            &times;
          </span>
        </button>
      </div>
      <form autocomplete="off" data-form-type="loan_receipt" id="form_loan_receipt_edit" data-modal-id="loan_receipt_edit_modal" method="post" action="<?php echo base_url().'accounts/update_transaction'?>" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
        <div class="modal-body">
          <div class="m-form__content">
            <div class="m-alert m-alert--icon alert alert-warning m--hide" role="alert" id="form_loan_receipt_edit_msg">
              <div class="m-alert__icon">
                <i class="la la-warning"></i>
              </div>
              <div class="m-alert__text">
                Oh snap! Change a few things up and try submitting again.
              </div>
              <div class="m-alert__close">
                <button type="button" class="close" data-close="alert" aria-label="Close"></button>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-lg-6">
              <div class="form-group m-form__group">
                <label for="user_name">
                  Loan Title
                </label>
                <div class="m-input-icon m-input-icon--right">
                  <input disabled="" type="text" id="loan_title_edit_loan_receipt" class="form-control m-input m-input--pill m-input--air form_bill_payment_add_fields" aria-describedby="basic-addon1">
                  <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-edit"></i></span></span>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-6">
              <div class="form-group m-form__group">
                <label for="user_name">
                  Loan Provider
                </label>
                <div class="m-input-icon m-input-icon--right">
                  <input disabled="" type="text" id="loan_provider_edit_loan_receipt" class="form-control m-input m-input--pill m-input--air form_bill_payment_add_fields" aria-describedby="basic-addon1">
                  <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-user"></i></span></span>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group" >
                <label for="loan_receipt_amount">
                  Received Amount
                </label>
                <div class="m-input-icon m-input-icon--right">
                  <input required type="text" name="received_amount" id="loan_receipt_received_amount_edit"  class="form-control form_loan_receipt_edit_fields m-input m-input--pill m-input--air" placeholder="Payment Amount" aria-describedby="basic-addon1">
                  <span class="m-input-icon__icon m-input-icon__icon--right"><span><?php echo $this->config->item('Currency_currency_format'); ?></span></span>
                </div>
                <span class="m-form__help"></span>
              </div>

            </div>
            <div class="col-lg-4" >
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Received Date
                </label>
                <div class="m-input-icon m-input-icon--right">
                  <input  data-date-format="dd-mm-yyyy" id="loan_receipt_received_date_edit" required type="text" name="received_date" class="form-control form_loan_receipt_edit_fields m-input m-input--pill m-input--air" placeholder="Received Date" >
                  <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-calendar"></i></span></span>
                </div>
                <span class="m-form__help"></span>
              </div>

            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Received To Acc
                </label>
                <div class="m-select2 m-select2--air m-select2--pill">
                  <select required id="loan_receipt_acc_edit" name="credit_acc" style="width: 100%" class="form-control m-input"  aria-describedby="basic-addon1">
                    <?php
                    foreach($this->config->item('account_heads') as $row):
                      $selected="";
                      if($row->acc_head_id==1){
                        $selected="selected";
                      }
                      ?>
                      <option <?php echo $selected?> value="<?php echo $row->acc_head_id?>"><?php echo $row->acc_head_name?></option>
                      <?php
                    endforeach;
                    ?>
                  </select>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-12">
              <div class="form-group m-form__group" style=" !important">
                <label for="loan_receipt_remarks">
                  Remarks
                </label>
                <div class="m-input-icon m-input-icon--right">
                  <input type="text" name="tr_remarks" id="loan_receipt_remarks_edit"  class="form-control form_loan_receipt_edit_fields m-input m-input--pill m-input--air" placeholder="Remarks" aria-describedby="basic-addon1">
                  <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-edit"></i></span></span>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>


            <input type="hidden" name="transaction_id" id="tr_id_edit_loan_receipt">
            <input type="hidden" name="tr_type" value="loan_receipt_transaction" >
            <input type="hidden" name="reference_id">
            <input type="hidden" name="reference_type" value="loan_receipt">
            <input type="hidden" name="redirect_url" value="<?php echo base_url(uri_string())?>" >
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">
            Close
          </button>
          <button type="submit" class="btn form_submit_btn btn-primary">
            Submit
          </button>
        </div>
      </form>
    </div>
  </div>
</div>
