<?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 ID</td> 
    <td>Passing Agent Name</td>
  <td>Date</td>
  <td>Vehicle Type</td>
  <td>Amount</td>
  </tr>
  
<?php

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

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

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


$master = '';
$notification = '';
$trip = '';
$accounting = '';
$accpay = '';
$report = '';

$i=1;
$sq_arr="select * from cf_lab where (pass_agent_id!='' or passing_chg != 0 ) ";

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

$sq_arr.=" order by lab_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=1;
}

 $totpass_amt = 0;


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

$pass_agent_id=$res['pass_agent_id'];
        $result=mysql_query("select * from cf_passing where pass_id = '$pass_agent_id'");
      $res1=mysql_fetch_array($result);
  ?> 
  <tr>
    <td><?php echo $pagecnt;?></td>   
     <td><?php echo "PR-".$res['pur_id'];?></td>
   <td><?php echo $res1['passname'];?></td>
   <td><?php echo date(('d-m-Y'),strtotime($res['lab_date']));?></td>   
   <td><?php if($res['vehicle_type']=='1'){ echo "Big Vehicle"; } else if($res['vehicle_type']=='2'){ echo "Small Vehicle"; }?></td>  
   <td><?php echo $res['passing_chg'];?></td>     
   </tr>
  <?php 
  $totpass_amt += $res['passing_chg'];
  }}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></td>
   <td></td>
   <td></td>
   <td>Total</td>
     <td><?=$totpass_amt?></td>     
   </tr>
</table>

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