<?php include "layouts/menu.php"; ?> 
 <?php 
 $vno=$_REQUEST['vno'];
  $vname=$_REQUEST['vname'];
   $hpamount=$_REQUEST['hpamount'];
    $address=$_REQUEST['address'];
	 $idate=$_REQUEST['idate'];
	  $uname=$_REQUEST['uname'];
	   $pwd=$_REQUEST['pwd'];
 
 ?>
  <!--  page-wrapper -->
         <div class="right_col" role="main">
            <div class="row">
                 <!-- page header -->
                <div class="col-lg-12">
                    <h1 class="page-header">Pending List</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">
                            Vehicle Loan
                        </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>Hpl</th>
						<th>Name</th>
					
						<th>Reg Date</th>
						<th>Phone</th>
						<?php if($vno == 1) { ?>
						<th>Vehicl No</th>
						<?php } ?>
						<?php if($vname == 1) { ?>
						<th>Vehicle Name</th>
						<?php } ?>
						<?php if($hpamount == 1) { ?>
						<th>H.P Amount</th>
						<?php } ?>
						<?php if($address == 1) { ?>
						<th>Address</th>
						<?php } ?>
						<?php if($idate == 1) { ?>
						<th>Insurance Date</th>
						<?php } ?>
						<?php if($uname == 1) { ?>
						<th>FC Date</th>
						<?php } ?>
						<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 
$qry29 = "SELECT * FROM customerdetails where mfin='$mfin'";
  $result9 = mysqli_query($conn, $qry29);
while($rowt = mysqli_fetch_array($result9))
  { $x = $rowt['hpl'];
  $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'];
	   
	    $bvno = $row['vno'];
	   $bvname = $row['vname'];
	   $bhpamt = $row['hpamount'];
	   $badd = $row['address'];
	   $bidate = $row['idate'];
	   $buname = $row['uname'];
 $yt = $row['uimg'];
	   $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($n<$pp && $n8==0){?>
		
		
   <tbody>
		<tr>
					<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $x;?></font></a></td>
	                    <td><a href="register.php?hpl=<?php echo $x; ?>"><strong><?php echo $r;?></strong></a></td>
						
						<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $t;?></font></a></td>
						<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $tr;?></font></a></td>
						<?php if($vno == 1) { ?>
						<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $bvno;?></font></a></td>
						<?php } ?>
						<?php if($vname == 1) { ?>
						<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $bvname;?></font></a></td>
						<?php } ?>
						<?php if($hpamount == 1) { ?>
						<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $bhpamt;?></font></a></td>
						<?php } ?>
						<?php if($address == 1) { ?>
						<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $badd;?></font></a></td>
						<?php } ?>
						<?php if($idate == 1) { ?>
					<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $bidate;?></font></a></td>
						<?php } ?>
						<?php if($uname == 1) { ?>
						<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $buname;?></font></a></td>
						<?php } ?>
						<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $u;?></font></a></td>
						<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $ldd;?></font></a></td>
						<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $pp;?></font></a></td>
						<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $i;?></font></a></td>
						<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $n;?></font></a></td>
						<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $e;?></font></a></td>
						<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $f;?></font></a></td>
						<td><a href="register.php?hpl=<?php echo $x; ?>"><font color="brown"><?php echo $gh;?></font></a></td>
						<td><a href="response.php?hpl=<?php echo $x;?>" target="_blank">Add Date</a></td>
						</tr></tbody>

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