<?php
include("../include/config.php");
require_once "../include/Database_functions.php";
?>

  <table  border="0" cellspacing="0" cellpadding="0" class="tableList"  style="margin-left:20px; ">
<tr class="heading">
     <td>No</td>    
    <td>Brand</td>	
    <td>Litre</td>
	<td>Date</td>
	<td>Quantity</td>
	<td>Box</td>   	
   </tr>
<?php

$vendortype ='';
$fromdate='';
$todate='';
$fromdate1='';
$todate1='';
if(isset($_REQUEST['vendortype'])){
$vendortype=$_REQUEST['vendortype'];
}

if(isset($_REQUEST['fromdate'])){
$fromdate=$_REQUEST['fromdate'];
$fromdate1 = date('Y-m-d', strtotime($fromdate));
}

if(isset($_REQUEST['todate'])){
$todate=$_REQUEST['todate'];
$todate1 = date('Y-m-d', strtotime($todate));
}
$i=1;

$sq_arr="select sum(pack_qty) as pack_qty,sum(pack_box) as pack_box,brand_name,sku_adddate,liter_qty from cf_package_sub as pack join cf_brand as brand on pack.brnch_id = brand.brand_id join cf_liter as litre on pack.litre_id = litre.liter_id where 1 ";

$sq_arr="select sum(packqty) as pack_qty,sum(packbox) as pack_box,brand_name,sku_adddate,liter_qty from cf_sku_stock as sku join cf_brand as brand on sku.brnd_id = brand.brand_id join cf_liter as litre on sku.ltre_id = litre.liter_id where 1 ";


if($vendortype!='')
{
$sq_arr.="and brnd_id='".$vendortype."'";
}
if($fromdate1!='' && $todate1!='')
{
$sq_arr.="and sku_adddate between '".$fromdate1."' and '".$todate1."' ";
}

$sq_arr.=" group by sku.brnd_id,sku.ltre_id order by brand.brand_name asc ";
$query=$sq_arr;
//echo $query;
$function="Searchdate";
include("../paging.php");
$sq_arr.=" LIMIT $start, $limit";

if(isset($_REQUEST['page'])){
$page=$_REQUEST['page'];
}else{
$page=1;
}

    $totkopra_kg = '';
  $totconv_oil = '';
  $totconv_pinnaku = '';
  $totsack_no = '';
  $totdamaged_qty = '';

 
$array=mysql_query($sq_arr);
if($array && mysql_num_rows($array)>0){
$pagecnt=$start;
while($res=mysql_fetch_array($array))
{
//------------get the clientname-----------------------//
$pagecnt++;

  ?> 
<tr>
     <td><?php echo $pagecnt;?></td>
     <td><?php echo $res['brand_name'];?></td>    
     <td><?php echo $res['liter_qty'];?></td> 
	 <td><?php echo date('d-m-Y',strtotime($res['sku_adddate']));?></td> 
	 <td><?php echo $res['pack_qty'];?></td>     
	 <td><?php echo $res['pack_box'];?></td>     
    </tr>
  <?php 
	 
    }}else{?>
	 <tr>
    <td class="errorMessage"  style="border-right:0px;border-bottom:0px; "><font color="#FF0000">No Records Found</font></td></tr>
	<? }
  ?>
  
  <tr class="heading">
     <td></td>
     <td>Total</td>    
     <td><?=$totsack_no?></td>        
   </tr>
 
  
</table>
  
   <div align="right" style="padding-top:10px;"><?=$pagination?></div>