<?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 >Lab Name</td>  
    <td>Vehicle Type</td>
    <td>Pass Agent</td>
    <td>Pass Charge</td>
    <td>Date</td>
    <td>Bill No</td>
	<td>Quantity</td>
    <td>Amount</td>
    <td>Vehicle No</td>
    <td>Company</td>
    <td align="center">Edit</td>
    <td align="center">Del</td>
  </tr>
<?php

$vehtype ='';
$pass_agent='';
$fromdate='';
$todate='';

if(isset($_REQUEST['vehtype'])){
$vehtype=$_REQUEST['vehtype'];
}
if(isset($_REQUEST['pass_agent'])){
$pass_agent=$_REQUEST['pass_agent'];
}
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_lab where pur_id=0 ";

if($pass_agent!=''){
$sq_arr.=" and pass_agent_id = '".$pass_agent."' ";
}
if($vehtype!=''){
$sq_arr.=" and vehicle_type = '".$vehtype."' ";
}
if($fromdate!="" && $todate!=""){
$sq_arr.=" and lab_date between '$fromdate1' and '$todate1'";
}


/*if($sdate_12!=''){
$sq_arr.=" and date='".$sdate."' ";
}*/
$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=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 
		$lab_name = $res['lab_name'];	
        $sq_ven=mysql_query("select * from cf_lab_agent where lab_agent_id = '$lab_name'");
    	$resven=mysql_fetch_array($sq_ven);
    	
    	$vehicle_type = $res['vehicle_type'];	
    	if($vehicle_type==1)$vehicle_type="Big";else if($vehicle_type==2) $vehicle_type="Small";
    	
    	$pass_agent_id=$res['pass_agent_id'];
        $result=mysql_query("select * from cf_passing where pass_id = '$pass_agent_id'");
    	$result=mysql_fetch_array($result);
    	
    	$lab_year=date('Y',strtotime($res['lab_date']));
          if($lab_year=="1970")$lab_date="";else $lab_date=date(('d-m-Y'),strtotime($res['lab_date']));
    ?>	
     <td><?php echo $resven['labagent_name'];?></td>     
     <td><?php echo $vehicle_type;?></td>
     <td><?php echo $result['passname'];?></td>
     <td><?php echo $res['passing_chg'];?></td>
  	<td><?php echo $lab_date;?></td>
  	 <td><?php echo $res['lab_billnum'];?></td>
     <td><?php echo $res['lab_qty'];?></td>
     <td><?php echo $res['lab_bill_amt'];?></td>
     <td><?php echo $res['lab_vehicle_no'];?></td>
     <td><?php echo $res['lab_company'];?></td>
    
    
	 

   <td align="center" class="tr_td_b"><a href="add-lab-test.php?lab_id=<?=$res['lab_id']?>"><img src="images/edit.png" title="edit"></a></td>
   
   <td align="center" class="tr_td_r" ><a href="lab_test_list.php?pur_del=<?=$res['lab_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 
    }}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>