<?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'];
$pno = $row1['pno']; 
$dueamt = $row1['dueamt']; 	
$interest = $row1['interest']; 
$g1 = $row1['g1']; 	
$b1 = $row1['b1']; 					
	$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>


<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<=50;$i++) { 
$a = $i + 50;
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((($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-".$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> -->


</div>
<?php } ?>

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