<?
session_start();
include_once('includes/top.php');
include_once("test.php");
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
//$br=$_SESSION['branch'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}
$level=$_REQUEST['level'];
$res=mysqli_query($db,"select max(slno) from vehinout where brcode='$brcode'");
 $row=mysqli_fetch_row($res);
 if($row[0]<=0)
  //$dbno=37910001;
  $dbno='1';
 else
  $dbno=($row[0]+1);
?>

<script>
    function edit(a)
{
   document.location='editvehinout.php?dbno='+a;
}


</script>

<style>
 td{font-family:verdana;font-size:14;color:black;}
 th{font-family:verdana;font-size:14;color:white;background-color:#5b5858}
 body{background-color:silver;}
 select
  {border-style:ridge;
   border-color:black;
   height:25px;
   border-size=1;
   font-family:verdana;
   color:black;
  }
 input
  {border-style:ridge;
   border-color:#22437f;
   background-color:white;
   height:25px;
   font-weight:bold;
   border-size=1;
   font-family:sans-serif;
   color:BLACK;
  }
</style>
<head>
<title>AMPLEICHER</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">
        $(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>
 var dr_cr=[];
function showNature()
{
 var nature=dr_cr[document.f1.grp.selectedIndex];
 if(nature=='Assets'||nature=='Expenses')
    document.f1.drcr.value='Dr';
 else if(nature=='Liabilities'||nature=='Income')
    document.f1.drcr.value='Cr';
 else
   document.f1.drcr.value='';
}

function chkey(abc)
{
 yy=abc.value
 if(yy.indexOf('  ')>-1) 
  {
    alert('Multiple space is not allowed');
    abc.value='';
  }
 if(yy.indexOf("'")>-1) 
  {
    alert("\' is not allowed");
    abc.value='';
  }
 if(yy.indexOf('"')>-1) 
  {
    alert("\" is not allowed");
    abc.value='';
  }
 if(yy.indexOf('&')>-1) 
  {
    alert("\& is not allowed");
    abc.value='';
  }
}

function valid()
{ 
 subOK="true";
 
  if(document.f1.mob.value.length<=0)
 {
   subOK="false";
   alert('Invalid mobile No.');
 }
 
   if(document.f1.inttype.value.length<=0)
 {
   subOK="false";
   alert('Please select AM/PM');
 }
 
if(document.f1.d.value.length<=0)
 {
   subOK="false";
   alert('Please  enter intime day');
 }
 
 if(document.f1.m.value.length<=0)
 {
   subOK="false";
   alert('Please enter intime month');
 }
 
 if(document.f1.y.value.length<=0)
 {
   subOK="false";
   alert('Please enter intime year');
 }
 
 
 if(subOK=="true")
{
 x=confirm("Do you want to save?");
 if(x)
   subOK="true";
 else
    subOK="false";
}


   if(subOK=="true")
     return true;
   else
     return false;
} 

</script>

<body background="back_ground.jpg">
<?
if($level>=0)
{?>
<body>
<center>
<form name=f1 action="svvehinout.php" method=post onSubmit="return valid()">
<table width=90%>
<tr><td colspan=3 bgcolor=#5b5858 align=center><font color=white size=3>Vehicle In Out <input type=hidden name=dbno value=<? print $dbno ?>><? print $dbno ?></font></tr></td>
<tr><td>Reg. No:</td><td><input type=text name='reg' size=20 value=''>
In Date:dd <input type=text name='d' size='2' value='<?print date("d",time());?>'>
mm <input type=text name='m' size='2' value='<?print date("m",time());?>'>
yy <input type=text name='y' size='4' value='<?print date("Y",time());?>'>

In Time:Hour <input type=text name='h' size='2' value=''>
Min <input type=text name='min' size='2' value=''>

<select name='inttype' ><option></option><option value='AM'>AM</option><option value='PM'>PM</option></select>
</td>
</tr>

<tr><td colspan=1>Contact Person</td><td><input type=text name='cp' size='50' value=''>
Mob: No:<input type=text name='mob' size='20' value=''></td></tr>

<tr><td colspan=4>Out Date:dd <input type=text name='d1' size='2' value='00'>
mm <input type=text name='m1' size='2' value='00'>
yy <input type=text name='y1' size='4' value='0000'>

Out Time:Hour <input type=text name='h1' size='2' value='00'>
Min <input type=text name='min1' size='2' value='00'>    <select name='ottype' ><option></option><option value='AM'>AM</option><option value='PM'>PM</option></select></td></tr>


<tr><td colspan=4>Remarks<input type=textarea name=desc  size=60 ></td></tr>

<tr><td colspan=2 bgcolor=#5b5858 align=center>
<input type=submit value="Save"> <input type=button value="Cancel" onClick=document.location='blank.html'> 
</tr></td>
</table>
</form>

<?
}
?>

<script>

</script>
<table border=1 width='90%'>
<th>slno<th>No<th>InDate<th>Intime<th>Regno<th>customer<th>mob<th>Out Date<th>Out Time<th>Remarks<th>Update</th>
<?
$res1=mysqli_query($db,"select * from vehinout where brcode='$brcode' and outdate='0000-00-00'");
$k=1;
$a=1;
while( $row1=mysqli_fetch_array($res1))
{
print"<tr ><form action='updvehinout.php' name='f2' method='post'>";
print "\n<input type=hidden name='inslno[$a]' id='inslno$a' value='$row1[slno]'>";
print"<td>$k</td><td>$row1[slno]</td><td>".datetohtml($row1[indate])."</td><td>$row1[intime]</td><td>$row1[regno]</td><td>$row1[customer]</td><td>$row1[contactno]</td><td>  <input type=text name='td2[$a]' id='td2$a' size='2' value= '".date("d")."'>
mm <input type=text name='tm2[$a]' id='tm2$a' size='2' value='".date("m")."'>
yy <input type=text name='ty2[$a]' id='ty2$a' size='4' value='".date("Y")."'></td><td>  <input type=text name='th2[$a]' id='th2$a' size='2' value= ''>
mm <input type=text name='tmin2[$a]' id='tmin2$a' size='2' value=''><select name='ottype1[$a]' id='ottype1$a' ><option value='AM'>AM</option><option value='PM'>PM</option></select></td><td><input type=text name='desc1[$a]' id='desc1$a'  size=40 >
</td>
<td align=center><input type=submit name='upd' value='Update' ></td></form></tr>";
$k++;
 $a++;
}

?>
</table>
