<?php $this->view("includes/Inc_pagehead");?>
<!-- Page Styles Goes Here-->

<style>
.m-invoice-2 .m-invoice__wrapper .m-invoice__body table thead tr th {
  color: #000000;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body table tbody tr td {
  color: #000000;
}
.item_table td{
  padding: .75rem !important;
}
.item_table th{
  white-space: nowrap;
  padding: .75rem !important;
}
.table thead th {
  border-top: 2px solid #00000091 !important;
}
.table thead th {
  border: 2px solid #00000091 !important;
}
.table tbody td {
  border: 2px solid #00000091 !important;
}
.payment-table tbody td{
  border-top: 2px solid #00000091 !important;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__head .m-invoice__container.m-invoice__container--centered {
  width: 90%;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body.m-invoice__body--centered {
  width: 95%;
  padding: 1rem 1rem 1rem 1rem;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body table thead tr th {
  padding: 0.2rem 0.5rem 0.3rem 0.5rem !important
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body table tbody tr td {
  padding: 0.2rem 0.5rem 0.3rem 0.5rem !important
}
.m-invoice-2{
  line-height: 20px !important;
}

@media print
{
  body * {
    visibility: hidden;
  }
  .m-portlet__body * {
    visibility: visible;
    overflow: visible !important;
  }
  .table-bordered td{
    padding: .75rem !important;
  }
  .table-bordered th{
    white-space: nowrap;
    padding: .75rem !important;
  }
  .table-bordered .table thead th {
    border-top: 2px solid #00000091 !important;
  }
  .table thead th {
    border-top: 2px solid #00000091 !important;
  }
  .table tbody td {
    border: 2px solid #00000091 !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%;
    padding: 0rem !important;
  }
  .m-invoice__container{
    width: 100%;
  }
  .m-content{
    padding: 0px !important;
  }
  body{
    background-color: white !important;
  }
  .m-body .m-content {
    min-height: 200px !important;
  }
  #print, .print_hide_div
  {
    display: none !important;
    height: 0px !important;
    padding: 0px !important;
    margin: 0px !important;
  }
  .m-portlet .m-portlet__head {
    display: none !important;
    height: 0px !important;
  }
  .m-subheader  {
    display: none !important;
    height: 0px !important;
  }
  .m-header--fixed .m-body {
    padding-top: 0px !important;
    padding-bottom: 0px !important;
  }
  .m-header {
    height: 0px !important;
  }
  .m-portlet {
    margin-bottom: 0px !important;
  }
  .m-footer--push.m-aside-left--enabled:not(.m-footer--fixed) .m-aside-right, .m-footer--push.m-aside-left--enabled:not(.m-footer--fixed) .m-wrapper {
    margin-bottom: 0px !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; } }

.no-border thead th {
  border: none !important;
  border-top: none !important;
}
@page {
  size: auto;
  margin: 0;
}
</style>
<?php $this->view("includes/Inc_navigation");?>
<div class="m-grid__item m-grid__item--fluid m-wrapper">
  <!-- BEGIN: Subheader -->
  <div class="m-subheader ">
    <div class="d-flex align-items-center">
      <div class="mr-auto">
        <h3 class="m-subheader__title m-subheader__title--separator">
          <?php echo $this->config->item('Quotation_sales_estimation_title') ?>
        </h3>
        <ul class="m-subheader__breadcrumbs m-nav m-nav--inline">
          <li class="m-nav__item m-nav__item--home">
            <a href="#" class="m-nav__link m-nav__link--icon">
              <i class="m-nav__link-icon la la-home"></i>
            </a>
          </li>
          <li class="m-nav__separator">
            -
          </li>
          <li class="m-nav__item">
            <a href="<?php echo base_url().'dashboard'?>" class="m-nav__link">
              <span class="m-nav__link-text">
                Home
              </span>
            </a>
          </li>
          <li class="m-nav__separator">
            -
          </li>
          <li class="m-nav__item">
            <a href="<?php echo base_url().'sales_invoice' ?>" class="m-nav__link">
              <span class="m-nav__link-text">
                <?php echo $this->config->item('Quotation_sales_estimation_title') ?>
              </span>
            </a>
          </li>


        </ul>
      </div>
      <div>

      </div>
    </div>
  </div>
  <!-- END: Subheader -->
  <div class="m-content">
    <div class="m-portlet m-portlet--full-height">
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
            </h3>
          </div>
        </div>
        <div class="m-portlet__head-tools" >
          <!-- <a href="<?php //echo base_url().'sales_invoice/add?estimation_id='.$estimation_data->estimation_id ?>" style="margin-left: 5px;margin-right: 5px" class="btn m-btn--gradient-from-info m-btn--gradient-to-success  m-btn  m-btn--icon m-btn--air m-btn--pill">
          <span>
          <i class="fa fa-plus-circle"></i>
          <span>
          Create Sales Invoice
        </span>
      </span>
    </a> -->
    <a style="margin-left: 5px;margin-right: 5px" href="javascript:;" onclick="window.print()" id="btn_print_invoice" class="btn m-btn--gradient-from-warning m-btn--gradient-to-danger  m-btn  m-btn--icon m-btn--air m-btn--pill">
      <span>
        <i class="la la-print"></i>
        <span>
          Print <?php echo $this->config->item('Quotation_sales_estimation_title') ?>
        </span>
      </span>
    </a>
    <?php if($this->session->userdata('user_role')!='auditor'){ ?>
      <?php
      if($estimation_data->balance_amount > 0){?>
        <a style="margin-left: 5px;margin-right: 5px" data-bill-type="sales_invoice" data-bill-id="<?php echo $estimation_data->estimation_id?>" id="btn_receive_payment_add" data-toggle="modal"  href="#receive_payment_add_modal" class="btn m-btn--gradient-from-success m-btn--gradient-to-focus  m-btn  m-btn--icon m-btn--air m-btn--pill">
          <span>
            <i class="la la-plus"></i>
            <span>
              Receive Payment
            </span>
          </span>
        </a>
      <?php } ?>
    <?php } ?>

  </div>
</div>
<div class="m-portlet__body m-portlet__body--no-padding" id="print_view">
  <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="">
        <table class="" style="width:100%;margin-bottom:0px !important">
          <thead>
            <tr>
              <th style="width:20%;padding: 0px !important;"><img style="height:200px" src="<?php echo base_url()."uploads/quotation_workorder/".$estimation_data->workorder_logo?>"></th>
              <th colspan="3" style="padding: 0px !important;">
                <table style="width:100%">
                  <tr>
                    <td colspan="2" style="text-align:center;text-decoration:underline;text-decoration-color:rgb(255, 204, 0);"><h1>QUOTATION</h1></td>
                  </tr>
                  <tr>
                    <td style="text-align:left;width:70%">
                      <?php if($estimation_data->estimation_branch_id!=0){ ?>
                        <h5><?php echo $estimation_data->branch_name ?></h5>
                        <span><?php echo nl2br($estimation_data->branch_address) ?></span>
                      <?php }else{ ?>
                        <h5><?php echo $this->config->item('company_name')?></h5>
                        <?php echo preg_replace('#(<br */?>\s*)+#i', '<br />',$this->config->item('company_address'))?>
                      <?php } ?>
                    </td>
                    <td style="float:right;padding: 0px !important;">
                      <table style="width:100%"  class="table m-table table-bordered item_table">
                        <tr>
                          <td style="text-align:center"><h5>Quotation No</h5></td>
                        </tr>
                        <tr>
                          <td style="text-align:center;width:60% !important"><h5><?php echo $estimation_data->estimation_no?></h5></td>
                        </tr>
                        <br/>
                        <table style="width:100% "  class="table m-table table-bordered item_table">
                          <tr>
                            <td style="text-align:center"><h5>Date</h5></td>
                          </tr>
                          <tr>
                            <td style="text-align:center;width:60% !important"><h5><?php echo date('d-m-Y',strtotime($estimation_data->estimation_date))?></h5></td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                </th>
              </tr>
            </thead>
          </table>
          <table class="table m-table table-bordered item_table" style="width:100%;margin-bottom:0px !important">
            <thead>
              <tr>
                <th style="width:50%;padding: 0px !important;vertical-align: top">
                  <label style="margin:10px"><strong>Buyer Details</strong></label>
                  <table class="no-border">
                    <thead>
                      <tr>
                        <th style="text-align:left"><strong>Customer</strong></th>
                        <th>:</th>
                        <th colspan="4" style="text-align:left"><strong><?php echo $estimation_data->buyer_name?></strong></th>
                      </tr>
                      <tr>
                        <th style="text-align:left;vertical-align:top"><strong>Address</strong></th>
                        <th style="vertical-align:top">:</th>
                        <th style="text-align:left;white-space: break-spaces;" colspan="4"><?php echo $estimation_data->buyer_address?></th>
                      </tr>
                      <tr>
                        <th style="text-align:left"><strong>Phone</strong></th>
                        <th>:</th>
                        <th style="text-align:left" colspan="4"><?php echo $estimation_data->buyer_phone?></th>
                      </tr>
                      <tr>
                        <th style="text-align:left"><strong>GSTIN</strong></th>
                        <th>:</th>
                        <th style="text-align:left" colspan="4"><strong><?php echo $estimation_data->buyer_taxno?></strong></th>
                      </tr>
                      <tr>
                        <th style="text-align:left"><strong>State</strong></th>
                        <th>:</th>
                        <th style="text-align:left"><?php echo $estimation_data->state_name?></th>
                        <th style="text-align:left"><strong>State Code</strong></th>
                        <th>:</th>
                        <th style="text-align:left"><?php echo $estimation_data->state_code?></th>
                      </tr>
                    </thead>
                  </table>
                </th>
                <th style="text-align:left">
                  <label style="margin:10px;text-align:left"><strong>Buyer Shipping Address</strong></label>
                  <table class="no-border">
                    <thead>
                      <tr>
                        <th style="text-align:left"><strong>Customer</strong></th>
                        <th>:</th>
                        <th colspan="4" style="text-align:left"><strong><?php echo $estimation_data->buyer_name?></strong></th>
                      </tr>
                      <tr>
                        <th style="text-align:left;vertical-align:top"><strong>Address</strong></th>
                        <th style="vertical-align:top">:</th>
                        <th style="text-align:left;white-space: break-spaces;" colspan="4"><?php echo $estimation_data->buyer_address?></th>
                      </tr>
                      <tr>
                        <th style="text-align:left"><strong>Phone</strong></th>
                        <th>:</th>
                        <th style="text-align:left" colspan="4"><?php echo $estimation_data->buyer_phone?></th>
                      </tr>
                      <tr>
                        <th style="text-align:left"><strong>GSTIN</strong></th>
                        <th>:</th>
                        <th style="text-align:left" colspan="4"><strong><?php echo $estimation_data->buyer_taxno?></strong></th>
                      </tr>
                      <tr>
                        <th style="text-align:left"><strong>State</strong></th>
                        <th>:</th>
                        <th style="text-align:left"><?php echo $estimation_data->state_name?></th>
                        <th style="text-align:left"><strong>State Code</strong></th>
                        <th>:</th>
                        <th style="text-align:left"><?php echo $estimation_data->state_code?></th>
                      </tr>
                    </thead>
                  </table>
                </th>
              </tr>
            </thead>
            <tbody>

            </tbody>
          </table>
          <table class="table m-table table-bordered item_table" style="width:100%;margin-bottom:0px !important">
            <?php
            $tax0_have = $tax1_have = $tax2_have = $tax3_have = $colspan = 0;
            foreach($estimation_items as $row):
              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){
                $tax0_have = 1;
              }
            endforeach;
            if($colspan == 0){
              $colspan = 1;
            }
            ?>
            <thead>
              <tr>
                <th rowspan="2" style="width:5% !important">Sl<br/>No</th>
                <th rowspan="2" style="text-align: left;width:22% !important">Item Name</th>
                <th rowspan="2" >HSN Code</th>
                <th rowspan="2" >Rate</th>
                <th rowspan="2" >Qty</th>
                <th rowspan="2" >UoM</th>
                <th rowspan="2" >Disc.</th>
                <th rowspan="2" >Net</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 } ?>
                <th rowspan="2" >Amount</th>
              </tr>
              <tr>
                <?php if($tax1_have==1){ ?>
                  <th>%</th>
                  <th>Amt</th>
                <?php } ?>
                <?php if($tax2_have==1){ ?>
                  <th>%</th>
                  <th>Amt</th>
                <?php } ?>
                <?php if($tax3_have==1){ ?>
                  <th>%</th>
                  <th>Amt</th>
                <?php } ?>
              </tr>
            </thead>
            <tbody>
              <?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;
                ${'tax_percent_'.$row->tax_id} = 0;
              }
              $total_tax0_amt = $total_tax1_amt = $total_tax2_amt = $total_tax3_amt = 0;
              foreach($estimation_items as $row):
                ${'tax_percent_'.$row->tax_id} = 1;
                $row->tax1_amount = round($row->taxable_amount*$row->tax1_percent/100,$this->config->item('Currency_amount_decimals_2'));
                $row->tax2_amount = round($row->taxable_amount*$row->tax2_percent/100,$this->config->item('Currency_amount_decimals_2'));
                $row->tax3_amount = round($row->taxable_amount*$row->tax3_percent/100,$this->config->item('Currency_amount_decimals_2'));
                if($row->tax1_percent==0 && $row->tax2_percent==0 && $row->tax3_percent==0){
                  $total_tax0_amt += $row->taxable_amount;
                }
                $total_tax1_amt += $row->tax1_amount;
                $total_tax2_amt += $row->tax2_amount;
                $total_tax3_amt += $row->tax3_amount;
                ?>
                <tr>
                  <td style="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->material_name?><br/><span style="font-style: italic"><?php echo $row->description?></span></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->unit_sale_price,$this->config->item('Currency_currency_shortname'));?></td>
                  <td style="white-space: nowrap;border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"><?php echo $row->quantity?></td>
                  <td style="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 $this->config->item('currency_format')->formatCurrency($row->discount_amount,$this->config->item('Currency_currency_shortname'));?></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->taxable_amount,$this->config->item('Currency_currency_shortname'));?></td>
                  <?php if($tax1_have==1){ ?>
                    <td style="white-space: nowrap;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($row->tax1_amount,$this->config->item('Currency_currency_shortname'));?></td>
                  <?php } ?>
                  <?php if($tax2_have==1){ ?>
                    <td style="white-space: nowrap;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($row->tax2_amount,$this->config->item('Currency_currency_shortname'));?></td>
                  <?php } ?>
                  <?php if($tax3_have==1){ ?>
                    <td style="white-space: nowrap;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($row->tax3_amount,$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->total_amount,$this->config->item('Currency_currency_shortname'));?></td>
                </tr>
                <?php
                ${'total_taxable_amt_'.$row->tax_id} += $row->taxable_amount;
                $total_qty += $row->quantity;
              endforeach;
              if(sizeof($estimation_items)<10){ //Add Blank Columns
                for($i=1;$i<(10-sizeof($estimation_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>
                    <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>
                    <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($tax1_have==1){ ?>
                      <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 } ?>
                    <?php if($tax2_have==1){ ?>
                      <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 } ?>
                    <?php if($tax3_have==1){ ?>
                      <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 } ?>
                    <td style="border-top: 0px !important;border-bottom: 0px !important;vertical-align:top"></td>
                  </tr>
                <?php }
              }
              ?>
            </tbody>
            <tfoot>
              <tr>
                <td colspan="4" style="text-align:right;border:2px solid #00000091 !important;"><strong> Total Qty : </strong></td>
                <td style="text-align:right;border:2px solid #00000091 !important;"><strong><?php echo $total_qty?></strong></td>
                <td style="border:2px solid #00000091 !important;"colspan="<?php echo $colspan+4?>"></td>
              </tr>
            </tfoot>
          </table>
          <table class="table  m-table table-bordered item_table" style="width:100%;margin-bottom:0px !important">
            <thead>

            </thead>
            <tbody>
              <tr>
                <td rowspan="10" style="width:65%;border-top: 2px solid #b7b7b7 !important;padding: 0px !important;border-bottom:0px !important">
                  <table class="table  m-table table-bordered item_table">
                    <caption style="color:black">TAX DETAILS</caption>
                    <thead>
                      <tr>
                        <th style="text-align: center">Class</th>
                        <th style="text-align: center">Taxable Amt</th>
                        <?php if($tax1_have==1){ ?>
                          <th style="text-align: center"><?php echo $this->config->item('Tax_tax1_name')?></th>
                          <th style="text-align: center">Amount</th>
                        <?php } ?>
                        <?php if($tax2_have==1){ ?>
                          <th style="text-align: center"><?php echo $this->config->item('Tax_tax2_name')?></th>
                          <th style="text-align: center">Amount</th>
                        <?php } ?>
                        <?php if($tax3_have==1){ ?>
                          <th style="text-align: center"><?php echo $this->config->item('Tax_tax3_name')?></th>
                          <th style="text-align: center">Amount</th>
                        <?php } ?>
                      </tr>
                    </thead>
                    <tbody>
                      <?php
                      $tax_percent = $this->config->item('Tax_tax_percent');
                      foreach ($tax_percent as $row){
                        if(${'tax_percent_'.$row->tax_id} == 1){
                          if($row->tax1_percent==0 && $row->tax2_percent==0 && $row->tax3_percent==0){ ?>
                            <tr>
                              <td style="text-align: center"><?php echo $this->config->item('Tax_tax_name')." ".$row->tax_percentage."%" ?></td>
                              <td style="text-align: center"><?php echo ${'total_taxable_amt_'.$row->tax_id}; ?></td>
                              <?php if($tax1_have==1){ ?>
                                <td style="text-align: center"><?php echo $row->tax1_percent."%" ?></td>
                                <td style="text-align: center"><?php echo $this->config->item('currency_format')->formatCurrency(((${'total_taxable_amt_'.$row->tax_id})*$row->tax1_percent/100),$this->config->item('Currency_currency_shortname')); ?></td>
                              <?php } ?>
                              <?php if($tax2_have==1){ ?>
                                <td style="text-align: center"><?php echo $row->tax2_percent."%" ?></td>
                                <td style="text-align: center"><?php echo $this->config->item('currency_format')->formatCurrency(((${'total_taxable_amt_'.$row->tax_id})*$row->tax2_percent/100),$this->config->item('Currency_currency_shortname')); ?></td>
                              <?php } ?>
                              <?php if($tax3_have==1){ ?>
                                <td style="text-align: center"><?php echo $row->tax3_percent."%" ?></td>
                                <td style="text-align: center"><?php echo $this->config->item('currency_format')->formatCurrency(((${'total_taxable_amt_'.$row->tax_id})*$row->tax3_percent/100),$this->config->item('Currency_currency_shortname')); ?></td>
                              <?php } ?>
                            </tr>
                          <?php }
                          if($row->tax1_percent!=0 || $row->tax2_percent!=0 || ($tax3_have==1 && $row->tax3_percent!=0) ){ ?>
                            <tr>
                              <td style="text-align: center"><?php echo $this->config->item('Tax_tax_name')." ".$row->tax_percentage."%" ?></td>
                              <td style="text-align: center"><?php echo ${'total_taxable_amt_'.$row->tax_id}; ?></td>
                              <?php if($tax1_have==1){ ?>
                                <td style="text-align: center"><?php echo $row->tax1_percent."%" ?></td>
                                <td style="text-align: center"><?php echo $this->config->item('currency_format')->formatCurrency(((${'total_taxable_amt_'.$row->tax_id})*$row->tax1_percent/100),$this->config->item('Currency_currency_shortname')); ?></td>
                              <?php } ?>
                              <?php if($tax2_have==1){ ?>
                                <td style="text-align: center"><?php echo $row->tax2_percent."%" ?></td>
                                <td style="text-align: center"><?php echo $this->config->item('currency_format')->formatCurrency(((${'total_taxable_amt_'.$row->tax_id})*$row->tax2_percent/100),$this->config->item('Currency_currency_shortname')); ?></td>
                              <?php } ?>
                              <?php if($tax3_have==1){ ?>
                                <td style="text-align: center"><?php echo $row->tax3_percent."%" ?></td>
                                <td style="text-align: center"><?php echo $this->config->item('currency_format')->formatCurrency(((${'total_taxable_amt_'.$row->tax_id})*$row->tax3_percent/100),$this->config->item('Currency_currency_shortname')); ?></td>
                              <?php } ?>
                            </tr>
                          <?php }
                        }
                      } ?>
                    </tbody>
                  </table>
                  <table class="no-border" style="width:100%">
                    <thead>
                      <tr>
                        <th colspan="4" style="white-space: inherit;font-size: 1.2rem;text-align:center;border-bottom:2px solid #00000091 !important"><?php echo $estimation_data->receivable_amount_in_words ?></th>
                      </tr>
                      <tr>
                        <th style="text-align:left">Bank Name</th>
                        <th style="text-align:left;width:40%;min-width:40%"><?php echo $estimation_data->bank_name ?></th>
                      </tr>
                      <tr>
                        <th style="text-align:left">Branch</th>
                        <th style="text-align:left"><?php echo $estimation_data->bank_branch ?></th>
                      </tr>
                      <tr>
                        <th style="text-align:left">Acc No</th>
                        <th style="text-align:left"><?php echo $estimation_data->bank_account_no ?></th>
                      </tr>
                      <tr>
                        <th style="text-align:left"><?= $this->config->item('bank_ifsc_name')?></th>
                        <th style="text-align:left"><?php echo $estimation_data->bank_ifsc ?></th>
                        <th style="text-align:left"><h6>Receivers Signature</h6></th>
                        <th></th>
                      </tr>
                    </thead>
                  </table>
                </td>
                <td style="text-align:left;border:none !important"><strong>NET TOTAL</strong></td>
                <td style="border:none !important;border-left:2px solid #00000091 !important;border-right:2px solid #00000091 !important"><strong><?php echo $this->config->item('currency_format')->formatCurrency($estimation_data->net_total,$this->config->item('Currency_currency_shortname'));?></strong></td>
              </tr>
              <tr>
                <td style="text-align:left;border:none !important"><?php echo $this->config->item('Tax_tax1_name')?></td>
                <td style="border:none !important;border-left:2px solid #00000091 !important;border-right:2px solid #00000091 !important"><?php echo $this->config->item('currency_format')->formatCurrency($total_tax1_amt,$this->config->item('Currency_currency_shortname'));?></td>
              </tr>
              <tr>
                <td style="text-align:left;border:none !important"><?php echo $this->config->item('Tax_tax2_name')?></td>
                <td style="border:none !important;border-left:2px solid #00000091 !important;border-right:2px solid #00000091 !important"><?php echo $this->config->item('currency_format')->formatCurrency($total_tax2_amt,$this->config->item('Currency_currency_shortname'));?></td>
              </tr>
              <tr>
                <td style="text-align:left;border:none !important"><?php echo $this->config->item('Tax_tax3_name')?></td>
                <td style="border:none !important;border-left:2px solid #00000091 !important;border-right:2px solid #00000091 !important"><?php echo $this->config->item('currency_format')->formatCurrency($total_tax3_amt,$this->config->item('Currency_currency_shortname'));?></td>
              </tr>
              <tr>
                <td style="text-align:left;border:none !important">&nbsp;</td>
                <td style="border:none !important;border-left:2px solid #00000091 !important;border-right:2px solid #00000091 !important">&nbsp;</td>
              </tr>
              <tr>
                <td style="text-align:left;border:none !important"><strong>GRAND TOTAL</strong></td>
                <td style="border:none !important;border-left:2px solid #00000091 !important;border-right:2px solid #00000091 !important"><strong><?php echo $this->config->item('currency_format')->formatCurrency($estimation_data->net_total+$estimation_data->tax_amount,$this->config->item('Currency_currency_shortname'));?></strong></td>
              </tr>
              <tr>
                <td style="text-align:left;border:none !important">Other Charges</td>
                <td style="border:none !important;border-left:2px solid #00000091 !important;border-right:2px solid #00000091 !important"><?php echo $this->config->item('currency_format')->formatCurrency(0,$this->config->item('Currency_currency_shortname'));?></td>
              </tr>
              <tr>
                <td style="text-align:left;border:none !important">Other Discount</td>
                <td style="border:none !important;border-left:2px solid #00000091 !important;border-right:2px solid #00000091 !important"><?php echo $this->config->item('currency_format')->formatCurrency(0,$this->config->item('Currency_currency_shortname'));?></td>
              </tr>
              <tr>
                <td style="text-align:left;border:none !important">Round Off</td>
                <td style="border:none !important;border-left:2px solid #00000091 !important;border-right:2px solid #00000091 !important"><?php echo $this->config->item('currency_format')->formatCurrency($estimation_data->round_amount,$this->config->item('Currency_currency_shortname'));?></td>
              </tr>
              <tr>
                <td style="text-align:left;border:none !important;border-bottom:2px solid #00000091 !important;font-size:1.8rem !important;"><strong>EST AMOUNT</strong></td>
                <td style="border:none !important;border-left:2px solid #00000091 !important;border-right:2px solid #00000091 !important;border-bottom:2px solid #00000091 !important;font-size:1.8rem !important;"><strong><?php echo $this->config->item('currency_format')->formatCurrency($estimation_data->receivable_amount,$this->config->item('Currency_currency_shortname'));?></strong></td>
              </tr>
            </tbody>
          </table>
          <table style="width:100%">
            <thead>
              <tr>
                <th style="border-left:2px solid #00000091 !important;border-bottom:2px solid #00000091 !important;">
                  <strong>Declaration :<br/><br/>Certified that the Particulars given above are true and correct</strong>
                </th>
                <th style="text-align:right;border-right:2px solid #00000091 !important;border-bottom:2px solid #00000091 !important;">
                  <h5 style="margin-top:10px">
                    <?php if($estimation_data->estimation_branch_id!=0){ ?>
                      <?php echo $estimation_data->branch_name ?></h3>
                    <?php }else{ ?>
                      <?php echo $this->config->item('company_name') ?>
                    <?php } ?>
                  </h5><br/><br/><br/>
                  <strong>Authorised Signatory</strong>
                </th>
              </tr>
            </thead>
          </table>
          <?php
          $terms = unserialize($estimation_data->terms_and_conditions);
          if($terms!='' && $terms!=null) {?>
          <table class="table m-table table-bordered item_table" style="width:100%;margin-top:20px !important">
            <thead>
              <tr>
                <th style="text-align:center">Terms & Conditions</th>
              </tr>
            </thead>
            <tbody>
              <tbody>
                <?php
                $count = sizeof($terms);
                $i = 1;
                foreach ($terms as $key => $value5) { ?>
                  <tr>
                    <td style="border-top:none !important;"><?php echo $i.". ".$value5['description'] ?></td>
                  </tr>
                  <?php $i++;
                }
                ?>
              </tbody>
            </tbody>
          </table>
        <?php } ?>
        </div>


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

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

<!-- end:: Page -->

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


<!--begin::Page Snippets -->
<?php $this->view("modules/include_scripts/bill_scripts");?>
<script>
//    Toggle Sidebar
// $("#m_aside_left_minimize_toggle").addClass("m-brand__toggler--active");
// $("#body").addClass("m-brand--minimize m-aside-left--minimize");

$("#sales_estimation_menu").addClass('m-menu__item--active m-menu__item--open');
$("#sales_estimation_menu2").addClass('m-menu__item--active');

$("#page_title").text("<?php echo $this->config->item('Quotation_sales_estimation_title') ?> - <?php echo $estimation_data->estimation_no."-".$estimation_data->buyer_name?>")
</script>
<script>
$('body').on('click', '#sales_estimation_transaction_delete_btn', function() {
  var no = $(this).closest('tr').children('td');
  $('#transaction_id_delete').val(no.eq(11).text());
});
$('#payment_view_table').DataTable({
  "scrollX" : true,
  scrollX:!0, scrollCollapse:!0,
  dom:"<'row'<'col-sm-6 text-left'><'col-sm-6 text-right'f>>\n\t\t\t<'row'<'col-sm-12'tr>>\n\t\t\t<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7 dataTables_pager'lp>>", // horizobtal scrollable datatable
  "paging":   false,
  "ordering": false,
  "info":     false,
  searching: false
});
$(".form_submit_btn").click(function (e) {

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

</script>
