<?php
$frmdate11='';
$todate_11='';
$sdate_12='';
$billno='';
$frmdate1='';
$todate_1='';
$todate_12='';
$from='';
$to='';
$sdate='';
$vechnum='';
$vech_num='';

if(isset($_REQUEST['frmdate1'])){
$frmdate11=$_REQUEST['frmdate1'];
$frmdate1=explode("-",$frmdate11);
$from=$frmdate1[2].'-'.$frmdate1[1].'-'.$frmdate1[0];
}
if(isset($_REQUEST['todate_1'])){
$todate_11=$_REQUEST['todate_1'];
$todate_1=explode("-",$todate_11);
$to  =$todate_1[2].'-'.$todate_1[1].'-'.$todate_1[0];
}
if(isset($_REQUEST['singdate'])){
$sdate_12=$_REQUEST['singdate'];
$todate_12=explode("-",$sdate_12);
$sdate=$todate_12[2].'-'.$todate_12[1].'-'.$todate_12[0];
}
if(isset($_REQUEST['vechnum'])){
$vech_num=$_REQUEST['vechnum'];
}
$i=1;
include("../include/config.php");
require_once "../include/Database_functions.php";
?>

 <table width="98%" border="0" cellspacing="0" cellpadding="0">
     <tr>
       <th width="10%" align="left" valign="middle" class="tr_td">Vehicle No</th>
	  <th width="10%" align="left" valign="middle" class="tr_td">Container No</th>
	  <th width="10%" align="left" valign="middle" class="tr_td">Date</th>
     </tr>
<?php
//$array=mysql_query("select * from tbl_trip_sheet order by bill_no asc");
$i=1;
$sq_arr="SELECT * FROM tbl_trip_sheet
WHERE (datediff( NOW( ) , date ) >3) AND (update_date = '' OR update_date = '0000-00-00') ";

if($vech_num!=''){
$sq_arr.=" and 	vehicle_no='".$vech_num."' ";
}
if($frmdate11!='' && $todate_11!=''){
$sq_arr.=" and date between '$from' and '$to' ";
}
if($frmdate11!='' && $todate_11==''){
$sq_arr.=" and date>='".$from."' ";
}
if($frmdate11=='' && $todate_11!=''){
$sq_arr.=" and date <='".$to."' ";
}
if($sdate_12!=''){
$sq_arr.=" and date='".$sdate."' ";
}
$sq_arr.=" order by id desc";
//echo $sq_arr;


$query=$sq_arr;
$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){
while($res=mysql_fetch_array($array))
{
$dat_today=$res['date'];
$dat_today=explode("-",$dat_today);
?>	
    <tr>
      <td class="tr_td"><?php echo $res['vehicle_no'];?></td>
	  <td class="tr_td"><?php echo $res['container_no'];?></td>
     <td class="tr_td"><?php echo $res['date'];?></td>
	 
    </tr>
<?php
$i++;
}
}else{?>
 <tr>
      <td class="tr_td" colspan="3" ><span class="err_msg"><?php  ?></span>
	  </td>
	  </tr>
<? }
?>      </table>
 <div align="right" style="padding-top:10px;"><?=$pagination?></div>