<?php ob_start(); ?>
<?php include "layouts/db_connect.php"; ?> 
<?php
{
		
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php include "layouts/db_con.php"; ?>  
<head><meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Print Page</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<link rel="shortcut icon" href="images/favicon.ico">
<script type="text/javascript">
window.onload=function(){self.print();setTimeout("window.close()", 10);}

    window.onfocus = function() { window.close(); }
	 $(function(){ 
   setTimeout(function(){
      $('form').print();
    },100);
});

</script>
<style type="text/css"> 

#table1 
{ 
position:absolute; 
bottom:5%; 
} 
#table2 
{ 
position:absolute; 
bottom:15%; 
} 
#table3 
{ 
position:absolute; 
bottom:30%; 
} 

</style> 
<style type="text/css">
<!--
.style1 {font-size: 10px}
-->
</style>
<style>
p.ex1 {
    border: 1px solid white; 
    padding-top: 5px;
}
</style>
</head>

<body onload="self.print()" onfocus="window.close()">
<?php
	$hpl=$_REQUEST['hpl'];
	$hpl2=$_REQUEST['hpl2'];
		$mfin=$_REQUEST['mfin'];
		for($hpl=$hpl;$hpl<=$hpl2;$hpl++) {
		
					$qry=mysqli_query($conn, "select * from customerdetails where hpl='$hpl' && mfin='$mfin'");
					$n=mysqli_num_rows($qry);
	$sno = 0;
					
while($row1=mysqli_fetch_array($qry))
  { 	
$duemnt = $row1['duemnt']; 
$tott = $row1['total']; 
$hpdate = $row1['hpdate'];
$dueamt = $row1['dueamt']; 	
$interest = $row1['interest']; 					
	$r=0;	
	$r++;   
?> <div class="row">
<div class="col-md-12">
 <font size="2.5" color="red">
<h3> <center> <b> <u> <?php echo $row1['mfin']; ?></u></center></b></h3> </font>
<?php 
$qry=mysqli_query($conn, "select * from mfin where name='$mfin'");
					$row=mysqli_fetch_array($qry); ?>
<table width="90%" cellspacing="0" cellpadding="0">

<tr>
<td><b><font size="3.5" color="red"> HP A/c No  </br></br>
HP Agreement Date</b></font>
</td>
<td><b><font size="3.5" color="blue">:<b> <?php echo $row1['hpl']; ?></b></br></br>
:  <b><?php echo $row1['hpdate']; ?></b></font> </td> 
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td><td>&nbsp;</td>
 <td><b><font size="3.5" color="red">Loan Amount  </br></br>
 No Of Dues</b></font>
 </td><td><b><font size="3.5" color="blue">: <b><?php echo $row1['hpamount']; ?></b></br>
 </br>: <b><?php echo $row1['duemnt']; ?></b>
</b></font> </td></tr> 
<tr> &nbsp;</tr>


<tr><td colspan="2"><u><b></br><font size="4" color="red"> BORROWER NAME & ADDRESS</b></u> </br>
 <?php
$sql22 = mysqli_query($conn, "select * from addr where hpl='$hpl' && mfin='$mfin' order by id asc");
$row3 = mysqli_fetch_array($sql22);
$nn = mysqli_num_rows($sql22);
$iddf = $row3['id'];

if($nn>0) {

$iddf = $row3['id'];
for($i=1;$i<=7;$i++){
	
$sql223 = mysqli_query($conn, "select * from addr where id='$iddf' order by id asc");
$row33 = mysqli_fetch_array($sql223);
?>
<b><font size="3.5" color="blue"><?php echo $row33['addr']; ?></b></br>
<?php  $iddf++;  }

    if($hpl>5000){
	?><b><font size="3.5" color="blue"><?php echo $pno; ?> </b> <?php
}
elseif($hpl<100){
	?><b><font size="3.5" color="blue"><?php echo $pno; ?> </b> <?php
}
}
else { ?>
	<b><font size="3.5" color="blue">S/O <?php echo $row1['fname']; ?></br>
	<b><font size="3.5" color="blue"><?php echo $row1['address']; ?></br>
	<b><font size="3.5" color="blue"><?php echo $row1['lmark']; ?></br>
	
<?php } ?> </font>
 </font> 
 <b><font size="3" color="blue">Aadhar : <?php echo $row1['g1']; ?></br>
 
</td>
<td>&nbsp;</td>
<td colspan="2"><u><b></br><font size="4" color="red"> BORROWER OFFICE / BUSINESS ADDRESS </b></u> </br>
 <?php
$sql22 = mysqli_query($conn, "select * from addr where hpl='$hpl' && mfin='$mfin' order by id asc");
$row3 = mysqli_fetch_array($sql22);
$nn = mysqli_num_rows($sql22);
$iddf = $row3['id'];

if($nn>0) {

$iddf = $row3['id'];
for($i=1;$i<=7;$i++){
	
$sql223 = mysqli_query($conn, "select * from addr where id='$iddf' order by id asc");
$row33 = mysqli_fetch_array($sql223); $iddf++;
?>
<b><font size="3.5" color="blue"><?php echo $row33['oadd']; ?></br>
<?php } }
else { ?>
	<b><font size="3.5" color="blue"><?php echo $row1['oaddress']; ?></br>
	
<?php }
 ?>  </b>  </font> 
  
</td>
<?php $imgg = $row1['uimg']; ?>
<td><img src="user/<?php echo $imgg; ?>" width="150px" height="160px"></td>
</tr>


<tr><td colspan="2"><u><b></br><font size="4" color="red"> Co-Applicant NAME & ADDRESS </b></u> </br>
 <?php
$sql22 = mysqli_query($conn, "select * from addr where hpl='$hpl' && mfin='$mfin' order by id asc");
$row3 = mysqli_fetch_array($sql22);
$nn = mysqli_num_rows($sql22);
$iddf = $row3['id'];

if($nn>0) {

$iddf = $row3['id'];
for($i=1;$i<=7;$i++){
	
$sql223 = mysqli_query($conn, "select * from addr where id='$iddf' order by id asc");
$row33 = mysqli_fetch_array($sql223); $iddf++;
?>
<?php if($i==1) { ?> <b> <?php } ?> <font size="3.5" color="blue"><?php echo $row33['co']; ?></b></br>
<?php } }
else { ?>
	<b><font size="3.5" color="blue">S/O <?php echo $row1['cofname']; ?></br>
	<b><font size="3.5" color="blue"><?php echo $row1['co']; ?></br>
	<b><font size="3.5" color="blue"><?php echo $row1['coaland']; ?></br>
	
<?php } ?> 
<b><font size="3" color="blue">Aadhar : <?php echo $row1['b1']; ?></br></font></b>
</td>
<td>&nbsp;</td>
<td colspan="2"><u><b></br><font size="4" color="red"> Co-Applicant OFFICE ADDRESS </b></u> </br>
 <?php
$sql22 = mysqli_query($conn, "select * from addr where hpl='$hpl' && mfin='$mfin' order by id asc");
$row3 = mysqli_fetch_array($sql22);
$nn = mysqli_num_rows($sql22);
$iddf = $row3['id'];

if($nn>0) {

$iddf = $row3['id'];
for($i=1;$i<=7;$i++){
	
$sql223 = mysqli_query($conn, "select * from addr where id='$iddf' order by id asc");
$row33 = mysqli_fetch_array($sql223); $iddf++;
?>
<?php if($i==1) { ?> <b> <?php } ?> <font size="3.5" color="blue"><?php echo $row33['co2']; ?></b></br>
<?php } }
else { ?>
	<b><font size="3.5" color="blue">S/O <?php echo $row1['cofname2']; ?></br>
	<b><font size="3.5" color="blue"><?php echo $row1['co2']; ?></br>
	<b><font size="3.5" color="blue"><?php echo $row1['coaland2']; ?></br>
	
<?php } ?>  </br></b></font>
</td>
<?php $imgg = $row1['img']; ?>
<td><img src="user/<?php echo $imgg; ?>" width="150px" height="160px"></td>
</tr>

<tr>
<td><b><font size="3.5" color="red"> 
Vehicle No  </br>
Make </br>
Model </br>

</b></font>
</td>
<td colspan="3"><b><font size="3.5" color="blue">
:  <?php echo $row1['vno']; ?></br>
:  <?php echo $row1['vname']; ?></br>
:  <?php echo $row1['model']; ?></br>

</b></font> </td> 
 <td><b><font size="3.5" color="red">Chassis No  </br>
Engine No </br>

Date of Regn </br>

Broker</br>
</b></font>
 </td><td><b><font size="3.5" color="blue">: <?php echo $row1['cno']; ?></br>
:  <?php echo $row1['eno']; ?></br>
:</br>

: <?php echo $row1['bname']; ?></br></b></font> </td></tr> 


</table> 

<br>
<table border="1" width="90%"   cellspacing="0" cellspadding="0">
<thead>
<tr>
<th width="5%" color="red">No</th>
<th  width="8%" color="red">Amount</th>
<th width="15%" color="red">Due On</th>
<th width="8%" color="red">Rcpt No</th>
<th width="15%" color="red">Rcpt Date</th>
<th width="5%" color="red">No</th>
<th  width="8%" color="red">Amount</th>
<th width="15%" color="red">Due On</th>
<th width="8%" color="red">Rcpt No</th>
<th width="15%" color="red">Rcpt Date</th>
</tr></thead><tbody>
<?php 
$duedat = $hpdate;
$duedat1 = date("d-m-Y", strtotime("$hpdate + " . 15 . " month"));
for($i = 1;$i<=15;$i++) { 
$a = $i + 15;
if($i <= $duemnt) {
?>
<tr>
<td widtd="5%">&nbsp;<?php echo $i; ?></td>
<td  widtd="8%">&nbsp;<?php echo $tott; ?></td>
<td width="15%"><?php //echo $duedat = date("d-m-Y", strtotime("$hpdate + " . $i . " month")); 
$selected_date=$duedat;
 
		  	$selected_date=strtotime( $selected_date );
			$mysqldate = date( 'd-m-Y', $selected_date );
			$month = date( 'm', $selected_date );
			$day = date( 'd', $selected_date );
			$yyyy = date( 'Y', $selected_date );
			
if((($day==30)&&($month==01)) || (($day==29)&&($month==01)) || (($day==31)&&($month==01)))	
{
echo $duedat = "28-02-".$yyyy;
}
elseif((($day==31)&&($month==10)) || (($day==31)&&($month=='08')) || (($day==31)&&($month=='08')) || (($day==31)&&($month=='05')) || (($day==31)&&($month=='03')) || (($day==31)&&($month=='05')) || (($day==31)&&($month=='03')))	
{
	$hpdate55 =  "20-".$month."-".$yyyy;
	$duedat55 = date("d-m-Y", strtotime("$hpdate55 + " . 1 . " month"));
	$selected_date55=$duedat55;
		  	$selected_date55=strtotime( $selected_date55 );
			$mysqldate55 = date( 'd-m-Y', $selected_date55 );
			$month55 = date( 'm', $selected_date55 );
echo $duedat = "30-".$month55."-".$yyyy;
}
else {	
echo $duedat = date("d-m-Y", strtotime("$hpdate + " . $i . " month"));
}


?> </td>
<td widtd="8%">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td widtd="15%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> <?php } 
else { ?>
<tr>
<td widtd="5%">&nbsp;<?php echo $i; ?></td>
<td widtd="8%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td widtd="10%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td widtd="8%">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td widtd="15%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<?php } if($a <= $duemnt) { ?>
<td widtd="5%">&nbsp;<?php  echo $a; ?></td>
<td  widtd="8%">&nbsp;<?php echo $tott; ?></td>
<td width="15%"><?php //echo $duedat = date("d-m-Y", strtotime("$hpdate + " . $i . " month")); 
$selected_date11=$duedat1;
		  	$selected_date11=strtotime( $selected_date11 );
			$mysqldate11 = date( 'd-m-Y', $selected_date11 );
			$month11 = date( 'm', $selected_date11 );
			$day11 = date( 'd', $selected_date11 );
			$yyyy11 = date( 'Y', $selected_date11 );
if((($day11==30)&&($month11==01)) || (($day11==29)&&($month11==01)) || (($day11==31)&&($month11==01)))	
{
echo $duedat1 = "28-02-".$yyyy11;
}
elseif((($day11==31)&&($month11==10)) || (($day11==31)&&($month11==08)) || (($day11==31)&&($month11==8)) || (($day11==31)&&($month11==05)) || (($day11==31)&&($month11==03)) || (($day11==31)&&($month11==5)) || (($day11==31)&&($month11==3)))	
{
	$hpdate55 =  "20-".$month11."-".$yyyy11;
	$duedat55 = date("d-m-Y", strtotime("$hpdate55 + " . 1 . " month"));
	$selected_date55=$duedat55;
		  	$selected_date55=strtotime( $selected_date55 );
			$mysqldate55 = date( 'd-m-Y', $selected_date55 );
			$month55 = date( 'm', $selected_date55 );
echo $duedat1 = "30-".$month55."-".$yyyy11;
}
else {	
echo $duedat1 = date("d-m-Y", strtotime("$hpdate + " . $a . " month"));
}


?> </td>
<td widtd="8%">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td widtd="15%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>    </tr>  <?php } 
else {
?>

<td widtd="5%">&nbsp;<?php echo $a; ?></td>
<td widtd="8%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td widtd="10%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td widtd="8%">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td widtd="15%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>    </tr>  <?php } } ?>
</tbody>
</table>
<!--
<table border="1" width="90%" cellspacing="0" cellspadding="0" height="50px" width="100%">
<tbody>
<tr><th>Date</th>
<th>Type</th>
<th>Remarks</th>
<th>Credit</th>
<th>Debit</th><tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td>
</tr><tr>
<td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<br><tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<br> -->
<table border="0"cellspacing="0" width="90" cellspadding="0" style="float:left;"> 
<table border="0"cellspacing="0" cellspadding="0"  width="65%" style="float:left;"> 
 <font size="3.5" style="float:left;"><tr><td> <b>  RC Book & All Documents Are Received&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b> </td>  </font> 
<td>&nbsp; </td>  

</tr></table> 
<table border="1" cellspacing="0" cellspadding="0" width="25%"  >
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<tr>
<td> <b><?php echo $dueamt; ?> + <?php echo $interest; ?> </b></td>
 <td><b> <?php echo $duemnt; ?></b></td>

</tr></table> </table> 
<table border="0">
<tr>
<td><font size="3.5"><b>
SIGNATURE </br></br>
NAME : </br>
DATE  :
</b></font> </td>


</tr>
</table>

</div></div>
<?php } ?>
<p style="page-break-before: always">
<?php		} ?>

</body>
</html>
<?php } ?>
