<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title><?= $this->config->item('company_name')?></title>
  </head>
<style type="text/css">

  body {
    font-family:Tahoma, Geneva, sans-serif;
    font-style:normal;
    font-weight:normal;
    font-variant:normal;
    font-size:10px;
    padding:0px;
    margin:0px;
    /* line-height:8px; */
  }
  .item_table td{
    padding: .75rem !important;
  }
  .item_table th{
    white-space: nowrap;
    padding: .75rem !important;
  }
  .table thead th {
    border-top: 2px solid #f4f5f8 !important;
  }
  @media print
  {
    #print, .print_hide_div
    {
      display: none !important;

    }
  }
  @media print {
    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;

      }

    }

    @media print { tr.bg_S { background-color: rgb(224, 224, 224) !important; -webkit-print-color-adjust: exact; } } @media print { .bg_S th { background-color: rgb(224, 224, 224) !important; } }
    @media print { tr.bg_H { background-color: rgb(224, 224, 224) !important; -webkit-print-color-adjust: exact; } } @media print { .bg_H th { background-color: rgb(224, 224, 224) !important; } }
    @media print { tr.bg_L { background-color: #7f7f7f !important; -webkit-print-color-adjust: exact; } } @media print { .bg_L th { background-color: #7f7f7f !important; } }
    @media print { tr.bg_N { background-color: rgba(94, 94, 94, 0.52) !important; -webkit-print-color-adjust: exact; } } @media print { .bg_N th { background-color: rgba(94, 94, 94, 0.52) !important; } }


  </style>

  <body>
    <div class="m-content">
      <div class="m-portlet m-portlet--full-height">


       <div class="m-portlet__body m-portlet__body--no-padding">
        <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 " >

         <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" style="width: 100%;">
              <div class="m-invoice__logo" style="padding-top: 3rem;">
                <a href="#">
                </a>
              </div>
              <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: 1rem 0 1rem 0 !important;line-height: 2;">
                    <span class="m-invoice__subtitle"><strong>Bill From.</strong></span>
                    <span><?= nl2br($invoice->invoice_from)?></span>
                  </span>
                </div>
                <div class="col-md-5" style="margin-left:-50px;">
                  <div class="m-invoice__logo" style="padding-top: 1rem;">
                    <a href="#">
                      <h2>INVOICE #<?php echo $invoice->invoice_id?></h2>
                      <img src="<?php echo base_url()?>uploads/company/logo.png">
                    </a>
                  </div>
                </div>
              <div class="m-invoice__items" style="padding: 2rem 2rem 3rem 2rem;">
                <div class="m-invoice__item" style="line-height: 1.1;">
                  <span class="m-invoice__subtitle">BILL TO</span>
                  <span class="m-invoice__text"><?php echo $invoice->client_name?></span>
                  <span class="m-invoice__text"><?php echo $invoice->client_address?></span>
                  <span class="m-invoice__text"><?php echo $invoice->client_email?></span>
                  <span class="m-invoice__text"><?php echo $invoice->client_contact?></span>
                  <span class="m-invoice__text">Tax No: <?php echo $invoice->tax_no?></span>
                </div>
                <div class="m-invoice__item" style="text-align: center">
                  <span class="m-invoice__subtitle">BILL DATE</span>
                  <span class="m-invoice__text"><?php echo date('d-m-Y',strtotime($invoice->invoice_date))?></span>
                </div>
                <div class="m-invoice__item" style="text-align: right">
                  <span class="m-invoice__subtitle">BILL NO</span>
                  <span class="m-invoice__text"><?php echo $invoice->reference_no?></span>
                </div>
              </div>
            </div>
          </div>
          <div class="m-invoice__body m-invoice__body--centered" style="min-height: 200px;width: 100%;">
            <div class="table-responsive">
              <table class="table m-table table-bordered item_table">
                <thead>
                  <?php if($this->config->item('Client_Payment_client_payment_invoice_template')==1){ ?>
                  <tr>
                    <th width="7%">Sl No</th>
                    <th width="31%" style="text-align: left">Description</th>
                    <th width="10%">Quantity</th>
                    <th width="10%">Price</th>
                    <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 } ?>
                </thead>
                <tbody id="item_body">
                  <?php
                  $n = 1;
                  foreach($invoice_items as $row):
                    if($this->config->item('Client_Payment_client_payment_invoice_template')==1){
                    ?>
                    <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_currency_format')." ".$this->config->item('currency_format')->formatCurrency($row->price,$this->config->item('Currency_currency_shortname'));?></td>
                      <td><?php echo $this->config->item('Currency_currency_format')." ".$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')==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><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($row->total_amount,$this->config->item('Currency_currency_shortname'));?></td>
                    </tr>
                  <?php }
                  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;
                  }
                   ?>
                   <tr>
                     <td style="border-bottom: 1px solid #c5c5c5"></td>
                     <td colspan="4" class="m--font-danger" style="border-bottom: 1px solid #c5c5c5"><span style="text-align: right;font-weight: 300;margin-right: 52%;color: #000;white-space:nowrap">SUB TOTAL :</span> <strong><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($sub_total,$this->config->item('Currency_currency_shortname'));?></strong></td>
                   </tr>
                </tbody>
              </table>
            </div>
          </div>
          <div class="m-invoice__body m-invoice__body--centered" style="width: 100%;">
            <div class="m-invoice__table  m-invoice__table--centered table-responsive">
              <table class="table">
                <thead>
                  <tr>
                    <th>TAXABLE AMT</th>
                    <th><?php if($this->config->item('Tax_tax_splitting')==1){ echo "Total ";}?>TAX %</th>
                    <th><?php if($this->config->item('Tax_tax_splitting')==1){ echo "Total ";}?>TAX AMT</th>
                    <th>DISCOUNT</th>
                    <th>ROUND</th>
                    <th>NET TOTAL</th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <td><strong><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->invoice_taxable_amount,$this->config->item('Currency_currency_shortname'));?></strong></td>
                    <td><strong><?php echo $invoice->tax_percentage." % (".$invoice_tax_inclusive.")";?></strong></td>
                    <td><strong><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->invoice_tax_amount,$this->config->item('Currency_currency_shortname'));?></strong></td>
                    <td><strong><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->invoice_discount_amount,$this->config->item('Currency_currency_shortname'));?></strong></td>
                    <td><strong><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($invoice->invoice_round_amount,$this->config->item('Currency_currency_shortname'));?></strong></td>
                    <td class="m--font-danger"><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>
                </tbody>
              </table>
            </div>
            <?php if($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">
                    <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 } ?>
          </div>

          <div class="" style="width: 100%;margin: 0 auto;padding: 2rem 0 0 0;">
            <div class="" style="margin-bottom: 100px">
              <table id="payment_view_table" class="table m-table nowrap table-header-fixed table-striped table-bordered table-hover table-header-fixed" width="100%">
                <thead style="font-weight: 500;font-size: 1.1rem;">
                  <tr>
                    <th>Sl No</th>
                    <th>Received Date</th>
                    <th>Received Amount</th>
                    <th>Credit Acc</th>
                    <th>Remarks</th>
                    <th>Created By</th>
                    <th>Created Date</th>
                  </tr>
                </thead>
                <tbody style="font-weight: 600;font-size: 1.1rem;">
                  <?php
                  $sl_no=0;
                  foreach($invoice_payments as $row):
                    $sl_no++;

                    ?>
                    <tr >
                      <td><?php echo $sl_no?></td>
                      <td><?php echo date('d-m-Y',strtotime($row->tr_date))?></td>
                      <td><?php echo $this->config->item('Currency_currency_format'); ?> <?php echo $row->tr_amount?>/-</td>
                      <td><?php echo $row->credit_account?></td>
                      <td><?php echo $row->tr_remarks?></td>
                      <td><?php echo $row->created_user?></td>
                      <td><?php if ($this->config->item('UI_hide_created_date_field')==0){echo date('d-m-Y',strtotime($row->created_date));}else{ echo '';}?></td>
                    </tr>
                    <?php
                  endforeach;
                  ?>
                </tbody>
              </table>
            </div>
            <div class="m-invoice__table  m-invoice__table--centered table-responsive" >
              <table class="table">
                <thead>
                  <tr>
                    <th width="50%">PAYMENT STATUS :
                      <label class="m--font-danger" style="line-height: 2;">
                        <strong>
                          <?php
                          if($invoice->payment_status == 1){
                            echo "RECEIVED";
                          }elseif($invoice->balance_amount>0 && $invoice->total_paid>0) {
                            echo "PARTIALLY RECEIVED";
                          }else {
                            echo "NOT RECEIVED";
                          }
                          ?>

                        </strong>
                      </label>
                    </th>
                    <th width="30%" style="vertical-align: top">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 $invoice->balance_amount;
                        ?>
                      </strong>
                    </th>
                  </tr>

                </thead>

              </table>
            </div>
            <div class="m-invoice__table  m-invoice__table--centered table-responsive" style="margin-bottom: 100px">
              <table class="table">
                <thead>
                  <tr>
                    <th width="50%">
                    </th>

                    <th width="30%" style="vertical-align: top">Signature :  </th>
                  </tr>
                </thead>
              </table>
            </div>
          </div>
          <div class="row">
            <div class="col-md-12" style="border-right: 1px solid #ebedf2;">
              <span class="m-invoice__desc" style="text-align: left;padding: 1rem 0 1rem 0 !important;line-height: 1.1;">
                <!-- <span class="m-invoice__subtitle">Account Details</span><br> -->

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

        </div>
      </div>
    </form>
  </div>
</div>
<?php //$this->view("modules/include_modals/modal_bills");?>
</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>

<script>
  jQuery(document).ready(function() {

  });
</script>
</body>
</html>
