<style type="text/css">
  .fa-3x {
    font-size: 2em !important;
  }

  .report_view_th {
    background-color: #428bca;
    color: #fff !important;
    font-size: 14px;
  }

  .table-responsive td {
    font-size: 14px;
  }

  h4 {
    font-size: 13px;
  }
</style>

<style>
  .upload-box {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 15px;
    width: 250px;
    text-align: center;
    margin: 10px;
    display: inline-block;
    vertical-align: top;
  }

  .upload-box img {
    max-width: 100%;
    max-height: 150px;
    margin-bottom: 10px;
  }

  .progress-bar {
    height: 6px;
    background: #4caf50;
    width: 0%;
    transition: width 0.3s;
  }

  .file-name {
    font-size: 12px;
    color: #555;
    margin-top: 5px;
  }
</style>

<style>
  .upload-box {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 15px;
    width: 225px;
    text-align: center;
    margin: 10px;
    display: inline-block;
    vertical-align: top;
  }

  .upload-box img {
    max-width: 100%;
    max-height: 150px;
    margin-bottom: 10px;
  }

  .progress-bar {
    height: 6px;
    background: #4caf50;
    width: 0%;
    transition: width 0.3s;
  }

  .file-name {
    font-size: 12px;
    color: #555;
    margin-top: 5px;
  }

  .upload-box .img-thumb {
    max-width: 100px;
    max-height: 100px;
    border-radius: 5px;
    border: 1px solid #ddd;
  }

  .upload-box .pdf-thumb {
    width: 60px;
    height: 60px;
  }
</style>
<style>
  .preview img {
    width: 150px;
    border: 1px solid #ddd;
    margin: 5px;
  }

  .upload-box {
    margin-bottom: 15px;
  }

  #uploadContainer {
    margin-top: 15px;
    ;
  }
</style>
<?php $this->load->view("common/header"); ?>
<!-- end: HEAD -->
<!-- end: CSS REQUIRED FOR THIS PAGE ONLY -->
<!-- end: HEAD -->
<!-- start: BODY -->

<body>
  <!-- start: HEADER -->
  <div class="navbar navbar-inverse navbar-fixed-top">
    <!-- start: TOP NAVIGATION CONTAINER -->
    <div class="container">
      <div class="navbar-header">
        <!-- start: RESPONSIVE MENU TOGGLER -->
        <button data-target=".navbar-collapse" data-toggle="collapse" class="navbar-toggle" type="button"> <span class="clip-list-2"></span> </button>
        <!-- end: RESPONSIVE MENU TOGGLER -->
        <!-- start: LOGO -->
        <?php $this->load->view("common/logo"); ?>
        <!-- end: LOGO -->
      </div>
      <div class="navbar-tools">
        <!-- start: TOP NAVIGATION MENU -->
        <?php $this->load->view("common/notifications.php"); ?>
        <!-- end: TOP NAVIGATION MENU -->
      </div>
    </div>
    <!-- end: TOP NAVIGATION CONTAINER -->
  </div>
  <!-- end: HEADER -->
  <!-- start: MAIN CONTAINER -->
  <div class="main-container">
    <div class="navbar-content">
      <!-- start: SIDEBAR -->
      <?php $this->load->view("common/navigation"); ?>
      <!-- end: SIDEBAR -->
    </div>
    <!-- start: PAGE -->
    <div class="main-content">
      <!-- end: SPANEL CONFIGURATION MODAL FORM -->
      <div class="container">
        <!-- start: PAGE HEADER -->
        <div class="row">
          <div class="col-sm-12">
            <!-- start: PAGE TITLE & BREADCRUMB -->
            <ol class="breadcrumb">
              <li> <a href="<?php echo base_url('dashboard'); ?>"> Dashboard </a> </li>
              <li> <a href="<?php echo base_url('loan'); ?>"> List Loan </a> </li>
              <li class="active"> View </li>
              <li class="search-box">
                <form class="sidebar-search">
                  <div class="form-group">
                    <input type="text" placeholder="Start Searching...">
                    <button class="submit"> <i class="clip-search-3"></i> </button>
                  </div>
                </form>
              </li>
            </ol>
            <div class="page-header">
              <?php
              $message = $this->session->flashdata('message');
              if ($message) { ?>
                <div class="alert alert-success">
                  <button type="button" class="close" data-dismiss="alert">×</button>
                  <?php echo $message ?>
                </div>
              <?php
              }
              ?>
            </div>
          </div>
        </div>
        <!-- end: PAGE HEADER -->
        <!-- start: PAGE CONTENT 
                    <!-- start grid -->
        <div class="row">
          <div class="col-md-12">
            <!-- start: DYNAMIC TABLE PANEL -->
            <div class="panel panel-default">
              <div class="panel-heading"> <i class="fa fa-external-link-square"></i> Reference ID <?php echo $loan_id ?>
                <div class="panel-tools" style="top:2px;">
                  <?php if ($this->session->userdata('ss_group_id') == 1 && $loan_details->is_closed == 0) { ?>
                    <button class="btn btn-blue dropdown-toggle" data-toggle="dropdown"> <i class="clip-list-5"></i> Modify Loan </button>

                  <?php } ?>
                  <ul class="dropdown-menu dropdown-light pull-right">
                    <li> <a id="" data-toggle="modal" href="<?php echo base_url("loan/loan_modify/$loan_id"); ?>"> <i class="fa fa-plus"></i> Modify this Loan Details </a> </li>
                  </ul>
                </div>
                <!--panel-tools-->
              </div>
              <!--panel-heading-->
              <div class="panel-body">
                <div class="well well-sm">
                  <div class="col-xs-4 border-right">
                    <div class="col-xs-1"><i class="fa fa-2x fa-file-text-o  text-muted"></i></div>
                    <div class="col-xs-10">
                      <h4 class="">Reference ID : <?php echo $loan_details->loan_ref; ?></h4>
                      <p>Created Date: <?php echo $loan_details->loan_creted_date; ?></p>
                      <p>Loan Opening : <?php echo $loan_details->loan_date; ?></p>
                      <?php if($loan_details->loan_payment_term==1){ ?>
                      <p>Loan Closing : <?php echo $loan_details->loan_close_date; ?></p>
                      <?php } ?>
                      <p style="display: none;">Total Holidays : <?php echo $holiday_count; ?> ( Include : <?php echo $include_holi_date; ?> Extend : <?php echo $addition_holi_date; ?> )</p>
                     


                    </div>
                    <div class="clearfix"></div>
                  </div>
                  <div class="col-xs-4 border-right">
                    <div class="col-xs-1"><i class="fa fa-2x fa-file-text-o padding010 text-muted"></i></div>
                    <div class="col-xs-10">
                      <h4>Loan Capital : Rs. <?php echo number_format($loan_details->loan_tot_amount, 2, '.', ','); ?></h4>
                      <p>Payment Term : <?php echo $loan_details->payment_term_name; ?> </p>
                      <p>Interest : <?php echo $loan_details->loan_interest; ?> %</p>
                      <?php if($loan_details->loan_payment_term==1){ ?>
                      <p style="display:none">Total Interest : Rs. <?php echo $loan_details->total_interest; ?> </p>
                      <?php }else{ ?>
                        <p style="display:none">Total Interest : Rs. <?php echo number_format($loan_details->loan_tot_amount-$loan_details->loan_payable_total_amount, 2, '.', ',') ?> </p>
                        <?php } ?>
                      <p>Total Loan Amount : Rs. <?php echo number_format($loan_details->loan_payable_total_amount, 2, '.', ',') ?></p>
                      <p>No. of Terms : <?php echo $loan_details->loan_no_of_terms; ?></p>
                      <?php if($loan_details->loan_payment_term==1){ ?>
                      <p><strong>Term Amount : Rs. <?php echo number_format($loan_details->loan_term_amount, 2, '.', ','); ?></strong></p>
                      <?php } ?>
                    </div>
                    <div class="clearfix"></div>
                  </div>
                  <div class="col-xs-4 border-right">
                    <div class="col-xs-1"><i class="fa fa-2x fa-user padding010 text-muted"></i></div>
                    <div class="col-xs-10">
                      <h4 class=""><?php echo $customer_details['cus_name']; ?></h4>
                      <p><?php echo $customer_details['cus_address']; ?></p>
                      <p>Tel: <?php echo $customer_details['cus_mobile']; ?> &nbsp; <?php echo $customer_details['cus_mobile_2']; ?> <?php echo $customer_details['cus_home_phone']; ?> </p>
                      <p>Garanter: <?php echo $loan_details->garanter_name; ?></p>
                      <p>NIC: <?php echo $customer_details['cus_nic']; ?></p>

                    </div>
                    <div class="clearfix"></div>
                  </div>
                  <div class="clearfix"></div>
                </div>

                <!--col-xs-4-->

                <div class="col-xs-5">
                  <input name="loan_id" type="hidden" id="loan_id" value="<?php echo $loan_id ?>">
                  <input type="hidden" id="sale_type" name="sale_type" value="sale">
                  <div class="clearfix"></div>
                </div>
                <!--col-xs-4"-->
                <div class="clearfix"></div>
                <div class="clearfix"></div>

                <!--  start -->

                <!--  start -->

                <div class="well well-sm">
                  <div class="col-xs-12 border-right">
                    <div class="col-xs-1"><i class="fa fa-2x fa-text-o text-muted"></i></div>
                    <div class="col-xs-10">
                      <h4 class=""> Note </h4>
                      <p> <?php echo $loan_details->note; ?> </p>


                      <hr>
                      <p style="color:#D00"> <?php echo $loan_details->close_reason; ?> </p>
                    </div>
                    <div class="clearfix"></div>
                  </div>


                  <div class="clearfix"></div>
                </div>
                <div class="clearfix"></div>
              </div>


              <!------------------------------------------------------------------------------------------->


              <div class="clearfix"></div>
            </div>


            <div id="uploadContainer">
              <div class="panel-heading">Loan Customer Attached Documents ( Types: .JPG, .PNG )</div>
              <input type="hidden" id="loan_id" name="loan_id" value="<?php echo $loan_id ?>" readonly />

              <?php
              $doc_types = [
                'nic_front' => 'National ID Front',
                'nic_back' => 'National ID Back',
                'electricity_bill' => 'Electricity Bill',
                'card' => 'Card',
                'road_map' => 'Road Map'
              ];

              $documents_by_type = [];
              if (!empty($loan_documents)) {
                foreach ($loan_documents as $doc) {
                  $documents_by_type[$doc['person_type']][$doc['doc_type']] = $doc;
                }
              }
              ?>

              <!-- Customer Documents -->
              <h4>Customer Documents</h4>
              <?php foreach ($doc_types as $type_key => $type_label):
                $existing = isset($documents_by_type['customer'][$type_key]) ? $documents_by_type['customer'][$type_key] : null;
              ?>
                <div class="upload-box" data-person="customer" data-type="<?= $type_key ?>">
                  <label><?= $type_label ?></label>
                  <div class="preview" id="preview_<?= $type_key ?>_customer">
                    <?php if ($existing): ?>
                      <img src="<?= base_url($existing['file_path']) ?>">
                    <?php else: ?>
                      <span>No file uploaded</span>
                    <?php endif; ?>
                  </div>

                  <div class="file-name"></div>
                </div>
              <?php endforeach; ?>

              <!-- Guarantor Documents -->
              <h4>Guarantor Documents</h4>
              <?php foreach ($doc_types as $type_key => $type_label):
                $existing = isset($documents_by_type['guarantor'][$type_key]) ? $documents_by_type['guarantor'][$type_key] : null;
              ?>
                <div class="upload-box" data-person="guarantor" data-type="<?= $type_key ?>">
                  <label><?= $type_label ?></label>
                  <div class="preview" id="preview_<?= $type_key ?>_guarantor">
                    <?php if ($existing): ?>
                      <img src="<?= base_url($existing['file_path']) ?>">
                    <?php else: ?>
                      <span>No file uploaded</span>
                    <?php endif; ?>
                  </div>

                  <div class="file-name"></div>
                </div>
              <?php endforeach; ?>
            </div>




            <!-- end-->

            <!-- payment list -->
            <div class="col-xs-12 border-right">
              <h4>Terms List</h4>
            </div>
            <div class="row">
              <div class="col-xs-12">
                <div class="table-responsive">
                   <table class="table table-bordered" id="loan_terms_table">
                    <thead>
                      <tr>
                        <th>Term No</th>
                        <th>Term Date</th>
                        <th>Realize Date</th>
                        <th>Term Amount</th>
                        <th>Paid Amount</th>
                        <th>Penalty</th>
                        <th>Status</th>
                        <th>Payment Date</th>
                        <th>Days</th>
                        <th>Delay Charges</th>
                      </tr>
                    </thead>
                    <tbody>
                      <?php
                      $total_charges = 0; // initialize total
                       if (!empty($loan_terms)) {
                        foreach ($loan_terms as $term) {
                          $total_charges += $term->delay_charge; // add each delay charge
                           ?>
                          <tr>
                            <td><?= $term->term_no ?></td>
                            <td><?= !empty($term->term_date) ? date("Y-m-d", strtotime($term->term_date)) : '-' ?></td>
                            <td><?= !empty($term->realize_date) ? date("Y-m-d", strtotime($term->realize_date)) : '-' ?></td>
                            <td><?= number_format($term->term_amount, 2) ?></td>
                            <td><?= number_format($term->paid_amount, 2) ?></td>
                            <td><?= number_format($term->penalty_amount, 2) ?></td>
                            <td>
                              <?php if ($term->status == "Pending") { ?>
                                <span class="label label-warning">Pending</span>
                              <?php } elseif ($term->status == "Paid") { ?>
                                <span class="label label-success">Paid</span>
                              <?php } elseif ($term->status == "Not Collected") { ?>
                                <span class="label label-info">Not Collected</span>
                              <?php } else { ?>
                                <span class="label label-danger">Colsed</span>
                              <?php } ?>
                            </td>
                            <td><?= !empty($term->payment_date) ? date("d-m-Y", strtotime($term->payment_date)) : '-' ?></td>
                            <td><?= $term->different_days ?></td>
                            <td><?= number_format($term->delay_charge, 2) ?></td>
                          </tr>
                        <?php }
                      } else { ?>
                        <tr>
                          <td colspan="11" class="text-center">No loan terms found.</td>
                        </tr>
                      <?php } ?>
                    </tbody>
                    <?php if (!empty($loan_terms)) { ?>
                      <tfoot>
                        <tr>
                          <td colspan="9" class="text-right"><strong>Total Delay Charges:</strong></td>
                          <td><strong><?= number_format($total_charges, 2) ?></strong></td>
                        </tr>
                      </tfoot>
                    <?php } ?>
                  </table>


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

            <!-- payment list -->
            <div class="col-xs-12 border-right">
              <h4>Payment History</h4>
            </div>
            <div class="row">
              <div class="col-xs-12">
                <div class="table-responsive">
                  <table class="table items table-striped table-bordered table-condensed table-hover">
                    <thead>
                      <tr class="report_view_th">
                        <th width="50 px;">No</th>
                        <th width="100 px;">Date Added</th>
                        <th width="100 px;">Payment <br>Date</th>
                        <th>Reference</th>
                        <th>Tracking<br>Number</th>
                        <th>Paid by</th>
                        <th>Status</th>
                        <th>Received<br>Panalty Rs.</th>
                        <th>Received<br>Due Rs.</th>
                        <th>Received<br>interest Rs.</th>
                        <th>Received<br>Capital Rs.</th>
                        <th>Received<br>Loan Rs.</th>
                        <th>Received<br>Money Rs.</th>
                      </tr>
                    </thead>
                    <tbody>
                      <?php $total_payment = 0;
                      $payment_count = 0;
                      foreach ($loan_payment_list as $row) {

                        if ($row->pymnt_amount > 0) {
                          $total_payment += $row->pymnt_amount;
                          $payment_count++;
                        }


                      ?>
                        <tr>
                          <td><?php if ($row->pymnt_amount > 0) {
                                echo $payment_count;
                              } ?></td>
                          <td><?php echo  date('Y-m-d', strtotime($row->pymnt_added_date_time)); ?></td>
                          <td><?php echo  date('Y-m-d', strtotime($row->pymnt_date_time)); ?></td>
                          <td><?php echo $row->pymnt_ref_no ?></td>
                          <td><?php echo $row->tracking_number ?></td>
                          <td><?php echo $row->pymnt_paying_by ?></td>
                          <?php
                          $status = "check this recode";
                          if ($row->pymnt_collected == 1) {
                            $status = "Collected";
                          }
                          if ($row->pymnt_deposited == 1) {
                            $status = "Deposited";
                          }
                          if ($row->pymnt_realize == 1) {
                            $status = "Realize";
                          }
                          if ($row->pymnt_returned == 1) {
                            $status = "Return";
                          }




                          ?>
                          <td><?php echo $status ?></td>

                          <td style="text-align:end"><?php echo $row->panalty_received ?></td>
                          <td style="text-align:end"><?php echo number_format($row->due_received, 2, '.', ',') ?></td>
                          <td style="text-align:end"><?php echo number_format($row->loan_interest_recived, 2, '.', ',') ?></td>
                          <td style="text-align:end"><?php echo number_format($row->capital_received, 2, '.', ',') ?></td>
                          <td style="text-align:end"><?php echo number_format($row->loan_received, 2, '.', ',') ?></td>
                          <td style="text-align:end"><?php echo number_format($row->pymnt_amount, 2, '.', ',') ?></td>
                        </tr>
                      <?php } ?>

                    </tbody>
                    <tfoot>
                      <th>No</th>
                      <th>Date Added</th>
                      <th>Payment <br>Date</th>
                      <th>Reference</th>
                      <th>Tracking<br>Number</th>
                      <th>Paid by</th>
                      <th>Status</th>
                      <th>Received<br>Panalty Rs.</th>
                      <th>Received<br>Due Rs.</th>
                      <th>Received<br>interest Rs.</th>
                      <th>Received<br>Capital Rs.</th>
                      <th>Received<br>Loan Rs.</th>
                      <th><?php echo number_format($total_payment, 2, '.', ',');  ?></th>

                    </tfoot>
                  </table>
                </div>
              </div>
            </div>


            <!-- Holiday list -->
            <div class="col-xs-12 border-right">
              <h4>Loan Holidays </h4>
            </div>
            <div class="row">
              <div class="col-xs-12">
                <div class="table-responsive">
                  <table class="table items table-striped table-bordered table-condensed table-hover">
                    <thead>
                      <tr class="report_view_th">
                        <th>Year</th>
                        <th>Month</th>
                        <th>Date</th>
                        <th>Remark</th>
                      </tr>
                    </thead>
                    <tbody>
                      <?php
                      foreach ($holiday_list as $row) { ?>
                        <tr>
                          <td><?php echo $row->year ?></td>
                          <td><?php echo $row->month ?></td>
                          <td><?php echo $row->holiday_date ?></td>
                          <td><?php echo $row->remarks ?></td>
                        </tr>

                      <?php } ?>


                    </tbody>
                  </table>
                </div>
              </div>
            </div>
            <!-- panalty list -->
            <div class="col-xs-12 border-right">
              <h4>Due History </h4>
            </div>
            <div class="row">
              <div class="col-xs-12">
                <div class="table-responsive">
                  <table class="table items table-striped table-bordered table-condensed table-hover">
                    <thead>
                      <tr class="report_view_th">
                        <th width="100px;">Date</th>
                        <th>Amount</th>
                        <th>Remark</th>
                        <th>%</th>
                      </tr>
                    </thead>
                    <tbody>
                      <?php $tot = 0;
                      foreach ($loan_due as $row) { ?>
                        <tr>
                          <td><?php echo date('Y-m-d', strtotime($row->system_date_time))  ?></td>
                          <td style="text-align:end"><?php echo number_format($row->due_amount, 2, '.', ',') ?></td>
                          <td><?php echo $row->remarks ?></td>
                          <td><?php echo $row->due_precentage ?> %</td>
                        </tr>
                      <?php $tot += $row->due_amount;
                      } ?>
                      <tr>
                        <td> Total </td>
                        <td style="text-align:right;"><?php echo $tot; ?></td>
                        <td></td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
            <div class="clearfix"></div>
            <br>
            <div class="clearfix"></div>

            <!-- panalty list -->
            <div class="col-xs-12 border-right">
              <h4>Panalty History </h4>
            </div>
            <div class="row">
              <div class="col-xs-12">
                <div class="table-responsive">
                  <table class="table items table-striped table-bordered table-condensed table-hover">
                    <thead>
                      <tr class="report_view_th">
                        <th width="100px;">Date</th>
                        <th>Amount</th>
                        <th>Remark</th>
                        <th>%</th>
                      </tr>
                    </thead>
                    <tbody>
                      <?php $tot = 0;
                      foreach ($loan_panalty as $row) { ?>
                        <tr>
                          <td><?php echo $row->payment_date ?></td>
                          <td style="text-align:end"><?php echo number_format($row->panalty_amount, 2, '.', ',') ?></td>
                          <td><?php echo $row->remark ?></td>
                          <td><?php echo $row->panalty_precentage ?> %</td>



                        </tr>
                      <?php $tot += $row->panalty_amount;
                      } ?>
                      <tr>
                        <td> Total </td>
                        <td style="text-align:right;"><?php echo $tot; ?></td>
                        <td></td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
            <!-- panalty list -->

            <!-- end payment list-->

            <div class="buttons">
              <div class="btn-group btn-group-justified">
                <div class="btn-group" onClick="fbs_click(<?php echo $loan_id; ?>)"><a title="" class="tip btn btn-primary" data-original-title="Print"><i class="fa fa-print"></i> <span class="hidden-sm hidden-xs">Print</span></a> </div>
              </div>
            </div>
            <!--buttons-->

          </div>
          <!--panel-body-->
        </div>
        <!--panel-->

      </div>
      <!--col-md-12-->
    </div>
    <!--row-->

    <!-- end grid -->

  </div>
  <!-- end: PAGE -->
  </div>
  <!-- end: MAIN CONTAINER -->
  <!-- start: FOOTER -->
  <div class="footer clearfix">
    <div class="footer-inner"> <?php echo date("Y"); ?> &copy; Vehical Maintacne Management System by sallelanka solutions. </div>
    <div class="footer-items"> <span class="go-top"><i class="clip-chevron-up"></i></span> </div>
  </div>
  <!-- end: FOOTER -->
  <!-- start: RIGHT SIDEBAR -->
  <!-- end: RIGHT SIDEBAR -->
  <div id="event-management" class="modal fade" tabindex="-1" data-width="760" style="display: none;">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times; </button>
          <h4 class="modal-title">Event Management</h4>
        </div>
        <div class="modal-body"></div>
        <div class="modal-footer">
          <button type="button" data-dismiss="modal" class="btn btn-light-grey"> Close </button>
          <button type="button" class="btn btn-danger remove-event no-display"> <i class='fa fa-trash-o'></i> Delete Event </button>
          <button type='submit' class='btn btn-success save-event'> <i class='fa fa-check'></i> Save </button>
        </div>
      </div>
    </div>
  </div>
  </div>

  <!-- start ajax model -->
  <div id="ajax-modal" class="modal fade" data-backdrop="static" data-keyboard="false" tabindex="-1" style="display: none;"></div>
  <!-- end ajax model -->

  <!-- start: MAIN JAVASCRIPTS -->
  <?php $this->load->view("common/footer"); ?>
  <!-- end: MAIN JAVASCRIPTS -->

  <!-- start: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->

  <?php /*?>	<script type="text/javascript" src="<?php echo asset_url(); ?>plugins/bootbox/bootbox.min.js"></script>
		<script src="<?php echo asset_url(); ?>plugins/bootstrap-modal/js/bootstrap-modal.js"></script>
		<script src="<?php echo asset_url(); ?>plugins/bootstrap-modal/js/bootstrap-modalmanager.js"></script>
		<script src="<?php echo asset_url(); ?>js/ui-modals.js"></script>       
        <script src="<?php echo asset_url(); ?>plugins/jQuery-lib/2.0.3/jquery.min.js"></script><?php */ ?>
  <!-- end: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->
  <script>
    jQuery(document).ready(function() {
      //TableData.init();
      //Main.init();
      //TableData.init();
      //UIModals.init();
    });
  </script>
  <script type="text/javascript" language="javascript">
    function fbs_click(id, d) {
      u = location.href;
      t = document.title;
      window.open('<?php echo base_url() ?>loan/print_loan_invoice/' + id, 'sharer', 'toolbar=0,status=0,width=700,height=700, left=10, top=10,scrollbars=yes');
      return false;
    }
  </script>
</body>
<!-- end: BODY -->

</html>