<?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>Purchase Date</td>  
    <td>Party Name</td>
    <td>Quantity</td>
    <td>Rate</td>
    <td>Total Amount</td>
	<td>Status</td>
    <td align="center">Edit</td>
    <td align="center">Del</td>
  </tr>
<?php

$vendorid='';
$fromdate='';
$todate='';

if(isset($_REQUEST['vendorid'])){
$vendorid=$_REQUEST['vendorid'];
}
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_purchase_booking where 1 ";

if($vendorid!=''){
$sq_arr.=" and purchase_partyid = '".$vendorid."' ";
}

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


/*if($sdate_12!=''){
$sq_arr.=" and date='".$sdate."' ";
}*/
$sq_arr.=" order by purchase_bookid 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;
}
$array=mysql_query($sq_arr);
if($array && mysql_num_rows($array)>0){
$pagecnt=$start;$grandTot = 0;
while($res=mysql_fetch_array($array))
{
//------------get the clientname-----------------------//
$pagecnt++;

  ?> 
<tr>
    <td><?php echo $pagecnt;?></td>
   <?php 
		$pur_partyid = $res['purchase_partyid'];	
        $sq_ven=mysql_query("select * from cf_reseller where reseller_id = '$pur_partyid'");
    	$resven=mysql_fetch_array($sq_ven);
    	
    	
    ?>	
     <td><?php echo date(('d-m-Y'),strtotime($res['purchase_bookdate']));?></td>     
     <td><?php echo $resven['res_name'];?></td>
     <td><?php echo $res['purchase_quantity'];?></td>
	  <td><?php echo $res['purchase_rate'];?></td>
     <td><?php echo $res['purchase_total'];?></td>
	 <td><?php  if($res['purchase_status'] == 0) { echo "Pending"; }else { echo "Completed"; }?></td>
  	

   <td align="center" class="tr_td_b"><a href="purchase_booking.php?lab_id=<?=$res['purchase_bookid']?>"><img src="images/edit.png" title="edit"></a></td>
   
   <td align="center" class="tr_td_r" ><a href="purchase_booking_list.php?pur_del=<?=$res['purchase_bookid']?>&del=delete" onClick="return confirm('Do you really want to delete this field?');"><img src="images/delete.png" title="delete"></a></td>
  </tr>
  <?php 
    }}else{?>
	 <tr>
    <td class="errorMessage"  style="border-right:0px;border-bottom:0px; "><font color="#FF0000">No Records Found</font></td></tr>
	<? }
  ?>
 

  
</table>
  
   <div align="right" style="padding-top:10px;"><?=$pagination?></div>