<?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'];
		$mfin=$_REQUEST['mfin'];
		
					$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">
<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="blue"> HP A/c No  </br></br>
HP Agreement Date</b></font>
</td>
<td><b><font size="3.5" color="blue">: <?php echo $row1['hpl']; ?></br></br>
:  <?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="blue">Loan Amount  </br></br>
 No Of Dues</b></font>
 </td><td><b><font size="3.5" color="blue">: <?php echo $row1['hpamount']; ?></br>
 </br>: <?php echo $row1['duemnt']; ?>
</b></font> </td></tr> 
<tr> &nbsp;</tr>


<tr><td colspan="2"><u><b></br><font size="3.5" color="blue"> Party 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' && hpl='$hpl' order by id asc");
$row33 = mysqli_fetch_array($sql223);
?>
<b><font size="3.5" color="blue"><?php echo $row33['addr']; ?></b></br>
<?php  $iddf++;  } }
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> 
</td>
<td>&nbsp;</td><td>&nbsp;</td>
<td colspan="2"><u><b></br><font size="3.5" color="blue"> 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' && hpl='$hpl' 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></tr>


<tr><td colspan="2"><u><b></br><font size="3.5" color="blue"> Co-Obligant</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' && hpl='$hpl' order by id asc");
$row33 = mysqli_fetch_array($sql223); $iddf++;
?>
<b><font size="3.5" color="blue"><?php echo $row33['co']; ?></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 } ?> </br></font></b>
</td>
<td>&nbsp;</td><td>&nbsp;</td>
<td colspan="2"><u><b></br><font size="3.5" color="blue"> Co-Obligant </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' && hpl='$hpl' order by id asc");
$row33 = mysqli_fetch_array($sql223); $iddf++;
?>
<b><font size="3.5" color="blue"><?php echo $row33['co2']; ?></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></tr>

<tr>
<td><b><font size="3.5" color="blue"> 
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="blue">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%">No</th>
<th  width="10%">Amount</th>
<th width="15%">Due On</th>
<th width="10%">Rcpt No</th>
<th width="10%">Rcpt Date</th>
<th width="5%">No</th>
<th  width="10%">Amount</th>
<th width="15%">Due On</th>
<th width="10%">Rcpt No</th>
<th width="10%">Rcpt Date</th>
</tr></thead><tbody>
<?php for($i = 1;$i<=15;$i++) { 
$a = $i + 15;
if($i <= $duemnt) {
?>
<tr>
<td widtd="5%">&nbsp;<?php echo $i; ?></td>
<td  widtd="10%">&nbsp;<?php echo $tott; ?></td>
<td widtd="15%">&nbsp;<?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;
}
else {	
echo $duedat = date("d-m-Y", strtotime("$hpdate + " . $i . " month"));
}


?>  </td>
<td widtd="10%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td widtd="10%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> <?php } 
else { ?>
<tr>
<td widtd="5%">&nbsp;<?php echo $i; ?></td>
<td widtd="10%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td widtd="10%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td widtd="10%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td widtd="10%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<?php } if($a <= $duemnt) { ?>
<td widtd="5%">&nbsp;<?php  echo $a; ?></td>
<td  widtd="10%">&nbsp;<?php echo $tott; ?></td>
<td widtd="15%">&nbsp;<?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;
}
else {	
echo $duedat = date("d-m-Y", strtotime("$hpdate + " . $a . " month"));
}


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

<td widtd="5%">&nbsp;<?php echo $a; ?></td>
<td widtd="10%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td widtd="10%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td widtd="10%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td widtd="10%">&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></br>
NAME : </br>
DATE  :
</b></font> </td>


</tr>
</table>

</div>
<?php } ?>

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