<?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>Vendor</td>	  
    <td>Sack No</td>	
   </tr>
<?php

$vendortype ='';
$fromdate='';
$todate='';

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 * from cf_kopra_purchase where 1 ";
if($vendortype!=''){
$sq_arr.=" and kop_vendor_id = '".$vendortype."' ";
}

if($fromdate!="" && $todate!=""){
$sq_arr.=" and add_date between '$fromdate1' and '$todate1'";
}


/*if($sdate_12!=''){
$sq_arr.=" and date='".$sdate."' ";
}*/
$sq_arr.=" order by kop_pur_id desc ";
$query=$sq_arr;
//echo $query;
$function="Searchdate";
include("../paging.php");
$sq_arr.=" LIMIT $start, $limit";

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

  
$totsack_no = '';
 
$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>       
    <?php 
		$vendorid = $res['kop_vendor_id'];	
        $sq_ven=mysql_query("select * from cf_reseller where reseller_id = '$vendorid'");
    	$resven=mysql_fetch_array($sq_ven);
    ?>	
     <td><?php echo $resven['res_name'];?></td>
     <td><?php echo $res['sack_no'];?></td>      
   </tr>
  <?php 
  	$totsack_no += round($res['sack_no']);
	 
    }}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>