<?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-2">  <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-2">   <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-2">    <select type="text" class="form-control thicker" id="typp" name="typp" value="">
	<option>All Staff</option>
<?php	$qryv=mysqli_query($conn, "select * from customer order by name asc");
			while($rowv=mysqli_fetch_array($qryv)){ ?>
	<option><?php echo $rowv['code']; ?></option>
			<?php } ?> </select>
	
	</select>
    </div>
       <div class="col-md-3">    <select type="text" class="form-control thicker" id="typp2" name="typp2" value="">
	<option>All Mode</option>
		<option>Cash A/c</option>
<?php	$qryv=mysqli_query($conn, "select * from ledger where under='Bank Accounts'");
			while($rowv=mysqli_fetch_array($qryv)){ ?>
	<option><?php echo $rowv['ledger']; ?></option>
			<?php } ?> </select>
	
	</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:billrep2.php?fdate=$fdate&&tdate=$tdate&&typp=$typp&&typp2=$typp2");
								} ?>
								<?php $bal = 0; $a22 = 0; 
										$fdate=$_REQUEST['fdate'];
    $tdate=$_REQUEST['tdate'];
 $typp=$_REQUEST['typp']; 
  $typp2=$_REQUEST['typp2']; 
//echo $typp;
	?>
  <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%">Loan No</th>
						
						<th style="width:15%">Name</th>
					
						
						
						<th> Date</th>
							<th>Total</th>
					
						
						<th>Def Amt</th>
					<th>Mode</th>
		<?php if(($postt == 'MD') || ($postt == 'Manager'))  { ?> 	<th>#Options</th> <?php } ?>
				<th>Created By </th>
							<th>Altered By</th>
					<th>Loan Type</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=='All Staff') && ($typp2=='All Mode')){ 		
//echo "366";		
$qry=mysqli_query($conn, "select * from user where mfin='$mfin' && paydate2 between '$fdate' and '$tdate'");
$qry1=mysqli_query($conn, "select * from net where mfin='$mfin' && paydate2 between '$fdate' and '$tdate'");
}
if(($typp!='All Staff') && ($typp2!='All Mode')){ 		
//echo "366";		
$qry=mysqli_query($conn, "select * from user where mfin='$mfin' && scode='$typp' && mode='$typp2' && paydate2 between '$fdate' and '$tdate'");
$qry1=mysqli_query($conn, "select * from net where mfin='$mfin' && scode='$typp' && mode='$typp2' && paydate2 between '$fdate' and '$tdate'");
}
elseif($typp!='All Staff'){ 
//echo "3";
	$qry=mysqli_query($conn, "select * from user where mfin='$mfin' && scode='$typp' && paydate2 between '$fdate' and '$tdate'");
	$qry1=mysqli_query($conn, "select * from net where mfin='$mfin' && scode='$typp' && paydate2 between '$fdate' and '$tdate'");
}
elseif($typp2 != 'All Mode'){ 
//echo "3";
	$qry=mysqli_query($conn, "select * from user where mfin='$mfin' && mode='$typp2' && paydate2 between '$fdate' and '$tdate'");
	$qry1=mysqli_query($conn, "select * from net where mfin='$mfin' && mode='$typp2' && 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'];?>DC</b></td>
						
						<td><b><?php echo $row['name']; ?>
						</b></td>
					<?php
 $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><?php echo $row['paydate'];?></b></td>
							<td><b><?php echo $aaa;?></b></td>
						<td><b><?php echo $row['fine'];?></b></td>
			
					
											<td><b><?php echo $row['mode'];?></b></td>

					
			<?php if(($postt == 'MD') || ($postt == 'Manager'))  { ?>   
				<td><b>
<a href="editrcpt.php?fid=<?php echo $row['fid'];?>" class="btn btn-warning btn-xs" onclick="return confirm('Are you sure WANT TO Edit?');">edit</a></b>

<a href="cancel.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>
						<td><b>Daily</b></td>
		</tr>  
					<?php
						$x++;} }
						
	/////
	$n1=mysqli_num_rows($qry1);
				while($row1=mysqli_fetch_array($qry1))
  { 
$sts = $row1['status'];
$sts2 = "Reloan";
						if($n==0)
						{
							$x++;
						}
						else
					{ $aaa  = $row1['urname'];
?>				<tr>
					<td><b><?php echo $row1['rno'];?></b></td>
						<td><b><?php echo $row1['hpl'];?> DC</b></td>
						
						<td><b><?php echo $row1['name']; ?>
						</b></td>
					<?php
 $damt = $damt + $row1['dueamount']; $pass = $pass + $row1['pass']; $rno = $rno + $row1['rno']; 
						$fine = $fine + $row1['fine']; $hll = $hll + $row1['hloan']; $bal = $bal + $row1['bal'];$a22 = $a22 + $a2; $urname = $urname + $aaa;  
	
						 ?>
		
<td><b><?php echo $row1['paydate'];?></b></td>
							<td><b><?php echo $row1['dueamt'] + $row1['amt'];?></b></td>
						<td><b><?php echo $row1['fine'];?></b></td>
			
					
											<td><b><?php echo $row1['mode'];?></b></td>

					
			<?php if(($postt == 'MD') || ($postt == 'Manager'))  { ?>   
				<td><b>
<a href="editrcpt.php?fid=<?php echo $row1['fid'];?>" class="btn btn-warning btn-xs" onclick="return confirm('Are you sure WANT TO Edit?');">edit</a></b>

<a href="cancel.php?fid=<?php echo $row1['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 $row1['createdate'];?></br>
						<?php echo $row1['scode'];?></font>
						</b></td>
						<td><b><font size="1"><?php echo $row1['altdate'];?></br><?php echo $row1['altby'];?></b></font></td>
						<td><b>Daily-Closed</b></td>
		</tr>  
					<?php
						$x++;} }
						
if(($typp=='All Staff') && ($typp2=='All Mode')){ 		
//echo "366";		
$qry=mysqli_query($conn, "select * from userw where mfin='$mfin' && paydate2 between '$fdate' and '$tdate'");
$qry2=mysqli_query($conn, "select * from netw where mfin='$mfin' && paydate2 between '$fdate' and '$tdate'");
}
if(($typp!='All Staff') && ($typp2!='All Mode')){ 		
//echo "366";		
$qry=mysqli_query($conn, "select * from userw where mfin='$mfin' && scode='$typp' && mode='$typp2' && paydate2 between '$fdate' and '$tdate'");
$qry2=mysqli_query($conn, "select * from netw where mfin='$mfin' && scode='$typp' && mode='$typp2' && paydate2 between '$fdate' and '$tdate'");
}
elseif($typp!='All Staff'){ 
//echo "3";
	$qry=mysqli_query($conn, "select * from userw where mfin='$mfin' && scode='$typp' && paydate2 between '$fdate' and '$tdate'");
		$qry2=mysqli_query($conn, "select * from netw where mfin='$mfin' && scode='$typp' && paydate2 between '$fdate' and '$tdate'");
}
elseif($typp2 != 'All Mode'){ 
//echo "3";
	$qry=mysqli_query($conn, "select * from userw where mfin='$mfin' && mode='$type2' && paydate2 between '$fdate' and '$tdate'");
		$qry2=mysqli_query($conn, "select * from netw where mfin='$mfin' && mode='$type2' && 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'];?> WC</b></td>
						
						<td><b><?php echo $row['name']; ?>
						</b></td>
					<?php
 $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><?php echo $row['paydate'];?></b></td>
							<td><b><?php echo $aaa;?></b></td>
						<td><b><?php echo $row['fine'];?></b></td>
			
					
					
																<td><b><?php echo $row['mode'];?></b></td>

			<?php if(($postt == 'MD') || ($postt == 'Manager'))  { ?>   
				<td><b>
<a href="editrcpt.php?fid=<?php echo $row['fid'];?>" class="btn btn-warning btn-xs" onclick="return confirm('Are you sure WANT TO Edit?');">Edit</a></b>

<a href="cancel.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>
						<td><b>Weekly</b></td>
		</tr>  
					<?php
						$x++;} }
						
// \\\\\\
$n2=mysqli_num_rows($qry2);
				while($row2=mysqli_fetch_array($qry2))
  { 
$sts = $row2['status'];
$sts2 = "Reloan";
						if($n==0)
						{
							$x++;
						}
						else
					{ $aaa  = $row2['urname'];
?>				<tr>
					<td><b><?php echo $row2['rno'];?></b></td>
						<td><b><?php echo $row2['hpl'];?>WC</b></td>
						
						<td><b><?php echo $row2['name']; ?>
						</b></td>
					<?php
 $damt = $damt + $row2['dueamount']; $pass = $pass + $row2['pass']; $rno = $rno + $row2['rno']; 
						$fine = $fine + $row2['fine']; $hll = $hll + $row2['hloan']; $bal = $bal + $row2['bal'];$a22 = $a22 + $a2; $urname = $urname + $aaa;  
	
						 ?>
		
<td><b><?php echo $row2['paydate'];?></b></td>
							<td><b><?php echo $row2['dueamt'] + $row2['amt'];?></b></td>
						<td><b><?php echo $row2['fine'];?></b></td>
			
					
					
																<td><b><?php echo $row2['mode'];?></b></td>

			<?php if(($postt == 'MD') || ($postt == 'Manager'))  { ?>   
				<td><b>
<a href="editrcpt.php?fid=<?php echo $row2['fid'];?>" class="btn btn-warning btn-xs" onclick="return confirm('Are you sure WANT TO Edit?');">Edit</a></b>

<a href="cancel.php?fid=<?php echo $row2['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 $row2['createdate'];?></br>
						<?php echo $row2['scode'];?></font>
						</b></td>
						<td><b><font size="1"><?php echo $row2['altdate'];?></br><?php echo $row2['altby'];?></b></font></td>
						<td><b>Weekly-Closed</b></td>
		</tr>  
					<?php
						$x++;} }
						
if(($typp=='All Staff') && ($typp2=='All Mode')){ 		
//echo "366";		
$qry=mysqli_query($conn, "select * from userm where mfin='$mfin' && paydate2 between '$fdate' and '$tdate'");
$qry1=mysqli_query($conn, "select * from netm where mfin='$mfin' && paydate2 between '$fdate' and '$tdate'");
}
if(($typp!='All Staff') && ($typp2!='All Mode')){ 		
//echo "366";		
$qry=mysqli_query($conn, "select * from userm where mfin='$mfin' && scode='$typp' && mode='$typp2' && paydate2 between '$fdate' and '$tdate'");
$qry1=mysqli_query($conn, "select * from netm where mfin='$mfin' && scode='$typp' && mode='$typp2' && paydate2 between '$fdate' and '$tdate'");
}
elseif($typp!='All Staff'){ 
//echo "3";
	$qry=mysqli_query($conn, "select * from userm where mfin='$mfin' && scode='$typp' && paydate2 between '$fdate' and '$tdate'");
	$qry1=mysqli_query($conn, "select * from netm where mfin='$mfin' && scode='$typp' && paydate2 between '$fdate' and '$tdate'");
}
elseif($typp2 != 'All Mode'){ 
//echo "3";
	$qry=mysqli_query($conn, "select * from userm where mfin='$mfin' && mode='$type2' && paydate2 between '$fdate' and '$tdate'");
	$qry1=mysqli_query($conn, "select * from netm where mfin='$mfin' && mode='$type2' && 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
 $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">Monthly</button></a></b></td>
<td><b><?php echo $row['paydate'];?></b></td>
							<td><b><?php echo $aaa;?></b></td>
						<td><b><?php echo $row['fine'];?></b></td>
			
					
					
					
					<?php  if($postt == 'MD') { ?>     
				<td><b>

</br><a href="cancelm.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>
						<td><b>Monthly</b></td>
		</tr>  
					<?php
						$x++;} }
				// 	\\\\\\\
						$n1=mysqli_num_rows($qry1);
				while($row1=mysqli_fetch_array($qry1))
  { 
$sts = $row1['status'];
$sts2 = "Reloan";
						if($n==0)
						{
							$x++;
						}
						else
					{ $aaa  = $row1['urname'];
?>				<tr>
					<td><b><?php echo $row1['roll'];?></b></td>
						<td><b><?php echo $row1['hpl'];?></b></td>
						
						<td><b><?php echo $row1['name']; ?></br>
						<?php echo $row1['vno'];?>
						</b></td>
					<?php
 $damt = $damt + $row1['dueamount']; $pass = $pass + $row1['pass']; $rno = $rno + $row1['rno']; 
						$fine = $fine + $row1['fine']; $hll = $hll + $row1['hloan']; $bal = $bal + $row1['bal'];$a22 = $a22 + $a2; $urname = $urname + $aaa;  
	
						 ?>
			<td><b><a href="editrcpt.php?fid=<?php echo $row1['fid'];?>"><button class="btn btn-success">Monthly</button></a></b></td>
<td><b><?php echo $row1['paydate'];?></b></td>
						<td><b><?php echo $row1['dueamt'] + $row1['amt'];?></b></td>
						<td><b><?php echo $row1['fine'];?></b></td>
			
					
					
					
					<?php  if($postt == 'MD') { ?>     
				<td><b>

</br><a href="cancelm.php?fid=<?php echo $row1['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 $row1['createdate'];?></br>
						<?php echo $row1['scode'];?></font>
						</b></td>
						<td><b><font size="1"><?php echo $row1['altdate'];?></br><?php echo $row1['altby'];?></b></font></td>
						<td><b>Monthly-Closed</b></td>
		</tr>  
					<?php
						$x++;} }
						
						
if($typp==0){					
$qry=mysqli_query($conn, "select * from cancl where mfin='$mfin' && paydate2 between '$fdate' and '$tdate'");
}
elseif($typp==1){
	$qry=mysqli_query($conn, "select * from cacel where mfin='$mfin' && mode='$cass' && paydate2 between '$fdate' and '$tdate'");
}
else{
	$qry=mysqli_query($conn, "select * from canel 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
					{ $aaa  = $row['urname'];
?>				<tr>
					<td><b><font color="red"><?php echo $row['roll'];?></font></b></td>
						<td><b><font color="red"><?php echo $row['hpl'];?></font></b></td>
						
						<td><b><font color="black"><?php echo $row['name']; ?></br>
						<?php echo $row['vno'];?>
						</font></b></td>
						<td><b><button class="btn btn-Danger">Due-Can</button></b></td>
						
						
						<td><b><font color="black"><?php echo $row['paydate'];?></font></b></td>
							<td><b><font color="black"><?php echo $aaa;?></font></b></td>
			
						<td><b><font color="black"><?php echo $row['fine'];?></font></b></td>
						
				<?php if(($postt == 'MD') || ($postt == 'Manager'))  { ?>
				<td><b>

</br><a href="cancel.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><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++; } } ?>

					
			
			<tr>
					    <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><font size="4" color="red"><b><?php echo $urname;?></b></font></b></td>
					<td><b><font color="red"><?php echo $fine;?></b></font></td>
	<td><b></b></td>
				<?php if(($postt == 'MD') || ($postt == 'Manager'))  { ?>	<td><b></b></td> <?php } ?>
						<td><b></b></td>	
						
					    </tr> </tbody>
							
                          </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>