<html>
<head>
  <?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');
    }
  }
  $invoice_no .= sprintf('%03u', $invoice->invoice_no);
  $invoice_no .= $invoice->invoice_suffix;
  ?>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Client Invoice - <?php echo $invoice_no.' ['.$invoice->client_name.'] ['.$invoice->work_name.']'?></title>

  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous" media="all">
  <!--end::Web font -->
  <!--begin::Base Styles -->
  <link href="<?php  echo $this->config->item('Template_template_file_url'); ?>template/assets/vendors/base/vendors.bundle.css" rel="stylesheet" type="text/css" />
  <link href="<?php echo $this->config->item('Template_template_file_url'); ?>template/assets/demo/default/base/style.bundle.css" rel="stylesheet" type="text/css" />
  <script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.16/webfont.js"></script>
  <script>
  WebFont.load({
    google: {"families":["Poppins:300,400,500,600,700","Roboto:300,400,500,600,700"]},
    active: function() {
      sessionStorage.fonts = true;
    }
  });
  </script>
</head>
<style>

.item_table td{
  padding: .75rem !important;
}
.item_table th{
  white-space: nowrap;
  padding: .75rem !important;
}
.table thead th {
  border: 0px !important;
}
.table thead th {
  border: 0px !important;
}
.table tbody td {
  border: 0px !important;
}
.payment-table tbody td{
  border: 0px !important;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__head .m-invoice__container.m-invoice__container--centered {
  width: 100%;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body.m-invoice__body--centered {
  width: 100%;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__head .m-invoice__container.m-invoice__container--centered {
  width: 100%;
}
</style>


<style>

@media print {

  .table-bordered td{
    padding: .75rem !important;
  }
  .table-bordered th{
    white-space: nowrap;
    padding: .75rem !important;
  }
  .table-bordered .table thead th {
    border: 0px !important;
  }
  .m-invoice-2 .m-invoice__wrapper .m-invoice__head .m-invoice__container.m-invoice__container--centered {
    width: 97%;
  }
  .m-invoice-2 .m-invoice__wrapper .m-invoice__body.m-invoice__body--centered {
    width: 97%;
  }
  .m-invoice-2 .m-invoice__wrapper .m-invoice__body.m-invoice__body--centered {
    margin-left: 10px !important;
  }

  body.m-content--skin-light2 {
    background-color: white !important;
  }
  .m-invoice-2 .m-invoice__wrapper .m-invoice__head .m-invoice__container.m-invoice__container--centered {
    width: 97% !important;
  }
  .m-invoice-2 .m-invoice__wrapper .m-invoice__head .m-invoice__container .m-invoice__items .m-invoice__item {
    display: table-cell;
  }
  .m-content{
    width:100% !important;
  }
}
.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-sm-5 {
  -webkit-box-flex: 0;
  -ms-flex: 0 0 41.66667%;
  flex: 0 0 41.66667%;
  max-width: 41.66667%;
}
.col-sm-7 {
  -webkit-box-flex: 0;
  -ms-flex: 0 0 58.3333%;
  flex: 0 0 58.3333%;
  max-width: 58.3333%;
}
.table th, .table td {
  padding: 0.25rem !important;
}
.m-invoice-2{
  font-size: 13px !important;
  font-weight: 500 !important;
  font-family: "Poppins" !important;
  color: black;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body table tbody tr td {
  font-size: 13px !important;
  font-weight: 500 !important;
  font-family: "Poppins" !important;
  color: black;
}
table tbody tr td {
  font-size: 13px !important;
  font-weight: 500 !important;
  font-family: "Poppins" !important;
  color: black;
}
table thead tr th {
  font-size: 13px !important;
  font-weight: 500 !important;
  font-family: "Poppins" !important;
  color: black;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body table thead tr th {
  color: black;
}
</style>
<style type="text/css">

body {
  font-size: 20pt !important;
  line-height: 25px;
  /* font-size: 13px;
  font-weight: 300;
  font-family: Poppins;
  -ms-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  line-height: 20px;
  padding:0px;
  margin:0px;
  line-height:18px; */
}
.item_table td{
  padding: .75rem !important;
}
.item_table th{
  white-space: nowrap;
  padding: .75rem !important;
}


.page-header, .page_table .page-header-space {
  height: 300px;
}
.page-footer, .page-footer-space {
  height: 120px;
}
.page-footer {
  position: fixed;
  bottom: 0;
  width: 100%;
}
.page-header {
  position: fixed;
  top: 0mm;
  width: 100%;
}

.page {
  page-break-after: always;
}
@page {
  margin: 20mm
}

@media print {
  thead {display: table-header-group;}
  tfoot {display: table-footer-group;}
  button {display: none;}
  body {margin: 0;}

}
* {
  -webkit-print-color-adjust: exact !important;   /* Chrome, Safari, Edge */
  color-adjust: exact !important;                 /*Firefox*/
}

</style>


<body class="">
  <div class="m-grid__item m-grid__item--fluid m-wrapper" id="content">
    <div class="m-content" style="height:auto; float:left; width:100% !important;">
      <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 } ?>
        <h4 style="text-align:right;margin-right:10px">Tax Invoice</h4>
        <div class="m-invoice-2" style="padding-bottom: 0px">
          <div class="m-invoice__wrapper">
            <div class="m-invoice__head" >
              <div class="m-invoice__container m-invoice__container--centered">
                <div class="m-invoice__logo" style="padding-top: 0rem;">
                  <a href="#"></a>
                </div>
                <div class="row">
                  <div class="col-xs-7 col-sm-7 col-md-7" >
                    <span class="m-invoice__desc" style="text-align: left;padding: 1rem 0 0 0 !important;">
                      <span class="m-invoice__subtitle"></span>
                      <table>
                        <thead>
                          <tr>
                            <th>Customer Name:</th>
                            <th>&nbsp;<?php echo $client_data->client_name?></th>
                          </tr>
                          <tr>
                            <th>PO BOX:</th>
                            <th>&nbsp;<?php if($client_data->po_box_no!=''){ echo $client_data->po_box_no.", ";} ?><?php echo $invoice->client_address?></th>
                          </tr>
                          <tr>
                            <th>Tel:</th>
                            <th>&nbsp;<?php echo $client_data->client_contact?></th>
                          </tr>
                          <tr>
                            <th>TRN:</th>
                            <th>&nbsp;<?php echo $client_data->tax_no?></th>
                          </tr>
                          <tr>
                            <th>Atn:</th>
                            <th>&nbsp;<?php echo $client_data->contact_person?></th>
                          </tr>
                        </thead>
                      </table>
                    </div>
                    <div class="col-xs-5 col-sm-5 col-md-5 ">
                      <span class="m-invoice__desc" style="text-align: left;padding: 1rem 0 1rem 0 !important;float:right">
                        <span class="m-invoice__subtitle">
                          <table >
                            <tr>
                              <td >Invoice No</td>
                              <td>:</td>
                              <td>&nbsp;<?php echo $invoice_no?></strong></span>
                              </td>
                            </tr>
                            <?php if($invoice->reference_no!=''){ ?>
                              <tr>
                                <td>Ref No</td>
                                <td>:</td>
                                <td>&nbsp;<?php echo $invoice->reference_no; ?></td>
                              </tr>
                            <?php } ?>
                            <tr>
                              <td>Invoice Date</td>
                              <td>:</td>
                              <td>&nbsp;<?php echo date('d-m-Y',strtotime($invoice->invoice_date)); ?></td>
                            </tr>
                            <tr>
                              <td>LPO No</td>
                              <td>:</td>
                              <td>&nbsp;<?php echo $invoice->lpo_no?></td>
                            </tr>
                            <tr>
                              <td>TRN No</td>
                              <td>:</td>
                              <td>&nbsp;<?php echo $this->config->item('company_tax_no') ?></td>
                            </tr>
                            <tr>
                              <td>Customer ID</td>
                              <td>:</td>
                              <td>&nbsp;<?php echo $invoice->client_id?></td>
                            </tr>
                          </table>
                        </span>
                      </div>
                      <div class="col-xs-12 col-sm-12 col-md-12" >
                        <table >
                          <tr>
                            <td>Project</td>
                            <td>:</td>
                            <td>&nbsp;<?php echo $invoice->work_name; ?></td>
                          </tr>
                        </table>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="page-footer">
            <?php if($this->config->item('purchase_order_footer')!=''){ ?>
              <img class="letter_head_img" style="width: 100%;" src="<?php echo base_url().'uploads/company/'.$this->config->item('purchase_order_footer')?>" />
            <?php } ?>
          </div>
          <table class="page_table" style="width:100%">
            <thead>
              <tr>
                <td>
                  <!--place holder for the fixed-position header-->
                  <div class="page-header-space"></div>
                </td>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>
                  <div class="page" >
                    <div class="m-invoice-2" style="padding-bottom: 0px">
                      <div class="m-invoice__wrapper">
                        <br/>
                        <div class="m-invoice__body m-invoice__body--centered" style="padding-top:0px !important">
                          <div class="row">
                            <div class="col-xs-12 col-sm-12 col-md-12" >
                              <div class="table-responsive" style="width:100%">
                                <table class="table m-table table-bordered item_table" style="width:100%;font-size: 13px !important;
                                font-weight: 500 !important;
                                font-family: "Poppins" !important;">
                                <thead>
                                  <tr>
                                    <?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="";
                                    } ?>
                                    <th style="text-align:center">SNo</th>
                                    <th  style="text-align: center;width:50%">Description</th>
                                    <th  style="text-align:center">Qty</th>
                                    <th  style="text-align:center">Unit</th>
                                    <th  style="text-align:center">Invoice<br/>Amount</th>
                                    <?php if($this->config->item('Tax_tax_enabled')==1){ ?>
                                      <th style="text-align:center"><?php echo $this->config->item('Tax_tax_name') ?><br/>Rate %</th>
                                      <th style="text-align:center"> <?php echo $this->config->item('Tax_tax_name') ?><br/>Amount</th>
                                    <?php } ?>
                                    <th  style="text-align:center">Payable<br/>Amount</th>
                                  </tr>
                                </thead>
                                <tbody>
                                  <?php
                                  $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'));
                                    ?>
                                    <tr>
                                      <td style="text-align:center"><?php echo $n++?></td>
                                      <td style="text-align: left"><?php echo $row->name?></td>
                                      <td style="text-align:center"><?php echo $row->quantity?></td>
                                      <td style="text-align:center"><?php echo $row->unit_name?></td>
                                      <td style="text-align:center;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('Tax_tax_enabled')==1 ){ ?>
                                        <td style="text-align:center"><?php echo $row->tax_percentage?>%</td>
                                        <td style="text-align:center;white-space:nowrap"><?php echo $this->config->item('currency_format')->formatCurrency($row->item_tax_amount,$this->config->item('Currency_currency_shortname'));?></td>

                                      <?php }?>
                                      <td style="text-align:center"><?php echo $this->config->item('currency_format')->formatCurrency($row->total_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                    </tr>
                                    <?php
                                  endforeach;
                                  if(sizeof($invoice_items)<15){
                                    for($i=1;$i<(15-sizeof($invoice_items));$i++){ ?>
                                      <tr>
                                        <td>&nbsp;</td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <?php if($this->config->item('Tax_tax_enabled')==1){ ?>
                                          <td></td>
                                          <td></td>

                                        <?php }?>
                                        <td></td>
                                      </tr>
                                    <?php }
                                  }
                                  ?>
                                </tbody>
                              </table>
                            </div>
                          </div>
                        </div>
                      </div>
                      <div class="m-invoice__body m-invoice__body--centered" style="padding-top:0px !important">
                        <div class="row">
                          <div class="col-sm-8 col-md-8 col-lg-8">

                          </div>
                          <div class="col-sm-4 col-md-4 col-lg-4">
                            <table class="table item_table">
                              <thead>
                                <tr>
                                  <th>Total Invoice Amount</th>
                                  <th><?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>
                                <tr>
                                  <th>Total <?php echo $this->config->item('Tax_tax_name')?> Amount</th>
                                  <th><?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>
                                <tr>
                                  <th>Total Payable Amount</th>
                                  <th><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></th>
                                </tr>
                              </thead>
                            </table>
                          </div>

                        </div>
                        <div class="row">
                          <div class="col-sm-12 col-md-12 col-lg-12">
                            <table class="table m-table">
                              <thead>
                                <tr>
                                  <th style="text-align:left;font-size: 13px !important;
                                  font-weight: 500 !important;
                                  font-family: "Poppins" !important;">
                                  Total In Words : <?php echo $invoice->receivable_amount_in_words ?>
                                </th>
                              </tr>
                            </thead>
                          </table>
                        </div>
                      </div>
                      <div class="m-invoice__table  m-invoice__table--centered" >
                        <div class="row">
                          <div class="col-sm-12 col-md-12">
                            <table class="table m-table" style="width:100%">
                              <thead>
                                <tr>
                                  <td style="border:0px !important">Del. Note No & Date</td>
                                  <td style="border:0px !important">:</td>
                                  <td style="border:0px !important" colspan="4">&nbsp;<?php echo $invoice->delivery_note?></td>
                                </tr>
                                <tr>
                                  <td style="border:0px !important">Works Carried at</td>
                                  <td style="border:0px !important">:</td>
                                  <td style="border:0px !important" colspan="4">&nbsp;<?php echo $invoice->works_carried_at?></td>
                                </tr>
                                <tr>
                                  <td style="border:0px !important">Payment Terms</td>
                                  <td style="border:0px !important">:</td>
                                  <td style="border:0px !important" colspan="4">&nbsp;<?php echo $invoice->payment_terms?></td>
                                </tr>
                                <tr>
                                  <td style="border:0px !important">Other Terms</td>
                                  <td style="border:0px !important">:</td>
                                  <td style="border:0px !important" colspan="4">&nbsp;<?php echo $invoice->other_terms?></td>
                                </tr>
                                <tr>
                                  <td style="border:0px !important">Remarks</td>
                                  <td style="border:0px !important">:</td>
                                  <td style="border:0px !important" colspan="4">&nbsp;<?php echo $invoice->invoice_notes?></td>
                                </tr>
                                <tr>
                                  <td style="border:0px !important">Bank Name</td>
                                  <td style="border:0px !important">:</td>
                                  <td style="border:0px !important;width:40%">&nbsp;<?php echo $invoice->bank_name?></td>
                                  <td style="border:0px !important">Branch Name</td>
                                  <td style="border:0px !important">:</td>
                                  <td style="border:0px !important">&nbsp;<?php echo $invoice->bank_branch?></td>
                                </tr>
                                <tr>
                                  <td style="border:0px !important">Account Number</td>
                                  <td style="border:0px !important">:</td>
                                  <td style="border:0px !important">&nbsp;<?php echo $invoice->bank_account_no?></td>
                                  <td style="border:0px !important">IBAN no</td>
                                  <td style="border:0px !important">:</td>
                                  <td style="border:0px !important">&nbsp;<?php echo $invoice->bank_ifsc?></td>
                                </tr>
                              </thead>
                            </table>
                            <table class="table m-table" style="width:100%">
                              <thead>
                                <tr>
                                  <td style="border:0px !important"><h6 style="text-align:center">Customer Name, Signature & Stamp</h6></td>
                                  <td style="border:0px !important"><h6 style="text-align:center">Authorized Signature</h6></td>
                                </tr>
                              </thead>
                            </table>

                          </div>
                        </div>

                      </div>
                    </div>


                  </div>
                </div>

              </div>

            </td>
          </tr>
        </tbody>
        <tfoot>
          <tr>
            <td>
              <!--place holder for the fixed-position footer-->
              <div class="page-footer-space"></div>
            </td>
          </tr>
        </tfoot>
      </table>
    </div>
  </div>
  <script src="<?php echo $this->config->item('Template_template_file_url'); ?>template/assets/vendors/base/vendors.bundle.js" type="text/javascript"></script>
  <script src="<?php echo $this->config->item('Template_template_file_url'); ?>template/assets/demo/default/base/scripts.bundle.js" type="text/javascript"></script>

  <!--end::Base Scripts -->


  <script>
  jQuery(document).ready(function() {
    window.print();
  });
</script>
<style>
</style>

</body>
</html>
