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

  <table  border="0" cellspacing="0" cellpadding="0" class="tableList"  style="margin-left:20px; ">
  
  <?php
  $vendortype ='';
$fromdate='';
$todate='';
$prdtype='';
$grandtotpayable ='';
if(isset($_REQUEST['vendortype'])){
$vendortype=$_REQUEST['vendortype'];
}
if(isset($_REQUEST['prdtype'])){
$prdtype=$_REQUEST['prdtype'];
}

$i=1;


$sq_arr="SELECT  cf_acountspayable.*,cf_reseller.res_name from  cf_acountspayable
inner join cf_reseller on cf_reseller.reseller_id= cf_acountspayable.vendorid
";


if($vendortype!=''){
$sq_arr.=" and cf_acountspayable.vendorid = '".$vendortype."' ";
}
/*if($prdtype!=''){
$sq_arr.=" and cf_oilpurchase.pur_prd_id = '".$prdtype."' ";
}*/

/*if($sdate_12!=''){
$sq_arr.=" and date='".$sdate."' ";
}*/
//$sq_arr.=" order by pur_id desc ";
$nolimitqry=$query=$sq_arr;

$function="Searchdate";
include("../paging.php");
$sq_arr.=" LIMIT $start, $limit";

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

$totalpayable=0;
$nolimitarray=mysql_query($nolimitqry);
if($nolimitarray && mysql_num_rows($nolimitarray)>0)
{
while($nolimitres=mysql_fetch_array($nolimitarray))
{
$totalpayable=$totalpayable+$nolimitres['pendingamount'];
}
}

  ?>
   <!--<tr><td colspan="4"></td><td><b>Grand Total:<?php// echo $totalpayable;?></b></td></tr>-->

<tr class="heading">
   <td>No</td>    
    
	<td>Vendor Name</td>
	<td>Pending Amount</td>
	<td>Pay</td>
  </tr>
<?php

$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['res_name'];?></td>
   
    
     
     <td><?php echo $res['pendingamount'];?></td>
	
    <?php /*?><td align="center" class="tr_td_b"><a href="changepassword.php?user_main=<?=$res['pur_id']?>"><img src="images/edit.png" title="print"></a></td><?php */?>
 
	 <td>
	<a href="voucher-form.php?vouchertype=accoppbal&empid=<?=$res['vendorid']?>&salamt=<?=$res['pendingamount']?>&accid=<?=$res['pur_id']?>"><img src="images/payslip.jpg" width="20" height="20"></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>
	<? }

  ?>
 <tr><td colspan="3"></td><td><b>Grand Total:<?php echo $totalpayable;?></b></td></tr>
  
</table>
  
   <div align="right" style="padding-top:10px;"><?=$pagination?></div>