<?php include "layouts/menu.php"; ?>
		<script type="text/javascript">
	  $(function() {
   $("#datepicker").datepicker({ dateFormat: 'dd-mm-yy' });
  });
</script>
<script type="text/javascript">
function zp(n){
return n<10?("0"+n):n;
}
function insertDate(t,format){
var now=new Date();
var DD=zp(now.getDate());
var MM=zp(now.getMonth()+1);
var YYYY=now.getFullYear();
format=format.replace(/DD/,DD);
format=format.replace(/MM/,MM);
format=format.replace(/YYYY/,YYYY);
t.value=format;
}
</script>
    <script>
  $(function() {
   $("#datepicker1").datepicker({ dateFormat: 'dd-mm-yy' });
  });
  </script>
    <script>
  $(function() {
   $("#datepicker2").datepicker({ dateFormat: 'dd-mm-yy' });
  });
  </script>
      <script>
  $(function() {
   $("#datepicker8").datepicker({ dateFormat: 'dd-mm-yy' });
  });
  </script>
    <script>
  $(function() {
   $("#datepicker9").datepicker({ dateFormat: 'dd-mm-yy' });
  });
  </script>
  <script type="text/javascript">

    function PrintElem(elem)
    {
        Popup($(elem).html());
    }

    function Popup(data) 
    {
        var mywindow = window.open('', 'my div', 'height=400,width=600');
        mywindow.document.write('<html><head><title>INFOSSEL SOFT SOLUTIONS</title>');
        /*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
        mywindow.document.write(' <h1 style="color:green;text-align:center;" >INFOSSEL SOFT SOLUTIONS</h1><body >');
        mywindow.document.write(data);
        mywindow.document.write('<h3 style="text-align:right;">Signed by</h3><h3 style="color:blue;text-align:right;">For INFOSSEL SOFT SOLUTIONS</h3></body></html>');

        mywindow.print();
        mywindow.close();

        return true;
    }

</script>
   <script type="text/javascript">
function CollapseForm()
{
// Two places to customize:

// Specify the id of the form.
var IDofForm = "form1";

// Specify the id of the div containing the form.
var IDofDivWithForm = "demo";

// This line submits the form. (If Ajax processed, call Ajax function, instead.)
document.getElementById(IDofForm).submit();

// This line collapses the form.
document.getElementById(IDofDivWithForm).style.display = "none";
}
</script>
     
<?php include "layouts/menu1.php"; ?>
            <!-- Right side column. Contains the navbar and content of the page -->
           <div class="right_col" role="main">
                <!-- Content Header (Page header) -->
              <section class="content-header">
                    <div class="col-lg-6">  	
   
 
  </br></br>
</div>

  <div class="pull-right box-tools">

   <form id="form1" name="form1" class="form-horizontal" method="post" action="" enctype="multipart/form-data">
   
  
                                        <button class="btn btn-danger btn-sm refresh-btn" data-toggle="tooltip" title="Reload"  ><i class="fa fa-refresh"></i></button>
                                        <button class="btn btn-danger btn-sm" data-widget='collapse' data-toggle="tooltip" title="Collapse" ><i class="fa fa-minus"></i></button>
                                        <button class="btn btn-danger btn-sm" data-widget='remove' data-toggle="tooltip" title="Remove" ><i class="fa fa-times"></i></button>
                                    </div>

                </section>
				
                 
                <!-- Main content -->
                <section class="content">
                    <div class="row">
                        <div class="col-xs-12"> 
                            <div class="box">
                               <!-- /.box-header -->
                                <div class="box-body table-responsive">
                                  
 				
									 <div class="alert alert-info">MONTHLY LOG REPORT</div>
    <form class="form-horizontal" method="post" action="" enctype="multipart/form-data">
    <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Enter From Date</label>
    <div class="col-sm-4">
    <input type="text" class="form-control" id="datepicker" name="fdate" value="<?php echo date('01-m-Y'); ?>" placeholder="DD/MM/YYYY" onfocus="insertDate(this,'DD-MM-YYYY')">
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Enter To Date</label>
    <div class="col-sm-4">
    <input type="text" class="form-control" id="datepicker" name="tdate" value="<?php echo date('t-m-Y'); ?>" placeholder="DD/MM/YYYY" onfocus="insertDate(this,'DD-MM-YYYY')">
    </div>
  </div>
			<div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default" name="s129">Total</button>
    </div>
  </div>
    <?php
								if(isset($_POST['s129']))
								{
									extract($_POST);
									
									 ?>
									 <div id="mydiv">
<input type="button" value="Print" onclick="PrintElem('#mydiv')"  style="margin:20px;">
<h4><b>LOG REPORT <?php echo $fdate; ?> To <?php echo $tdate; ?> Print Time : <? echo date('d-m-Y h:i:sa'); ?></b></h4>
										<table class="table table-striped" table class="table" border="1" align="center" cellspacing="0" cellpadding="10" >
					<col width="100px">
						<tr class="danger" style="color:purple;">
						<th>VEHICLE</th>
						<th>CLOSING KM</th>
						<th>OPENING KM</th>
						<th>TOTAL KM</th>
						<th>CLASS</th>
						<th>FUEL</th>
						<th>CLASS MILEAGE</th>
						<th>WORKSHOP</th>
						
						
					</tr>
									
									<?php    $exp = 0; $class5 = 0;
									$ffdate = $fdate;
									$qry55=mysqli_query($conn, "select * from veh");
									while($row55=mysqli_fetch_array($qry55)) {
									$fdate = $ffdate;
									$e=0;  $s=0;  $r=0;  $t=0; $d=0; $t1 = 0; $deb = 0;
									$open = 0;
									$close = 0;
									$exp = 0; $class5 = 0;
									$mil = 0;
										$vehh = $row55['debit'];
								while (strtotime($fdate) <= strtotime($tdate)) 
								{
									   $paydate = $fdate;
						$qry=mysqli_query($conn, "select * from vehc where mfin='$mfin' &&  date='$paydate' && veh='$vehh'");
									while($row=mysqli_fetch_array($qry))
						{ $t1++;
						 if($t1==1){
						 $open = $row['open'];
						 }
						 $close = $row['close'];
									}
									$qry=mysqli_query($conn, "select * from vdebit where mfin='$mfin' &&  date='$paydate' && car='$vehh' && cat='Fuel'");
									while($row=mysqli_fetch_array($qry))
						{ 
						 $deb = $deb + $row['debit'];
									}
									$qry7=mysqli_query($conn, "select * from att where mfin='$mfin' &&  date='$paydate' && car='$vehh'");
									while($row7=mysqli_fetch_array($qry7))
						{ 
						 $class5 = $class5 + $row7['class'];
						 
									}
									$qry22=mysqli_query($conn, "select * from vdebit where mfin='$mfin' &&  date='$paydate' && car='$vehh' && cat!='Fuel'");
					while($row26=mysqli_fetch_array($qry22))
						{
					$exp = $exp + $row26['debit']; 

								} 
									$fdate = date ("d-m-Y", strtotime("+1 day", strtotime($fdate))); 
									}
						
						?></p>
				
					<tr class="warning">
					<col width="100px">
				
					<tr class="warning">
					<col width="100px"> <?php
					$total = 0;
					$total = $close - $open;
                    $mil = $total / $class5; 		
					?>
					<td><?php echo $vehh;?></td>
						<td><?php echo $close;?></td>
						<td><?php echo $open;?></td>
						<td><?php echo $total;?></td><td><?php echo $class5;?></td>
						<td><?php echo $deb;?></td>
						<td><?php echo round($mil,2);?></td>
						<td><?php echo $exp; ?></td>
											</tr>
				
						
					 
					 <?php
									}}
					
				
					?>
					</table>	</form> 
                                  	
                              </div>  </div><!-- /.box-body -->
                            </div><!-- /.box -->
                        </div>
                    </div>

                </section><!-- /.content -->
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->


        <!-- jQuery 2.0.2 -->
       <?php include "layouts/footer.php"; ?>

    </body>
</html>