<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Purchase Order - #<?php echo $order_data->order_id.' ['.$order_data->supplier_name.'] ['.$order_data->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">LOCAL PURCHASE ORDER</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>
                      <span>Supplier: <?php echo $order_data->supplier_name?></span>
                      <span><?php echo $order_data->supplier_address?></span>
                      <span><?php if($order_data->supplier_phone!=''){ echo "Phone: ".$order_data->supplier_phone;} ?></span>
                        <span><?php if($order_data->supplier_email!=''){ echo "Email: ".$order_data->supplier_email;} ?></span>
                          <span><?php if($order_data->supplier_tax_no!=''){ echo "TRN No: ".$order_data->supplier_tax_no;}?></span>
                          </span>
                        </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 >LPO No</td>
                                  <td>:</td>
                                  <td>&nbsp;<?php echo $order_data->reference_no."/".$order_data->order_id; ?></td>
                                </tr>
                                <tr>
                                  <td>Date</td>
                                  <td>:</td>
                                  <td>&nbsp;<?php echo date('d-m-Y',strtotime($order_data->order_date)); ?></td>
                                </tr>
                                <tr>
                                  <td>Service</td>
                                  <td>:</td>
                                  <td>&nbsp;<?php echo $order_data->service?></td>
                                </tr>
                                <tr>
                                  <td>TRN No</td>
                                  <td>:</td>
                                  <td>&nbsp;<?php echo $this->config->item('company_tax_no') ?></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 $order_data->location_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($order_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 && $this->config->item('Tax_tax_splitting')==1 && $this->config->item('Tax_purchase_tax_type')=='item_wise'  && $this->config->item('Purchase_order_tax_enabled')==1){
                                        $rowspan="rowspan='2'";
                                      }else{
                                        $rowspan="";
                                      } ?>
                                      <th <?php echo $rowspan ?>>SNo</th>
                                      <th <?php echo $rowspan ?> style="text-align: left;">Description</th>
                                      <th <?php echo $rowspan ?> >Qty</th>
                                      <th <?php echo $rowspan ?> >Unit</th>
                                      <th <?php echo $rowspan ?> >Unit Price</th>
                                      <?php if($this->config->item('Tax_tax_enabled')==1 && $this->config->item('Tax_tax_splitting')==1 && $this->config->item('Tax_purchase_tax_type')=='item_wise'  && $this->config->item('Purchase_order_tax_enabled')==1){ ?>
                                        <th colspan="2" style="text-align: center"><?php if($this->config->item('Tax_tax_splitting')==1){ echo "Total ";}?><?php echo $this->config->item('Tax_tax_name') ?></th>
                                        <?php if($tax_splitting==1){ ?>
                                          <th colspan="2" style="text-align: center"><?php echo $this->config->item('Tax_tax1_name')?></th>
                                          <th colspan="2" style="text-align: center"><?php echo $this->config->item('Tax_tax2_name')?></th>
                                          <th colspan="2" style="text-align: center"><?php echo $this->config->item('Tax_tax3_name')?></th>
                                        <?php } ?>
                                      <?php } ?>
                                      <th <?php echo $rowspan ?> >Total Amount</th>
                                    </tr>
                                    <tr>
                                      <?php if($this->config->item('Tax_tax_enabled')==1 && $this->config->item('Tax_tax_splitting')==1 && $this->config->item('Tax_purchase_tax_type')=='item_wise'  && $this->config->item('Purchase_order_tax_enabled')==1){ ?>
                                        <th>%</th>
                                        <th>Amt</th>
                                        <?php if($tax_splitting==1){ ?>
                                          <th>%</th>
                                          <th>Amt</th>
                                          <th>%</th>
                                          <th>Amt</th>
                                          <th>%</th>
                                          <th>Amt</th>
                                        <?php } ?>
                                      <?php } ?>
                                    </tr>
                                  </thead>
                                  <tbody>
                                    <?php
                                    $n = 1;
                                    $description_colspan=7;
                                    if($this->config->item('Tax_tax_enabled')==1 && $this->config->item('Tax_purchase_tax_type')=='item_wise' && $this->config->item('Purchase_order_tax_enabled')==1){
                                      $description_colspan=15;
                                    }
                                    if ($this->config->item('Purchase_delivery_challan') == 1) {
                                      $description_colspan++;
                                    }
                                    foreach($order_items as $row):
                                      $row->tax1_amount = round($row->unit_price*$row->quantity*$row->tax1_percent/100,$this->config->item('Currency_amount_decimals_2'));
                                      $row->tax2_amount = round($row->unit_price*$row->quantity*$row->tax2_percent/100,$this->config->item('Currency_amount_decimals_2'));
                                      $row->tax3_amount = round($row->unit_price*$row->quantity*$row->tax3_percent/100,$this->config->item('Currency_amount_decimals_2'));
                                      ?>
                                      <tr>
                                        <td><?php echo $n++?></td>
                                        <td style="text-align: left"><?php echo $row->material_name?> <?php echo $row->description?></td>
                                        <td><?php echo $row->quantity?></td>
                                        <td><?php echo $row->unit_name?></td>
                                        <td style="white-space:nowrap"><?php echo $this->config->item('currency_format')->formatCurrency($row->unit_price,$this->config->item('Currency_currency_shortname'));?></td>
                                        <?php if($this->config->item('Tax_tax_enabled')==1 && $this->config->item('Tax_tax_splitting')==1 && $this->config->item('Tax_purchase_tax_type')=='item_wise' && $this->config->item('Purchase_order_tax_enabled')==1){ ?>
                                          <td><?php echo $row->tax_percentage?>%</td>
                                          <td style="white-space:nowrap"><?php echo $this->config->item('currency_format')->formatCurrency($row->item_tax_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                          <?php if($tax_splitting==1){ ?>
                                            <td><?php echo $row->tax1_percent?>%</td>
                                            <td style="white-space:nowrap"><?php echo $this->config->item('currency_format')->formatCurrency($row->tax1_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                            <td><?php echo $row->tax2_percent?>%</td>
                                            <td style="white-space:nowrap"><?php echo $this->config->item('currency_format')->formatCurrency($row->tax2_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                            <td><?php echo $row->tax3_percent?>%</td>
                                            <td style="white-space:nowrap"><?php echo $this->config->item('currency_format')->formatCurrency($row->tax3_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                          <?php }?>
                                        <?php }?>
                                        <td><?php echo $this->config->item('currency_format')->formatCurrency(($row->total_amount-$row->item_tax_amount),$this->config->item('Currency_currency_shortname'));?></td>
                                      </tr>
                                      <?php
                                    endforeach;
                                    if(sizeof($order_items)<15){
                                      for($i=1;$i<(15-sizeof($order_items));$i++){ ?>
                                        <tr>
                                          <td>&nbsp;</td>
                                          <td></td>
                                          <td></td>
                                          <td></td>
                                          <td></td>
                                          <?php if($this->config->item('Tax_tax_enabled')==1 && $this->config->item('Tax_tax_splitting')==1 && $this->config->item('Tax_purchase_tax_type')=='item_wise' && $this->config->item('Purchase_order_tax_enabled')==1){ ?>
                                            <td></td>
                                            <td></td>
                                            <?php if($tax_splitting==1){ ?>
                                              <td></td>
                                              <td></td>
                                              <td></td>
                                              <td></td>
                                              <td></td>
                                              <td></td>
                                            <?php }?>
                                          <?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 Taxable Amount</th>
                                        <th><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($order_data->taxable_amount,$this->config->item('Currency_currency_shortname'));?></th>
                                      </tr>
                                      <tr>
                                        <th><?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($order_data->tax_amount,$this->config->item('Currency_currency_shortname'));?></th>
                                      </tr>
                                      <tr>
                                        <th>Grand Total Amount</th>
                                        <th><?php echo $this->config->item('Currency_currency_format')." ".$this->config->item('currency_format')->formatCurrency($order_data->total_est_amount,$this->config->item('Currency_currency_shortname'));?></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 $order_data->total_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">Required By</td>
                                          <td style="border:0px !important">:</td>
                                          <td style="border:0px !important">&nbsp;<?php echo $order_data->requiredby?></td>
                                        </tr>
                                        <tr>
                                          <td style="border:0px !important">Site Address</td>
                                          <td style="border:0px !important">:</td>
                                          <td style="border:0px !important">&nbsp;<?php echo $order_data->work_location?></td>
                                        </tr>
                                        <tr>
                                          <td style="border:0px !important">Delivery Mode</td>
                                          <td style="border:0px !important">:</td>
                                          <td style="border:0px !important">&nbsp;<?php echo $order_data->delivery_mode?></td>
                                        </tr>
                                        <tr>
                                          <td style="border:0px !important">Payment Terms</td>
                                          <td style="border:0px !important">:</td>
                                          <td style="border:0px !important">&nbsp;<?php echo $order_data->payment_terms?></td>
                                        </tr>
                                        <tr>
                                          <td style="border:0px !important">Remarks</td>
                                          <td style="border:0px !important">:</td>
                                          <td style="border:0px !important">&nbsp;<?php echo $order_data->remarks?></td>
                                        </tr>
                                        <tr>
                                          <td style="border:0px !important">Contact Person</td>
                                          <td style="border:0px !important">:</td>
                                          <td style="border:0px !important">&nbsp;<?php echo $order_data->contact_person_name?> - <?php echo $order_data->contact_person_phone?></td>
                                        </tr>
                                      </thead>
                                    </table>
                                    <h6 style="text-align:center">This is computer generated LPO, hence no signature required</h6>
                                  </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>
