<?php include "layouts/menu.php"; ?> 
		 <?php $month=$_REQUEST['month'];?>
  <!--  page-wrapper -->
         <div class="right_col" role="main">
            <div class="row">
                 <!-- page header -->
                <div class="col-lg-12">
                    <h1 class="page-header">Forms</h1>
                </div>
                <!--end page header -->
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <!-- Form Elements -->
					 <!-- Form Elements -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            Fill the form
                        </div>
                        <div class="panel-body">
                            <div class="row">
                   
<div id="mydiv">
<input type="button" value="Print" onclick="PrintElem('#mydiv')"  style="margin:20px;">
<div class="table-responsive">
  <table class="table table-bordered table-hover"><thead>
  <tr class="info">
						<th>Name</th>
						
						<th>Loan No</th>
						<th>Reg Date</th>
						<th>Phone</th>
						<th>Due Amount</th>
						<th>L.D.Date</th>
						<th>Total due </th>
						<th>Till due </th>
						<th>payed Due</th>
						<th>Pending Due</th>
						<th>Pending amnt</th>
						<th>Rdate</th>
						<th>Add Response</th>
					</tr> </thead>
					
					<?php 
$x=1; 
while($x<=2000)
  {
  $qry2 = "SELECT * FROM customerdetails where mfin='$mfin' &&  hpl='$x'";
  $result = mysqli_query($conn, $qry2);
	if (mysqli_num_rows($result) >= 1) 
				{ 
	  $rs = mysqli_query($conn, $qry2);
	  // Loop the recordset $rs
	// Each row will be made into an array ($row) using mysqli_fetch_array
	while($row = mysqli_fetch_array($rs)) {

	   // Write the value of the column FirstName (which is now in the array $row)
	   $r = $row['name'];
	   $t = $row['hpdate'];
	   $tr = $row['pno'];
	   $u = $row['total'];
	   $pp = $row['duemnt'];

	   $row = str_replace('/', '-', $row['hpdate']);
  $d1 = strtotime($row);
$d2 = strtotime("today");
$min_date = min($d1, $d2);
$max_date = max($d1, $d2);
$i = 0;
while (($min_date = strtotime("+1 MONTH", $min_date)) <= $max_date) {
    $i++;
}}
$sql1 = "select sum(paymnt) from user where mfin='$mfin' &&  hpl=$x";
$qt = mysqli_query($conn, $sql1);
$row1 = mysqli_fetch_array($qt);
if($i>$pp)
{$i=$pp;}
$n=$row1[0];
$e = $i - $n;
$f = $u * $e;
$qry1=mysqli_query($conn, "select * from response where mfin='$mfin' &&  hpl=$x");
				$row1=mysqli_fetch_array($qry1);
				$nl=mysqli_num_rows($qry1);
						if($nl==0)
						{ $gh = 0;}
						else
						{ $gh = $row1['rdate']; }
						$qryt=mysqli_query($conn, "select * from user where mfin='$mfin' &&  hpl=$x");
						while($rowe=mysqli_fetch_array($qryt))
						{
						$ldd = $rowe['paydate'];
						}
						$qry8=mysqli_query($conn, "select * from net where mfin='$mfin' &&  hpl=$x");
				$row8=mysqli_fetch_array($qry8);
				$n8=mysqli_num_rows($qry8);
	if($e>=$month && $n8==0)
	{ ?>
  <tbody>
		<tr>
					
	                    <td><?php echo $r;?></td>
					
						<td><?php echo $x;?></td>
						<td><?php echo $t;?></td>
						<td><?php echo $tr;?></td>
						<td><?php echo $u;?></td>
						<td><?php echo $ldd;?></td>
						<td><?php echo $pp;?></td>
						<td><?php echo $i;?></td>
						<td><?php echo $n;?></td>
						<td><?php echo $e;?></td>
						<td><?php echo $f;?></td>
						<td><?php echo $gh;?></td>
						<td><a href="response.php?hpl=<?php echo $x;?>">Add Date</a></td></tr></tbody>

<?php		}	
				
				}$x++;	}?>
			
				</table>
 </div>
 
 
</div>
</div></div>
</div><?php include "layouts/footer.php"; ?></body></html>