<?php  include "layouts/menu.php"; ?>
 <style>
  .tfoot {
      font-weight:bold;
      text-transform:uppercase;
      color:@color-footer;
      text-shadow:1px 1px 1px #fff;
    }
	</style>
        <div class="right_col" role="main">
          <div class="">


            <div class="clearfix"></div>

            <div class="clearfix"></div>

            <div class="row">
      <div class="col-md-12">
       
				        <form id="demo-form2" data-parsley-validate class="form-horizontal form-label-left" method="post"  enctype="multipart/form-data">
  <div class="col-md-3">  <input type="date" class="form-control thicker" id="datepicker" name="fdate" value="<?php echo date("Y-m-d"); ?>" placeholder="From Date" onfocus="insertDate(this,'DD-MM-YYYY')">
    </div>
    <div class="col-md-3">   <input type="date" class="form-control thicker" id="datepicker" name="tdate" value="<?php echo date("Y-m-d"); ?>" placeholder="To Date" onfocus="insertDate(this,'DD-MM-YYYY')">
   </div>
   <div class="col-md-3">    <select type="text" class="form-control thicker" id="typp" name="typp" value="">
	<option value="0">All</option>
	<option value="1">Cash A/C</option>
	<option value="2">Bank A/C</option></select>
    </div>
   <div class="col-md-3">      <button type="submit" class="btn btn-info" name="s15">Show It</button></div>
              
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  
                  <div class="x_content">
                    <div class="row">
                      <div class="col-sm-12">
                        <div class="card-box table-responsive">
                          
                                        <?php
		
								if(isset($_POST['s15']))
								{
									extract($_POST);
									
									header("location:monbillrep2.php?fdate=$fdate&&tdate=$tdate");
								} ?>
								<?php $bal = 0; $a22 = 0; 
										$fdate = date("Y-m-d");
$tdate = date("Y-m-d"); ?>
						
  <table id="datatable-buttons" id="datatable-buttons" class="table table-striped table-bordered">                            <thead>
                             <tr class="alert alert-info">
					<th style="width:7%">Rcpt No</th>	<th style="width:10%">Laon No</th>
						
						<th style="width:15%">Name</th>
							<th style="width:10%">Status</th>
						
						
						<th> Date</th>
							<th>Total</th>
					
						<th>Prin Amt</th>
						<th>Int Amt</th>
						<th>Def Amt</th>
						<th>HL Amt</th>
			<?php  if(($postt == 'MD') || ($postt == 'Office All')) { ?> 	<th>#Options</th> <?php } ?>
				<th>Created By </th>
							<th>Altered By</th>
					
					</tr>
                            </thead>
                           <tbody>			
					<?php $damt = 0; $pass = 0; $rno = 0; $fine = 0; $urname = 0; $hll = 0;
					//while (strtotime($fdate) <= strtotime($tdate)) 
							//	{  
						$paydate = $fdate;
					$i =0; $cass = "Cash A/C";
if($typp==0){ 				
$qry=mysqli_query($conn, "select * from monuser where mfin='$mfin' && paydate2 between '$fdate' and '$tdate'");
}
elseif($typp==1){ echo 2;
	$qry=mysqli_query($conn, "select * from monuser where mfin='$mfin' && mode='$cass' && paydate2 between '$fdate' and '$tdate'");
} 
else{ echo 3;
	$qry=mysqli_query($conn, "select * from monuser where mfin='$mfin' && mode!='$cass' && paydate2 between '$fdate' and '$tdate'");
}
				$n=mysqli_num_rows($qry);
				while($row=mysqli_fetch_array($qry))
  { 
$sts = $row['status'];
$sts2 = "Reloan";
						if($n==0)
						{
							$x++;
						}
						else
					{ $aaa  = $row['urname'];
?>				<tr>
					<td><b><?php echo $row['roll'];?></b></td>
						<td><b><?php echo $row['hpl'];?></b></td>
						
						<td><b><?php echo $row['name']; ?></br>
						<?php echo $row['vno'];?>
						</b></td>
					 <?php if($sts == $sts2){ 
 $damt = $damt + $row['dueamount']; $pass = $pass + $row['urname'] - $row['fine'] - $row['hloan'];
						$fine = $fine + $row['fine']; $hll = $hll + $row['hloan']; $bal = $bal + $row['bal'];$a22 = $a22 + $a2; $urname = $urname + $aaa;  
						 ?>
<td><b><a href="editrcpt.php?fid=<?php echo $row['fid'];?>"><button class="btn btn-warning">Reloan</button></a></b></td>
<td><b><?php echo $row['paydate'];?></b></td>
							<td><b><?php echo $aaa;?></b></td>
						
						<td><b><?php echo $ddd = $row['urname'] - $row['fine'] - $row['hloan'];?></b></td>
						<td><b></b></td>
						<td><b><?php echo $row['fine'];?></b></td>
						<td><b><?php echo $row['hloan'];?></b></td>
						 <?php } else {
 $damt = $damt + $row['dueamount']; $pass = $pass + $row['pass']; $rno = $rno + $row['rno']; 
						$fine = $fine + $row['fine']; $hll = $hll + $row['hloan']; $bal = $bal + $row['bal'];$a22 = $a22 + $a2; $urname = $urname + $aaa;  
	
						 ?>
			<td><b><a href="editrcpt.php?fid=<?php echo $row['fid'];?>"><button class="btn btn-success">Due</button></a></b></td>
<td><b><?php echo $row['paydate'];?></b></td>
							<td><b><?php echo $aaa;?></b></td>
						
						<td><b><?php echo $row['pass'];?></b></td>
						<td><b><?php echo $row['rno'];?></b></td>
						<td><b><?php echo $row['fine'];?></b></td>
						<td><b><?php echo $row['hloan'];?></b></td>			
						 <?php } ?>
					
					
					<?php  if(($postt == 'MD') || ($postt == 'Office All')) { ?>     
				<td><b>
<a href="moncancel.php?fid=<?php echo $row['fid'];?>" class="btn btn-primary btn-xs" onclick="return confirm('Are you sure WANT TO CANCEL?');">Cancel</a></b></td>	
					<?php } ?>
						<td><b><font size="1"><?php echo $row['createdate'];?></br>
						<?php echo $row['scode'];?></font>
						</b></td>
						<td><b><font size="1"><?php echo $row['altdate'];?></br><?php echo $row['altby'];?></b></font></td>
		</tr>  
					<?php
						$x++;} }

if($typp==0){					
$qry=mysqli_query($conn, "select * from monnet where mfin='$mfin' && paydate2 between '$fdate' and '$tdate'");
}
elseif($typp==1){
	$qry=mysqli_query($conn, "select * from monnet where mfin='$mfin' && mode='$cass' && paydate2 between '$fdate' and '$tdate'");
}
else{
	$qry=mysqli_query($conn, "select * from monnet where mfin='$mfin' && mode!='$cass' && paydate2 between '$fdate' and '$tdate'");
}						

				$n=mysqli_num_rows($qry);
				while($row=mysqli_fetch_array($qry))
  { 
$x = $row['hpl'];
						if($n==0)
						{
							$x++;
						}
						else
					{
?>				<tr>
						<td><b><?php echo $row['rrno'];?></b></td>
						<td><b><?php echo $row['hpl'];?></b></td>
					
						<td><b><?php echo $row['name']; ?></b></td>
						<td><b><a href="editsettle.php?fid=<?php echo $row['id'];?>"><button class="btn btn-info">Close</button></a></b></td>
						
						
						<td><b><?php echo $row['paydate'];?></b></td>
						<td><b><?php echo $row['tot'];?></b></td>
		
						<td><b><?php echo $ss=$row['dueamt']  - $row['addless'];?></b></td>
						<td><b><?php echo $row['amt'];?></b></td>
						<td><b><?php echo $row['fine'];?></b></td>
						<td><b><?php echo $row['hloan'];?></b></td>
						
				<?php	 $pass = $pass + $ss; $rno = $rno + $row['amt']; 
						$fine = $fine + $row['fine']; $urname = $urname + $row['tot']; 
						 $hll = $hll + $row['hloan'];
						?>
						
				
<?php  if(($postt == 'MD') || ($postt == 'Office All')) { ?> 
<td><b>
<a href="moncancel2.php?fid=<?php echo $row['id'];?>" class="btn btn-primary btn-xs" onclick="return confirm('Are you sure WANT TO CANCEL?');">Cancel</a></b></td>					
<?php } ?>
						<td><font size="1"><b><?php echo $row['createdate'];?></br><?php echo $row['scode'];?></b></font></td>
					
						<td><font size="1"><b><?php echo $row['altdate'];?></br><?php echo $row['altby'];?></b></font></td>		
					</tr>
					<?php
						$x++;}}

						
					// $fdate = date ("d-m-Y", strtotime("+1 day", strtotime($fdate))); }
						$ssa = $fine - $a22;	?>  </tbody>
			<tfoot class="tfoot">		<tr class="alert alert-success">
					    <td><b></b></td>
						<td><b></b></td>
					<td><font size="4" color="red"><b>Total</b></font></b></td>
						<td><b>-</b></td>
					    <td><b></b></td>
						<td><b><font size="4" color="red"><b><?php echo $urname;?></b></font></b></td>
					
						<td><b><font color="red"><?php echo $pass;?></b></font></td>
						<td><b><font color="red"><?php echo round($rno,0);?></b></font></td>
						<td><b><font color="red"><?php echo $fine;?></b></font></td>
					    <td><b><font color="red"><?php echo $hll; ?></b></font></td>
					<?php  if(($postt == 'MD') || ($postt == 'Office All')) { ?> 	<td><b></b></td> <?php } ?>
						<td><b></b></td>	
						<td><b></b></td>
					    </tr> </tfoot>
							
                          </table>
                      
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>

              
        <!-- /page content -->

        <!-- footer content --> 
        <footer>
          <div class="pull-right">
             <a href="https://infossel.com">Infossel Soft Solution</a>
          </div>
          <div class="clearfix"></div>
        </footer>
        <!-- /footer content -->
      </div>
    </div>

    <!-- jQuery -->
    <script src="vendors/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <script src="vendors/fastclick/lib/fastclick.js"></script>
    <!-- NProgress -->
    <script src="vendors/nprogress/nprogress.js"></script>
    <!-- iCheck -->
    <script src="vendors/iCheck/icheck.min.js"></script>
    <!-- Datatables -->
    <script src="vendors/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
    <script src="vendors/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
    <script src="vendors/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>
    <script src="vendors/datatables.net-buttons/js/buttons.flash.min.js"></script>
    <script src="vendors/datatables.net-buttons/js/buttons.html5.min.js"></script>
    <script src="vendors/datatables.net-buttons/js/buttons.print.min.js"></script>
    <script src="vendors/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>
    <script src="vendors/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>
    <script src="vendors/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
    <script src="vendors/datatables.net-responsive-bs/js/responsive.bootstrap.js"></script>
    <script src="vendors/datatables.net-scroller/js/dataTables.scroller.min.js"></script>
    <script src="vendors/jszip/dist/jszip.min.js"></script>
    <script src="vendors/pdfmake/build/pdfmake.min.js"></script>
    <script src="vendors/pdfmake/build/vfs_fonts.js"></script>

    <!-- Custom Theme Scripts -->
    <script src="build/js/custom.min.js"></script>

  </body>
</html>