<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>World Wide Automotive Center</title>
    <script src=" rightclick_deactive.js"></script> 
    <script type="text/javascript" src="scripts/jquery-latest.js"></script>
	<link type="text/css" href="includes/style1.css" rel="stylesheet" />
      <link type="text/css" href="css/form.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>

    <script type="text/javascript">
        $(function() {
          if ($.browser.msie && $.browser.version.substr(0,1)<7)
          {
			$('li').has('ul').mouseover(function(){
				$(this).children('ul').show();
				}).mouseout(function(){
				$(this).children('ul').hide();
				})
          }
        });        
    </script>
	<script type="text/javascript">
    $(document).ready(function() {
        var cont_left = $("#container").position().left;
        $("a img").hover(function() {
            // hover in
            //$(this).parent().parent().css("z-index", 1);
            $(this).animate({
               height: "110",
               width: "110",
              
            }, "fast");
        }, function() {
            // hover out
         //   $(this).parent().parent().css("z-index", 0);
            $(this).animate({
                height: "80",
                width: "80",
                
            }, "fast");
        });
        
        $(".img").each(function(index) {
            var left = (index * 160) + cont_left;
            $(this).css("left", left + "px");
        });
    });




    </script>

<!-- js code below for active enter with textfield-->


<script type="text/javascript">

/***********************************************
* Disable "Enter" key in Form script
* This notice must stay intact for use
***********************************************/
                
function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	}      

</script>


<style>
.cont
	{


       background-color:#3b5998;

	//background:url(images/bg-inner.jpg) #e9e0c3 repeat-x;
  	width: 100%;position: absolute ;
	height:99%;
    	/* Optional - just for DIV)*/
    	//border: solid 1px #000000;
	-moz-box-shadow: 0px 5px 5px #888;
	-webkit-box-shadow: 0px 5px 5px #888;
	box-shadow: 0px 5px 10px #888;
    
	}





input[type=search] {
	outline: none;
}
input[type=search] {
	-webkit-appearance: textfield;
	-webkit-box-sizing: content-box;
	font-family: inherit;
	font-size: 100%;
}
input[type=search]::-webkit-search-decoration,
input[type=search]::-webkit-search-cancel-button {
	display: none; /* remove the search and cancel icon */
}

/* search input field */
input[type=search] {
	background: #ededed url(images/search-icon.png) no-repeat 9px center;
	border: solid 1px #ccc;
	padding: 9px 10px 9px 32px;
	width: 45px;
	
	-webkit-border-radius: 10em;
	-moz-border-radius: 10em;
	border-radius: 10em;
	
	-webkit-transition: all .5s;
	-moz-transition: all .5s;
	transition: all .5s;
}
input[type=search]:focus {
	width: 130px;
	background-color: #fff;
	border-color: #6dcff6;
	
	-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
	-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
	box-shadow: 0 0 5px rgba(109,207,246,.5);
}

/* placeholder */
input[type=search]:-moz-placeholder {
	color: #999;
}
input[type=search]::-webkit-input-placeholder {
	color: #999;
}

#reg_sea_bttn{

       background-color: #fff;
	border-color: #6dcff6;
	
	-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
	-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
	box-shadow: 0 0 5px rgba(109,207,246,.5);
      border: solid 1px #ccc;
	padding: 9px 10px 9px 2px;
	width: 30px;
	
	-webkit-border-radius: 10em;
	-moz-border-radius: 10em;
	border-radius: 10em;
	
	-webkit-transition: all .5s;
	-moz-transition: all .5s;
	transition: all .5s;
       outline: none;
        -webkit-appearance: textfield;
	-webkit-box-sizing: content-box;
	font-family: inherit;
	font-size: 100%;

 }












</style>


<link href="css/form.css" type="text/css" rel="stylesheet" media="screen"  />
<body bgcolor="#0033FF">
<div class='cont'>



<?
session_start();
include("opendb.php");
include("test.php");
include('includes/top.php');
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}
?>
<font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px; color:white;">  &nbsp;&nbsp;Master >> Vehicle Master</font>
<?
if($save)
{
$ch=mysqli_query($db,"select * from vehicle_master where regno='$rgno'");
if(mysqli_num_rows($ch)>0)
{
print "<script> alert('Duplicate RegNo'); document.location='vehmast.php'</script>";
return;
}
$ch1=mysqli_query($db,"select * from vehicle_master where chasisno='$chasno'");
if(mysqli_num_rows($ch1)>0)
{
print "<script> alert('Duplicate ChasisNo'); document.location='vehmast.php'</script>";
return;
}

$custcode=substr($cust,0,3).$rgno;
//echo $code;
$dt=date("Y-m-d");
$purdt=$yy."-".$mm."-".$dd;
$sql="insert into vehicle_master(brcode,regno,owner,make,model,mobile,address,engno,chasisno,purdt,cust_code) values('$brcode','$rgno','$cust','$make','$model','$mob','$add','$engno','$chasno','$purdt','$custcode')";
mysqli_query($db,$sql) or die('Insert Err:'.mysqli_error($db));

//$sql="insert into partpricemaster(partcode,partname,mrp,list,ndp,brcode,entrydate,user) values('$pcode','$pname','$srate','$srate','$prate','$brcode','$dt','$user')";
//mysqli_query($db,$sql) or die('Insert Err:'.mysqli_error($db));


//$sql="insert into spareprmast values('$pcode','$dt','9999-12-31','$prate','$srate','$srate',0,'$brcode')";
//mysqli_query($db,$sql) or die('Insert Err:'.mysqli_error($db));


print "<script> document.location='vehmast.php'</script>";




return;
} // end save


//$re=mysqli_query($db,"select * from configmaster");
//$row=mysqli_fetch_array($re);



?>
<style>
th{background-color:steelblue;color:white}
</style>
<script>
function valid()
{
 
 if(document.f1.rgno.value.length<=0)
 {
   alert("Invalid Register No.");
   document.f1.pcode.focus();
   return false;
 }

if(document.f1.cust.value.length<=0)
 {
   alert("Invalid Customer Name.");
   document.f1.cust.focus();
   return false;
 }

if(document.f1.make.value.length<=0)
 {
   alert("Invalid Make.");
   document.f1.make.focus();
   return false;
 }
if(document.f1.model.value.length<=0)
 {
   alert("Invalid Model.");
   document.f1.model.focus();
   return false;
 }



}
</script>
<script type="text/javascript">

/***********************************************
* Disable "Enter" key in Form script- By Nurul Fadilah(nurul@REMOVETHISvolmedia.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
                
function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	}      

</script>
<center>
<table cellspacing=1 cellpadding=1 bgcolor=black>
<tr><td align=center bgcolor='white'>
<form name='f1' action='<?print $PHP_SELF?>' method='post' onSubmit="return valid()">
<table cellspacing=1 cellpadding=3 >
<th colspan=4><font size=3>VEHICLE MASTER</th>
 <tr><td>Purchase Date</td><td>dd<input type='text' name='dd' value='<? echo date('d');?>' size='2' onKeyPress="return handleEnter(this, event)"/>
                              mm<input type='text' name='mm' value='<? echo date('m');?>' size='2' onKeyPress="return handleEnter(this, event)"/>
                               yy<input type='text' name='yy' value='<? echo date('Y');?>' size='2' onKeyPress="return handleEnter(this, event)"/></TD>
	</tr>

<tr><td>Register Number</td><td><input type=text name='rgno'  size=20 onKeyPress="return handleEnter(this, event)"></td>
  <td>Owner</td><td><select name='cust' onKeyPress="return handleEnter(this, event)">
<?
$g=mysqli_query($db,"select * from customer where brcode='$brcode' order by cname");
while($grow=mysqli_fetch_array($g))
{
print "<option>$grow[cname]</option>";
}
?></select></td></tr>
<tr><td>Make</td><td><input type=text name='make'  size=20 onKeyPress="return handleEnter(this, event)"></td> 
<td>Model</td><td><input type=text name='model'  size=20 onKeyPress="return handleEnter(this, event)"></td></tr>
<tr><td>Mobile No</td><td><input type=text name='mob'  size=20 onKeyPress="return handleEnter(this, event)"></td>    
 <td>Address</td><td><input type=text name='add'  size=20 onKeyPress="return handleEnter(this, event)"></td> </tr>
 <tr><td>Year</td><td><input type=text name='engno'  size=20 onKeyPress="return handleEnter(this, event)"></td>    
 <td>Chasis No</td><td><input type=text name='chasno'  size=20 onKeyPress="return handleEnter(this, event)"></td> </tr>

<tr><th colspan=4 ><input type=submit value='Save' name='save'></tr>
</table>
</form>
</td></tr>
</table>

<script>
 
  
</script>
<?
?>
<br>

<form name='f2' action='vehmast.php' method='post'><input type='search' name='sea_regno' placeholder='Search By Regno'><input type='submit' value='Go' id='reg_sea_bttn' name='search_bttn'/></form>
<form name='f1' action='' method='post'>
<table cellspacing=1 cellpadding=5 bgcolor='orange'>
<th>No <th>Register No <th>Owner <th>Make<th>Model<th>Mobile<th>Address<th>Edit<th>Del
<?
$i=1;
if($search_bttn)
{
$res=mysqli_query($db,"select * from vehicle_master where brcode='$brcode' and regno='$sea_regno' order by id");

}
else
{
$res=mysqli_query($db,"select * from vehicle_master where brcode='$brcode' order by owner");
}
while($row=mysqli_fetch_array($res))
{


/*  print "";
 print "\n<form action='updveh.php' method='post'>";
 print "\n<input type=hidden name='part' value='$row[partcode]'>";
 print "\n<input type=hidden name='ndp value='$row[ndpcost]'>";
 print "\n<input type=hidden name='list' value='$row[lstprice]'>";
 print "\n<input type=hidden name='pname' value='$row[partname]'>"; */


print "<tr bgcolor='white' onMouseOver=bgColor='b8d7b4'; onMouseOut=bgColor='white'><td>".$i."</td><td >$row[regno]</td><td>$row[owner]</td>";
 print "<td align=left>$row[make]</td><td align=left>$row[model]</td><td align=left>$row[mobile]</td><td align=left>$row[address]</td>";
 ?>
<td><a href='#' onClick="editfun('<? echo $row[id];?>')"  style="text-decoration:none;"><input type=button value='Edit' name='edit' ></a></td>
<td><a href='#' onClick="delfun('<? echo $row[id];?>')"  style="text-decoration:none;"><input type=button value='Del' name='del' ></a></td>

</form>
</tr>
<?
$i++;
}
?>
</form>

</table>
<script>
function editfun(str)
 {
  if (confirm('do you want to edit '+str+' ?'))
   document.location="editvehmast.php?id="+str;
 }
function delfun(str)
 {
  if (confirm('do you want to delete '+str+' ?'))
   document.location="delveh.php?id="+str;
 }
</script>
