<?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 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>
  $(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 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">Salary 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">Name</label>
    <div class="col-sm-4">
      <select type="text" class="form-control" id="inputPassword3" name="name" value="" placeholder="">
	  <option>Select</option>
	  <?php $qry=mysqli_query($conn, "select * from customer");
	  while($row2=mysqli_fetch_array($qry))
						{ ?>
						<option><?php echo $row2['name'];?></option> <?php } ?></select> 
    </div>
  </div>	   
	<div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">From</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">To</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">Goto</button>
    </div>
  </div></div>
    <?php
								if(isset($_POST['s129']))
								{
									extract($_POST);
									$nna = $name;
									$ffdate= $fdate;
								
									 ?>
					</br>				 
<input type="button" value="Print" onclick="PrintElem('#mydiv')"  style="margin:20px;">
					<div id="mydiv">

<h4><b><?php echo $name; ?> Report - <?php echo $fdate; ?> To <?php echo $tdate; ?></b></h4>
									<table class="table table-bordered table-hover"><thead>
  <tr class="info">  
  <th>Date</th>
  <th>P/A</th>
					</tr></thead>	
									<?php $i5 = 1; $a = 0; $h = 0; $p = 0; $tot = 0; $dde = 0;
$qry3=mysqli_query($conn, "select * from customer");
while($row3=mysqli_fetch_array($qry3))
						{
							$qqw = $row3['name'];
							if($qqw == $nna){
								$qsm = $i + 1;
							}
							$i++;
						 } $as = "as".$qsm.""; 
								while (strtotime($fdate) <= strtotime($tdate)) 
								{
									$paydate = $fdate;
					$qryy=mysqli_query($conn, "select * from attt where mfin='$mfin' &&  date='$paydate'");
				
                ?>
					<tbody>
					<col width="100px">
								<?php 		while($roww=mysqli_fetch_array($qryy))
						{ ?><tr class="warning">
					<td><?php echo $roww['date'];?></td>
				<?php $dde = $dde + 1;
                           
						$ax1 = $roww[$as];
						if($ax1 == 'p')
						{
						$p = $p + 1; ?>
						<td><font color="green"><?php echo $roww[$as];?></font></td> <?php }
						
						if($ax1 == 'a')
						{ $a = $a + 1; ?>
						<td><font color="red"><?php echo $roww[$as];?></font></td> <?php }
						 
						  if($ax1 == 'h')
						{ $h = $h + 1; ?>
						<td><font color="blue"><?php echo $roww[$as];?></font></td> <?php }
												  ?>
				
					</tr>
					<?php } ?></tbody>					
					 <?php
						 
									
									$fdate = date ("d-m-Y", strtotime("+1 day", strtotime($fdate))); 
									}
?>
						</br>
					</table> <?php $tot = $p + ($h / 2) ; ?> Total Days Prensent = <?php echo $tot; ?> For <?php echo $dde; ?> Days<?php
					 
									 ?>
<table class="table table-striped" table class="table" border="1" align="center" cellspacing="0" cellpadding="10" >
					 
                                        <thead>
                                            <tr>
												<th>Date</th>
												<th>Amount</th>
												<th>Cat</th>
												<th>Details</th>
												
                                            </tr>
                                        </thead>
										<?php
$fdate = $ffdate; 
										while (strtotime($fdate) <= strtotime($tdate)) 
								{ 
							 $paydate = $fdate;
							$qry22=mysqli_query($conn, "select * from salary where mfin='$mfin' &&  date='$paydate' && name='$name'");
					while($row2=mysqli_fetch_array($qry22))
					{ 
					?>
                                        <tbody>
                                           <tr><col width="100px">
                                               <td><?php echo $row2['date'];?></td>
						<td><?php echo $row2['debit']; ?></td><td><?php echo $row2['cat']; ?></td>
						<td><?php echo $row2['details']; ?></td>
						
                                            </tr>
                                          </tbody>
                                        <?php

								} 
								$fdate = date ("d-m-Y", strtotime("+1 day", strtotime($fdate))); 
								}
				
					?>
					                    
                                    </table>		
                <?php
									}
					
				
					?>
						</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>