<?php $this->view("includes/Inc_pagehead");?>
<!-- Page Styles Goes Here-->
<style>
.m-invoice-2 .m-invoice__wrapper .m-invoice__body table thead tr th {
  color: #000000;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body table tbody tr td {
  color: #404040;
}
.item_table td{
  padding: .75rem !important;
}
.item_table th{
  white-space: nowrap;
  padding: .35rem !important;
}
.item_table1 th{
  background:#dfdddd61 !important;
}
.table thead th {
  border-top: 2px solid #b7b7b7 !important;
}
.table thead th {
  border: 2px solid #b7b7b7;
}
.table tbody td {
  border: 2px solid #b7b7b7;
}
.payment-table tbody td{
  border-top: 2px solid #b7b7b7 !important;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__head .m-invoice__container.m-invoice__container--centered {
  width: 90%;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body.m-invoice__body--centered {
  width: 90%;
  padding: 0rem 1rem 1rem 1rem;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body table thead tr th {
  padding: 0.5rem 0.5rem 0.5rem 0.5rem !important;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body table tbody tr td {
  padding: 0.5rem 0.5rem 0.5rem 0.5rem !important;
}
.invoice_term{
  font-weight: bold !important;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body table tbody tr td {
  padding: 1rem 0 1rem 0;
  vertical-align: middle;
  border-top: none;
  font-weight: 500 !important;
  font-size: 1.1rem;
}
@media print
{
  .fa, .fas {
    font-weight: 600 !important;
  }
  .m-portlet .m-portlet__body {
    color: black !important;
  }
  body * {
    visibility: hidden;
  }
  .m-portlet__body * {
    visibility: visible;
    overflow: visible !important;
  }
  .table-bordered td{
    /* padding: .75rem !important; */
  }
  .table-bordered th{
    white-space: nowrap;
    /* padding: .75rem !important; */
  }
  .table-bordered .table thead th {
    border-top: 2px solid #f4f5f8 !important;
  }
  .m-invoice-2 .m-invoice__wrapper .m-invoice__head .m-invoice__container.m-invoice__container--centered {
    width: 100% !important;
  }
  .m-invoice-2 .m-invoice__wrapper .m-invoice__body.m-invoice__body--centered {
    width: 100% !important;
  }
  .m-invoice__container{
    width: 100% !important;
  }
  .m-invoice-2 .m-invoice__wrapper .m-invoice__head .m-invoice__container.m-invoice__container--centered {
    width: 100% !important;
    margin :0 !important;
    padding :0 !important;
  }
  .m-content{
    padding: 0px !important;
  }
  #print_view {
    margin-top: -24%;
  }
  #print, .print_hide_div
  {
    display: none !important;
  }
  .m-portlet .m-portlet__head {
    /* display: none !important;
    height: 0px !important; */
  }
  body.m-content--skin-light2 {
    background-color: white !important;
  }
  .m-invoice-2 .m-invoice__wrapper .m-invoice__head .m-invoice__container .m-invoice__items .m-invoice__item {
    display: table-cell;
  }
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__head .m-invoice__container .m-invoice__items .m-invoice__item {
  display: table-cell !important;
}
.col-sm-4 {
  -webkit-box-flex: 0;
  -ms-flex: 0 0 33.33333%;
  flex: 0 0 33.33333%;
  max-width: 33.33333%;
}
.col-sm-8 {
  -webkit-box-flex: 0;
  -ms-flex: 0 0 66.66667%;
  flex: 0 0 66.66667%;
  max-width: 66.66667%;
}
.col-md-7 {
  -webkit-box-flex: 0;
  -ms-flex: 0 0 58.33333%;
  flex: 0 0 58.33333%;
  max-width: 58.33333%;
}
.col-md-5 {
  -webkit-box-flex: 0;
  -ms-flex: 0 0 41.66667%;
  flex: 0 0 41.66667%;
  max-width: 41.66667%;
}
.col-md-6 {
  -webkit-box-flex: 0;
  -ms-flex: 0 0 50%;
  flex: 0 0 50%;
  max-width: 50%;
}
.no-border thead th {
  border: none !important;
  border-top: none !important;
}
@media print {
  <?php if($this->config->item('Client_Payment_invoice_hide_invoice_term')==1){?>
    .invoice_term{
      display: none !important;
    }
    <?php } ?>
    html, body, div, span, applet, object, iframe, td, tr, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
      font-size: 15pt !important;  }
      h1.entry-title {
        font-size: 15pt !important;
      }
    }
    <?php if($this->config->item('Client_Payment_client_payment_invoice_template')==6){?>
      /* .outer{ width:100%; height:100%; float:left }
      .header{ width:100%; height:100%; float:left; }
      .address{ width:100%; height:100%; float:left; }
      .items_area{ width:100%; height:100%; float:left; }
      .heading h2 { font-family:Arial, Helvetica, sans-serif; font-size:22px; font-weight:bold; padding:0px; margin:0px; text-align:center; text-decoration:underline; }
      .text_padding{ padding-left:5px; }
      .items_table { width:100%; height:100%; float:left; margin-top:20px; }
      .bank_sign{ width:100%; height:100%; float:left; margin-top:40px; } */
      .m-invoice-2 .m-invoice__wrapper .m-invoice__body table tbody tr td:not(:first-child) {
        text-align: left;
      }
      <?php } ?>
      </style>
      <?php $this->view("includes/Inc_navigation");?>
      <div class="m-grid__item m-grid__item--fluid m-wrapper">
        <!-- BEGIN: Subheader -->
        <div class="m-subheader ">
          <div class="d-flex align-items-center">
            <div class="mr-auto">
              <h3 class="m-subheader__title m-subheader__title--separator">
                <?php if($invoice->invoice_type=='proforma'){
                  echo 'Proforma Invoice';
                }else{
                  echo 'Client Invoice';
                }?>
              </h3>
              <ul class="m-subheader__breadcrumbs m-nav m-nav--inline">
                <li class="m-nav__item m-nav__item--home">
                  <a href="#" class="m-nav__link m-nav__link--icon">
                    <i class="m-nav__link-icon la la-home"></i>
                  </a>
                </li>
                <li class="m-nav__separator">
                  -
                </li>
                <li class="m-nav__item">
                  <a href="<?php echo base_url().'dashboard'?>" class="m-nav__link">
                    <span class="m-nav__link-text">
                      Home
                    </span>
                  </a>
                </li>
                <li class="m-nav__separator">
                  -
                </li>
                <li class="m-nav__item">
                  <a href="<?php echo base_url().'purchases' ?>" class="m-nav__link">
                    <span class="m-nav__link-text">
                      Invoice
                    </span>
                  </a>
                </li>
              </ul>
            </div>
            <div>
            </div>
          </div>
        </div>
        <!-- END: Subheader -->
        <div class="m-content">
          <div class="m-portlet m-portlet--full-height">
            <div class="m-portlet__head">
              <div class="m-portlet__head-caption">
                <div class="m-portlet__head-title">
                  <h3 class="m-portlet__head-text">
                    Invoice ID : #<?php echo $invoice->invoice_id?>
                  </h3>
                </div>
              </div>
              <div class="m-portlet__head-tools" >
                <?php if($invoice->project_id!=0){?>
                  <a href="<?php echo base_url().'work/profile/'.$invoice->project_id?>" style="margin-left: 5px;margin-right: 5px" class="btn m-btn--gradient-from-focus m-btn--gradient-to-warning  m-btn  m-btn--icon m-btn--air m-btn--pill">
                    <span>
                      <i class="fa fa-eye"></i>
                      <span>
                        View Project Profile
                      </span>
                    </span>
                  </a>
                <?php } ?>
                <?php if($this->session->userdata('user_role')!='auditor' ){ ?>
                  <?php if($invoice->balance_amount>0){?>
                    <a style="margin-left: 5px;margin-right: 5px" data-bill-type="purchase_bill" data-bill-id="" id="receive_payment" data-toggle="modal"  href="#client_payment_add_modal" class="btn m-btn--gradient-from-primary m-btn--gradient-to-success  m-btn  m-btn--icon m-btn--air m-btn--pill">
                      <span>
                        <i class="la la-plus"></i>
                        <span>
                          Receive Payment
                        </span>
                      </span>
                    </a>
                  <?php } ?>
                <?php } ?>
                <?php if($invoice->entry_approval_status==1){ ?>

                  <?php if($this->config->item('Client_Payment_client_payment_invoice_template')==7){ ?>
                    <div class="btn-group">
                      <button type="button" style="margin-left: 5px;margin-right: 5px" href="javascript:;"  data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-toggle btn m-btn--gradient-from-warning m-btn--gradient-to-danger  m-btn  m-btn--icon m-btn--air m-btn--pill">
                        Print Invoice
                      </button>
                      <div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 40px, 0px);">
                        <a class="dropdown-item" id="btn_print_invoice" href="#">Print</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" id="btn_print_invoice_2" href="#">Print With Transactions</a>
                      </div>
                    </div>
                  <?php }else{ ?>
                    <a style="margin-left: 5px;margin-right: 5px" href="javascript:;" id="btn_print_invoice" class="btn m-btn--gradient-from-warning m-btn--gradient-to-danger  m-btn  m-btn--icon m-btn--air m-btn--pill">
                      <span>
                        <i class="la la-print"></i>
                        <span>
                          Print Invoice
                        </span>
                      </span>
                    </a>
                  <?php } ?>
                <?php } ?>
                <?php if($this->session->userdata('user_role')!='auditor' ){ ?>
                  <a href="<?php echo base_url().'invoices/edit/'.$invoice->invoice_id?>" style="margin-left: 5px;margin-right: 5px" class="btn m-btn--gradient-from-focus m-btn--gradient-to-danger  m-btn  m-btn--icon m-btn--air m-btn--pill">
                    <span>
                      <i class="fa fa-edit"></i>
                      <span>
                        Edit Invoice
                      </span>
                    </span>
                  </a>
                <?php } ?>
                <?php
                $invoice_no = '';
                if($invoice->invoice_type=='proforma'){
                  $invoice_no .= $this->config->item('client_invoice_proforma_prefix');
                }else{
                  if($invoice->tax_invoice==1){
                    if($invoice->business_type=='B2B'){
                      $invoice_no .= $this->config->item('client_invoice_tax_b2b_prefix');
                    }else{
                      $invoice_no .= $this->config->item('client_invoice_tax_b2c_prefix');
                    }
                  }else{
                    $invoice_no .= $this->config->item('client_invoice_prefix');
                  }
                }
                if (strpos($invoice_no, 'y') !== false) {
                  $year = date('y',strtotime($invoice->invoice_date));
                  $invoice_no = str_replace('y', $year, $invoice_no);
                }
                $invoice_no .= sprintf('%04u', $invoice->invoice_no);
                $invoice_no .= $invoice->invoice_suffix;
                if($invoice->reference_no!=''){
                  $invoice_no .= '<br/>Ref No: '.$invoice->reference_no;
                }
                ?>
              </div>
            </div>

            <div class="m-portlet__body m-portlet__body--no-padding" id="print_view">
              <form autocomplete="off" id="form_invoice_add" data-form-type="invoice_create" method="post" action="<?php echo base_url()?>invoices/update" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
                <?php if($this->config->item('client_invoice_header')!=''){ ?>
                  <img class="letter_head_img" style="width: 100%" src="<?php echo base_url().'uploads/company/'.$this->config->item('client_invoice_header')?>" />
                <?php } ?>
                <?php if($this->config->item('Client_Payment_client_payment_invoice_template')!=6 && $this->config->item('Client_Payment_client_payment_invoice_template')!=7){?>
                  <div class="m-invoice-2" style="padding-bottom: 20px">
                    <div  class="m-invoice__wrapper">
                      <div class="m-invoice__head" >
                        <div class="m-invoice__container m-invoice__container--centered">
                          <?php if(($this->config->item('Client_Payment_client_payment_invoice_template')==1 || $this->config->item('Client_Payment_client_payment_invoice_template')==3 || $this->config->item('Client_Payment_client_payment_invoice_template')==4 || $this->config->item('Client_Payment_client_payment_invoice_template')==5 ) && $this->config->item('Tax_tax_splitting')==1){ ?>
                            <div  style="text-align:center">

                              <h4><?php if($invoice->tax_invoice==1){ echo $invoice->business_type." - TAX INVOICE";}else{ echo $this->config->item('Client_Payment_client_payment_invoice_title');} ?></h4>

                            </div>
                          <?php } ?>
                          <?php if($this->config->item('client_invoice_header')==''){ ?>
                            <div class="row" style="padding-left: 10px;padding-right: 10px;">
                              <div class="col-md-7" style="border-right: 1px solid #ebedf2;">
                                <span class="m-invoice__desc" style="text-align: left;padding: 0.5rem 0.5rem 0.5rem 0.5rem !important;">
                                  <!-- <span class="m-invoice__subtitle"><strong><label class="invoice_term">INVOICE</label> FROM</strong></span> -->
                                  <span><?= preg_replace('#(<br */?>\s*)+#i', '<br />',nl2br($invoice->invoice_from)) ?></span>
                                </span>
                              </div>
                              <div class="col-md-5" style="">

                                <div class="m-invoice__logo" style="padding-top: 1rem;">
                                  <a href="#">
                                    <?php if($invoice->entry_approval_status!=1){ ?>
                                      <span class='m-badge m-badge--danger badge-lg m-badge--wide'><i class='fa fa-times-circle'></i> Invoice Not Approved</span>
                                    <?php } ?>
                                    <img src="<?= base_url()?>uploads/company/logo.png" >
                                  </a>
                                </div>
                              </div>
                            </div>
                          <?php } ?>
                          <div class="m-invoice__items" style="padding: 1rem 1rem 1rem 1rem;padding-bottom: 0 !important;margin-bottom: 0px !important;">
                            <div class="m-invoice__item" style="">
                              <span class="m-invoice__subtitle"><label class="invoice_term">INVOICE</label> TO</span>
                              <span class="m-invoice__text"><?php echo $invoice->client_name?></span>
                              <span class="m-invoice__text"><?php echo $invoice->client_address?></span>
                              <?php if($invoice->client_email!=''){?>
                                <span class="m-invoice__text">Email: <?php echo $invoice->client_email?></span>
                              <?php } ?>
                              <?php if(isset($enquiry_data) && !empty($enquiry_data)){?>
                                <span class="m-invoice__text">Contact No: <?php echo $enquiry_data->enq_contact_person_mobile?></span>
                                <span class="m-invoice__text">Contact Person: <?php echo $enquiry_data->enq_contact_person?></span>
                              <?php }else{ ?>
                                <span class="m-invoice__text">Contact No: <?php echo $invoice->client_contact?></span>
                              <?php } ?>

                              <span class="m-invoice__text"><?php echo $this->config->item('Tax_tax_name')." No: ". $invoice->tax_no?></span>
                              <?php if($client_data->tax_state_id!=0){?>
                                <span class="m-invoice__text">State: <?php echo $client_data->state_name?>-<?php echo $client_data->state_code?></span>
                              <?php } ?>
                            </div>
                            <!-- <div class="m-invoice__item" style="text-align: center">

                          </div> -->
                          <?php if($this->config->item('Client_Payment_client_payment_invoice_template')==3){ ?>
                            <div class="m-invoice__item" style="text-align: right">
                              <span class="m-invoice__subtitle">VEHICLE NO</span>
                              <span class="m-invoice__text"><?php echo $invoice->vehicle_no?></span>
                            </div>
                          <?php } ?>
                          <div class="m-invoice__item" style="text-align: right">
                            <span class="m-invoice__subtitle"><label class="invoice_term">INVOICE NO</label> :
                              <?php if($this->config->item('Client_Payment_invoice_hide_invoice_no')==0){ ?>
                                <?php echo $invoice_no?>
                                <!-- <br/>
                                <div style="border-top: 1px solid #ebedf2;"></div>
                                <br/>
                                <span class="m-invoice__subtitle">REFERENCE NO</span> -->
                              <?php } ?>
                              <?php if($this->config->item('Client_Payment_invoice_hide_invoice_no')==1){ ?>
                                <span class="m-invoice__text"><?php echo $invoice->reference_no?></span>
                              <?php } ?>
                            </span>

                            <span class="m-invoice__subtitle"><label class="invoice_term">INVOICE DATE : <?php echo date('d-m-Y',strtotime($invoice->invoice_date))?></label> </span>
                            <span class="m-invoice__text"></span>
                            <?php if($invoice->invoice_type=='other_income'){ ?>
                              <br/>
                              <div style="border-top: 1px solid #ebedf2;"></div>
                              <br/>
                              <span class="m-invoice__subtitle">WORK STATUS</span>
                              <span class="m-invoice__text"><?php if($invoice->project_status==1){
                                $project_status = "<span class='m-badge m-badge--success m-badge--wide'><i class='fa fa-check'></i> Completed</span>";
                              }elseif($invoice->project_status==2){
                                $project_status = "<span class='m-badge m-badge--warning m-badge--wide'><i class='fa fa-times-circle'></i> Pending</span>";
                              }else{
                                $project_status = '';
                              }
                              echo '<strong>'.$project_status.'</strong>';
                              ?></span>
                            <?php } ?>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="m-invoice__body m-invoice__body--centered" style="min-height: 100px">
                      <?php if($invoice->invoice_type=='project_invoice'){ ?>
                        <table class="">
                          <thead>
                            <tr>
                              <td>
                                <strong>PROJECT : </strong><?php echo strtoupper($invoice->work_name)?>
                              </td>
                            </tr>
                          </thead>
                        </table>
                      <?php } ?>
                      <div class="table-responsive">
                        <table class="item_table1" style="width:100%">
                          <thead>
                            <?php
                            $tax_splitting = 0;
                            $tax_percent = $this->config->item('Tax_tax_percent');
                            foreach ($tax_percent as $row){
                              ${'total_taxable_amt_'.$row->tax_id} = 0;
                            }
                            if($this->config->item('Client_Payment_client_payment_invoice_template')==1 || $this->config->item('Client_Payment_client_payment_invoice_template')==4){
                              if($invoice->tax1_percent!=0 || $invoice->tax2_percent!=0 || $invoice->tax3_percent!=0){
                                $tax_splitting = 1;
                              }
                            }
                            $total_qty=$total_taxable_amt=$total_tax1_amt=$total_tax2_amt=$total_tax3_amt=$total_disc_amt=$gt_total_amount=0;
                            $tax1=$tax2=$tax3=0;
                            if($this->config->item('Client_Payment_client_payment_invoice_template')==1 || $this->config->item('Client_Payment_client_payment_invoice_template')==4){ ?>
                              <tr>
                                <th width="7%">Sl No</th>
                                <th width="31%" style="text-align: left">Description</th>
                                <th width="10%"><?php echo $this->config->item('Client_Payment_invoice_item_code_title')?></th>
                                <th width="10%">Quantity</th>
                                <th width="10%">Unit</th>
                                <th width="10%">Price</th>
                                <?php if($this->config->item('Client_Payment_client_payment_invoice_template')==4){ ?>
                                  <th width="10%"><?php echo $this->config->item('Tax_tax_name')." @ ".$invoice->tax_percentage."%" ?></th>
                                <?php } ?>
                                <th width="18%">Total Amount</th>
                              </tr>
                            <?php }elseif($this->config->item('Client_Payment_client_payment_invoice_template')==2){ ?>
                              <tr>
                                <th width="7%">Sl No</th>
                                <th width="20%" style="text-align: left">Date</th>
                                <th width="40%" style="text-align: left">Complaint</th>
                                <th width="18%">Amount</th>
                              </tr>
                            <?php }elseif($this->config->item('Client_Payment_client_payment_invoice_template')==3){

                              foreach($invoice_items as $row):
                                if($row->tax1_percent!=0){
                                  $tax1=1;
                                }
                                if($row->tax2_percent!=0){
                                  $tax2=1;
                                }
                                if($row->tax3_percent!=0){
                                  $tax3=1;
                                }
                              endforeach;
                              ?>
                              <tr>
                                <th rowspan="2" >SNo</th>
                                <th rowspan="2" style="text-align: center"><?php echo $this->config->item('Client_Payment_invoice_item_code_title')?></th>
                                <th rowspan="2" style="text-align: center;width:15%">Description</th>
                                <th rowspan="2" style="text-align: center">HSN</th>
                                <th rowspan="2" style="text-align: center">MRP <?php echo $this->config->item('Currency_currency_format') ?></th>
                                <th rowspan="2" style="text-align: center">Trade Rate</th>
                                <th rowspan="2" style="text-align: center">Qty</th>
                                <th rowspan="2" style="text-align: center">Taxable Amt</th>
                                <?php if($tax1==1){?>
                                  <th colspan="2" style="text-align: center"><?php echo $this->config->item('Tax_tax1_name') ?></th>
                                <?php } ?>
                                <?php if($tax2==1){?>
                                  <th colspan="2" style="text-align: center"><?php echo $this->config->item('Tax_tax2_name') ?></th>
                                <?php } ?>
                                <?php if($tax3==1){?>
                                  <th colspan="2" style="text-align: center"><?php echo $this->config->item('Tax_tax3_name') ?></th>
                                <?php } ?>
                                <th colspan="2" style="text-align: center">Discount</th>
                                <th rowspan="2" style="text-align: center">Total Amount</th>
                              </tr>
                              <tr>
                                <?php if($tax1==1){?>
                                  <th style="text-align: center">%</th>
                                  <th style="text-align: center">Amount</th>
                                <?php } ?>
                                <?php if($tax2==1){?>
                                  <th style="text-align: center">%</th>
                                  <th style="text-align: center">Amount</th>
                                <?php } ?>
                                <?php if($tax3==1){?>
                                  <th style="text-align: center">%</th>
                                  <th style="text-align: center">Amount</th>
                                <?php } ?>
                                <th style="text-align: center">%</th>
                                <th style="text-align: center">Amount</th>
                              </tr>
                            <?php }elseif($this->config->item('Client_Payment_client_payment_invoice_template')==5 ){

                              foreach($invoice_items as $row):
                                if($row->tax1_percent!=0){
                                  $tax1=1;
                                }
                                if($row->tax2_percent!=0){
                                  $tax2=1;
                                }
                                if($row->tax3_percent!=0){
                                  $tax3=1;
                                }
                              endforeach;
                              ?>
                              <tr>
                                <th rowspan="2" >SNo</th>
                                <th rowspan="2" style="text-align: center;width:15%">Description</th>
                                <th rowspan="2" style="text-align: center">Qty</th>
                                <th rowspan="2" style="text-align: center">Unit Rate</th>
                                <th rowspan="2" style="text-align: center">Taxable Amt</th>
                                <?php if($tax1==1){?>
                                  <th colspan="2" style="text-align: center"><?php echo $this->config->item('Tax_tax1_name') ?></th>
                                <?php } ?>
                                <?php if($tax2==1){?>
                                  <th colspan="2" style="text-align: center"><?php echo $this->config->item('Tax_tax2_name') ?></th>
                                <?php } ?>
                                <?php if($tax3==1){?>
                                  <th colspan="2" style="text-align: center"><?php echo $this->config->item('Tax_tax3_name') ?></th>
                                <?php } ?>
                                <th rowspan="2" style="text-align: center">Total Amount</th>
                              </tr>
                              <tr>
                                <?php if($tax1==1){?>
                                  <th style="text-align: center">%</th>
                                  <th style="text-align: center">Amount</th>
                                <?php } ?>
                                <?php if($tax2==1){?>
                                  <th style="text-align: center">%</th>
                                  <th style="text-align: center">Amount</th>
                                <?php } ?>
                                <?php if($tax3==1){?>
                                  <th style="text-align: center">%</th>
                                  <th style="text-align: center">Amount</th>
                                <?php } ?>
                              </tr>
                            <?php } ?>
                          </thead>
                          <tbody id="item_body">
                            <?php
                            $n = 1;

                            foreach($invoice_items as $row):
                              if($this->config->item('Client_Payment_client_payment_invoice_template')==3 || $this->config->item('Client_Payment_client_payment_invoice_template')==5){
                                if($row->tax1_percent!=0 || $row->tax2_percent!=0 || $row->tax3_percent!=0){
                                  $tax_splitting = 1;
                                }
                              }
                              if($this->config->item('Client_Payment_client_payment_invoice_template')==1 || $this->config->item('Client_Payment_client_payment_invoice_template')==4){
                                ?>
                                <tr>
                                  <td><?php echo $n++?></td>
                                  <td style="text-align: left"><?php echo $row->name?></td>
                                  <td><?php echo $row->item_code?></td>
                                  <td><?php echo $row->quantity?></td>
                                  <td><?php echo $row->unit_name?></td>
                                  <td style="white-space: nowrap;"><?php echo $this->config->item('currency_format')->formatCurrency($row->price,$this->config->item('Currency_currency_shortname'));?></td>
                                  <?php if($this->config->item('Client_Payment_client_payment_invoice_template')==4){
                                    $tax_amount = $row->total_amount*$invoice->tax_percentage/100;
                                    $total_taxable_amt+=$tax_amount;
                                    $gt_total_amount+=$row->total_amount+$tax_amount;
                                    ?>
                                    <td style="white-space: nowrap;"><?php echo $this->config->item('currency_format')->formatCurrency($tax_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                    <td style="white-space: nowrap;"><?php echo $this->config->item('currency_format')->formatCurrency(($row->total_amount+$tax_amount),$this->config->item('Currency_currency_shortname'));?></td>
                                  <?php }else{ ?>
                                    <td style="white-space: nowrap;"><?php echo $this->config->item('currency_format')->formatCurrency($row->total_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                  <?php } ?>

                                </tr>
                              <?php }elseif($this->config->item('Client_Payment_client_payment_invoice_template')==2){ ?>
                                <tr>
                                  <td><?php echo $n++?></td>
                                  <td style="text-align: left"><?php echo $row->name?></td>
                                  <td style="text-align: left"><?php echo $row->description?></td>
                                  <td style="white-space: nowrap;"><?php echo $this->config->item('currency_format')->formatCurrency($row->total_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                </tr>
                              <?php }elseif($this->config->item('Client_Payment_client_payment_invoice_template')==3){
                                ?>
                                <tr>
                                  <td><?php echo $n++?></td>
                                  <td style="text-align: left"><?php echo $row->item_code?></td>
                                  <td style="text-align: left"><?php echo $row->name?></td>
                                  <td style="text-align: left"><?php echo $row->hsn_code?></td>
                                  <td><?php echo $row->mrp_amount?></td>
                                  <td><?php echo $this->config->item('currency_format')->formatCurrency($row->price,$this->config->item('Currency_currency_shortname'));?></td>
                                  <td><?php echo $row->quantity?></td>
                                  <td><?php echo $this->config->item('currency_format')->formatCurrency($row->item_taxable_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                  <?php if($tax1==1){?>
                                    <td><?php echo $row->tax1_percent; ?></td>
                                    <td><?php echo $this->config->item('currency_format')->formatCurrency(($row->item_taxable_amount*$row->tax1_percent/100),$this->config->item('Currency_currency_shortname'));?></td>
                                    <?php
                                    $total_tax1_amt+=($row->item_taxable_amount*$row->tax1_percent/100);
                                  } ?>
                                  <?php if($tax2==1){?>
                                    <td><?php echo $row->tax2_percent; ?></td>
                                    <td><?php echo $this->config->item('currency_format')->formatCurrency(($row->item_taxable_amount*$row->tax2_percent/100),$this->config->item('Currency_currency_shortname'));?></td>
                                    <?php
                                    $total_tax2_amt+=($row->item_taxable_amount*$row->tax2_percent/100);
                                  } ?>
                                  <?php if($tax3==1){?>
                                    <td><?php echo $row->tax3_percent; ?></td>
                                    <td><?php echo $this->config->item('currency_format')->formatCurrency(($row->item_taxable_amount*$row->tax3_percent/100),$this->config->item('Currency_currency_shortname'));?></td>
                                    <?php
                                    $total_tax3_amt+=($row->item_taxable_amount*$row->tax3_percent/100);
                                  } ?>
                                  <td><?php echo $row->item_discount_percent; ?></td>
                                  <td><?php echo $this->config->item('currency_format')->formatCurrency($row->item_discount_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                  <td><?php echo $this->config->item('currency_format')->formatCurrency($row->total_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                </tr>
                                <?php
                                ${'total_taxable_amt_'.$row->tax_id} += $row->item_taxable_amount;
                                $total_qty+=$row->quantity;
                                $total_taxable_amt+=$row->item_taxable_amount;
                                $total_disc_amt+=$row->item_discount_amount;
                                $gt_total_amount+=$row->total_amount;
                              }elseif($this->config->item('Client_Payment_client_payment_invoice_template')==5){
                                ?>
                                <tr>
                                  <td><?php echo $n++?></td>
                                  <td style="text-align: left"><?php echo $row->name?></td>
                                  <td><?php echo $row->quantity?></td>
                                  <td><?php echo $this->config->item('currency_format')->formatCurrency($row->price,$this->config->item('Currency_currency_shortname'));?></td>
                                  <td><?php echo $this->config->item('currency_format')->formatCurrency($row->item_taxable_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                  <?php if($tax1==1){?>
                                    <td><?php echo $row->tax1_percent; ?></td>
                                    <td><?php echo $this->config->item('currency_format')->formatCurrency(($row->item_taxable_amount*$row->tax1_percent/100),$this->config->item('Currency_currency_shortname'));?></td>
                                    <?php
                                    $total_tax1_amt+=($row->item_taxable_amount*$row->tax1_percent/100);
                                  } ?>
                                  <?php if($tax2==1){?>
                                    <td><?php echo $row->tax2_percent; ?></td>
                                    <td><?php echo $this->config->item('currency_format')->formatCurrency(($row->item_taxable_amount*$row->tax2_percent/100),$this->config->item('Currency_currency_shortname'));?></td>
                                    <?php
                                    $total_tax2_amt+=($row->item_taxable_amount*$row->tax2_percent/100);
                                  } ?>
                                  <?php if($tax3==1){?>
                                    <td><?php echo $row->tax3_percent; ?></td>
                                    <td><?php echo $this->config->item('currency_format')->formatCurrency(($row->item_taxable_amount*$row->tax3_percent/100),$this->config->item('Currency_currency_shortname'));?></td>
                                    <?php
                                    $total_tax3_amt+=($row->item_taxable_amount*$row->tax3_percent/100);
                                  } ?>
                                  <td><?php echo $this->config->item('currency_format')->formatCurrency($row->total_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                </tr>
                                <?php
                                ${'total_taxable_amt_'.$row->tax_id} += $row->item_taxable_amount;
                                $total_qty+=$row->quantity;
                                $total_taxable_amt+=$row->item_taxable_amount;
                                $total_disc_amt+=$row->item_discount_amount;
                                $gt_total_amount+=$row->total_amount;
                              }
                            endforeach;
                            ?>
                            <?php
                            if($invoice->invoice_tax_inclusive==1){
                              $invoice_tax_inclusive="Included";
                              $sub_total = $invoice->invoice_taxable_amount+$invoice->invoice_tax_amount;
                            }else{
                              $invoice_tax_inclusive="Excluded";
                              $sub_total = $invoice->invoice_taxable_amount;
                            }
                            if ($this->config->item('Client_Payment_client_payment_invoice_retention_before_tax') == 1) {
                              if ($this->config->item('Client_Payment_client_payment_invoice_retention_type') == 'deduction') {
                                $sub_total += $invoice->invoice_retention_amount;
                              }else{
                                $sub_total -= $invoice->invoice_retention_amount;
                              }
                            }
                            ?>
                            <?php if($this->config->item('Client_Payment_client_payment_invoice_template')==3 || $this->config->item('Client_Payment_client_payment_invoice_template')==5){ ?>
                              <tr >
                                <?php if($this->config->item('Client_Payment_client_payment_invoice_template')==3){?>
                                  <td style="border-bottom: 1px solid #c5c5c5 !important"></td>
                                  <td colspan="5" style="border-bottom: 1px solid #c5c5c5 !important;text-align:center" ><strong>No of Items : <?php echo $total_qty ;?></strong></td>
                                  <td style="border-bottom: 1px solid #c5c5c5 !important"></td>
                                <?php } ?>
                                <?php if($this->config->item('Client_Payment_client_payment_invoice_template')==5){?>
                                  <td colspan="4" style="border-bottom: 1px solid #c5c5c5 !important;text-align:center" ><strong>No of Items : <?php echo $total_qty ;?></strong></td>
                                <?php } ?>
                                <td style="border-bottom: 1px solid #c5c5c5 !important"><?php echo $this->config->item('currency_format')->formatCurrency($total_taxable_amt,$this->config->item('Currency_currency_shortname'));?></td>
                                <?php if($tax1==1){?>
                                  <td style="border-bottom: 1px solid #c5c5c5 !important"></td>
                                  <td style="border-bottom: 1px solid #c5c5c5 !important"><?php echo $this->config->item('currency_format')->formatCurrency($total_tax1_amt,$this->config->item('Currency_currency_shortname'));?></td>
                                <?php } ?>
                                <?php if($tax2==1){?>
                                  <td style="border-bottom: 1px solid #c5c5c5 !important"></td>
                                  <td style="border-bottom: 1px solid #c5c5c5 !important"><?php echo $this->config->item('currency_format')->formatCurrency($total_tax2_amt,$this->config->item('Currency_currency_shortname'));?></td>
                                <?php } ?>
                                <?php if($tax3==1){?>
                                  <td style="border-bottom: 1px solid #c5c5c5 !important"></td>
                                  <td style="border-bottom: 1px solid #c5c5c5 !important"><?php echo $this->config->item('currency_format')->formatCurrency($total_tax3_amt,$this->config->item('Currency_currency_shortname'));?></td>
                                <?php } ?>
                                <?php if($this->config->item('Client_Payment_client_payment_invoice_template')==3){?>
                                  <td style="border-bottom: 1px solid #c5c5c5 !important"></td>
                                  <td style="border-bottom: 1px solid #c5c5c5 !important"><?php echo $this->config->item('currency_format')->formatCurrency($total_disc_amt,$this->config->item('Currency_currency_shortname'));?></td>
                                <?php } ?>
                                <td style="border-bottom: 1px solid #c5c5c5 !important"><?php echo $this->config->item('currency_format')->formatCurrency($gt_total_amount,$this->config->item('Currency_currency_shortname'));?></td>
                              </tr>
                            <?php }elseif($this->config->item('Client_Payment_client_payment_invoice_template')==4){ ?>
                              <tr>
                                <td style="border-bottom: 1px solid #c5c5c5"></td>
                                <td colspan="7" class="m--font-danger" style="border-bottom: 1px solid #c5c5c5"><span style="font-weight:800;text-align: right;margin-right: 5%;color: #000;white-space:nowrap">TOTAL :</span> <strong><?php echo $this->config->item('currency_format')->formatCurrency($gt_total_amount,$this->config->item('Currency_currency_shortname'));?></strong></td>
                              </tr>
                            <?php } ?>

                          </tbody>
                        </table>
                      </div>

                      <div class="m-invoice__table  m-invoice__table--centered table-responsive" style="">
                        <?php if($this->config->item('Client_Payment_client_payment_invoice_template')==3){?>
                          <table class="table  m-table table-bordered item_table">
                            <thead>

                            </thead>
                            <tbody>
                              <tr>
                                <td style="width:75%;border-top: 2px solid #b7b7b7 !important;">
                                  <table class="table  m-table table-bordered item_table">
                                    <thead>
                                      <tr>
                                        <th style="text-align: center">Class</th>
                                        <th style="text-align: center">Taxable Amt</th>
                                        <th style="text-align: center"><?php echo $this->config->item('Tax_tax1_name')?></th>
                                        <th style="text-align: center">Amount</th>
                                        <th style="text-align: center"><?php echo $this->config->item('Tax_tax2_name')?></th>
                                        <th style="text-align: center">Amount</th>
                                        <th style="text-align: center"><?php echo $this->config->item('Tax_tax3_name')?></th>
                                        <th style="text-align: center">Amount</th>
                                      </tr>
                                    </thead>
                                    <tbody>
                                      <?php
                                      $tax_percent = $this->config->item('Tax_tax_percent');
                                      foreach ($tax_percent as $row){
                                        if($row->tax1_percent!=0 || $row->tax2_percent!=0 || $row->tax3_percent!=0 ){ ?>
                                          <tr>
                                            <td style="text-align: center"><?php echo $this->config->item('Tax_tax_name')." ".$row->tax_percentage."%" ?></td>
                                            <td style="text-align: center"><?php echo ${'total_taxable_amt_'.$row->tax_id}; ?></td>
                                            <td style="text-align: center"><?php echo $row->tax1_percent."%" ?></td>
                                            <td style="text-align: center"><?php echo $this->config->item('currency_format')->formatCurrency(((${'total_taxable_amt_'.$row->tax_id})*$row->tax1_percent/100),$this->config->item('Currency_currency_shortname')); ?></td>
                                            <td style="text-align: center"><?php echo $row->tax2_percent."%" ?></td>
                                            <td style="text-align: center"><?php echo $this->config->item('currency_format')->formatCurrency(((${'total_taxable_amt_'.$row->tax_id})*$row->tax2_percent/100),$this->config->item('Currency_currency_shortname')); ?></td>
                                            <td style="text-align: center"><?php echo $row->tax3_percent."%" ?></td>
                                            <td style="text-align: center"><?php echo $this->config->item('currency_format')->formatCurrency(((${'total_taxable_amt_'.$row->tax_id})*$row->tax3_percent/100),$this->config->item('Currency_currency_shortname')); ?></td>
                                          </tr>
                                        <?php }
                                      } ?>
                                    </tbody>
                                  </table>
                                </td>
                                <td style="border-top: 2px solid #b7b7b7 !important;text-align:center"><h4><strong>GRAND TOTAL</strong></h4></td>
                                <td style="border-top: 2px solid #b7b7b7 !important;text-align:center" class="m--font-danger"><h4><strong><?php echo $this->config->item('currency_format')->formatCurrency($invoice->invoice_total_amount,$this->config->item('Currency_currency_shortname'));?></strong></h4></td>
                              </tr>
                            </tbody>
                          </table>
                        <?php } ?>
                        <?php
                        $tds_view='';
                        if($this->config->item('Client_Payment_client_payment_invoice_tds_enable')==0){
                          // $tds_view='display:none';
                        }
                        ?>
                        <div class="row"  style="margin-top:10px;border-top: 2px solid #c5c5c5">
                          <div class="col-lg-6 col-md-6">

                            <table class="" style="width:100%">
                              <thead>
                                <tr>
                                  <th style="text-align:left">
                                    <h6 style="padding: 0px !important;
                                    margin: 0px !important;"><strong>DELIVERY NOTE</strong></h6>
                                  </th>
                                </tr>
                                <tr>
                                  <td style="text-align:left;background:#dfdddd61;padding: 0.2rem 0rem 0.5rem 0.5rem !important;">
                                    <h6 style="padding: 0px !important;
                                    margin: 0px !important;"><?php echo $invoice->delivery_note ?></h6>
                                  </td>
                                </tr>
                              </thead>
                            </table>
                            <table class="" style="width:100%">
                              <thead>
                                <tr>
                                  <th style="text-align:left">
                                    <h6 style="padding: 0px !important;
                                    margin: 0px !important;"><strong>WORKS CARRIED AT</strong></h6>
                                  </th>
                                </tr>
                                <tr>
                                  <td style="text-align:left;background:#dfdddd61;padding: 0.2rem 0rem 0.5rem 0.5rem !important;">
                                    <h6 style="padding: 0px !important;
                                    margin: 0px !important;"><?php echo $invoice->works_carried_at ?></h6>
                                  </td>
                                </tr>
                              </thead>
                            </table>
                            <table class="" style="width:100%">
                              <thead>
                                <tr>
                                  <th style="text-align:left">
                                    <h6 style="padding: 0px !important;
                                    margin: 0px !important;"><strong>PAYMENT TERMS</strong></h6>
                                  </th>
                                </tr>
                                <tr>
                                  <td style="text-align:left;background:#dfdddd61;padding: 0.2rem 0rem 0.5rem 0.5rem !important;">
                                    <h6 style="padding: 0px !important;
                                    margin: 0px !important;"><?php echo $invoice->payment_terms ?></h6>
                                  </td>
                                </tr>
                              </thead>
                            </table>
                            <table class="" style="width:100%">
                              <thead>
                                <tr>
                                  <th style="text-align:left">
                                    <h6 style="padding: 0px !important;
                                    margin: 0px !important;"><strong>OTHER TERMS</strong></h6>
                                  </th>
                                </tr>
                                <tr>
                                  <td style="text-align:left;background:#dfdddd61;padding: 0.2rem 0rem 0.5rem 0.5rem !important;">
                                    <h6 style="padding: 0px !important;
                                    margin: 0px !important;"><?php echo $invoice->other_terms ?></h6>
                                  </td>
                                </tr>
                              </thead>
                            </table>
                            <?php if($invoice->invoice_notes!=''){?>
                              <table class="" style="width:100%">
                                <thead>
                                  <tr>
                                    <th style="text-align:left">
                                      <h6 style="padding: 0px !important;
                                      margin: 0px !important;"><strong>NOTES</strong></h6>
                                    </th>
                                  </tr>
                                  <tr>
                                    <td style="text-align:left;background:#dfdddd61;padding: 0.2rem 0rem 0.5rem 0.5rem !important;">
                                      <h6 style="padding: 0px !important;
                                      margin: 0px !important;"><?php echo $invoice->invoice_notes ?></h6>
                                    </td>
                                  </tr>
                                </thead>
                              </table>
                            <?php }?>

                            <table class="" style="width:100%">
                              <thead>
                                <tr>
                                  <th style="text-align:left">
                                    <h6><strong>INVOICE AMOUNT IN WORDS</strong></h6>
                                  </th>
                                </tr>
                                <tr>
                                  <td style="text-align:left;background:#dfdddd61;padding: 0.2rem 0rem 0.5rem 0.5rem !important;">
                                    <h6><?php echo ucwords($invoice->receivable_amount_in_words)?></h6>
                                  </td>
                                </tr>
                              </thead>
                            </table>
                            <br/><br/>
                            <table class="" style="width:100%">
                              <thead>
                                <tr>
                                  <td style="text-align:left;background:#dfdddd61;padding: 0.2rem 0rem 0.5rem 0.5rem !important;">
                                    <h6 style="padding: 0px !important;
                                    margin: 0px !important;">Thank you for doing business with us.</h6>
                                  </td>
                                </tr>
                              </thead>
                            </table>
                          </div>
                          <div class="col-lg-6 col-md-6">
                            <div class="m-invoice__table  m-invoice__table--centered table-responsive">
                              <table class="item_table" style="width:100%">
                                <tbody>
                                  <tr>
                                    <th style="font-size: 15px;font-weight: 400;">Sub Total</th>
                                    <th style="text-align:right;font-weight:500;font-size: 15px;"><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->invoice_taxable_amount,$this->config->item('Currency_currency_shortname')) ?></th>
                                  </tr>
                                  <?php if ($this->config->item('Client_Payment_client_payment_invoice_retention_before_tax') == 1) { ?>
                                    <tr>
                                      <th style="font-size: 15px;font-weight: 400;">Retention @ <?php echo $invoice->invoice_retention_percent."% "?></th>
                                      <th style="text-align:right;font-weight:500;font-size: 15px;"><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->invoice_retention_amount,$this->config->item('Currency_currency_shortname')) ?></th>
                                    </tr>
                                  <?php } ?>
                                  <!-- <tr>
                                  <th style="font-size: 15px;font-weight: 400;">Taxable Amount</th>
                                  <th style="text-align:right;font-weight:500;font-size: 15px;"><?php //echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->invoice_taxable_amount,$this->config->item('Currency_currency_shortname')) ?></th>
                                </tr> -->
                                <?php
                                if($this->config->item('Tax_tax_splitting')==1){
                                  $invoice->tax1_amount = round($invoice->invoice_taxable_amount*$invoice->tax1_percent/100,$this->config->item('Currency_amount_decimals_2'));
                                  $invoice->tax2_amount = round($invoice->invoice_taxable_amount*$invoice->tax2_percent/100,$this->config->item('Currency_amount_decimals_2'));
                                  $invoice->tax3_amount = round($invoice->invoice_taxable_amount*$invoice->tax3_percent/100,$this->config->item('Currency_amount_decimals_2'));
                                  ?>
                                  <?php if($invoice->tax1_percent!=0){?>
                                    <tr>
                                      <th style="font-size: 15px;font-weight: 400;"><?php echo $this->config->item('Tax_tax1_name')?> @ <?php echo $invoice->tax1_percent ?>%</th>
                                      <th style="text-align:right;font-weight:500;font-size: 15px;"><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->tax1_amount,$this->config->item('Currency_currency_shortname')) ?></th>
                                    </tr>
                                  <?php } ?>
                                  <?php if($invoice->tax2_percent!=0){?>
                                    <tr>
                                      <th style="font-size: 15px;font-weight: 400;"><?php echo $this->config->item('Tax_tax2_name')?> @ <?php echo $invoice->tax2_percent ?>%</th>
                                      <th style="text-align:right;font-weight:500;font-size: 15px;"><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->tax2_amount,$this->config->item('Currency_currency_shortname')) ?></th>
                                    </tr>
                                  <?php } ?>
                                  <?php if($invoice->tax3_percent!=0){?>
                                    <tr>
                                      <th style="font-size: 15px;font-weight: 400;"><?php echo $this->config->item('Tax_tax3_name')?> @ <?php echo $invoice->tax3_percent ?>%</th>
                                      <th style="text-align:right;font-weight:500;font-size: 15px;"><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->tax3_amount,$this->config->item('Currency_currency_shortname')) ?></th>
                                    </tr>
                                  <?php } ?>
                                <?php }else{ ?>
                                  <?php if($invoice->invoice_tax_percent!=0){?>
                                    <tr>
                                      <th style="font-size: 15px;font-weight: 400;"><?php echo $this->config->item('Tax_tax_name')?> @ <?php echo $invoice->tax_percentage." % (".$invoice_tax_inclusive.")" ?></th>
                                      <th style="text-align:right;font-weight:500;font-size: 15px;"><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->invoice_tax_amount,$this->config->item('Currency_currency_shortname')) ?></th>
                                    </tr>
                                  <?php } ?>
                                <?php } ?>
                                <?php if($invoice->invoice_tds_percent!=0){?>
                                  <tr style="<?php echo $tds_view?>">
                                    <th style="font-weight:400;font-size: 15px;">TDS @ <?php echo $invoice->invoice_tds_percent."% "?></th>
                                    <th style="text-align:right;font-weight:400;font-size: 15px;"><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->invoice_tds_amount,$this->config->item('Currency_currency_shortname')) ?></th>
                                  </tr>
                                <?php } ?>
                                <?php if ($this->config->item('Client_Payment_client_payment_invoice_retention_before_tax') != 1) { ?>
                                  <?php if($invoice->invoice_retention_percent!=0){?>
                                    <tr>
                                      <th style="font-weight:400;font-size: 15px;">Retention @ <?php echo $invoice->invoice_retention_percent."% "?></th>
                                      <th style="text-align:right;font-weight:400;font-size: 15px;"><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->invoice_retention_amount,$this->config->item('Currency_currency_shortname')) ?></th>
                                    </tr>
                                  <?php } ?>
                                <?php } ?>
                                <?php if($invoice->advance_recovery_amt!=0){?>
                                  <tr>
                                    <th style="font-weight:400;font-size: 15px;">Advance Recovery</th>
                                    <th style="text-align:right;font-weight:400;font-size: 15px;"><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->advance_recovery_amt,$this->config->item('Currency_currency_shortname')) ?></th>
                                  </tr>
                                <?php } ?>
                                <?php if($invoice->invoice_discount_amount!=0){?>
                                  <tr>
                                    <th style="font-weight:400;font-size: 15px;">Discount/Different</th>
                                    <th style="text-align:right;font-weight:400;font-size: 15px;"><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->invoice_discount_amount,$this->config->item('Currency_currency_shortname')) ?></th>
                                  </tr>
                                <?php } ?>
                                <?php if($invoice->invoice_round_amount!=0){?>
                                  <tr>
                                    <th style="font-weight:400;font-size: 15px;">Round</th>
                                    <th style="text-align:right;font-weight:400;font-size: 15px;"><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->invoice_round_amount,$this->config->item('Currency_currency_shortname')) ?></th>
                                  </tr>
                                <?php } ?>
                                <tr>
                                  <th style="font-weight:800;font-size: 15px;background:#dfdddd61 !important;">NET Total</th>
                                  <th style="text-align:right;font-weight:800;font-size: 15px;background:#dfdddd61 !important;"><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->invoice_total_amount,$this->config->item('Currency_currency_shortname')) ?></th>
                                </tr>
                                <tr>
                                  <th style="font-size: 15px;font-weight: 400;">Received</th>
                                  <th style="text-align:right;font-weight:500;font-size: 15px;"><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->total_paid,$this->config->item('Currency_currency_shortname')) ?></th>
                                </tr>
                                <tr>
                                  <th style="font-size: 15px;font-weight: 400;">Balance</th>
                                  <th style="text-align:right;font-weight:500;font-size: 15px;"><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->balance_amount,$this->config->item('Currency_currency_shortname')) ?></th>
                                </tr>
                              </tbody>
                            </table>
                            <table style="width:100%">
                              <tbody>
                                <tr>
                                  <td style="text-align:center">For, <strong><?php echo $this->config->item('company_name') ?></strong></td>
                                </tr>
                                <tr>
                                  <td style="min-height:50px;text-align:center">&nbsp;
                                    <?php if($this->config->item('company_signature')!=''){
                                      echo '<img style="max-height:100px" src="'.base_url().'uploads/company/'.$this->config->item('company_signature').'">'; } ?>
                                    </td>
                                  </tr>
                                  <tr>
                                    <td style="text-align:center">Authorized Signature</td>
                                  </tr>
                                </tbody>
                              </table>
                            </div>
                          </div>
                        </div>
                      </div>
                      <?php if($this->config->item('Client_Payment_client_payment_invoice_template')!=4 ){?>
                        <?php if($tax_splitting==1 && $this->config->item('Client_Payment_client_payment_invoice_template')!=3 && $this->config->item('Client_Payment_client_payment_invoice_template')!=5 && $this->config->item('Client_Payment_client_payment_invoice_template')!=6 && $this->config->item('Tax_tax_splitting')==1){ ?>
                          <div class="row">
                            <div class="col-lg-5 col-md-5">
                              <div class="m-invoice__table  m-invoice__table--centered table-responsive">
                                <table class="table  m-table table-bordered item_table">
                                  <thead>
                                    <tr>
                                      <th>TAX TYPE</th>
                                      <th>TAX %</th>
                                      <th>TAX AMT</th>
                                    </tr>
                                  </thead>
                                  <tbody>
                                    <?php
                                    $invoice->tax1_amount = round($invoice->invoice_taxable_amount*$invoice->tax1_percent/100,$this->config->item('Currency_amount_decimals_2'));
                                    $invoice->tax2_amount = round($invoice->invoice_taxable_amount*$invoice->tax2_percent/100,$this->config->item('Currency_amount_decimals_2'));
                                    $invoice->tax3_amount = round($invoice->invoice_taxable_amount*$invoice->tax3_percent/100,$this->config->item('Currency_amount_decimals_2'));
                                    ?>
                                    <tr>
                                      <th><?php echo $this->config->item('Tax_tax1_name')?></th>
                                      <th style="text-align:right"><?php echo $invoice->tax1_percent ?></th>
                                      <th style="text-align:right"><?php echo $invoice->tax1_amount ?></th>
                                    </tr>
                                    <tr>
                                      <th><?php echo $this->config->item('Tax_tax2_name')?></th>
                                      <th style="text-align:right"><?php echo $invoice->tax2_percent ?></th>
                                      <th style="text-align:right"><?php echo $invoice->tax2_amount ?></th>
                                    </tr>
                                    <tr>
                                      <th><?php echo $this->config->item('Tax_tax3_name')?></th>
                                      <th style="text-align:right"><?php echo $invoice->tax3_percent ?></th>
                                      <th style="text-align:right"><?php echo $invoice->tax3_amount ?></th>
                                    </tr>
                                  </tbody>
                                </table>
                              </div>
                            </div>
                          </div>
                        <?php } ?>

                        <?php if($invoice->bank_account !=0 || $this->config->item('company_account_details')!='' ){?>
                          <div class="m-invoice__table  m-invoice__table--centered table-responsive" style="margin-bottom: 30px">
                            <table class="table">
                              <thead>
                                <tr>
                                  <th width="50%"  rowspan="3">
                                    <?php
                                    if($invoice->bank_account !=0){
                                      echo '<div class="notices">
                                      <div>Account Details:</div>
                                      <div class="notice">Name : '.$invoice->company_name.'<br/>
                                      A/C No : '.$invoice->bank_account_no.'<br/>
                                      Bank  : '.$invoice->bank_name.'<br/>
                                      '.$this->config->item('bank_ifsc_name').'  : '.$invoice->bank_ifsc.'<br/>
                                      Branch  : '.$invoice->bank_branch.'<br/></div>
                                      </div>';
                                    }elseif($this->config->item('company_account_details')!=''){
                                      echo '<div class="notices">
                                      <div>Account Details:</div>
                                      <div class="notice">'.$this->config->item('company_account_details').'</div>
                                      </div>'; } ?>
                                    </th>
                                    <th width="30%" style="vertical-align: top;text-align:left">Prepared By :
                                      <?php if($this->config->item('invoice_prepared_by_sign')!=''){
                                        echo '<img style="max-height:50px" src="'.base_url().'uploads/company/'.$this->config->item('invoice_prepared_by_sign').'">';
                                      } ?></th>
                                      <th width="20%" style="vertical-align: top;text-align:left">Checked By :
                                      </th>
                                    </tr>
                                    <tr>
                                      <th colspan="2" width="50%"  style="vertical-align: top;text-align:left">Sanctioned By :
                                        <?php if($this->config->item('company_signature')!=''){
                                          echo '<img style="max-height:50px" src="'.base_url().'uploads/company/'.$this->config->item('company_signature').'">'; } ?></th>
                                        </tr>
                                        <tr>
                                          <th colspan="2" width="50%" style="vertical-align: top;text-align:left">Recipient signature : <br/>&nbsp; </th>
                                        </tr>
                                      </thead>
                                    </table>
                                  </div>
                                <?php } ?>
                              <?php } ?>

                            </div>
                          </div>
                        </div>
                      <?php }elseif($this->config->item('Client_Payment_client_payment_invoice_template')==6){?>
                        <!-- Template 6 -->
                        <div class="m-invoice-2" style="padding-bottom: 20px">
                          <div  class="m-invoice__wrapper">
                            <div class="m-invoice__body m-invoice__body--centered" style="min-height: 100px">
                              <div class="outer">
                                <div class="page-header" style="text-align: left;padding-left: 0px;">
                                  <?php if($this->config->item('company_letter_head')!=''){ ?>
                                    <img class="letter_head_img" style="width:100%" src="<?php echo base_url().'uploads/company/'.$this->config->item('company_letter_head')?>" />
                                  <?php } ?>
                                </div>
                                <div class="heading"><h2>TAX INVOICE</h2></div>
                                <br />
                                <label>TRNo : <?php echo $this->config->item('company_tax_no') ?></label>
                                <div class="header">

                                  <table width="100%" border="1" bordercolor="#666666" cellspacing="0" cellpadding="0" style="font-family:Arial, Helvetica, sans-serif; font-weight:lighter;  font-style:normal; font-size:14px;">
                                    <tr>
                                      <td width="9%" class="text_padding">Customer Name</td>
                                      <td width="25%" class="text_padding"><?php echo $client_data->client_name?></td>
                                      <td width="12%" class="text_padding">Invoice No:</td>
                                      <td width="19%" class="text_padding"><?php echo $invoice_no?></td>
                                      <td width="18%" class="text_padding">Date</td>
                                      <td width="17%" class="text_padding"><?php echo date('d-m-Y',strtotime($invoice->invoice_date)); ?></td>
                                    </tr>
                                    <tr>
                                      <td height="127" rowspan="3" class="text_padding">Address: </td>
                                      <td rowspan="3" class="text_padding"><?php echo $client_data->client_address?></td>
                                      <td height="31" class="text_padding">Payment Terms:</td>
                                      <td colspan="3" class="text_padding"><?php echo $invoice->payment_terms; ?></td>
                                    </tr>
                                    <tr>
                                      <td height="33" class="text_padding">Customer PO</td>
                                      <td class="text_padding"><?php echo $client_data->po_box_no?></td>
                                      <td><span class="text_padding">Currency Code</span></td>
                                      <td><span class="text_padding"><?php echo $this->config->item('Currency_currency_shortname')?></span></td>
                                    </tr>
                                    <tr>
                                      <td height="34" class="text_padding">Delivery Ref.</td>
                                      <td class="text_padding"><?php echo $invoice->delivery_note; ?></td>
                                      <td><span class="text_padding">Delivery Date</span></td>
                                      <td><span class="text_padding"><?php if($invoice->delivery_date!='0000-00-00'){ echo date('d-m-Y',strtotime($invoice->delivery_date)) ;} ?></span></td>
                                    </tr>
                                    <tr>
                                      <td height="52" class="text_padding">Contact Person</td>
                                      <td class="text_padding"><?php echo $client_data->contact_person?></td>
                                      <td class="text_padding">Ship to Name</td>
                                      <td colspan="3" class="text_padding"><?php echo $invoice->shipping_name; ?></td>
                                    </tr>
                                    <tr>
                                      <td height="51" class="text_padding">Customer TRN No</td>
                                      <td class="text_padding"><?php echo $client_data->tax_no?></td>
                                      <td class="text_padding">Ship to Address</td>
                                      <td colspan="3" class="text_padding"><?php echo $invoice->shipping_address; ?></td>
                                    </tr>
                                  </table>
                                </div>
                                <?php
                                $tax_splitting = 0;
                                foreach($invoice_items as $row){
                                  if($row->tax1_percent!=0 || $row->tax2_percent!=0 || $row->tax3_percent!=0){
                                    $tax_splitting = 1;
                                  }
                                }
                                if($this->config->item('Tax_tax_enabled')==1){
                                  $rowspan="rowspan='2'";
                                }else{
                                  $rowspan="";
                                } ?>
                                <div class="items_table">
                                  <table width="100%" border="1" bordercolor="#666666" cellspacing="0" cellpadding="0" style="font-family:Arial, Helvetica, sans-serif; font-weight:lighter;  font-style:normal; font-size:14px;">
                                    <tr>
                                      <td width="5%" class="text_padding" height="48"><strong>S.no</strong></td>
                                      <td width="5%" class="text_padding"><strong>Item</strong></td>
                                      <td width="31%" class="text_padding"><strong>Item Description</strong></td>
                                      <td width="7%" class="text_padding"><strong>Qty</strong></td>
                                      <td width="12%" class="text_padding"><strong>Unit Price</strong></td>
                                      <td width="11%"text_padding"" class="text_padding"><strong>Total</strong></td>
                                      <?php if($this->config->item('Tax_tax_enabled')==1){ ?>
                                        <td width="10%"text_padding"" class="text_padding"><strong>VAT %</strong></td>
                                        <td width="8%" class="text_padding"><strong>VAT Amount</strong></td>
                                      <?php } ?>
                                      <td width="11%" class="text_padding"><strong>Total Amount</strong></td>
                                    </tr>
                                    <?php
                                    $tax_percentage = 0;
                                    $n = 1;
                                    $description_colspan=7;
                                    if($this->config->item('Tax_tax_enabled')==1){
                                      $description_colspan=15;
                                    }
                                    if ($this->config->item('Purchase_delivery_challan') == 1) {
                                      $description_colspan++;
                                    }
                                    foreach($invoice_items as $row):
                                      $row->tax1_amount = round($row->price*$row->quantity*$row->tax1_percent/100,$this->config->item('Currency_amount_decimals_2'));
                                      $row->tax2_amount = round($row->price*$row->quantity*$row->tax2_percent/100,$this->config->item('Currency_amount_decimals_2'));
                                      $row->tax3_amount = round($row->price*$row->quantity*$row->tax3_percent/100,$this->config->item('Currency_amount_decimals_2'));
                                      $tax_percentage = $row->tax_percentage;
                                      ?>
                                      <tr>
                                        <td class="text_padding"><?php echo $n++?></td>
                                        <td class="text_padding"><?php echo $row->item_code?></td>
                                        <td class="text_padding" style="margin-top:10px;"><?php echo $row->name?></td>
                                        <td class="text_padding"><?php echo $row->quantity?></td>
                                        <td class="text_padding"><?php echo $this->config->item('currency_format')->formatCurrency($row->price,$this->config->item('Currency_currency_shortname'));?></td>
                                        <td class="text_padding"><?php echo $this->config->item('currency_format')->formatCurrency($row->item_taxable_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                        <td class="text_padding"><?php echo $row->tax_percentage?>%</td>
                                        <td class="text_padding"><?php echo $this->config->item('currency_format')->formatCurrency($row->item_tax_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                        <td class="text_padding"><?php echo $this->config->item('currency_format')->formatCurrency($row->total_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                      </tr>
                                    <?php endforeach; ?>
                                    <tr>
                                      <td height="36">&nbsp;</td>
                                      <td>&nbsp;</td>
                                      <td class="text_padding">Total <?php echo $this->config->item('Currency_currency_shortname')?></td>
                                      <td>&nbsp;</td>
                                      <td>&nbsp;</td>
                                      <td class="text_padding"><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->invoice_taxable_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                      <td class="text_padding"><?php echo $tax_percentage?>%</td>
                                      <td class="text_padding"><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->invoice_tax_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                      <td class="text_padding"><strong><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->invoice_total_amount,$this->config->item('Currency_currency_shortname'));?></strong></td>
                                    </tr>
                                    <tr>
                                      <td height="36" colspan="9" align="left" valign="middle" class="text_padding">Total in words : <?php echo $invoice->receivable_amount_in_words ?></td>
                                    </tr>
                                  </table>
                                </div>
                                <div class="bank_sign">
                                  <table width="100%" border="0" cellspacing="0" cellpadding="0" style="font-family:Arial, Helvetica, sans-serif; font-weight:lighter;  font-style:normal; font-size:14px;">
                                    <tr>
                                      <td height="20" colspan="6" class="text_padding"><strong ><?php echo $this->config->item('company_name') ?></strong></td>
                                    </tr>
                                    <tr>
                                      <td width="11%" height="20" class="text_padding">Bank</td>
                                      <td width="1%">:</td>
                                      <td width="22%" class="text_padding"><?php echo $invoice->bank_name?>, Branch: <?php echo $invoice->bank_branch?></td>
                                      <td width="48%" rowspan="4" align="right">&nbsp;</td>
                                      <td width="14%" rowspan="7" align="left" valign="top"><img src="<?php echo base_url()?>uploads/company/seal.jpg" height="120" /></td>
                                      <td width="4%" rowspan="4" align="right">&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <td height="21" class="text_padding">Account Number</td>
                                      <td>:</td>
                                      <td class="text_padding"><?php echo $invoice->bank_account_no?></td>
                                    </tr>
                                    <tr>
                                      <td height="20" class="text_padding">IBAN No</td>
                                      <td>:</td>
                                      <td class="text_padding"><?php echo $invoice->bank_ifsc?></td>
                                    </tr>
                                    <tr>
                                      <td height="26" class="text_padding">Swift Code</td>
                                      <td>:</td>
                                      <td class="text_padding"><?php echo $invoice->bank_swift_code?></td>
                                    </tr>
                                    <tr>
                                      <td class="text_padding">&nbsp;</td>
                                      <td>&nbsp;</td>
                                      <td class="text_padding">&nbsp;</td>
                                      <td align="right">&nbsp;</td>
                                      <td align="right">&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <td class="text_padding">&nbsp;</td>
                                      <td>&nbsp;</td>
                                      <td class="text_padding">&nbsp;</td>
                                      <td align="right">&nbsp;</td>
                                      <td align="right">&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <td class="text_padding">&nbsp;</td>
                                      <td>&nbsp;</td>
                                      <td class="text_padding">&nbsp;</td>
                                      <td align="right">&nbsp;</td>
                                      <td align="right">&nbsp;</td>
                                    </tr>
                                  </table>
                                </div>
                                <div class="page-footer">
                                  <?php if($this->config->item('client_invoice_footer')!=''){ ?>
                                    <img class="letter_head_img" style="width: 100%;" src="<?php echo base_url().'uploads/company/'.$this->config->item('client_invoice_footer')?>" />
                                  <?php } ?>
                                </div>
                              </div>

                            </div>
                          </div>
                        </div>
                      <?php }elseif($this->config->item('Client_Payment_client_payment_invoice_template')==7){?>
                        <?php $this->view("modules/invoices/include_invoice_print");?>
                      <?php } ?>
                      <div class="m-invoice-2" style="padding-bottom: 20px">
                        <div  class="m-invoice__wrapper">
                          <div class="m-invoice__body m-invoice__body--centered" style="min-height: 100px">
                            <?php if(sizeof($invoice_payments)>0){ ?>
                              <div class="table-responsive" style="margin-bottom: 50px">
                                <table id="" class="table  m-table table-bordered item_table" width="100%">
                                  <thead style="font-weight: 500;font-size: 1.1rem;">
                                    <tr>
                                      <th style="text-align:left">Sl No</th>
                                      <th style="text-align:left;width:15%">Received<br/>Date</th>
                                      <th style="text-align:left;width:15%">Received<br/>Amount</th>
                                      <th style="text-align:left">Credit Acc</th>
                                      <th style="text-align:left">Remarks</th>
                                      <th style="text-align:left">Received From</th>
                                      <th class="print_hide_div">Created By</th>
                                      <th class="print_hide_div">Created Date</th>
                                      <th class="print_hide_div">Actions</th>
                                      <th class="hidden">tr_id</th>
                                      <th class="hidden">receipt_no</th>
                                      <th class="hidden">tr_credit_acc</th>
                                      <th class="hidden">tr_amount</th>
                                    </tr>
                                  </thead>
                                  <tbody style="font-weight: 600;font-size: 1.1rem;text-align:left">
                                    <?php
                                    $sl_no=0;
                                    foreach($invoice_payments as $row):
                                      $sl_no++;

                                      ?>
                                      <tr >
                                        <td style="text-align:left"><?php echo $sl_no?></td>
                                        <td style="text-align:left"><?php echo date('d-m-Y',strtotime($row->tr_date))?></td>
                                        <td style="text-align:left"><?php echo $this->config->item('Currency_currency_format'); ?> <?php echo $row->tr_amount?>/-</td>
                                        <td style="text-align:left"><?php echo $row->credit_account?></td>
                                        <td style="text-align:left"><?php echo $row->tr_remarks?></td>
                                        <td style="text-align:left"><?php echo $row->tr_other_data?></td>
                                        <td class="print_hide_div"><?php echo $row->created_user?></td>
                                        <td class="print_hide_div"><?php if ($this->config->item('UI_hide_created_date_field')==0){echo date('d-m-Y',strtotime($row->created_date));}else{ echo '';}?></td>
                                        <td class="print_hide_div">
                                          <a style="margin-left: 5px;margin-right: 5px" id="client_payment_edit_btn" href="#client_payment_edit_modal" data-toggle="modal" class="btn btn-info m-btn m-btn--icon  m-btn--icon-only m-btn--pill m-btn--air"><i class="la la-edit"></i></a>
                                          <a style="margin-left: 5px;margin-right: 5px" data-form-type="client_payment" data-tr-type="client_payment_transaction" data-form-type="client_payment" data-id-column="'.$transaction_id_column.'" id="client_payment_delete_btn"  href="#transaction_delete_modal" data-toggle="modal" class="btn btn-danger m-btn m-btn--icon  m-btn--icon-only m-btn--pill m-btn--air"><i class="la la-trash"></i></a>
                                        </td>
                                        <td class="hidden"><?= $row->transaction_id ?></td>
                                        <td class="hidden"><?= $row->tr_reference_no ?></td>
                                        <td class="hidden"><?= $row->tr_credit_acc ?></td>
                                        <td class="hidden"><?= $row->tr_amount ?></td>
                                      </tr>
                                      <?php
                                    endforeach;
                                    ?>
                                  </tbody>
                                </table>
                              </div>
                            <?php } ?>
                            <div class="m-invoice__table  m-invoice__table--centered table-responsive print_hide_div" >
                              <table class="table">
                                <thead>
                                  <tr>
                                    <th width="40%">PAYMENT STATUS :
                                      <?php
                                      if($invoice->payment_status == 1){
                                        $status = "RECEIVED";
                                        $class = 'm--font-success';
                                      }elseif($invoice->balance_amount>0 && $invoice->total_paid>0) {
                                        $status = "PARTIALLY RECEIVED";
                                        $class = 'm--font-warning';
                                      }else {
                                        $status = "NOT RECEIVED";
                                        $class = 'm--font-danger';
                                      }
                                      ?>
                                      <label class="<?php echo $class ?>">
                                        <strong>
                                          <?php echo $status ?>
                                        </strong>
                                      </label>
                                    </th>
                                    <th width="30%" style="vertical-align: top;white-space:nowrap">Total Received : <?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->total_paid,$this->config->item('Currency_currency_shortname'));?></th>
                                    <th width="30%" style="vertical-align: top">Balance :
                                      <strong class="m--font-danger">
                                        <?php
                                        echo  $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->balance_amount,$this->config->item('Currency_currency_shortname'));
                                        ?>
                                      </strong>
                                    </th>
                                  </tr>
                                </thead>
                              </table>
                            </div>
                            <?php if($this->config->item('client_invoice_bottom')!=''){ ?>
                              <img class="letter_head_img" style="width: 100%;" src="<?php echo base_url().'uploads/company/'.$this->config->item('client_invoice_bottom')?>" />
                            <?php } ?>
                            <?php if($this->config->item('client_invoice_footer')!=''){ ?>
                              <img class="letter_head_img" style="width: 100%;" src="<?php echo base_url().'uploads/company/'.$this->config->item('client_invoice_footer')?>" />
                            <?php } ?>
                          </div>
                        </div>
                      </div>
                    </form>
                  </div>
                </div>
              </div>
            </div>
          </div>


          <div class="modal fade" tabindex="-1" id="client_payment_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" >
                    Receive Payment From Client
                  </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="client_payment" id="form_client_payment_add" data-modal-id="client_payment_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_client_payment_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">
                      <?php if($invoice->invoice_type=='project_invoice'){ ?>
                        <div class="col-lg-6" >
                          <div class="form-group m-form__group" >
                            <label for="user_name">
                              Work Name
                            </label>
                            <?php if($page_name=='invoice_profile'){?>
                              <div class="m-select2 m-select2--air m-select2--pill">
                                <select required style="width: 100%" class="form-control m-select2 form_client_payment_add_select" id="client_payment_work_add"  name="work_id" data-placeholder="Select Work">
                                  <option selected disabled>Select Work</option>
                                  <?php
                                  foreach($work_contracts as $row): ?>
                                  <option data-work-status="<?php echo $row->work_status?>" value="<?php echo $row->work_id?>"><?php echo $row->work_name?></option>
                                  <?php
                                endforeach;
                                ?>
                              </select>
                            </div>
                          <?php }elseif($page_name=='work_profile' || $page_name=='projects_profile'){ ?>
                            <div class="m-input-icon m-input-icon--right">
                              <input value="<?php echo $work_data->work_name?>" type="text"  readonly class="form-control m-input m-input--pill m-input--air"  aria-describedby="basic-addon1">
                              <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-tag"></i></span></span>
                            </div>
                          <?php } ?>
                          <span class="m-form__help"></span>
                        </div>
                      </div>
                    <?php } ?>
                    <div class="col-lg-6">
                      <div class="form-group m-form__group" >
                        <label for="user_name">
                          Client Name
                        </label>
                        <div class="m-input-icon m-input-icon--right">
                          <?php if($page_name=='invoice_profile'){?>
                            <input type="text" name="client_name" readonly class="form-control form_client_payment_add_fields m-input m-input--pill m-input--air" value="<?php echo $invoice->client_name?>"  aria-describedby="basic-addon1">
                          <?php }elseif($page_name=='work_profile' || $page_name=='projects_profile'){ ?>
                            <input value="<?php echo $work_data->client_name?>" type="text" name="client_name" readonly class="form-control m-input m-input--pill m-input--air"  aria-describedby="basic-addon1">
                          <?php } ?>
                          <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>
                  <div class="row">
                    <input type="hidden" name="invoice_id" value="<?php echo $invoice->invoice_id;?>" />
                    <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_client_payment_add_fields m-input m-input--pill m-input--air" placeholder="Received Amount" max="<?php echo $invoice->balance_amount?>" aria-describedby="basic-addon1">
                          <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-money"></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 Date
                        </label>
                        <div class="m-input-icon m-input-icon--right">
                          <input  data-date-format="dd-mm-yyyy" id="client_payment_received_date_add" required type="text" name="received_date" class="form-control form_client_payment_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="client_payment_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-5">
                      <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_client_payment_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>
                    <div class="col-lg-3">
                      <div class="form-group m-form__group" style="  !important">
                        <label for="user_name">
                          Receipt No
                        </label>
                        <div class="m-input-icon m-input-icon--right">
                          <input type="text" name="reference_no"  class="form-control form_client_payment_add_fields m-input m-input--pill m-input--air" placeholder="Receipt No" aria-describedby="basic-addon1">
                          <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-tag"></i></span></span>
                        </div>
                        <span class="m-form__help"></span>
                      </div>
                    </div>
                    <div class="col-lg-4">
                      <div class="form-group m-form__group" style="  !important">
                        <label for="user_name">
                          Received From
                        </label>
                        <div class="m-input-icon m-input-icon--right">
                          <input type="text" name="received_from"  class="form-control form_client_payment_add_fields m-input m-input--pill m-input--air" placeholder="Received From" aria-describedby="basic-addon1">
                          <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-tag"></i></span></span>
                        </div>
                        <span class="m-form__help"></span>
                      </div>
                    </div>
                    <input type="hidden" name="client_id" id="client_payment_client_id_add" value="<?php if($page_name=='work_profile' || $page_name=='projects_profile'){ echo $work_data->client_id; }?>"/>
                    <?php if($invoice->invoice_type=='other_income'){ ?>
                      <input type="hidden" name="tr_type" value="income_receipt_transaction" id="tr_type_add_client_payment">
                      <input type="hidden" name="reference_id" id="reference_id_add_client_payment" value="<?php echo $invoice->client_id; ?>">
                      <input type="hidden" name="reference_type" value="client" id="reference_type_add_client_payment">
                    <?php }else{ ?>
                      <input type="hidden" name="tr_type" value="client_payment_transaction" id="tr_type_add_client_payment">
                      <input type="hidden" name="reference_id" id="reference_id_add_client_payment" value="<?php if($page_name=='work_profile' || $page_name=='projects_profile'){ echo $work_data->work_id; }?>">
                      <input type="hidden" name="reference_type" value="project" id="reference_type_add_client_payment">
                    <?php } ?>
                    <input type="hidden" name="redirect_url" value="<?php echo base_url(uri_string())?>" >
                    <input type="hidden" name="invoice_id" value="<?php echo $invoice->invoice_id?>" >
                  </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_4 btn-primary">
                    Submit
                  </button>
                </div>
              </form>
            </div>
          </div>
        </div>
        <div class="modal fade" tabindex="-1" id="client_payment_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 Invoice Payment Received
                </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="client_payment" id="form_client_payment_edit" data-modal-id="client_payment_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_client_payment_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">
                    <input type="hidden" name="invoice_id" value="<?= $invoice->invoice_id?>">
                    <input type="hidden" name="work_id" value="<?= $invoice->project_id?>">
                  </div>

                  <div class="row">
                    <div class="col-lg-4">
                      <div class="form-group m-form__group" >
                        <label for="client_payment_amount">
                          Received Amount
                        </label>
                        <div class="m-input-icon m-input-icon--right">
                          <input required type="text" name="received_amount" id="client_payment_received_amount_edit"  class="form-control form_client_tax_amount_edit_fields form_client_payment_edit_fields m-input m-input--pill m-input--air" placeholder="Payment Amount" aria-describedby="basic-addon1" min="1">
                          <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="client_payment_received_date_edit" required type="text" name="received_date" class="form-control form_client_payment_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="client_payment_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>
                  <div class="row">
                    <div class="col-lg-5">
                      <div class="form-group m-form__group" style=" !important">
                        <label for="client_payment_remarks">
                          Remarks
                        </label>
                        <div class="m-input-icon m-input-icon--right">
                          <input type="text" name="tr_remarks" id="client_payment_remarks_edit"  class="form-control form_client_payment_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>
                    <div class="col-lg-3">
                      <div class="form-group m-form__group" style="  !important">
                        <label for="user_name">
                          Receipt No
                        </label>
                        <div class="m-input-icon m-input-icon--right">
                          <input type="text" name="reference_no" id="client_payment_receipt_no_edit"  class="form-control form_client_payment_add_fields m-input m-input--pill m-input--air" placeholder="Receipt No" aria-describedby="basic-addon1">
                          <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-tag"></i></span></span>
                        </div>
                        <span class="m-form__help"></span>
                      </div>
                    </div>
                    <div class="col-lg-4">
                      <div class="form-group m-form__group" style="  !important">
                        <label for="user_name">
                          Received From
                        </label>
                        <div class="m-input-icon m-input-icon--right">
                          <input type="text" name="received_from" id="client_payment_received_from_edit"  class="form-control form_client_payment_add_fields m-input m-input--pill m-input--air" placeholder="Received From" aria-describedby="basic-addon1">
                          <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-tag"></i></span></span>
                        </div>
                        <span class="m-form__help"></span>
                      </div>
                    </div>
                    <input type="hidden" name="client_id" id="client_payment_client_id_edit" value="<?php if($page_name=='work_profile' || $page_name=='projects_profile'){ echo $work_data->client_id; }?>"/>
                    <input type="hidden" name="transaction_id" id="client_payment_tr_id_edit">
                    <?php if($invoice->invoice_type=='other_income'){ ?>
                      <input type="hidden" name="tr_type" value="income_receipt_transaction" id="tr_type_add_client_payment">
                      <input type="hidden" name="reference_id" id="reference_id_add_client_payment" value="<?php echo $invoice->client_id; ?>">
                      <input type="hidden" name="reference_type" value="client" id="reference_type_add_client_payment">
                    <?php }else{ ?>
                      <input type="hidden" name="tr_type" value="client_payment_transaction" id="tr_type_add_client_payment">
                      <input type="hidden" name="reference_id" id="reference_id_add_client_payment" value="<?php if($page_name=='work_profile' || $page_name=='projects_profile'){ echo $work_data->work_id; }?>">
                      <input type="hidden" name="reference_type" value="project" id="reference_type_add_client_payment">
                    <?php } ?>
                    <input type="hidden" name="redirect_url" value="<?php echo base_url(uri_string())?>" >
                    <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_4 btn-primary">
                    Submit
                  </button>
                </div>
              </form>
            </div>
          </div>
        </div>


        <?php $this->view("modules/include_modals/modal_transaction_delete");?>
        <!-- end:: Body -->
        <!-- begin::Footer -->

        <?php $this->view("includes/Inc_footer");?>
        <!-- end::Footer -->

        <!-- end:: Page -->

        <?php $this->view("includes/Inc_sidebar");?>
        <?php $this->view("includes/Inc_scripts");?>

        <?php $this->view("modules/include_scripts/invoices_payments_scripts");?>

        <script type="text/javascript">
        $("#page_title").text("Invoice - #<?php echo $invoice->invoice_id.' ['.$invoice->client_name.'] ['.$invoice->work_name.']'?>");

        <?php if($this->config->item('Client_Payment_client_payment_invoice_template')==5 || $this->config->item('Client_Payment_client_payment_invoice_template')==6 || $this->config->item('Client_Payment_client_payment_invoice_template')==7){ ?>
          $('#btn_print_invoice').click(function(e){
            var invoice_id = "<?php echo $invoice->invoice_id?>";
            myWindow = window.open('<?php echo base_url().'invoices/profile/'?>'+invoice_id+'/print','newwindow','width=1200,height=700');
            myWindow.document.close();
            myWindow.focus();
            myWindow.print();
          });
          $('#btn_print_invoice_2').click(function(e){
            var invoice_id = "<?php echo $invoice->invoice_id?>";
            myWindow = window.open('<?php echo base_url().'invoices/profile/'?>'+invoice_id+'/print/true','newwindow','width=1200,height=700');
            myWindow.document.close();
            myWindow.focus();
            myWindow.print();
          });
          <?php }else{ ?>
            $('#btn_print_invoice').click(function(e){
              window.print();
            })
            <?php } ?>

            $('body').on('click', '#client_payment_edit_btn', function() {
              var no = $(this).closest('tr').children('td');
              $('#client_payment_received_amount_edit').val(no.eq(12).text());
              $('#client_payment_received_date_edit').val(no.eq(1).text());
              $('#client_payment_remarks_edit').val(no.eq(4).text());
              $('#client_payment_received_from_edit').val(no.eq(5).text());
              $('#client_payment_receipt_no_edit').val(no.eq(10).text());
              $('#client_payment_acc_edit').val(no.eq(11).text()).trigger('change');
              $('#client_payment_tr_id_edit').val(no.eq(9).text());
              var balance = parseFloat(<?= $invoice->balance_amount ?>)+parseFloat(no.eq(2).text());
              $('#client_payment_received_amount_edit').attr('max',balance);
            });

            $('body').on('click', '#client_payment_delete_btn', function() {
              var no = $(this).closest('tr').children('td');
              $('#transaction_id_delete').val(no.eq(9).text());
            });
            </script>

            <!--begin::Page Snippets -->
            <script>

            <?php if($invoice->invoice_type=='other_income'){?>
              $("#other_income_menu").addClass('m-menu__item--active m-menu__item--open');
              $("#other_income_menu_1").addClass('m-menu__item--active');
              <?php }elseif($invoice->invoice_type=='proforma'){?>
                $("#proforma_invoices_menu").addClass('m-menu__item--active m-menu__item--open');
                <?php }else{ ?>
                  $("#client_payments_menu").addClass('m-menu__item--active m-menu__item--open');
                  $("#client_payments_menu_1").addClass('m-menu__item--active');
                  <?php } ?>


                  <?php if($this->config->item('Client_Payment_client_payment_invoice_template')==3){ ?>
                    $("#m_aside_left_minimize_toggle").addClass("m-brand__toggler--active");
                    $("#body").addClass("m-brand--minimize m-aside-left--minimize");
                    <?php } ?>

                    $('body').on('click', '#receive_payment', function() {
                      var work_id = <?php echo $invoice->project_id?>;
                      $("#client_payment_work_add").val(work_id).trigger('change');
                      $("#client_payment_work_add").attr('disabled','readonly');

                      $.post("<?php echo base_url() ?>work/select_details",{work_id:work_id},function(data) {
                        var obj = $.parseJSON(data);
                        var i=0;
                        if(obj.count==1) {
                          $("#client_payment_client_name_edit").val(obj.data['client_name']);
                        }
                      })
                      // $('#client_payment_client_name_edit').val(no.eq(4).text());
                    });


                    $("#client_payment_work_add").select2({
                      placeholder: "Select Work",
                      dropdownParent: $("#form_client_payment_add"),
                      templateResult: format_project_dropdown
                    })
                    $("#client_payment_acc_add").select2({
                      placeholder: "Select Credit Account",
                      dropdownParent: $("#form_client_payment_add")
                    })
                    $("#client_payment_received_date_add,#client_payment_received_date_edit").datepicker( {
                      todayHighlight:!0, orientation:"bottom left", templates: {
                        leftArrow: '<i class="la la-angle-left"></i>', rightArrow: '<i class="la la-angle-right"></i>'
                      }
                    })
                    $('body').on('change', '#client_payment_work_add', function() {
                      var work_id=$('#client_payment_work_add :selected').val();
                      $("#reference_id_add_client_payment").val(work_id);
                      $("#reference_type_add_client_payment").val('project');
                      $.post("<?php echo base_url() ?>work/select_details",{work_id:work_id},function(data) {
                        var obj = $.parseJSON(data);
                        var i=0;
                        if(obj.count==1) {
                          $("#client_payment_client_name_add").val(obj.data['client_name']);
                          $("#client_payment_client_id_add").val(obj.data['client_id']);
                        }
                      })
                    })

                    </script>
                    <script>
                    $('#payment_view_table').DataTable({
                      "scrollX" : true,
                      scrollX:!0, scrollCollapse:!0,
                      dom:"<'row'<'col-sm-6 text-left'><'col-sm-6 text-right'f>>\n\t\t\t<'row'<'col-sm-12'tr>>\n\t\t\t<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7 dataTables_pager'lp>>", // horizobtal scrollable datatable
                      "paging":   false,
                      "ordering": false,
                      "info":     false,
                      searching: false
                    });
                    $(".form_submit_btn_4,.form_submit_btn").click(function (e) {

                      e.preventDefault();
                      var a = $(this),
                      l = $(this).closest("form"),
                      action = l.attr('action');
                      var form_id = l.attr('id');
                      l.validate({
                        rules: {
                          "new_paid_amount": {
                            required: !0,
                            number: !0
                          }
                        }, invalidHandler: function (e, r) {
                          var i = $("#" + form_id + "_msg");
                          i.removeClass("m--hide").show(), mUtil.scrollTo(i, -200)
                        }, submitHandler: function (e) {
                        }
                      }), l.valid() && (a.addClass("m-loader m-loader--right m-loader--light").attr("disabled", !0),
                      l.ajaxSubmit({
                        url: action,
                        success: function (e, t, r, s) {
                          var modal_id = l.attr('data-modal-id');
                          var form_type = l.attr('data-form-type');
                          $("#" + form_id + "_msg").addClass("m--hide");
                          // Block UI
                          mApp.blockPage({
                            overlayColor: "#000000",
                            type: "loader",
                            state: "success",
                            message: "Please wait..."
                          }), setTimeout(function () {
                            mApp.unblockPage()
                          }, 2e3);
                          var obj = $.parseJSON(e);
                          if (obj.status == 1) {
                            a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
                            toastr[obj.flashdata_type](obj.flashdata_msg, obj.flashdata_title);
                            $("#"+modal_id).modal('toggle');
                            $("."+form_id+"_fields").val("");
                            location.reload();
                          } else {
                            a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
                            toastr[obj.flashdata_type](obj.flashdata_msg, obj.flashdata_title);
                          }
                          if (obj == null) {
                            setTimeout(function () {
                              a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
                              toastr["warning"]("Your Attempt is Timed Out. Please Try Again.", "Timed Out");
                            }, 2e4)
                          }
                        },error: function() {
                          a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
                          toastr["error"]("Sorry. There Has Been Some Error Occurred. Please Try Again.", "Error");
                        }
                      })
                    )
                  });

                  </script>
