<?php 
  $header_file=APPPATH.'views/include/header.php';
  require($header_file);
  $sidenav_file=APPPATH.'views/include/sidenav.php';
  require($sidenav_file); ?>
<!-- BEGIN: Content-->
    <div class="app-content content">
      <div class="content-overlay"></div>
      <div class="content-wrapper">
        <div class="content-header row">
          <div class="content-header-left col-md-6 col-12 mb-2 breadcrumb-new">
            <h3 class="content-header-title mb-0 d-inline-block"> Invoice </h3>
            <div class="row breadcrumbs-top d-inline-block">
              <div class="breadcrumb-wrapper col-12">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item"><a href="#">Home</a>
                  </li>
                  <li class="breadcrumb-item"><a href="#">Invoice </a>
                  </li>
                  <li class="breadcrumb-item active"> Invoice Receipt
                  </li>
                </ol>
              </div>
            </div>
          </div>
         
        </div>
        <div class="content-body"><section class="card">
  <div id="invoice-template" class="card-body p-4">
    
    <!-- Invoice Items Details -->
    <div id="invoice-items-details" class="pt-2">
      <div class="row">
        <div class="table-responsive col-12">
          <table class="table table-bordered ">
            <thead>
        <?php
          foreach($invoice_receipt as $invr)
        ?>
        <h4 class="heading_a uk-margin-bottom" style="text-align:center!important;"><strong><?php echo $_SESSION['username'] ?> - Invoice Order View<span class="pull-right"><?php echo $invr->user_name; ?></span> <!--<span class="hidden-print" style="text-align:right"><i class="md-icon material-icons" id="print">&#xE8ad;</i></span>--></strong></h4>
            <h6 class="heading_a uk-margin-bottom" style="text-align:center!important;"><strong>GST NO.- Bhattas Foods Pvt Ltd. 29AACEB0808Q1ZC</strong> </h6>
            <thead>
              <tr>
                <th colspan="3" >Invoice  No: <?php echo $invr->invoice_no; ?></th>
                <th colspan="3" >Invoice Date: <?php echo $invr->invoice_date; ?></th>
                <th colspan="4">Outlet Name: <?php echo $invr->outlet_name; ?></th>
              </tr>
              <tr>
                <td class="sub_heading">Sl.No</td>
                <td class="sub_heading">Product Name</td>
                <td class="sub_heading">UOM</td>
                <td class="sub_heading">Quantity</td>
                <td class="sub_heading">Present Stock</td>
                <td class="sub_heading">Price</td>
                <td class="sub_heading">Tax</td>
                <td class="sub_heading">Tax Amount</td>
                <td class="sub_heading">Amount</td>
                <td class="sub_heading">Remarks</td>
              </tr>
            </thead>
            <tbody>
              <?php
               $count = 1;
                
                  foreach($invoice_receipt_item as $iitem){
                  ?>
                  <tr>
                    <td><?php echo $count; ?></td>
                    <td><?php echo $iitem->item_name; ?></td>
                    <td><?php echo $iitem->uom; ?></td>
                    <td><?php echo $iitem->required_qty; ?></td>
                    <td><?php echo $iitem->present_stock; ?></td>
                    <td><?php echo $iitem->item_price; ?></td>
                    <td><?php echo $iitem->tax; ?></td>
                    <td><?php echo $iitem->tax_amount; ?></td>
                    <td><?php echo $iitem->total_amount; ?></td>
                    <td><?php echo $iitem->remarks; ?></td>
                  </tr>
                <?php $count++; } ?>
                 
              <?php
                
                 foreach($invoice_total_sum as $itotal){ 
                ?>
                <tr>
                  <td colspan="7" >Total Amount</td>
                  <td ><?php echo $itotal->sum_tax_amount; ?></td>
                  <td ><?php echo $itotal->sum_amount; ?></td>
                  <td></td>
                </tr>
                <?php
                }
              ?>              
            </tbody>
          </table>
        </div>
      </div>
  
    </div>

    <!-- Invoice Footer -->
    <div id="invoice-footer">
      <div class="row">
        <div class="col-sm-7 col-12 text-center text-sm-left">
          <!--<h6>Terms & Condition</h6>
          <p>Test pilot isn't always the healthiest business.</p>-->
        </div>
        <div class="col-sm-5 col-12 text-right">
          <button type="button" id="print_receipt" class="btn btn-info print_receipt  btn-lg my-1"><i class="fa ft-printer"></i></button>
        </div>
      </div>
    </div>
    <!-- Invoice Footer -->

  </div>
</section>
</section>
<!-- // Basic form layout section end -->
        </div>
      </div>
    </div>
    <?php //require('include/theme_customizer.php');?>

<?php 
  $footer_file=APPPATH.'views/include/footer.php';
  require($footer_file);
?>
<script>
  $("#print_receipt").click(function() {
    window.print();
    setTimeout("closePrintView()", 50);
  });
  function closePrintView() {
    window.location = '<?php echo site_url('Invoice/invoiceList/'.$submod_id.'');?>';
  } 
</script>
  