<?
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();
$imgvehiclevar='v';
$divcnt='';
$tyrenum='';
$div='';
$tablename='tbl_vehicle';
if(isset($_REQUEST['divcnt'])){
$cnt=$_POST['divcnt'];
$cntcnt=$cnt;
}else{
$cntcnt=0;
}
		if(isset($_REQUEST['save'])){
			$i=1;
			while($i<=$cnt)
			{
			if(isset($_POST['vehiclenum'.$i.''])){
			$vehiclenum= $_POST['vehiclenum'.$i.''];	
			}
			if(isset($_POST['kms'.$i.''])){
			$kms= $_POST['kms'.$i.''];
			}
			if(isset($_POST['regowner'.$i.''])){
			$regowner= addslashes($_POST['regowner'.$i.'']);
			}
			if(isset($_POST['servicedet'.$i.''])){
			$servicedet=$_POST['servicedet'.$i.''];
			}
			if(isset($_POST['chasisnum'.$i.''])){
			$chasisnum=$_POST['chasisnum'.$i.''];
			}
			if(isset($_POST['enginenum'.$i.''])){
			$enginenum=$_POST['enginenum'.$i.''];
			}
			if(isset($_POST['manufacture'.$i.''])){
			$manufacture=addslashes($_POST['manufacture'.$i.'']);
			}
			if(isset($_POST['tyrenum'.$i.''])){
			$tyrenum=addslashes($_POST['tyrenum'.$i.'']);
			}
			$date=date('Y/m/d');
			$sqlObj->tablename=$tablename;
			if($vehiclenum!=''){
			$sqlObj->fieldname='(vehiclenum,kms,regowner,servicedet,chasisnum,enginenum,manufacture,date,status,tyrenum)';
			$sqlObj->fieldvalue='"'.$vehiclenum.'","'.$kms.'","'.$regowner.'","'.$servicedet.'","'.$chasisnum.'","'.$enginenum.'","'.$manufacture.'","'.$date.'","1","'.$tyrenum.'"';
			$CreateVehicle 	= $sqlObj->AddTable();
			}
			$i++;
			}
			//$bill_no=$bill_no+1;
		
}
?>
<!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>
<script src="js/addmorevehicle.js"></script>
<script src="js/addmorevehicletyre.js"></script>
<script src="js/tyredropdown.js"></script>
<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];}
}
//-->
function validation(){
if(document.frmname.vehiclenum1.value==''){
alert("Enter the Vehicle Number");
document.frmname.vehiclenum1.focus();
return false;
}
/*var cnt=document.getElementById('divcnt').value;
for(i=1;i<=cnt;i++){alert(document.getElementById('vehiclenum'+i).value);
if(document.getElementById('vehiclenum'+i)){
if(document.getElementById('vehiclenum'+i).value==''){
alert("Enter the Vehicle Number");
document.getElementById('vehiclenum'+i).focus();
return false;
}
}
}*/
}
</script>
</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");
if($div=='')
$div=1;
if($divcnt=='')
$divcnt=1;
?>
<div style="width:1024px; float:left; clear:none">
  <div id="matter_center_in">
  <table width="98%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="465"></td>
    <td width="145">&nbsp;</td>
    <td width="145">&nbsp;</td>
    <td width="145">&nbsp;</td>
    <td width="100">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<div align="center">
<form name="frmname" method="post" action="">
<input type="hidden" id="tdcnt" value="1" name="tdcnt"/>
<input type="hidden" id="tyrdiv" value="1" name="tyrdiv"/>
<input type="hidden" id="tyrcnt" value="1" name="tyrcnt"/>
<input type="hidden" id="divcnt" value="1" name="divcnt"/>
<div id="div1">
  <table width="50%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <th width="45%" align="left" valign="middle">Vehicle Details Entry</th>
      <th width="55%" align="left" valign="middle">&nbsp;</th>
    </tr>
    <tr>
      <td class="tr_td">Vehicle No.<span class="err_msg">*</span></td>
      <td class="tr_td tr_td_r" align="left"><input name="vehiclenum1" type="text" /></td>
    </tr>
    <tr>
      <td class="tr_td">Kms</td>
      <td class="tr_td tr_td_r" align="left"><input name="kms1" type="text" /></td>
    </tr>
    <tr>
      <td class="tr_td">Reg Owner</td>
      <td class="tr_td tr_td_r" align="left"><textarea name="regowner1" cols="20" rows="5"></textarea></td>
    </tr>
    <tr>
      <td class="tr_td">Service Details</td>
      <td class="tr_td tr_td_r" align="left"><textarea name="servicedet1" cols="20" rows="5"></textarea></td>
    </tr>
    <tr>
      <td class="tr_td">Chasis No.</td>
      <td class="tr_td tr_td_r" align="left"><input name="chasisnum1" type="text" /></td>
    </tr>
    <tr>
      <td class="tr_td">Engine No.</td>
      <td class="tr_td tr_td_r" align="left"><input name="enginenum1" type="text" /></td>
    </tr>
    <tr>
      <td class="tr_td">Mileage Entry (auto calculate) </td>
      <td class="tr_td tr_td_r" align="left"><input name="mileage1" type="text" /></td>
    </tr>
    <tr>
      <td class="tr_td">Manufacture &amp; Model</td>
      <td class="tr_td tr_td_r" align="left"><input name="manufacture1" type="text" /></td>
    </tr>
    <tr>
      <td class="tr_td"><strong>Tyre Details</strong></td>
      <td class="tr_td tr_td_r">&nbsp;</td>
    </tr>
	<tr><td colspan="2"  class="tr_td tr_td_r" ><table width="100%"><tr>
      <td colspan="2">Location
        <select name="location1"  id="location1" onchange="locationval(1,1,this.value);">
		<option value="">--Select--</option>
		<option value="Front Wheel">Front Wheel</option>
		<option value="Back Wheel">Back Wheel</option>
        </select>      <span id="tyrenumval11"></span>
		
       <a style="cursor:pointer;" onclick="addmoretyre('<?=$div?>','2')">Add more</a></td>
      </tr></table>
	  <div id="td<?=$div?>2"></div>
	  </td></tr>
    
	
	  
	 <tr>
      <td class="tr_td tr_td_r" colspan="2"><a style="cursor:pointer;" onclick="addmore('2')">Add more</a></td>
    </tr>
	
  </table></div>
  <div id="div2">
</div>
<div><input name="save" type="submit" value="Save" onclick="return validation();"/></div>
  </form>
</div>
  <h3>&nbsp;</h3>
</div>
<? 
include("bottom_footer.php");?>
</div>
<? 
ob_flush();
include("footer.php");?>
</div>
</body>
</html>
