<?php

$i=1;
include("../include/config.php");
require_once "../include/Database_functions.php";
?>

  <table  border="0" cellspacing="0" cellpadding="0" class="tableList">
  <tr class="heading">
    <td>No</td>    
    <td>Vehicle Number</td>
    <td>Manufacture</td>
    <td>Type</td>
    <td>Insurance</td>
    <td>Tax</td>
    <td>Fittness</td>   
    <td>Edit</td>
    <td>Delete</td>
  
  </tr>
  
  <?php
if(isset($_REQUEST['todate_12'])){
$sdate_12=$_REQUEST['todate_12'];
$todate_12=explode("-",$sdate_12);
$sdate=$todate_12[2].'-'.$todate_12[1].'-'.$todate_12[0];
}
$veh_num='';
$typenames='';
if(isset($_REQUEST['billno'])){
$veh_num=$_REQUEST['billno'];
}

if(isset($_REQUEST['typename'])){
$typenames=$_REQUEST['typename'];
}

	$today=date("Y-m-d");
	$oneWeekAgo = strtotime ( '-1 week' , strtotime ( $today ) ) ; 
	$WeekAgo =  date ( 'Y-m-j' , $oneWeekAgo ) ; 

$i=1;
$sq_arr="select * from cf_vehicle where 1 ";
if($veh_num!=''){
$sq_arr.=" and vehiclenum = '".$veh_num."' and '".$WeekAgo."' >= idate and '".$WeekAgo."' >= tdate and  '".$WeekAgo."' >= fitdate  ";
}

if($typenames!=''){
$sq_arr.=" and type like '%".$typenames."%' ";
}

if($veh_num==''){
$sq_arr.=" and '".$WeekAgo."' >= idate or '".$WeekAgo."' >= tdate or  '".$WeekAgo."' >= fitdate ";
}

/*if($sdate_12!=''){
$sq_arr.=" and date='".$sdate."' ";
}*/
$sq_arr.=" order by 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){
while($res=mysql_fetch_array($array))
{

$dd=date("m-d-Y",strtotime($res['add_date']));
  ?> 
  <tr>
    <td><?php echo "Vech-". $res['id'];?></td>
    <td><a href="#login-box" class="login-window"><?php echo $res['vehiclenum'];?></a></td>
    <td><?php if($res['manufacture']!='')echo $res['manufacture'];else echo '--'; ?></td>
    <td><?php if($res['type']!='')echo $res['type'];else echo '--'; ?></td>
    <?php 
		$insval = '';
		$insdate = $res['idate'];
		$todaydate = date("Y-m-d");
		if($insdate < $todaydate)
		   {
				$insval =  "Expired";
		   }
		   else
		   {
		   		$insval =  "Not Expired";
		   }
	?>    
    <td><?php echo $insval;?></td>
    <?php 
		$taxval = '';
		$taxdate = $res['tdate'];
		if($taxdate < $todaydate)
		   {
				$taxval =  "Expired";
		   }
		   else
		   {
		   		$taxval =  "Not Expired";
		   }
	?>    
    <td><?php echo $taxval;?></td>
     
    <?php 
		$fitval = '';
		$fitdate = $res['fitdate'];
		if($fitdate < $todaydate)
		   {
				$fitval =  "Expired";
		   }
		   else
		   {
		   		$fitval =  "Not Expired";
		   }
	?>    
    <td><?php echo $fitval;?></td>
    
   <td align="center" class="tr_td_b"><a href="vechicle-details-entry.php?page=<?php echo $page; ?>&id=<?php echo $res['id']; ?>&ab=<?php echo $i;?>"><img src="images/edit.png" title="edit"></a></td> 
   
    <td align="center" class="tr_td_r" ><a href="vechicle-list.php?del=delete&id=<?php echo $res['id']; ?>" onclick="return confirm('Do you really want to delete this field?');"><img src="images/delete.png" title="delete"></a></td>
   
  </tr>
  <?php 
    }}
  ?>
 
  <!--<tr>
    <td><input type="checkbox">2</td>
    <td>2323d</td>
    <td>jinesh</td>
    <td>jose</td>
    <td>9443274636</td>
    <td>email@gmail.com</td>
    <td>design</td>
    <td>designer</td>
    <td>23/4/11</td>
    <td><div class="deletedStat"></div></td>
    <td><a href="#">
      <div class="actEdit"></div><div class="actDelete"></div>
    </a></td>
  </tr>-->

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