<?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>Kopra kg</td>    
    <td>Oil Conversion Kg</td>    
    <td>pinnaku Conversion Kg</td>    
	<td>Sack No</td>
    <td>Damaged</td>
    <!--<td align="center">Print</td>
    <td align="center">Edit</td>-->
    <td align="center">Delete</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;
}

  $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>
       
    <?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['kopra_kg'];?></td>     
     <td><?php echo $res['conv_oil'];?></td>     
     <td><?php echo $res['conv_pinnaku'];?></td>      
     <td><?php echo $res['sack_no'];?></td>
     <td><?php echo $res['damaged_qty'];?></td>
     <?php /*?><td align="center" class="tr_td_b"><a href="changepassword.php?user_main=<?=$res['kop_pur_id']?>"><img src="images/edit.png" title="print"></a></td>
   <td align="center" class="tr_td_b"><a href="add-purchase-kopra.php?pur_mainid=<?=$res['kop_pur_id']?>"><img src="images/edit.png" title="edit"></a></td><?php */?>
   
   <td align="center" class="tr_td_r" ><a href="kopra_purchase_list.php?pur_del=<?=$res['kop_pur_id']?>&del=delete" onClick="return confirm('Do you really want to delete this field?');"><img src="images/delete.png" title="delete"></a></td>
   </tr>
  <?php 
  	  $totkopra_kg += $res['kopra_kg'];
	  $totconv_oil += $res['conv_oil'];
	  $totconv_pinnaku += $res['conv_pinnaku'];
	  $totsack_no += round($res['sack_no']);
	  $totdamaged_qty += $res['damaged_qty'];
    }}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><?=$totkopra_kg?></td>     
     <td><?=$totconv_oil?></td>     
     <td><?=$totconv_pinnaku?></td>      
     <td><?=$totsack_no?></td>
     <td><?=$totdamaged_qty?></td>
     <td></td>
     <td></td>
     
  </tr>
 
  
</table>
  
   <div align="right" style="padding-top:10px;"><?=$pagination?></div>