<?
session_start();
include("opendb.php");
include("test.php");
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}

?>
<!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>Xpress</title>
 <script src=" rightclick_deactive.js"></script> 
</head>
<style type="text/css">

</style>
<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");
        });
    });









/////

(function($){
    $.fn.enterNext = function(){
       var _i =0;
       $('input[type=text], select',this)
            .each(function(index){
            _i = index;
            $(this)
                .addClass('tab'+index)
                .keydown(function(event){
                    if(event.keyCode==13){
                        $('.tab'+(index+1)).focus();
                        event.preventDefault();
                    }
                });

        })
     $( "input[type=submit]",this ).addClass('tab'+(_i+1));
}})(jQuery);
    </script>
<style>
table,tr,td{border-collapse:collapse;padding:5px;border: 1px solid black;}
body{text-transform:uppercase;font-family:Arial, Helvetica, sans-serif;font-size:13px;color:black;}

tr:nth-child(odd)    { background-color:white; }
tr:nth-child(even)    { background-color:#fff; }
p{
	padding:0px;
	margin:0px;
	text-align: left;text-transform:capitalize;font-size:15px;
}
select,input[type=text], textarea{  
background: #eeeeee; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2VlZWVlZSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjIzJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
background: -moz-linear-gradient(top, #eeeeee 0%, #ffffff 23%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#eeeeee), color-stop(23%,#ffffff)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #eeeeee 0%,#ffffff 23%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #eeeeee 0%,#ffffff 23%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #eeeeee 0%,#ffffff 23%); /* IE10+ */
background: linear-gradient(top, #eeeeee 0%,#ffffff 23%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff',GradientType=0 ); /* IE6-8 */
border:1px solid #999; padding:3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;


}p{padding:0px;}
em{font-size:14px;}
h3{color:#000;font-size:12px;margin:0px;padding:5px 20px;}
.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;
    
	}

#pg{
       text-decoration:none;
       text-align: center;
       vertical-align: top;
}
.pgbtn{
      float:left;
margin-left: 10px;
height: 20px;
line-height: 22px;
text-align:center;
background-color:#fbfbfb;
border:1px solid #b7b7b7;
color:#606060;
cursor:pointer;
display:inline-block;
font:bold 12px/100% Arial,sans-serif;
       
}





</style>
<script>
function pgnfn(str){
            document.getElementById('pgbtn'+str).style.background = "#ccc";
            document.f1.entrydate.focus();
}
</script>
<?
$xx=$_GET['id']+1;
?>
<body onload='pgnfn(<? echo $xx;?>)'>


<div class='cont'>



<?php include('includes/top.php'); ?>
<br/>

<font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px; color:white;">  &nbsp;&nbsp;REPORTS >>  Veh. Recd Report</font>
<br/><br/>
<table class="container" width="93%" align='center'>
<?

if(($show)||($pgbt))
{
 if($show){
 $df=$y1.'-'.$m1.'-'.$d1." ".'00:00:00';
 $dt=$y2.'-'.$m2.'-'.$d2.' '.'23:59:59';
}
?>
<tr ><td align=center ><h2><b><u>World Wide Automotive Center</b> <br>
<b>Daily Received Vehicles Report for Accident/Repair Cars</h2></b> </td>
<td><b><h2><? print dateandtimetoHtml($df) ?>&nbspto <?print dateandtimetoHtml($dt)?> </h2></u></b></td></tr><tr><td colspan='2'>


<?


if(!isset($_GET['id'])){
     $_GET['id']=0;
  }
if($rec_by=='All'){
$qry=mysqli_query($db,"select count(*) from gateentry where (entrydate>='$df' and entrydate<='$dt') and brcode='$brcode'");
}
else{
$qry=mysqli_query($db,"select count(*) from gateentry where (entrydate>='$df' and entrydate<='$dt') and receivedby='$rec_by' and brcode='$brcode' ");
}
$qry1=mysqli_fetch_array($qry);
$cnt=$qry1[0];

$rowcnt=50;
$pgno=floor($cnt/$rowcnt);
if(($cnt%$rowcnt)>0){
   $pgno=$pgno+1;
}
print "<table align='center' id='pagen'><tr>";

  if($pgno>6){
      
     if($_GET['id']>0)
        $m=$_GET['id']-1;
     else
        $m=$_GET['id'];
      
  }
$nxtid=$_GET['id']+2;
$nxtval=$_GET['id']+1;
$prvid=$_GET['id']-2;
$prval=$_GET['id']-1;
$flg=1;

for($i=$m;$i<$pgno;$i++){
    
    $j=$i+1;
     
    if(($flg==1)&& ($_GET['id']>0)){
       print "<td><a href='vehreceived.php?id=$prval&&df=$df&&dt=$dt&&rec_by=$rec_by&&pgbt=Show' id='pg'><input type='button' class='pgbtn' id='pgbtn".$prvid."' value='Previous' /></a></td>";
    }

    if(($_GET['id']==2) && ($flg==1)){
       print "<td><a href='vehreceived.php?id=0&&df=$df&&dt=$dt&&rec_by=$rec_by&&pgbt=Show' id='pg'><input type='button' class='pgbtn' id='pgbtn1' value='1' /></a></td>";
    }

    if(($_GET['id']>=3) && ($flg==1)) {
       print "<td><a href='vehreceived.php?id=0&&df=$df&&dt=$dt&&rec_by=$rec_by&&pgbt=Show' id='pg'><input type='button' class='pgbtn' id='pgbtn1' value='1' /></a></td><td>...</td>";
    }

    if($flg<5){
       print "<td><a href='vehreceived.php?id=$i&&df=$df&&dt=$dt&&rec_by=$rec_by&&pgbt=Show' id='pg'><input type='button' class='pgbtn' id='pgbtn".$j."' value='".$j."' /></a></td>";
    }

    if($flg==5){
       print "<td>.</td><td>.</td><td>.</td>"; 
       $i=$pgno-2; 
    }

    if($flg==6){  
 	  
       print "<td><a href='vehreceived.php?id=$i&&df=$df&&dt=$dt&&rec_by=$rec_by&&pgbt=Show' id='pg'><input type='button' class='pgbtn' id='pgbtn".$j."' value='".$j."' /></a></td>";
 	print "<td><a href='vehreceived.php?id=$nxtval&&df=$df&&dt=$dt&&rec_by=$rec_by&&pgbt=Show' id='pg'><input type='button' class='pgbtn' id='pgbtn".$nxtid."' value='Next' /></a></td>";  
    }
  
    $flg++;
}
print "</tr></table>";
?>



</td></tr>
<tr><td colspan='2'>
<table width="100%" border="2" cellspacing="1" cellpadding="1" align='center' >
 

<?

$lmt1=$_GET['id']*$rowcnt;
$k=$lmt1+1;
if($rec_by=='All'){
$sql="select * from gateentry where (entrydate>='$df' and entrydate<='$dt') and brcode='$brcode' order by jcno limit $lmt1,$rowcnt";
}
else{
$sql="select * from gateentry where (entrydate>='$df' and entrydate<='$dt') and receivedby='$rec_by' and brcode='$brcode' order by jcno limit $lmt1,$rowcnt";
}

$re=mysqli_query($db,$sql) or die(mysqli_error($db));
 if(mysqli_num_rows($re)>0)
 {
 print "<tr><td><h3>No </h3></td><td><h3>Vehicle Name </h3></td><td><h3>Model  </h3></td><td><h3>Reg.No. </h3></td><td><h3>Job Card </h3></td><td><h3>Customer </h3></td><td><h3>P/Report</h3></td><td><h3>Insu./Pvt</h3></td><td><h3>L/Charge </h3></td><td><h3>D/date </h3></td><td><h3>Received by</h3></td><td><h3> Remarks</h3></td></tr>";
  $i=1;
 while($row=mysqli_fetch_array($re))
 {
$pos = strpos($row[insurance], 'SELECT');

if($pos>='0')
{
$insur='Private';
}
else
{
$sql2=mysqli_query($db,"select web from insmaster where cname='$row[insurance]'");

$abc=mysqli_fetch_array($sql2) or die(mysqli_error($db));
$insur=$abc[0];
}

print "<tr><td align=center>".$k++."</h3></td><td><h3>$row[vehiclename]</h3></td><td><h3><center>$row[model]</h3></td><td><h3>$row[regno]</h3></td><td><h3>".round($row[jcno])."</h3></td><td><h3>$row[customer]</h3></td><td><h3>$row[policereport]</h3></td><td><h3>$row[instype]</h3></td><td align=right><h3>$row[labour]</h3></td>";
print "<td><h3>".dateandtimetoHtml($row[estdate])."</h3></td><td><h3>$row[receivedby]</h3></td><td><h3>$row[remarks]</h3></td></tr>";
 }
 

}
?>

  </tr>
</table>
</td></tr></table>
</body>
</html>
<?	
return; 
}

?>
<form action='<?print $PHP_SELF?>' method='post'>
<table bgcolor=aliceblue class='form' align=center>
<tr bgcolor='green'><th colspan='4'><font color='white'>VEHICLE RECEIVED REPORT</font></th></tr>
<tr><td>From </td><td>DD <input type=text name=d1 size=2 value='<?print date("d")?>'></td>
		<td>MM <input type=text name=m1 size=2 value='<?print date("m")?>'></td>
		<td>YY <input type=text name=y1 size=4 value='<?print date("Y")?>'></td>
</tr>

<tr><td>To </td><td>DD <input type=text name=d2 size=2 value='<?print date("d")?>'></td>
		<td>MM <input type=text name=m2 size=2 value='<?print date("m")?>'></td>
		<td>YY <input type=text name=y2 size=4 value='<?print date("Y")?>'></td>
</tr>
<!--
<tr><td colspan=4 align=center><input type=radio name='chk' value='m' checked>by Month/date
			       <input type=radio name='chk' value='h' >by Hour </td>
</tr>
-->
<tr><td colspan='2'>Received by</td>
<td colspan='2'><select name='rec_by' id='rec_by'><option>All</option>
<?
$qr=mysqli_query($db,"select distinct(receivedby) from gateentry where brcode='$brcode' and receivedby<>'' ");
while($qr1=mysqli_fetch_row($qr))
{
print "<option>$qr1[0]</option>";
}
?>
</select></td></tr>
<tr ><td colspan=4 align=center><input type=submit name='show' value='Show'></td></tr>
</table>
</form>
