<style>
.invoice_info_title{
  font-size:10px;
}
table th, table td{
  font-size:11px;
}
.table-bordered th, .table-bordered td {
  border: 1px solid #b7b7b7 !important;
}
</style>
<?php
$invoice_no = '';
if($invoice->invoice_type=='proforma'){
  $invoice_no .= $this->config->item('client_invoice_proforma_prefix');
}else{
  if($invoice->tax_invoice==1){
    if ($this->config->item('Client_Payment_invoice_business_type') == 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;
// }
?>
<?php if($this->config->item('Client_Payment_client_payment_invoice_template')==5){?>
<?php }elseif($this->config->item('Client_Payment_client_payment_invoice_template')==6){?>
<?php }elseif($this->config->item('Client_Payment_client_payment_invoice_template')==7){?>
  <div class="m-invoice-2" style="padding: 40px;padding-bottom:20px">
    <div  class="m-invoice__wrapper">
      <div class="m-invoice__body m-invoice__body--centered" style="">
        <?php if($this->config->item('client_invoice_header')!=''){ ?>
          <img class="letter_head_img" style="width:100%;max-height:250px" src="<?php echo base_url().'uploads/company/'.$this->config->item('client_invoice_header')?>" />
        <?php } ?>
        <table class="table m-table table-bordered item_table" style="width:100%;margin-bottom:0px !important">
          <thead>
            <tr>
              <th colspan="3" style="text-align:center">
                <h4 style="font-weight:700">
                  <?php
                  if($invoice->invoice_type=='proforma'){
                    echo "PROFORMA INVOICE";
                  }else{
                    if($invoice->tax_invoice==1){
                      if($invoice->business_type!=''){
                        // echo $invoice->business_type." - TAX INVOICE";
                        echo "TAX INVOICE";
                      }else{
                        echo "TAX INVOICE";
                      }
                    }else{
                      echo $this->config->item('Client_Payment_client_payment_invoice_title');
                    }
                  } ?>
                </h4>
              </th>
            </tr>
          </thead>
        </table>
        <table class="table m-table table-bordered item_table" style="width:100%;margin-bottom:0px !important">
          <thead>
            <tr>
              <td style="border-top:none !important;border-bottom:none !important;width:50%;max-width:50%;padding:0px !important">
                <table class="no-border" style="width:100%;margin-bottom:0px !important;word-wrap: break-word !important;">
                  <thead>
                    <tr>
                      <th rowspan="4" style="border-bottom: 1px solid #b7b7b7 !important;text-wrap:wrap;vertical-align: top;line-height: 24px !important;word-wrap: break-word !important;">
                        Supplier Details
                        <h3><?php echo $this->config->item('company_name')?></h3>
                        <?php echo preg_replace('#(<br */?>\s*)+#i', '<br />',$this->config->item('company_address'))?>
                      </th>
                    </tr>
                  </thead>
                </table>
                <table style="width:100%" class="no-border" >
                  <thead>
                    <tr>
                      <th style="text-align:left;text-wrap:wrap;">Buyer Details
                        <br/><h4><?php echo $invoice->client_name?></h4>
                        <?php echo $invoice->client_address?>
                        <table class="no-border" >
                          <thead>
                            <?php if($invoice->client_email!=''){?>
                              <tr>
                                <th style="text-align:left;padding:0px !important">Email</th>
                                <th style="padding:0px !important">&nbsp:&nbsp</th>
                                <th style="text-align:left;padding:0px !important" colspan="4"><?php echo $invoice->client_email?></th>
                              </tr>
                            <?php } ?>
                            <?php if(isset($enquiry_data) && !empty($enquiry_data)){?>
                              <tr>
                                <th style="text-align:left;padding:0px !important">Phone</th>
                                <th style="padding:0px !important">&nbsp:&nbsp</th>
                                <th style="text-align:left;padding:0px !important" colspan="4"><?php echo $enquiry_data->enq_contact_person_mobile?></th>
                              </tr>
                              <tr>
                                <th style="text-align:left;padding:0px !important">Contact Person</th>
                                <th style="padding:0px !important">&nbsp:&nbsp</th>
                                <th style="text-align:left;padding:0px !important" colspan="4"><?php echo $enquiry_data->enq_contact_person?></th>
                              </tr>
                            <?php }else{ ?>
                              <tr>
                                <th style="text-align:left;padding:0px !important">Phone</th>
                                <th style="padding:0px !important">&nbsp:&nbsp</th>
                                <th style="text-align:left;padding:0px !important" colspan="4"><?php echo $invoice->client_contact?></th>
                              </tr>
                            <?php } ?>
                            <tr>
                              <th style="text-align:left;padding:0px !important"><?php echo $this->config->item('Tax_tax_name')." No "?></th>
                              <th style="padding:0px !important">&nbsp:&nbsp</th>
                              <th style="text-align:left;padding:0px !important" colspan="4"><?php echo $invoice->tax_no?></th>
                            </tr>
                            <?php if($client_data->tax_state_id!=0){?>
                              <tr>
                                <th style="text-align:left;padding:0px !important">State</th>
                                <th style="padding:0px !important">&nbsp:&nbsp</th>
                                <th style="text-align:left;padding:0px !important"><?php echo $client_data->state_name?></th>
                                <th style="text-align:left;padding:0px !important">&nbsp&nbsp&nbsp&nbsp&nbspState Code</th>
                                <th style="padding:0px !important">&nbsp:&nbsp</th>
                                <th style="text-align:left;padding:0px !important"><?php echo $client_data->state_code?></th>
                              </tr>
                            <?php } ?>
                          </thead>
                        </table>
                      </th>
                    </tr>
                    <?php if($invoice->shipping_name!=''|| $invoice->shipping_address!=''){?>
                      <th style="text-align:left;text-wrap:wrap;border-top: 1px solid #b7b7b7 !important;">Delivery Details
                      <br/><h5><?php echo $invoice->shipping_name?></h5>
                      <?php echo $invoice->shipping_address?>
                    </th>
                    <?php } ?>
                  </thead>
                </table>
              </td>
              <td  style="border-top:none !important;border-bottom:none !important;width:50%;max-width:50%;padding:0px !important">
                <table class="table m-table table-bordered item_table" style="width:100%;margin-bottom:0px !important">
                  <thead>
                    <tr>
                      <th style="border-top:none !important;border-left:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title"><?php if($invoice->invoice_type=='proforma'){ echo "Proforma ";}?>Invoice No</span><br/><strong><?php echo $invoice_no?></strong></th>
                      <th style="border-top:none !important;border-right:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Dated</span><br/><strong><?php echo date('d-m-Y',strtotime($invoice->invoice_date))?></strong></th>
                    </tr>
                    <?php if($invoice->supplier_reference_no!='' || $invoice->reference_no!=''){?>
                      <tr>
                        <th style="border-left:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Reference No</span><br/><?php echo $invoice->reference_no?>&nbsp;</th>
                        <th style="border-right:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Supplier's Ref.</span><br/><?php echo $invoice->supplier_reference_no?>&nbsp;</th>
                      </tr>
                    <?php } ?>
                    <tr>
                      <th style="border-left:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Delivery Note</span><br/><?php echo $invoice->delivery_note?>&nbsp;</th>
                      <th style="border-right:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Mode/Terms of Payment</span><br/><?php echo $invoice->payment_terms?>&nbsp;</th>
                    </tr>
                    <?php if($invoice->quotation_no!=0){?>
                      <tr>
                        <th style="border-left:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Quotation No</span><br/><?php echo $invoice->quotation_no?>&nbsp;</th>
                        <th style="border-right:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Quotation Date</span><br/><?php if($invoice->quotation_date!='0000-00-00'){ echo date('d-m-Y',strtotime($invoice->quotation_date));}?>&nbsp;</th>
                      </tr>
                    <?php } ?>
                    <tr>
                      <th style="border-left:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Buyers Order No.</span><br/><?php echo $invoice->buyers_orderno?>&nbsp;</th>
                      <th style="border-right:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Dated </span><br/><?php if($invoice->buyers_order_date!='0000-00-00'){ echo date('d-m-Y',strtotime($invoice->buyers_order_date));}?>&nbsp;</th>
                    </tr>
                    <?php if($invoice->despatch_doc_no!='' || $invoice->delivery_note_date!='0000-00-00'){?>
                      <tr>
                        <th style="border-left:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Despatch Document No.</span><br/><?php echo $invoice->despatch_doc_no?>&nbsp;</th>
                        <th style="border-right:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Delivery Note Date </span><br/><?php if($invoice->delivery_note_date!='0000-00-00'){ echo date('d-m-Y',strtotime($invoice->delivery_note_date));}?>&nbsp;</th>
                      </tr>
                    <?php } ?>
                    <?php if($invoice->despatched_through!='' || $invoice->destination!=''){?>
                      <tr>
                        <th style="border-left:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Despatched through</span><br/><?php echo $invoice->despatched_through?>&nbsp;</th>
                        <th style="border-right:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Destination</span><br/><?php echo $invoice->destination?>&nbsp;</th>
                      </tr>
                    <?php } ?>
                    <?php if($invoice->shipping_name!=''|| $invoice->shipping_address!=''){?>
                      <tr>
                        <th style="border-left:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Shipping Name</span><br/><?php echo $invoice->shipping_name?>&nbsp;</th>
                        <th style="border-right:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Shipping Address</span><br/><?php echo $invoice->shipping_address?>&nbsp;</th>
                      </tr>
                    <?php } ?>
                    <tr>
                      <th style="border-left:none !important;border-bottom:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Terms of Delivery</span><br/><?php echo $invoice->delivery_terms?>&nbsp;</th>
                      <th style="border-right:none !important;border-bottom:none !important;text-align:left;text-wrap:wrap;vertical-align:top"><span class="invoice_info_title">Delivery Date </span><br/><?php if($invoice->delivery_date!='0000-00-00'){ echo date('d-m-Y',strtotime($invoice->delivery_date));}?>&nbsp;</th>
                    </tr>

                  </thead>
                </table>
              </td>
            </tr>
          </thead>
        </table>

        <?php
        $have_discount=$total_qty=$total_taxable_amt=$total_tax0_amt=$total_tax1_amt=$total_tax2_amt=$total_tax3_amt=$total_disc_amt=$gt_total_amount=0;
        $tax1=$tax2=$tax3=0;
        $tax0_have = $tax1_have = $tax2_have = $tax3_have = $colspan = 0;
        foreach($invoice_items as $row):
          if($row->item_discount_percent!=0){
            $have_discount=1;
          }
          if($row->tax1_percent!=0){
            $tax1_have = 1;
            $colspan += 2;
          }
          if($row->tax2_percent!=0){
            $tax2_have = 1;
            $colspan += 2;
          }
          if($row->tax3_percent!=0){
            $tax3_have = 1;
            $colspan += 2;
          }
          if($row->tax1_percent==0 && $row->tax2_percent==0 && $row->tax3_percent==0 && $row->tax_percentage!=0){
            $tax0_have = 1;
          }
        endforeach;
        if($colspan == 0){
          $colspan = 1;
        }
        ?>
        <table class="table m-table table-bordered item_table" style="width:100%;margin-bottom:0px !important">
          <thead>
            <tr>
              <th rowspan="2" style="text-align: center;width:5% !important">Sl<br/>No</th>
              <th rowspan="2" style="text-align: center;width:40% !important;">Item Description</th>
              <?php if($this->config->item('Client_Payment_invoice_item_code_show')==1){?>
                <th rowspan="2" style="text-align: center;width:10% !important"><?php echo $this->config->item('Client_Payment_invoice_item_code_title')?></th>
              <?php } ?>
              <th rowspan="2" style="text-align: center;width:5% !important">UOM</th>
              <th rowspan="2" style="text-align: center;">Quantity</th>
              <th rowspan="2" style="text-align: center;">Rate</th>
              <?php if($have_discount==1){?>
                <th rowspan="2" style="text-align:center;width:5% !important">Disc<br/>%</th>
                <th rowspan="2" style="display:none;text-align: center;">Net</th>
              <?php } ?>
              <?php if($invoice->tax_invoice==1){?>
                <th rowspan="2" style="text-align:center;width:5% !important"><?php echo $this->config->item('Tax_tax_name')?><br/>%</th>
              <?php } ?>
              <th rowspan="2" style="text-align: center;">Amount</th>
            </tr>
          </thead>
          <tbody>
            <?php if($this->config->item('Quotation_rate_type')=='supply_installation'){?>
              <tr>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top">&nbsp;</td>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top;text-align:left;font-weight:700 !important"><?php echo strtoupper($invoice->invoice_rate_type)?> ITEMS</td>
                <?php if($this->config->item('Client_Payment_invoice_item_code_show')==1){?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <?php } ?>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <?php if($have_discount==1){?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="display:none;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <?php } ?>
                <?php if($invoice->tax_invoice==1){?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <?php } ?>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
              </tr>
            <?php } ?>
            <?php
            $total_qty = 0;
            $n = 1;
            $tax_percent = $this->config->item('Tax_tax_percent');
            foreach ($tax_percent as $row){
              ${'total_taxable_amt_'.$row->tax_id} = 0;
            }
            $total_tax_amt =  0;
            foreach($invoice_items as $row):
              ?>
              <tr>
                <td style="text-align: center;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $n++?></td>
                <td style="text-align: left;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $row->name?></td>
                <?php if($this->config->item('Client_Payment_invoice_item_code_show')==1){?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $row->item_code?></td>
                <?php } ?>
                <td style="text-align:center;white-space: nowrap;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $row->unit_name?></td>
                <td style="white-space: nowrap;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo number_format($row->quantity, $this->config->item('Currency_amount_decimals_2'),'.','')?></td>
                <td style="white-space: nowrap;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('currency_format')->formatCurrency($row->price,$this->config->item('Currency_currency_shortname'));?></td>
                <?php if($have_discount==1){?>
                  <td style="white-space: nowrap;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $row->item_discount_percent?>%</td>
                  <td style="display:none;white-space: nowrap;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('currency_format')->formatCurrency($row->item_taxable_amount,$this->config->item('Currency_currency_shortname'));?></td>
                <?php } ?>
                <?php if($invoice->tax_invoice==1){?>
                  <td style="white-space: nowrap;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $row->tax_percentage?>%</td>
                <?php } ?>
                <td style="white-space: nowrap;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('currency_format')->formatCurrency($row->item_taxable_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;
              if($tax1_have==1){
                $total_tax1_amt+=($row->item_taxable_amount*$row->tax1_percent/100);
              }
              if($tax2_have==1){
                $total_tax2_amt+=($row->item_taxable_amount*$row->tax2_percent/100);
              }
              if($tax3_have==1){
                $total_tax3_amt+=($row->item_taxable_amount*$row->tax3_percent/100);
              }
              if($tax0_have==1){
                $total_tax0_amt+=($row->item_taxable_amount*$row->tax_percentage/100);
              }
            endforeach;
            if(sizeof($invoice_items)<10){ //Add Blank Columns
              for($i=1;$i<(6-sizeof($invoice_items));$i++){ ?>
                <tr>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top">&nbsp;</td>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php if($this->config->item('Client_Payment_invoice_item_code_show')==1){?>
                    <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php } ?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php if($have_discount==1){?>
                    <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                    <td style="display:none;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php } ?>
                  <?php if($invoice->tax_invoice==1){?>
                    <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php } ?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                </tr>
              <?php }
            }
            ?>
            <?php if($invoice->tax_invoice==1){?>
              <tr>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top">&nbsp;</td>
                <td style="text-align:right;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top">Taxable Value</td>
                <?php if($this->config->item('Client_Payment_invoice_item_code_show')==1){?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <?php } ?>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <?php if($have_discount==1){?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="display:none;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <?php } ?>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('currency_format')->formatCurrency($invoice->invoice_taxable_amount,$this->config->item('Currency_currency_shortname'));?></td>
              </tr>
              <?php if($tax1_have==1){ ?>
                <tr>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top">&nbsp;</td>
                  <td style="text-align:right;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('Tax_tax1_name')?></td>
                  <?php if($this->config->item('Client_Payment_invoice_item_code_show')==1){?>
                    <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php } ?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php if($have_discount==1){?>
                    <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                    <td style="display:none;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php } ?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('currency_format')->formatCurrency($total_tax1_amt,$this->config->item('Currency_currency_shortname'));?></td>
                </tr>
              <?php } ?>
              <?php if($tax2_have==1){ ?>
                <tr>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top">&nbsp;</td>
                  <td style="text-align:right;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('Tax_tax2_name')?></td>
                  <?php if($this->config->item('Client_Payment_invoice_item_code_show')==1){?>
                    <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php } ?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php if($have_discount==1){?>
                    <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                    <td style="display:none;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php } ?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('currency_format')->formatCurrency($total_tax2_amt,$this->config->item('Currency_currency_shortname'));?></td>
                </tr>
              <?php } ?>
              <?php if($tax3_have==1){ ?>
                <tr>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top">&nbsp;</td>
                  <td style="text-align:right;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('Tax_tax3_name')?></td>
                  <?php if($this->config->item('Client_Payment_invoice_item_code_show')==1){?>
                    <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php } ?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php if($have_discount==1){?>
                    <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                    <td style="display:none;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php } ?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('currency_format')->formatCurrency($total_tax3_amt,$this->config->item('Currency_currency_shortname'));?></td>
                </tr>
              <?php } ?>
              <?php if($tax0_have==1){ ?>
                <tr>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top">&nbsp;</td>
                  <td style="text-align:right;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('Tax_tax_name')?></td>
                  <?php if($this->config->item('Client_Payment_invoice_item_code_show')==1){?>
                    <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php } ?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php if($have_discount==1){?>
                    <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                    <td style="display:none;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <?php } ?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('currency_format')->formatCurrency($total_tax0_amt,$this->config->item('Currency_currency_shortname'));?></td>
                </tr>
              <?php } ?>
            <?php } ?>
            <?php if($invoice->invoice_round_amount!=0){ ?>
              <tr>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top">&nbsp;</td>
                <td style="text-align:right;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top">Round Off</td>
                <?php if($this->config->item('Client_Payment_invoice_item_code_show')==1){?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <?php } ?>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <?php if($invoice->tax_invoice==1){?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <?php } ?>
                <?php if($have_discount==1){?>
                  <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  <td style="display:none;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <?php } ?>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php
                if($invoice->invoice_round_amount<0){
                  echo "(+)";
                }else{
                  echo "(-)";
                }
                echo $this->config->item('currency_format')->formatCurrency($invoice->invoice_round_amount,$this->config->item('Currency_currency_shortname'));?></td>
              </tr>
            <?php } ?>
          </tbody>
          <tfoot>
            <tr>
              <td colspan="2" style="text-align:right;border:1px solid #b7b7b7 !important;"><strong> Total</strong></td>
              <td style="border:1px solid #b7b7b7 !important;"></td>
              <?php if($this->config->item('Client_Payment_invoice_item_code_show')==1){?>
                <td style="border:1px solid #b7b7b7 !important;"></td>
              <?php } ?>
              <td style="text-align:right;border:1px solid #b7b7b7 !important;"><strong><?php echo  number_format($total_qty, $this->config->item('Currency_amount_decimals_2'),'.','')?></strong></td>
              <td style="border:1px solid #b7b7b7 !important;"></td>
              <?php if($have_discount==1){?>
                <td style="border:1px solid #b7b7b7 !important;"></td>
                <td style="display:none;border:1px solid #b7b7b7 !important;"></td>
              <?php } ?>
              <?php if($invoice->tax_invoice==1){?>
                <td style="border:1px solid #b7b7b7 !important;"></td>
              <?php } ?>
              <td style="font-size:14px;text-align:right;border:1px solid #b7b7b7 !important;"><strong><?php echo $this->config->item('currency_format')->formatCurrency($invoice->invoice_total_amount,$this->config->item('Currency_currency_shortname'));?></strong></td>
            </tr>
            <?php if($invoice->invoice_type=='proforma'){?>
              <tr>
                <td colspan="<?php if($this->config->item('Client_Payment_invoice_item_code_show')==1){ echo 6;}else{echo 5;}?>" style="text-align:left;border:1px solid #b7b7b7 !important;font-size:16px;font-weight:700"><strong> Claiming Amount - <?php echo $invoice->claiming_advance_percentage?>% ADVANCE</strong></td>
                  <?php if($have_discount==1){?>
                    <td style="border:1px solid #b7b7b7 !important;"></td>
                    <td style="display:none;border:1px solid #b7b7b7 !important;"></td>
                  <?php } ?>
                  <?php if($invoice->tax_invoice==1){?>
                    <td style="border:1px solid #b7b7b7 !important;"></td>
                  <?php } ?>
                  <td style="font-size:14px;text-align:right;border:1px solid #b7b7b7 !important;"><strong><?php echo $this->config->item('currency_format')->formatCurrency($invoice->claiming_advance_amount,$this->config->item('Currency_currency_shortname'));?></strong></td>
                </tr>
              <?php } ?>
            </tfoot>
          </table>

          <table class="table m-table table-bordered item_table" style="width:100%;margin-bottom:0px !important">
            <tbody>
              <tr>
                <?php if($invoice->tax_invoice==1){?>
                  <td style="text-align:left;border-top:none !important;border-bottom:none !important;">
                  <?php }else{?>
                    <td style="text-align:left;border-top:none !important;">
                    <?php } ?>
                    Amount Chargeable (in words)<br/>
                    <label style="font-size: 1.2rem;font-weight:600;"><?php echo $invoice->receivable_amount_in_words ?></label>
                  </td>
                </tr>
              </tbody>
            </table>
            <?php if($invoice->tax_invoice==1){?>
              <table class="table  m-table table-bordered item_table" style="width:100%;margin-bottom:0px !important">
                <thead>
                  <tr>
                    <th rowspan="2" style="text-align: center">Sl No</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">Taxable<br/>Value</th>
                    <?php if($tax1_have==1){ ?>
                      <th colspan="2" style="text-align: center"><?php echo $this->config->item('Tax_tax1_name')?></th>
                    <?php } ?>
                    <?php if($tax2_have==1){ ?>
                      <th colspan="2" style="text-align: center"><?php echo $this->config->item('Tax_tax2_name')?></th>
                    <?php } ?>
                    <?php if($tax3_have==1){ ?>
                      <th colspan="2" style="text-align: center"><?php echo $this->config->item('Tax_tax3_name')?></th>
                    <?php } ?>
                    <?php if($tax0_have==1){ ?>
                      <th colspan="2" style="text-align: center"><?php echo $this->config->item('Tax_tax_name')?></th>
                    <?php } ?>
                    <th rowspan="2" style="text-align: center">Total<br/>Tax Amount</th>
                  </tr>
                  <tr>
                    <?php if($tax1_have==1){ ?>
                      <th style="text-align: center">Rate</th>
                      <th style="text-align: center">Amount</th>
                    <?php } ?>
                    <?php if($tax2_have==1){ ?>
                      <th style="text-align: center">Rate</th>
                      <th style="text-align: center">Amount</th>
                    <?php } ?>
                    <?php if($tax3_have==1){ ?>
                      <th style="text-align: center">Rate</th>
                      <th style="text-align: center">Amount</th>
                    <?php } ?>
                    <?php if($tax0_have==1){ ?>
                      <th style="text-align: center">Rate</th>
                      <th style="text-align: center">Amount</th>
                    <?php } ?>
                  </tr>
                </thead>
                <tbody>
                  <?php
                  $n=1;
                  foreach($invoice_items as $row):
                    if($row->tax1_percent!=0 || $row->tax2_percent!=0 || $row->tax3_percent!=0 || $row->tax_percentage!=0){
                      ?>
                      <tr>
                        <td style="text-align: center;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $n++?></td>
                        <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $row->item_code?></td>
                        <td style="white-space: nowrap;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('currency_format')->formatCurrency($row->item_taxable_amount,$this->config->item('Currency_currency_shortname'));?></td>
                        <?php if($tax1_have==1){
                          $tax1_amt=($row->item_taxable_amount*$row->tax1_percent/100);?>
                          <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $row->tax1_percent?>%</td>
                          <td style="white-space: nowrap;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('currency_format')->formatCurrency($tax1_amt,$this->config->item('Currency_currency_shortname'));?></td>
                        <?php } ?>
                        <?php if($tax2_have==1){
                          $tax2_amt=($row->item_taxable_amount*$row->tax2_percent/100);?>
                          <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $row->tax2_percent?>%</td>
                          <td style="white-space: nowrap;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('currency_format')->formatCurrency($tax2_amt,$this->config->item('Currency_currency_shortname'));?></td>
                        <?php } ?>
                        <?php if($tax3_have==1){
                          $tax3_amt=($row->item_taxable_amount*$row->tax3_percent/100);?>
                          <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $row->tax3_percent?>%</td>
                          <td style="white-space: nowrap;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('currency_format')->formatCurrency($tax3_amt,$this->config->item('Currency_currency_shortname'));?></td>
                        <?php } ?>
                        <?php if($tax0_have==1){
                          $tax0_amt=($row->item_taxable_amount*$row->tax_percentage/100);?>
                          <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $row->tax_percentage?>%</td>
                          <td style="white-space: nowrap;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('currency_format')->formatCurrency($tax0_amt,$this->config->item('Currency_currency_shortname'));?></td>
                        <?php } ?>
                        <td style="white-space: nowrap;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $this->config->item('currency_format')->formatCurrency($row->item_tax_amount,$this->config->item('Currency_currency_shortname'));?></td>
                      </tr>
                      <?php
                    }
                  endforeach;
                  ?>
                  <tr>
                    <td colspan="2" style="text-align:center;border-top: 1px solid #b7b7b7 !important;"><strong>Total</strong></td>
                    <td style="white-space: nowrap;border-top: 1px solid #b7b7b7 !important;vertical-align:top"><strong><?php echo $this->config->item('currency_format')->formatCurrency($invoice->invoice_taxable_amount,$this->config->item('Currency_currency_shortname'));?></strong></td>
                    <?php if($tax1_have==1){ ?>
                      <td style="text-align:center;border-top: 1px solid #b7b7b7 !important;"></td>
                      <td style="white-space: nowrap;border-top: 1px solid #b7b7b7 !important;vertical-align:top"><strong><?php echo $this->config->item('currency_format')->formatCurrency($total_tax1_amt,$this->config->item('Currency_currency_shortname'));?></strong></td>
                    <?php } ?>
                    <?php if($tax2_have==1){ ?>
                      <td style="text-align:center;border-top: 1px solid #b7b7b7 !important;"></td>
                      <td style="white-space: nowrap;border-top: 1px solid #b7b7b7 !important;vertical-align:top"><strong><?php echo $this->config->item('currency_format')->formatCurrency($total_tax2_amt,$this->config->item('Currency_currency_shortname'));?></strong></td>
                    <?php } ?>
                    <?php if($tax3_have==1){ ?>
                      <td style="text-align:center;border-top: 1px solid #b7b7b7 !important;"></td>
                      <td style="white-space: nowrap;border-top: 1px solid #b7b7b7 !important;vertical-align:top"><strong><?php echo $this->config->item('currency_format')->formatCurrency($total_tax3_amt,$this->config->item('Currency_currency_shortname'));?></strong></td>
                    <?php } ?>
                    <?php if($tax0_have==1){ ?>
                      <td style="text-align:center;border-top: 1px solid #b7b7b7 !important;"></td>
                      <td style="white-space: nowrap;border-top: 1px solid #b7b7b7 !important;vertical-align:top"><strong><?php echo $this->config->item('currency_format')->formatCurrency($total_tax0_amt,$this->config->item('Currency_currency_shortname'));?></strong></td>
                    <?php } ?>
                    <td style="white-space: nowrap;border-top: 1px solid #b7b7b7 !important;vertical-align:top"><strong><?php echo $this->config->item('currency_format')->formatCurrency($invoice->invoice_tax_amount,$this->config->item('Currency_currency_shortname'));?></strong></td>
                  </tr>
                </tbody>
              </table>
              <table class="table m-table table-bordered item_table" style="width:100%;margin-bottom:0px !important">
                <tbody>
                  <tr>
                    <td style="text-align:left;border-top:none !important;">
                      Tax Amount (in words)<br/>
                      <label style="font-size: 1.2rem;font-weight:600;"><?php echo $invoice->tax_amount_in_words ?></label>
                    </td>
                  </tr>
                </tbody>
              </table>
            <?php } ?>

            <table style="width:100%">
              <tbody>
                <tr>
                  <td style="width:<?php if($invoice->bank_name!=''){ echo 33;}else{ echo 50;}?>%;border-left:1px solid #b7b7b7 !important;border-right:1px solid #b7b7b7 !important;border-bottom:1px solid #b7b7b7 !important;">
                    Declaration :<br/>We declare that this invoice shows the actual price of the goods described and that all particulars are true and correct.
                  </td>
                  <?php if($invoice->bank_name!=''){?>
                    <td style="width:33%;border-left:1px solid #b7b7b7 !important;border-right:1px solid #b7b7b7 !important;border-bottom:1px solid #b7b7b7 !important;">
                      <table class="no-border" style="width:100%">
                        <tbody>
                          <tr>
                            <td style="text-align:left;width:32%">Bank Name</td>
                            <td style="text-align:left;width:1%">:</td>
                            <td style="text-align:left;"><?php echo $invoice->bank_name ?></td>
                          </tr>
                          <tr>
                            <td style="text-align:left">Branch</td>
                            <td style="text-align:left">:</td>
                            <td style="text-align:left"><?php echo $invoice->bank_branch ?></td>
                          </tr>
                          <tr>
                            <td style="text-align:left">Acc No</td>
                            <td style="text-align:left">:</td>
                            <td style="text-align:left"><?php echo $invoice->bank_account_no ?></td>
                          </tr>
                          <?php if($invoice->bank_ifsc!=''){?>
                            <tr>
                              <td style="text-align:left"><?= $this->config->item('bank_ifsc_name')?></td>
                              <td style="text-align:left">:</td>
                              <td style="text-align:left"><?php echo $invoice->bank_ifsc ?></td>
                            </tr>
                          <?php } ?>
                          <?php if($invoice->bank_swift_code!=''){?>
                            <tr>
                              <td style="text-align:left">SWIFT Code</td>
                              <td style="text-align:left">:</td>
                              <td style="text-align:left"><?php echo $invoice->bank_swift_code ?></td>
                            </tr>
                          <?php } ?>
                        </thead>
                      </tbody>
                    </table>
                  </td>
                <?php } ?>
                <td style="min-width:33%;text-align:right;border-right:1px solid #b7b7b7 !important;border-bottom:1px solid #b7b7b7 !important;">
                  <table style="width:100%">
                    <tr>
                      <?php if($invoice->prepared_by!=0){?>
                        <td style="text-align:left">Prepared By<br/><?php echo $invoice->prepared_by_user?></td>
                      <?php } ?>
                      <td style="text-align:right">
                        <h5 style="margin-top:10px">
                          For <?php echo $this->config->item('company_name') ?>
                        </h5>
                        <?php if($this->config->item('company_signature')!=''){?>
                          <img style="width:100%;max-height:250px" src="<?php echo base_url().'uploads/company/'.$this->config->item('company_signature')?>" />
                        <?php }else{ ?>
                          <br/><br/>
                        <?php } ?>
                        <br/>
                        <strong>Authorised Signatory</strong>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </tbody>
          </table>
          <table class="no-border" style="width:100%;margin-bottom:0px !important">
            <tbody>
              <tr>
                <td style="text-align:center;">
                  This is a Computer Generated Invoice
                </td>
              </tr>
            </tbody>
          </table>
        </div>


      </div>
    </div>
  <?php } ?>
  <?php
  if($print_transactions=='true'){ ?>
    <div class="m-invoice-2" style="padding: 40px;padding-bottom:20px;padding-top: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="">
            <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>

                </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>

                  </tr>
                  <?php
                endforeach;
                ?>
              </tbody>
            </table>
          </div>
            <?php } ?>
          <div class="m-invoice__table  m-invoice__table--centered table-responsive" >
            <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>

        </div>
      </div>
    </div>
  <?php } ?>
