<?
ob_start();
session_start();
if(isset($_SESSION['ses_name']))
{
$user=$_SESSION['ses_name'];
}else{
header("location:index.php");
}
$img_hr="images/menu4.jpg";
$img_acc="images/menu3.jpg";
$img_veh="images/menu2-o.jpg";

include("include/config.php");
require_once "include/Database_functions.php";
$sqlObj=new sqlclass();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Brothers - ERP</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="style/default.css">
<script type="text/javascript">
<!--
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 
// -->
function processNumber(inputField) {
    try {
        var inpVal = parseInt(inputField.value, 10);
        if (isNaN(inpVal)) {
            var msg = "Please enter a number only.";
			inputField.value='';
            var err = new Error(msg);
            if (!err.message) {
                err.message = msg;
            }
            throw err;
			
        }
    } catch (e) {
        alert(e.message);
        inputField.focus();
        inputField.select();
    }
}

</script>
<script type="text/javascript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

</script>
<script language="javascript">
var path="<?=$lnk;?>";
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 Search(val)
{  
	var billno= document.frm_voucher.bill_no.value;
	var strURL=path+"ajax/search_vehicle.php?billno="+billno;
	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);
   }
 
   
}

function Searchdate()
{  
	var frmdate1  = document.search_frm.frmdate1.value;
	var todate_1  = document.search_frm.todate_1.value;
	var singdate = document.search_frm.singdate.value;
	var billno= document.search_frm.bill_no.value;
	var page=val;
	if(frmdate1!='' || todate_1!=''){
	if(singdate!=''){
	alert('select either from and to dates or single date');
	document.search_frm.singdate.value='';
	}
	}
	
	var strURL=path+"ajax/search_vehicle_date.php?&page="+page;
	if(frmdate1!=''){
	strURL+="&frmdate1="+frmdate1;
	}
	if(todate_1!=''){
	strURL+="&todate_1="+todate_1;
	}
	if(singdate!=''){
	strURL+="&singdate="+singdate;
	}
	if(billno!=''){
	strURL+="&billno="+billno;
	}	

		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>
<? include("date.php");?>
</head>
<body onload="MM_preloadImages('images/menu2-o.jpg','images/menu1-o.jpg','images/menu3-o.jpg','images/menu4-o.jpg')">
<div id="main_div">
<? include("header.php");
?>
<div style="width:1024px; float:left; clear:none">
   <div id="matter_center_in">
  <form name="search_frm" id="search_frm" method="post" action="accounts.php" >
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
	 <tr>
    <td colspan="4" height="30" valign="top"><a href="vechicle-details-entry.php">
      <h3>Create vehicle details</h3></a></td>
    </tr>
      <tr>
        <td><table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="4%">From</td>
              <td width="19%"><table>
                  <tr>
                    <td><input type="text" class="content" id="frmdate1" size="10" maxlength="100" name="frmdate1"   onkeyup="change_sel(1,2)" /></td>
                  </tr>
              </table></td>
              <td width="3%">To</td>
              <td width="13%"><input type="text" class="content" id="todate_1" size="10" maxlength="100" name="todate_1"   onkeyup="change_sel(1,2)" /></td>
              <td width="22%">Choose Date
                  <input type="text" class="content" id="singdate" size="10" maxlength="100" name="singdate"   onkeyup="change_sel(1,1)" /></td>
              <td width="8%">Number</td>
              <td width="15%"><input type="text" name="bill_no" id="bill_no" /></td>
              <td width="16%"><input name="button" type="button" onclick="Searchdate(1);" value="search" /></td>
            </tr>
        </table></td>
      </tr>
    </table>
  </form>
  <!--<script src="js/jquery-latest.js"></script>
<script>
$("#billlink").live("click", function(){
$("#billdiv").load("bills.php");
}
</script>
<div id="billdiv"></div>
 --><div id="list">
  <table width="98%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <th width="8%" align="left" valign="middle">Index</th>
      <th width="8%" align="left" valign="middle">Vehicle Number</th>
      <th width="11%" align="left" valign="middle">Service Details</th>
      <th width="13%" align="left" valign="middle">Chasis Number</th>
      <th width="13%" align="left" valign="middle">Engine Number</th>
      <th width="12%" align="left" valign="middle">Manufacture</th>
      <th width="8%" align="left" valign="middle">Tyre Number</th>
      <th width="7%" align="left" valign="middle">Date</th>
      <th width="3%" align="left" valign="middle">&nbsp;</th>
      <th width="4%">&nbsp;</th>
      <th width="4%">&nbsp;</th>
      <th width="5%">&nbsp;</th>
      <th width="4%">&nbsp;</th>
    </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];
}
if(isset($_REQUEST['veh_num'])){
$veh_num=$_REQUEST['veh_num'];
}

$i=1;
$sq_arr="select * from tbl_vehicle where 1 ";
if($veh_num!=''){
$sq_arr.=" and vehiclenum='".$veh_num."' ";
}

if($sdate_12!=''){
$sq_arr.=" and date='".$sdate."' ";
}
$sq_arr.=" order by vehiclenum desc ";
$query=$sq_arr;
$function="Searchdate";
include("paging.php");
$sq_arr.=" LIMIT $start, $limit";

$array=mysql_query($sq_arr);
if($array && mysql_num_rows($array)>0){
while($result=mysql_fetch_array($array))
{
  ?> 
  <tr>
      <td class="tr_td"><?php echo $res['id'];?></td>
      <td class="tr_td"><?php echo $res['vehiclenum'];?></td>
      <td class="tr_td"><?php echo $res['servicedet']; ?></td>
      <td class="tr_td"><?php echo $res['chasisnum']; ?></td>
      <td class="tr_td"><?php echo $res['enginenum']; ?></td>
      <td class="tr_td"><?php echo $res['manufacture']; ?></td>
      <td class="tr_td"><?php echo $res['tyrenum']; ?></td>
      <td class="tr_td tr_td_r"><?php echo $res['date']; ?></td>
	  <td align="center" class="tr_td_b"><a href="edit_vehicle_list.php?id=<?php echo $res['id']; ?>&ab=<?php echo $i;?>"><img src="images/icon2.jpg" width="18" height="18" /></a></td>
      <td align="center" class="tr_td_b"><img src="images/icon3.jpg" width="17" height="22" /></td>
      <td align="center" class="tr_td_b"><img src="images/icon4.jpg" width="22" height="20" /></td>
      <td align="center" class="tr_td_b"><input type="hidden" name="save" /><input type="image" name="save" src="images/icon5.jpg" width="20" height="20" /></td>
   	  <td align="center" class="tr_td_r" ><a href="delete_vehicle.php?id=<?php echo $res['id']; ?>" onclick="return confirm('Do you really want to delete this field?');"><img src="images/icon1.jpg" width="21" height="21" /></a></td>
    </tr>
<?php
}
}
?>

  </table>
  <div align="right" style="padding-top:10px;"><?=$pagination?></div>
  </div>
</div>
<? 
include("bottom_footer.php");?>
</div>
<? 
ob_flush();
include("footer.php");?>
</div>
</body>
</html>
