
 <?
 session_start();
$db=mysqli_connect("172.17.17.14","root","psn123#");
mysqli_select_db("xcsdb1") or die(mysqli_error($db));
 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;
			}

 			#button1
			{

			        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>



    <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>
         <tr>
    		<td rowspan=3>NO. OF VEHICLES</td>
              
              <?

                $yr='2014';

                $vah_tot[]=0;
                $cancel_tot[]=0;

                 $net_tot=0;

                for($i=1; $i<4; $i++){

                   $tot=0;
                   
                    if($i==1){
                     
                       print "<td>Received</td>";
                    }

                    if($i==2){
                     
                       print "<tr><td>Cancelled</td>";
                     }
                   
                    if($i==3){
                     
                       print "<tr><td>Released</td>";
                     }

                      for($month=1; $month<13; $month++){
                        
                        $st_dt=$yr."-".$month."-01 00:00:00"; 

                        $timestamp    = strtotime($st_dt);
                        $end_dt  = date('Y-m-t 23:59:59', $timestamp);

                        if($i==1)
                               {
                            $sql=mysqli_query($db,"select count(jcno) from gateentry where entrydate between '$st_dt' and '$end_dt' and jcno>0 and brcode='$brcode'")  ;
                               }
                        if($i==2)
                               {
                            $sql=mysqli_query($db,"select count(jcno) from gateentry where entrydate between '$st_dt' and '$end_dt' and jcno>0 and work_status ='JOB CARD CANCELLED' and brcode='$brcode'")  ;
                            
                 
                               }

                        if($i==3)
                               {
				
                            $sql=mysqli_query($db,"select count(jcno) from gateentry where entrydate  between '$st_dt' and '$end_dt' and jcno>0 and work_status ='RELASED' and brcode='$brcode'")  ;

                               }
				 $result1=mysqli_fetch_row($sql);  


                             ?>

                             <td> <a href='#pop211' class='links11' onclick="showdet('<? echo $i;?>','<? echo $st_dt;?>','<? echo $end_dt;?>')" style=''><? echo $result1[0]; ?></td>

                              <?

                          $tot+= $result1[0]; 
   
                           if($i==1){
                                     $vah_tot[$month]+=$result1[0];
                           }

				if($i==2){
                                     $cencel_tot[$month]+=$result1[0];
                           }

                       }

                       print "<td><b>".putcoma( $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++){

                     $n_tot=$vah_tot[$i]-$cencel_tot[$i];

     			print "<td><b>". $n_tot."</b></td>";

                    $net_tot+=$vah_tot[$i];

                    $net_tot-=$cencel_tot[$i];
   		 }

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


              <tr>

    		  <td rowspan=3>LABOUR SALES</td>
             


                <?
                    $lab_month_tot[]=0;
                    $lab_month_tot_cancel[]=0;
                   $net_tot=0;
                   for($i=1; $i<4; $i++){

                   $lab_tot=0;
                 
                   
                    if($i==1){
                     
                       print "<td>Received</td>";
                    }

                    if($i==2){
                     
                       print "<tr><td>Cancelled</td>";
                     }
                   
                    if($i==3){
                     
                       print "<tr><td>Released</td>";
                     }

                      for($month=1; $month<13; $month++){
                        
                        $st_dt=$yr."-".$month."-01 00:00:00"; 

                        $timestamp    = strtotime($st_dt);
                        $end_dt  = date('Y-m-t 23:59:59', $timestamp);

                        if($i==1)
                               {
                            $sql=mysqli_query($db,"select sum(labour) from gateentry where entrydate between '$st_dt' and '$end_dt' and jcno>0 and brcode='$brcode'")  ;

                               }
                       if($i==2)
                               {
                            $sql=mysqli_query($db,"select sum(labour)  from gateentry where entrydate between '$st_dt' and '$end_dt' and jcno>0 and work_status ='JOB CARD CANCELLED' and brcode='$brcode'")  ;
                            
                 
                               }

                        if($i==3)
                               {
				
                            $sql=mysqli_query($db,"select sum(labour)  from gateentry where entrydate  between '$st_dt' and '$end_dt' and jcno>0 and work_status ='RELASED' and brcode='$brcode'")  ;

                               }

                             

				 $result1=mysqli_fetch_row($sql);  
                                 
                              ?>
                               <td> <a href='#pop211' class='links11' onclick="showdet('<? echo $i;?>','<? echo $st_dt;?>','<? echo $end_dt;?>')" style=''><? echo $result1[0]; ?></td>

                              <?
                             $lab_tot+= $result1[0];    

                            

                             if($i==1){
                                     $lab_month_tot[$month]+=$result1[0];
                           }

				if($i==2){
                                     $lab_month_tot_cancel[$month]+=$result1[0];
                           }
                       }

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

               print "<tr bgcolor='#FFDBDB'><td colspan='2' align='center'><b>Labour Total</b></td>";

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

                     $n_tot=$lab_month_tot[$i]-$lab_month_tot_cancel[$i];

     			print "<td><b>".$n_tot."</b></td>";

                    $net_tot+=$lab_month_tot[$i];
			$net_tot-=$lab_month_tot_cancel[$i];
   		 }

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

  ?>


              <tr>

    		  <td rowspan=2>Vehicle Nos</td>
             


                <?

                    $lab_month_tot[]=0;
                    $lab_month_tot_cancel[]=0;
                   $net_tot=0;
                   $lab_tot=0;
                   for($i=1; $i<3; $i++){

                   $lab_tot=0;
                 
                   
                    if($i==1){
                     
                       print "<td>Private</td>";
                    }

                    if($i==2){
                     
                       print "<tr><td>Insurance</td>";
                     }
                   
                    

                      for($month=1; $month<13; $month++){
                        
                        $st_dt=$yr."-".$month."-01 00:00:00"; 

                        $timestamp    = strtotime($st_dt);
                        $end_dt  = date('Y-m-t 23:59:59', $timestamp);

                        if($i==1)
                               {
                            $sql=mysqli_query($db,"select count(*) from gateentry where entrydate between '$st_dt' and '$end_dt' and jcno>0 and brcode='$brcode' and instype!='Insurance'")  ;

                               }
                        if($i==2)
                               {
                           $sql=mysqli_query($db,"select count(*) from gateentry where entrydate between '$st_dt' and '$end_dt' and jcno>0 and brcode='$brcode' and instype='Insurance'")  ;

 
                               }

                        

                             

				 $result1=mysqli_fetch_row($sql);  
                                 
        
                             print "<td> $result1[0]</td>";

                             $lab_tot+= $result1[0];    

                            

                             if($i==1){
                                     $lab_month_tot[$month]+=$result1[0];
                           }

				if($i==2){
                                     $lab_month_tot_cancel[$month]+=$result1[0];
                           }
                       }

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

               print "<tr bgcolor='#FFDBDB'><td colspan='2' align='center'><b>Vehicle Total</b></td>";

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

                     $n_tot=$lab_month_tot[$i];

     			print "<td><b>".$nn_tot."</b></td>";

                    $net_tot+=$lab_month_tot[$i];
			$net_tot-=$lab_month_tot_cancel[$i];
   		 }

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

?>



              <tr>

    		  <td rowspan=2>Insurance (Sale)</td>
             


                <?

                   $credit_tot[]=0;
                   $cash_tot[]=0;
                   $net_tot=0;
                   $sale_tot=0;
                   $n_tot=0;
                   $grand_tot[]=0;
                   for($i=1; $i<3; $i++){

                   $sale_tot=0;
                 
                   
                    if($i==1){
                     
                       print "<td>Credit</td>";
                    }

                    if($i==2){
                     
                       print "<tr><td>Cash</td>";
                     }
                   
                    
                        $yr='2013';
                      for($month=1; $month<13; $month++){
                        
                        $st_dt=$yr."-".$month."-01 00:00:00"; 

                        $timestamp    = strtotime($st_dt);
                        $end_dt  = date('Y-m-t 23:59:59', $timestamp);

                        if($i==1)
                               {
                            $sql=mysqli_query($db,"select sum(amt) from jcardinvoice where date between '$st_dt' and '$end_dt' and invno>0 and brcode='$brcode' and typ='ins' and pmode='CREDIT'");
echo "select sum(amt) from jcardinvoice where date between '$st_dt' and '$end_dt' and invno>0 and brcode='$brcode' and typ='ins' and pmode='CREDIT' "."<br>";

                               }
                        if($i==2)
                               {
                           $sql=mysqli_query($db,"select sum(amt) from jcardinvoice where date between '$st_dt' and '$end_dt' and invno>0 and brcode='$brcode' and typ='ins' and pmode='CASH'");

 
                               }

                        

                             

				 $result1=mysqli_fetch_row($sql);  
                                 
        
                             print "<td> $result1[0]</td>";

                             $sale_tot+= $result1[0];    

                            

                             if($i==1){
                                     $credit_tot[$month]+=$result1[0];

                           }

				if($i==2){
                                     $cash_tot[$month]+=$result1[0];

                           }
                       }

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

               print "<tr bgcolor='#FFDBDB'><td colspan='2' align='center'><b>Insurance sale Total</b></td>";

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

                     $n_tot=$credit_tot[$i]+$cash_tot[$i];

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

                    $net_tot+=$n_tot;
                    $grand_tot[$i]+=$n_tot;
			
   		 }
  		
		print "<td><b>".putcoma($net_tot)."</b></td></tr>";

?>





              <tr>

    		  <td rowspan=2>Private (Sale)</td>
             


                <?

                   $pvt_credit_tot[]=0;
                   $pvt_cash_tot[]=0;
			$pvt_grand_tot[]=0;
                   $pvt_net_tot=0;
                   $pvt_sale_tot=0;
                    $pvt_n_tot=0;
			
                   for($i=1; $i<3; $i++){

                   $pvt_sale_tot=0;
                 
                   
                    if($i==1){
                     
                       print "<td>Credit</td>";
                    }

                    if($i==2){
                     
                       print "<tr><td>Cash</td>";
                     }
                   
                     $yr='2013';

                      for($month=1; $month<13; $month++){
                        
                        $st_dt=$yr."-".$month."-01 00:00:00"; 

                        $timestamp    = strtotime($st_dt);
                        $end_dt  = date('Y-m-t 23:59:59', $timestamp);

                        if($i==1)
                               {
                            $sql=mysqli_query($db,"select sum(amt) from jcardinvoice where date between '$st_dt' and '$end_dt' and invno>0 and brcode='$brcode' and typ='cus' and pmode='CREDIT'");
//echo "select sum(amt) from jcardinvoice where date between '$st_dt' and '$end_dt' and invno>0 and brcode='$brcode' and typ='cus' and pmode='CREDIT'";
                               }
                        if($i==2)
                               {
                           $sql=mysqli_query($db,"select sum(amt) from jcardinvoice where date between '$st_dt' and '$end_dt' and invno>0 and brcode='$brcode' and typ='cus' and pmode='CASH'");

 
                               }

                        

                             

				 $result1=mysqli_fetch_row($sql);  
                                 
        
                             print "<td> $result1[0]</td>";

                             $pvt_sale_tot+= $result1[0];    

                            

                             if($i==1){
                                     $pvt_credit_tot[$month]+=$result1[0];

                           }

				if($i==2){
                                     $pvt_cash_tot[$month]+=$result1[0];

                           }
                       }

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

               print "<tr bgcolor='#FFDBDB'><td colspan='2' align='center'><b>Private sale Total</b></td>";

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

                     $pvt_n_tot=$pvt_credit_tot[$i]+$pvt_cash_tot[$i];

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

                    $pvt_net_tot+=$pvt_n_tot;
                     $pvt_grand_tot[$i]+=$pvt_n_tot;
			
   		 }
  		
		print "<td><b>".putcoma($pvt_net_tot)."</b></td></tr>";

print "<tr bgcolor='#FFDBDB'><td colspan='2' align='center'><b>Total sale </b></td>";
$grand_both_tot=0;
for($i=1;$i<=12;$i++){

                     $both_tot=$grand_tot[$i]+$pvt_grand_tot[$i];

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

                     $grand_both_tot+=$both_tot;
           
                   }
                print "<td><b>".putcoma($grand_both_tot)."</b></td></tr>";
               print "<tr><th colspan='15' height='10'></th></tr></table>";
               ?>

             
                 
            
       </body>



  <script>

function showdet(status,from_dt,to_dt)
{

document.getElementById("popScroll211").innerHTML="Loading...";

if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("popScroll211").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","mis_serv_type_detail.php?status="+status+"&&st_dt="+from_dt+"&&end_dt="+to_dt, true);
xmlhttp.send();
}

</script>              
               
                     
                 

        


