
 <?
 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>

 		<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() {
          
           			 	$(this).animate({
               		 	height: "110",
               	 		width: "110",
              
            				}, "fast");
                    			}, function() {
            
                    			$(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>

 			th{
 
    				font-weight: bold;  
    				color: white; 
    				border:1px solid #D7D7D1;
   			       border-collapse:collapse;
    				background: rgb(181,189,200); /* Old browsers */
    				background: -moz-linear-gradient(top, rgba(181,189,200,1) 0%, rgba(130,140,149,1) 36%, rgba(40,52,59,1) 100%); /* FF3.6+ */
    				background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(181,189,200,1)), color-stop(36%,rgba(130,140,149,1)), color-stop(100%,rgba(40,52,59,1))); /* Chrome,Safari4+ */
    				background: -webkit-linear-gradient(top, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); /* Chrome10+,Safari5.1+ */
    				background: -o-linear-gradient(top, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); /* Opera 11.10+ */
				background: -ms-linear-gradient(top, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); /* IE10+ */
				background: linear-gradient(to bottom, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); /* W3C */
				filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b5bdc8', endColorstr='#28343b',GradientType=0 ); /* IE6-9 */
			}

			#tbl td{
				border: 1px solid black;
				border-collapse:collapse;
				border-style:dotted;
			}

			#tbl{
				border: 1px solid black;
				border-collapse:collapse;
				border-style:dotted;
			}

 			#button6
			{

			        color:red;
			}

           
			 #links{

			       color:#777777;

			}


.pop-up211 {position:absolute; top:10px; left:50px;padding-left:360px;}
.pop-up211:target {position:static; left:0;}

.popBox211 {
  background:#ffffff;

 
  width:40%;
  min-height:60%;



   z-index:1;

  border:1px solid #3a3a3a;


  -moz-border-radius:12px;
  border-radius:12px;
  -webkit-box-shadow:2px 2px 4px #3a3a3a;
  -moz-box-shadow:2px 2px 4px #3a3a3a;
  box-shadow:2px 2px 4px #3a3a3a;
  opacity:0;
 -webkit-transition: opacity 0.5s ease-in-out;
  -moz-transition: opacity 0.5s ease-in-out;
  -o-transition: opacity 0.5s ease-in-out;
  -ms-transition: opacity 0.5s ease-in-out;
  transition: opacity 0.5s ease-in-out;  
}
:target .popBox211 {position:fixed; opacity:1;}

.popBox211:hover {box-shadow:3px 3px 6px #5a5a5a;}



.lightbox11 {display:none; text-indent:0em; background:#000; opacity:0.0; width:100%; height:100%; position:fixed; top:0; left:0; bottom:0; right:0;}
:target .lightbox11 {display:block}

.popScroll211 {position:absolute; top:9%; left:3%; right:3%; bottom:9%; overflow-y:auto; *overflow-y:scroll; padding-right:0.5em}



			


		</style>

   <body background="back_ground.jpg">

    <?php 

	include('includes/top.php');

        
      include('mis_repo1.php');
     ?>

<div id="pop211" class="pop-up211" >
  <div class="popBox211">
<div class="popScroll211" id='popScroll211' >
</div>
  </div>
 <a href="#" class="lightbox11"></a>
</div>


<center><h2><font color='white'>MONTHLY SERVICE MIS</font></h2></center>
<br>
<table class='tbl' id='tbl'  align='center' width='100%' border='1' bgcolor='white'>
<tr><th colspan='2' height='35'><b>PARAMETER</b></th><th><b>JAN</th><th><b>FEB</th><th><b>MAR</th><th><b>APRIL</b></th><th><b>MAY</th><th><b>JUNE</th><th><b>JULY</th><th><b>AUG</th><th><b>SEPT</th><th><b>OCT</th><th><b>NOV</th><th><b>DEC</th><th><b>TOTAL</th></TR>
 <?
 $qry=mysqli_query($db,"select count(jobtype) from jobtype_master where brcode='$brcode'");
 $qry1=mysqli_fetch_row($qry);
 ?>
<tr ><td rowspan='<? echo $qry1[0]; ?> '><b>NO. OF VEHICLES</b></td>
 <?
 $sql=mysqli_query($db,"select jobtype from jobtype_master where brcode='$brcode'");

 for($i=1;$i<=12;$i++){
     $tot[$i]=0;
 }
 $net_tot=0;
 while($row=mysqli_fetch_row($sql))
 { 
   print "<td >".$row[0]."</td>";
   
   $j=12;
   $veh_tot=0;
  
    for($i=1;$i<=12;$i++){
   

     if($i<=12){
     $from_dt=$yr."-".$i."-01 ";
     $to_dt=$yr."-".$i."-31 ";
     $sql1=mysqli_query($db,"select count(jcno) from gateentry where entrydate between '$from_dt' and '$to_dt' and jcno>'0' and instype='$row[0]' and brcode='$brcode'");
     }
     else{
     $yr=$yr+1;
     $k=$i-$j;
     $from_dt=$yr."-".$k."-01 ";
     $to_dt=$yr."-".$k."-31 ";
     $sql1=mysqli_query($db,"select count(jcno) from gateentry where entrydate between '$from_dt' and '$to_dt' and jcno>'0' and instype='$row[0]' and brcode='$brcode'");
     }
 //print "select count(jcno) from gateentry where inv_date between '$from_dt' and '$to_dt' and jcno>'0' and instype='$row[0]' and brcode='$brcode'";
     $row1=mysqli_fetch_row($sql1);
     print "<td >$row1[0]</td>";
     $veh_tot+=$row1[0];
     $tot[$i]+=$row1[0];
     $net_tot+=$row1[0];
   }
   print "<td ><b>".$veh_tot."</b></td></tr>";
 }

   print "<tr bgcolor='#FFDBDB'><td colspan='2' align='center'><b>Total no. of Vehicles</b></td>";
   for($i=1;$i<=12;$i++){
     echo "<td><b>". $tot[$i]."</b></td>";
   }
print "<td><b>".$net_tot."</b></td></tr>";

print "<tr bgcolor='#D6D6FF'><td colspan='2' ><b>No. of Bays</b></td>";
  for($i=1;$i<=13;$i++){
    print "<td>25</td>";
   }
?>
</tr>

 <?
 $qry2=mysqli_query($db,"select count(jobtype) from jobtype_master where brcode='$brcode'");
 $qry3=mysqli_fetch_row($qry2);
 ?>
<tr ><td rowspan='<? echo $qry3[0]; ?> '><b>LABOUR SALES</b></td>
<?
 $sql=mysqli_query($db,"select jobtype from jobtype_master where brcode='$brcode'");

     for($i=1;$i<=12;$i++){
     $ltot[$i]=0;
     }
 $lnet_tot=0;
 while($row=mysqli_fetch_row($sql))
 { 
   print "<td >".$row[0]."</td>";

   $j=12;
   $lab_tot=0;
  
    for($i=1;$i<=12;$i++){
   

     if($i<=12){
     $from_dt=$yr."-".$i."-01";
     $to_dt=$yr."-".$i."-31";
     $sql1=mysqli_query($db,"select sum(jcardserv.servamt) from jcardserv INNER JOIN gateentry ON jcardserv.jcno=gateentry.jcno where gateentry.inv_date between '$from_dt' and '$to_dt' and jcardserv.jcno>'0' and  gateentry.instype='$row[0]' and jcardserv.brcode='$brcode'");

     }
     else{
     $yr=$yr+1;
     $k=$i-$j;
     $from_dt=$yr."-".$k."-01 ";
     $to_dt=$yr."-".$k."-31";
     $sql1=mysqli_query($db,"select sum(jcardserv.servamt) from jcardserv INNER JOIN gateentry ON jcardserv.jcno=gateentry.jcno where gateentry.inv_date between '$from_dt' and '$to_dt' and jcardserv.jcno>'0' and  gateentry.instype='$row[0]' and jcardserv.brcode='$brcode'");

     }
     //print "select sum(jcardserv.servamt) from jcardserv INNER JOIN gateentry ON jcardserv.jcno=gateentry.jcno where gateentry.inv_date between '$from_dt' and '$to_dt' and jcardserv.jcno>'0' and  gateentry.instype='$row[0]' and jcardserv.brcode='$brcode'";
     $row1=mysqli_fetch_row($sql1);
     print "<td >$row1[0]</td>";
     $lab_tot+=$row1[0];
     $ltot[$i]+=$row1[0];
     $lnet_tot+=$row1[0];
   }
   print "<td ><b>".putcoma($lab_tot)."</b></td></tr>";
 }
   print "<tr bgcolor='#FFDBDB'><td colspan='2' align='center'><b>Total Labour Sales</b></td>";
   for($i=1;$i<=12;$i++){
     echo "<td><b>".putcoma( $ltot[$i])."</b></td>";
   }
print "<td><b>".putcoma($lnet_tot)."</b></td></tr>";


print "<tr bgcolor='#D6D6FF'><td colspan='2' align='center'>Outside Labour</td>";

  
   $j=12;
   
   $lab_tot=0;
   $net_lab_total=0;
    for($i=1;$i<=12;$i++){
        $sub_tot[$i]=0;
        $net_lab_tot[$i]=0;
    

     if($i<=12){
     $from_dt=$yr."-".$i."-01";
     $to_dt=$yr."-".$i."-31";
     $sql1=mysqli_query($db,"select sum(jcardserv.subamt) from jcardserv INNER JOIN gateentry ON jcardserv.jcno=gateentry.jcno where gateentry.inv_date between '$from_dt' and '$to_dt' and jcardserv.jcno>'0'  and jcardserv.brcode='$brcode'");
     }
     else{
     $yr=$yr+1;
     $k=$i-$j;
     $from_dt=$yr."-".$k."-01";
     $to_dt=$yr."-".$k."-31";
     $sql1=mysqli_query($db,"select sum(jcardserv.subamt) from jcardserv INNER JOIN gateentry ON jcardserv.jcno=gateentry.jcno where gateentry.inv_date between '$from_dt' and '$to_dt' and jcardserv.jcno>'0'  and jcardserv.brcode='$brcode'");
     }
     $row1=mysqli_fetch_array($sql1);
     print "<td>$row1[0]</td>";

     $subnet_tot+=$row1[0];
     $sub_tot[$i]+=$row1[0];
     $net_lab_tot[$i]=$ltot[$i]-$sub_tot[$i];
     $net_lab_total+=$net_lab_tot[$i];
   }
   print "<td><b>".putcoma($subnet_tot)."</b></td></tr>";
  
  print "<tr bgcolor='#FFDBDB'><td colspan='2' align='center'><b>Net Labour</b></td>";
       for($i=1;$i<=12;$i++){
     echo "<td><b>".putcoma($net_lab_tot[$i])."</b></td>";
   }

 print "<td><b>".putcoma($net_lab_total)."</b></td></tr>";

print "<tr bgcolor='#D6D6FF'><td colspan='2' align='center'><b>Net Labour per Vehicle</b></td>";
       $net_lab_pveh=0;
       for($i=1;$i<=12;$i++){
      $lab_pveh[$i]=round($net_lab_tot[$i]/$tot[$i]);
      $net_lab_pveh+=$lab_pveh[$i];
     echo "<td>".putcoma($lab_pveh[$i])."</td>";
   }
print "<td><b>".putcoma($net_lab_pveh)."</b></td></tr>";
?>

 <?
 $qry4=mysqli_query($db,"select count(jobtype) from jobtype_master where brcode='$brcode'");
 $qry5=mysqli_fetch_row($qry4);
 ?>

<tr ><td rowspan='<? echo $qry5[0]; ?> '><b>PARTS SALES</b></td>
<?
 $sql=mysqli_query($db,"select jobtype from jobtype_master where brcode='$brcode'");

     for($i=1;$i<=12;$i++){
     $ptot[$i]=0;
     }
 $pnet_tot=0;
 while($row=mysqli_fetch_row($sql))
 { 
   print "<td >".$row[0]."</td>";
  
   $j=12;
   $part_tot=0;
  
    for($i=1;$i<=12;$i++){
   

     if($i<=12){
     $from_dt=$yr."-".$i."-01";
     $to_dt=$yr."-".$i."-31";
     $sql1=mysqli_query($db,"select sum(jcardparts.gtot) from jcardparts INNER JOIN gateentry ON jcardparts.jcno=gateentry.jcno where gateentry.inv_date between '$from_dt' and '$to_dt' and jcardparts.jcno>'0' and  gateentry.instype='$row[0]' and jcardparts.brcode='$brcode'");
     
     }
     else{
     $yr=$yr+1;
     $k=$i-$j;
     $from_dt=$yr."-".$k."-01";
     $to_dt=$yr."-".$k."-31";
     $sql1=mysqli_query($db,"select sum(jcardparts.gtot) from jcardparts INNER JOIN gateentry ON jcardparts.jcno=gateentry.jcno where gateentry.inv_date between '$from_dt' and '$to_dt' and jcardparts.jcno>'0' and  gateentry.instype='$row[0]' and jcardparts.brcode='$brcode'");
     }
//print "select sum(jcardparts.gtot) from jcardparts INNER JOIN gateentry ON jcardparts.jcno=gateentry.jcno where gateentry.inv_date between '$from_dt' and '$to_dt' and jcardparts.jcno>'0' and  gateentry.instype='$row[0]' and jcardparts.brcode='$brcode'";
     $row1=mysqli_fetch_row($sql1);
     print "<td >$row1[0]</td>";
     $part_tot+=$row1[0];
     $ptot[$i]+=$row1[0];
     $pnet_tot+=$row1[0];
   }
   print "<td ><b>".putcoma($part_tot)."</b></td></tr>";
 }
   print "<tr bgcolor='#FFDBDB'><td colspan='2' align='center'><b>Total Parts Sales</b></td>";
   for($i=1;$i<=12;$i++){
     echo "<td><b>".putcoma( $ptot[$i])."</b></td>";
   }
print "<td><b>".putcoma($pnet_tot)."</b></td></tr>";

print "<tr bgcolor='#D6D6FF'><td colspan='2' align='center'><b>Spare per Vehicle</b></td>";
       $net_part_pveh=0;
       for($i=1;$i<=12;$i++){
      $part_pveh[$i]=round($ptot[$i]/$tot[$i]);
      $net_part_pveh+=$part_pveh[$i];
     echo "<td>".putcoma($part_pveh[$i])."</td>";
   }
print "<td><b>".putcoma($net_part_pveh)."</b></td></tr>";
?>
<tr><th colspan='15' height='20'></th></tr>

</table>
</body>