<?
ob_start();
session_start();
if(isset($_SESSION['ses_name']))
{
$user=$_SESSION['ses_name'];
}else{
header("location:index.php");
}


$veh_num='';
$sdate_12 ='';
$page='1';
include("include/config.php");
require_once "include/Database_functions.php";
$sqlObj=new sqlclass();
$msg = '';

if(isset($_REQUEST['del']) && $_REQUEST['del']=='delete')
{
	$id = $_REQUEST['id'];
	$sql=mysql_query("delete from cf_vehicle where id='$id'");
	header("location:vechicle-list.php?msg=You Have Successfully Deleted");
}

?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OIL FILL</title>
<link href="css/styles.css" rel="stylesheet"  />
<link href="css/menu.css" rel="stylesheet" type="text/css" />
<script type='text/javascript' src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>


<script src="js/popup1.js" type="text/javascript"></script>


<script type='text/javascript' src="js/jquery.autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="js/jquery.autocomplete.css" />

<script type="text/javascript">
$().ready(function() {
	$("#regowner").autocomplete("autoCompleterestaurant.php", {
		width: 260,
		matchContains: true,
		//mustMatch: true,
		//minChars: 0,
		//multiple: true,
		//highlight: false,
		//multipleSeparator: ",",
		selectFirst: false
	});
});

</script>
<script language="javascript">
function getXMLHTTP()
	 { //fuction to return the xml http object
	var xmlhttp=false;	
		try
		{
		xmlhttp=new XMLHttpRequest();
		}
		catch(e)	
		{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
				}
			catch(e)
			{
				try
				{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1)
				{
				xmlhttp=false;
				}
			}
		}
	return xmlhttp;
	}   


function Searchdate(val)
{ 
 	 var page=val;	
	 var billno='';
     var model='';
	 var insurestat='';
	 var taxstat='';
	 var fitstat='';
	 var pollstat='';
	 var servicestat='';
	 	 	
	 if(document.search_frm.bill_no){
	 billno= document.search_frm.bill_no.value;
	 }
	 
	 if(document.search_frm.model){
	 model= document.search_frm.model.value;
	 }
	 
	 if(document.search_frm.capacity){
	 capacity= document.search_frm.capacity.value;
	 }
	 
	 if(document.search_frm.insure_status){
	 insurestat= document.search_frm.insure_status.value;
	 }
	 
	 if(document.search_frm.tax_status){
	 taxstat= document.search_frm.tax_status.value;
	 }
	 
	 if(document.search_frm.fittness_status){
	 fitstat= document.search_frm.fittness_status.value;
	 }
	 
	 if(document.search_frm.poll_status){
	 pollstat= document.search_frm.poll_status.value;
	 }
	 
	 if(document.search_frm.service_status){
	 servicestat= document.search_frm.service_status.value;
	 }
	 
	 
	 
	
	var strURL="ajax/vehicle_notification_15days.php?&page="+page;
	if(billno!=''){
	strURL+="&billno="+billno;
	}
			
	if(capacity!=''){
	strURL+="&capacity="+capacity;
	}	
		
	if(model!=''){
	strURL+="&model="+model;
	}
	
	if(insurestat!=''){
	strURL+="&insurestat="+insurestat;
	}	
	
	if(taxstat!=''){
	strURL+="&taxstat="+taxstat;
	}	
	
	if(fitstat!=''){
	strURL+="&fitstat="+fitstat;
	}
	
	if(pollstat!=''){
	strURL+="&pollstat="+pollstat;
	}
	
	if(servicestat!=''){
	strURL+="&servicestat="+servicestat;
	}		
		
	//alert(strURL);
	var req = getXMLHTTP();
   if (req)
   {
     req.onreadystatechange = function()
     {
		 
			if ((req.readyState == 0)||(req.readyState == 1)||(req.readyState == 2)||(req.readyState == 3))
      		{
			//document.getElementById('order').innerHTML='<div align="center"><img src="'+path+'images/ajax_loader.gif"/></div>';
			//document.getElementById('Cakeorder').innerHTML='<div align="center"><img src="'+path+'images/ajax_loader.gif"/></div>';
			}
		 
		 
      if (req.readyState == 4)
      {
	 // only if "OK"
	 	if (req.status == 200)
	 	{ 
	   document.getElementById('list').innerHTML=req.responseText;
	//	document.getElementById('Cakeorder').innerHTML=req.responseText;
	 	}
	  else 
	 	{
   	   alert("There was a problem while using XMLHTTP:\n" + req.statusText);

	 }
     }
     }
   req.open("GET", strURL, true);
   req.send(null);
   }
 
   
}
</script>
</head>

<body>

<!------------------popup area (view, edit)--------------->

<div class="viewEmployeePopup login-popup"  id="login-box" style="width:400px;height:400px;">
<a href="#" class="close"><img src="images/close.png" class="btn_close" title="Close Window" alt="Close" /></a>
   <div id="popupid"></div>
   
     
    </div>

<!---------------popup area ends------------------>
<div class="wrapper">
 <div>
<?php 
	include("header.php");	
?>
 
</div>
 
 <div class="tabbedArea">
  
  <div class="tabBody">
   <h1>Vehicle Notification 15 Days List</h1>
   <form name="search_frm" id="search_frm" method="post"  >
   <div class="searchBox" style="width:93%; margin-right:0px;  padding:0px; ">
   <div style="padding:20px;">
    <div class="searchField">
     <p class="input1">Vehicle No</p>
     <input type="text" name="bill_no" id="bill_no" class="input1" style="width:100px;" />
    </div>
    
    <div class="searchField">
     <p class="input1">Manufacture & Model</p>
     <input type="text" name="model" id="model" class="input1" style="width:75px;" />
    </div>
    
    <div class="searchField">
     <p class="input1">Capacity</p>
     <input type="text" name="capacity" id="capacity" class="input1" style="width:75px;"  />
    </div>
    
    <div class="searchField" style="padding-left:10px;">
     <p class="input1">Insurance</p>
     <select name="insure_status" class="input1">
         <option value="">-Status-</option>
         <option value="Expired">Expired</option>
         <option value="NotExpired">Not Expired</option>         
     </select>
    </div>
    
    <div class="searchField" style="padding-left:10px;">
     <p class="input1">Tax</p>
     <select name="tax_status" class="input1">
         <option value="">-Status-</option>
         <option value="Expired">Expired</option>
         <option value="NotExpired">Not Expired</option>         
     </select>
    </div>
    
    <div class="searchField" style="padding-left:10px;">
     <p class="input1">Fittness</p>
     <select name="fittness_status" class="input1">
         <option value="">-Status-</option>
         <option value="Expired">Expired</option>
         <option value="NotExpired">Not Expired</option>         
     </select>
    </div>
	
	<div class="searchField" style="padding-left:10px;">
     <p class="input1">Pollution</p>
     <select name="poll_status" class="input1">
         <option value="">-Status-</option>
         <option value="Expired">Expired</option>
         <option value="NotExpired">Not Expired</option>         
     </select>
    </div>
	
	<div class="searchField" style="padding-left:10px;">
     <p class="input1">Service</p>
     <select name="service_status" class="input1">
         <option value="">-Status-</option>
         <option value="Expired">Expired</option>
         <option value="NotExpired">Not Expired</option>         
     </select>
    </div>
      
    
    <div class="searchField">
     <input name="button" type="button" class="input1" onClick="Searchdate(1);" value="search" />
     
   
    </div>
    
</div>
    
   </div>
   </form>
   <div id="list">
   <table  border="0" cellspacing="0" cellpadding="0" class="tableList" style="width:93%;">
  <tr class="heading">
    <td>No</td>    
    <td>Vehicle Number</td>
    <td>Manufacture</td>  
    <td>Capacity</td>  
    <td>Insurance</td>
    <td>Tax</td>
    <td>Fittness</td>   
	<td>Pollution</td>   
	<td>Service</td>  
	<td>National Permit</td>
	<td>State Permit</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];
}

$typenames='';
$model ='';
$regowner='';

//$_SESSION['ses_name'];
if(isset($_REQUEST['veh_num'])){
$veh_num=$_REQUEST['veh_num'];
}

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

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

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

$i=1;
$sq_arr="select * from cf_vehicle where 1 ";

if(($_SESSION['typename'] == 'SuperAdmin')) {
	$sq_arr="select * from cf_vehicle where  (idate < NOW() + INTERVAL 15 DAY AND idate >= NOW()  or tdate < NOW() + INTERVAL 15 DAY AND tdate >= NOW() or fitdate < NOW() + INTERVAL 15 DAY AND fitdate >= NOW() or pollution_date < NOW() + INTERVAL 15 DAY AND pollution_date >= NOW() or service_date < NOW() + INTERVAL 15 DAY AND service_date >= NOW() or national_permit_dt < NOW() + INTERVAL 15 DAY AND national_permit_dt >= NOW() or state_permit_dt < NOW() + INTERVAL 15 DAY AND state_permit_dt >= NOW()) ";	
}

if(($_SESSION['typename'] == 'SubAdmin')) {
	$sesname = $_SESSION['ses_name'];
	$userids = $_SESSION['admin_id'];
	
	$sq_user1 = mysql_query("select cf_client.client_sub_id from cf_user_clientid join cf_client on cf_user_clientid.client_code = cf_client.client_newcode where cf_user_clientid.user_id = '$userids' ");
	$rw1=mysql_fetch_array($sq_user1);
	$clientsubid = $rw1['client_sub_id'];
	/*$sq_user1=mysql_query("select * from cf_user_clientid where user_id = '$userids'");
	$rw1=mysql_fetch_array($sq_user1);
	$clientcode=$rw1['client_code'];
	$sq_clients=mysql_query("select * from cf_client where client_newcode	 = '$clientcode'");*/
	
	
	
	$sq_arr="select * from cf_vehicle where  vehclient_ids = $clientsubid  "; 	
}



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


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

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

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

/*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 $res['id'];?></td>
    
    <td><a href="#login-box" class="login-window"  data-id=<?php echo $res['id'];?>><?php echo $res['vehiclenum'];?></a></td>
    <td><?php if($res['manufacture']!='')echo $res['manufacture'];else echo '--'; ?></td>
    <td><?php if($res['maxcapacity']!='')echo $res['maxcapacity'];else echo '--'; ?></td>
    <?php 
		$insval = '';
		$insdate = $res['idate'];
		$todaydate = date("Y-m-d");
		if($insdate != '0000-00-00')
		{
		if($insdate < $todaydate)
		   {
				$insval =  "Expired";
				
		   }
		   else
		   {
		   		$insval =  "Not Expired";
		   }
		 }  
	?>    
    <td <?php if($insval== "Expired"){ ?>style="color:#FF0000" <?php }else{ ?> style="color:#FF9900" <?php }?>><?php echo $insval;?></td>
    <?php 
		$taxval = '';
		$taxdate = $res['tdate'];
		if($taxdate != '0000-00-00')
		{
		if($taxdate < $todaydate)
		   {
				$taxval =  "Expired";
		   }
		   else
		   {
		   		$taxval =  "Not Expired";
		   }
		}
	?>    
    <td <?php if($taxval== "Expired"){ ?>style="color:#FF0000" <?php }else{ ?> style="color:#FF9900" <?php }?>><?php echo $taxval;?></td>
    
    
    <?php 
		$fitval = '';
		$fitdate = $res['fitdate'];
		if($fitdate != '0000-00-00')
		{
		if($fitdate < $todaydate)
		   {
				$fitval =  "Expired";
		   }
		   else
		   {
		   		$fitval =  "Not Expired";
		   }
		}
	?>    
    <td <?php if($fitval== "Expired"){ ?>style="color:#FF0000" <?php }else{ ?> style="color:#FF9900" <?php }?>><?php echo $fitval;?></td>
	
	<?php 
		$pollval = '';
		$polldate = $res['pollution_date'];
		if($polldate != '0000-00-00')
		{
		if($polldate < $todaydate)
		   {
				$pollval =  "Expired";
		   }
		   else
		   {
		   		$pollval =  "Not Expired";
		   }
		 }  
	?>    
    <td <?php if($pollval== "Expired"){ ?>style="color:#FF0000" <?php }else{ ?> style="color:#FF9900" <?php }?>><?php echo $pollval;?></td>
	
	
	 <?php 
		$serval = '';
		$serdate = $res['service_date'];
		if($serdate != '0000-00-00')
		{
		if($serdate < $todaydate)
		   {
				$serval =  "Expired";
		   }
		   else
		   {
		   		$serval =  "Not Expired";
		   }
		 }  
	?>    
    <td <?php if($serval== "Expired"){ ?>style="color:#FF0000" <?php }else{ ?> style="color:#FF9900" <?php }?>><?php echo $serval;?></td>
	
	<?php 
		$natval = '';
		$natdate = $res['national_permit_dt'];
		if($natdate != '0000-00-00')
		{
		if($natdate < $todaydate)
		   {
				$natval =  "Expired";
		   }
		   else
		   {
		   		$natval =  "Not Expired";
		   }
		 }  
	?>    
    <td <?php if($natval== "Expired"){ ?>style="color:#FF0000" <?php }else{ ?> style="color:#FF9900" <?php }?>><?php echo $natval;?></td>
	
	 <?php 
		$stateval = '';
		$statedate = $res['state_permit_dt'];
		if($statedate != '0000-00-00')
		{
		if($statedate < $todaydate)
		   {
				$stateval =  "Expired";
		   }
		   else
		   {
		   		$stateval =  "Not Expired";
		   }
		 }  
	?>    
    <td <?php if($stateval== "Expired"){ ?>style="color:#FF0000" <?php }else{ ?> style="color:#FF9900" <?php }?>><?php echo $stateval;?></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> 
  </div>
  </div>
 </div>
 <div class="footer"><p>Powered by <a href="http://www.aadhocc.co.uk/" target="_blank">Aadhocc</a></p></div>
 
</div>
<div class="quicLInksCover">
 <?php 
	include("leftlink.php");
?>

</div>
</body>
</html>
