<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
      <div class="main my-0">
        <div class="row mt-3 mx-0">
          <div class="col-md-12">
            <h3><?php echo $pgheading;?></h3>
          </div>
         
        </div>
        
        <div class="container_fluid mt-2 px-3">
		<form name="frmsearch" method="get" action="outlet/orders/product/<?php echo encodeValue($rsrcid);?>/">
         <table class="webforms sttbl bg-light my-0 table-responsive-sm">
          <tr>
           <td class="pr-0" width="20%"><input type="text" name="search" size="20" value="<?php echo $this->input->get("search");?>" placeholder="search "></td>
          
           <td>
           	<button class="btn btn-dark pt-0 pb-1 px-2">Go</button>
           </td>
          </tr>
         </table>
       </form>
         <?php
			if($this->session->flashdata("message")!="" && $this->session->flashdata("alerttype")!="")
			{
         ?>
         <div class="text-center my-4">
			 <span class="alert <?php echo $this->session->flashdata("alerttype");?>"><?php echo $this->session->flashdata("message");?></span>
         </div>
         <?php
			}
         ?>
         
        <table class="table mt-2 table-responsive-sm">
	
                <thead>
                	<tr>
                    	<th width="5%">SRNo.</th>
                    	<th width="10%">Customer</th>                    	
                    	<th width="10%">Invoice NO.</th>
                    	<th width="10%">Invoice Date</th>
                    	<th width="10%" class="text-right">Order Amt</th>
                    	<th width="10%" class="text-right">QTY</th>
                    	<th width="10%" class="text-right">Price</th>
                    	<th width="10%" class="text-right">Product Amt</th>

                    	<th width="15%" class="text-center">Action</th>
                    </tr>
                    </thead>
                    <tbody>
					<?php
					$totalqty = 0;
					$totalprice = 0;
					$totalproductamount = 0;
					if(is_array($results) && count(array_filter($results))>0)
					{
						$rowindex = 0;
						foreach($results as $row)
						{
							$rowindex++;
							$productamount =($row->fld_qty*$row->fld_price)


					?>
                    <tr>
						<td class="text-center"><?php echo $rowindex;?>.</td>                    	       
						<td><?php echo $row->fld_name;?></td>
						<td><?php echo $row->fld_billno;?></td>              
						<td><?php echo date("d-M-Y", strtotime($row->fld_billdate));?></td>           
						<td align="right"><?php echo $row->fld_netamount;?></td>
						<td align="right"><?php echo round($row->fld_qty);?></td>
						<td align="right"><?php echo $row->fld_price;?></td>
						<td align="right"><?php echo $productamount;?></td>
						<td align="center">
						<a href="billing/view/<?php echo encodeValue($row->fld_id);?>" class="fancybox fancybox.iframe" aria-label="View" title="View"><span class="fa fa-eye fa-lg"></span></a><span class="ml-2"></span></a>
						</td>
                    </tr>
                    <?php
						$totalqty += $row->fld_qty;
						$totalprice += $row->fld_price;
						$totalproductamount += $productamount;
						}
					?>
                    <tr>
						          
						<th colspan="5" class="text-right">Total:</th>
						<th class="text-right"><?php echo round($totalqty,2);?></th>
						<th class="text-right"><?php echo number_format($totalprice,2);?></th>
						<th class="text-right"><?php echo number_format($totalproductamount,2);?></th>
						<th align="center">&nbsp;</th>
                    </tr>
					<?php							
					}
					else
					{
                    ?>
                    <tr><td colspan="9" style="text-align:center">Record not found!</td></tr>
                    <?php
					}
                    ?>
                    
                    
                    </tbody>
                </table>
                 
	         <div class="clearfix"></div>
          
        </div>
        <div id="paginate" class="row">
			<?php echo $this->ajax_pagination->create_links(); ?>
        </div>
            
        </div>
