<?php ob_start(); 
session_start(); ?>
<!DOCTYPE html>
<html>
<?php include "layouts/db_connect.php"; ?>
		<head>
		<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Sales Print</title>
<style type="text/css" media="print">
.hide{display:none}
table, tr, td {
 
}
tr.noBorder td {
  border: 0;
}
</style><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">
<!--
.style1 {font-size: 10px}
-->
</style>
</head>
<body onload="self.print()" onfocus="window.close()">
	<?php 	 $hpl=$_REQUEST['hpl'];
	$fid=$_REQUEST['fid'];
	$qry=mysqli_query($conn, "select * from monuser where fid=$fid");
					$row=mysqli_fetch_array($qry);
	//	$sch = $row['edate'];
$mode = $row['mode'];
$hpl = $row['hpl'];
$mfin5 = $row['mfin'];
$sql678 = mysqli_query($conn, "select * from mfin where name='$mfin5'");
$row678 = mysqli_fetch_array($sql678);
	$qry22=mysqli_query($conn, "select * from moncust where hpl='$hpl' && mfin='$mfin5'");
					$row22=mysqli_fetch_array($qry22);
				?>	<center>
				<?php
	function convert_digit_to_words($no)  
	{   
	
	//creating array  of word for each digit
	 $words = array('0'=> 'Zero' ,'1'=> 'one' ,'2'=> 'two' ,'3' => 'three','4' => 'four','5' => 'five','6' => 'six','7' => 'seven','8' => 'eight','9' => 'nine','10' => 'ten','11' => 'eleven','12' => 'twelve','13' => 'thirteen','14' => 'fourteen','15' => 'fifteen','16' => 'sixteen','17' => 'seventeen','18' => 'eighteen','19' => 'nineteen','20' => 'twenty','30' => 'thirty','40' => 'forty','50' => 'fifty','60' => 'sixty','70' => 'seventy','80' => 'eighty','90' => 'ninty','100' => 'hundred','1000' => 'thousand','100000' => 'lakh','10000000' => 'crore');
	 //$words = array('0'=> '0' ,'1'=> '1' ,'2'=> '2' ,'3' => '3','4' => '4','5' => '5','6' => '6','7' => '7','8' => '8','9' => '9','10' => '10','11' => '11','12' => '12','13' => '13','14' => '14','15' => '15','16' => '16','17' => '17','18' => '18','19' => '19','20' => '20','30' => '30','40' => '40','50' => '50','60' => '60','70' => '70','80' => '80','90' => '90','100' => '100','1000' => '1000','100000' => '100000','10000000' => '10000000');
	 
	 
	 //for decimal number taking decimal part
	 
	$cash=(int)$no;  //take number wihout decimal
	$decpart = $no - $cash; //get decimal part of number
	
	$decpart=sprintf("%01.2f",$decpart); //take only two digit after decimal
	
	$decpart1=substr($decpart,2,1); //take first digit after decimal
	$decpart2=substr($decpart,3,1);   //take second digit after decimal  
	
	$decimalstr='';
	
	//if given no. is decimal than  preparing string for decimal digit's word
	
	if($decpart>0)
	{
	 $decimalstr.="point ".$numbers[$decpart1]." ".$numbers[$decpart2];
	}
	 
	    if($no == 0)
	        return ' ';
	    else {
	    $novalue='';
	    $highno=$no;
	    $remainno=0;
	    $value=100;
	    $value1=1000;       
	            while($no>=100)    {
	                if(($value <= $no) &&($no  < $value1))    {
	                $novalue=$words["$value"];
	                $highno = (int)($no/$value);
	                $remainno = $no % $value;
	                break;
	                }
	                $value= $value1;
	                $value1 = $value * 100;
	            }       
	          if(array_key_exists("$highno",$words))  //check if $high value is in $words array
	              return $words["$highno"]." ".$novalue." ".convert_digit_to_words($remainno).$decimalstr;  //recursion
	          else {
	             $unit=$highno%10;
	             $ten =(int)($highno/10)*10;
	             return $words["$ten"]." ".$words["$unit"]." ".$novalue." ".convert_digit_to_words($remainno
	             ).$decimalstr; //recursion
	           }
	    }
	} ?>
	<table width="384px" cellspacing="0" cellpadding="0" border="0">
	<center>
<h3><strong><b><font style="color:black;letter-spacing: 2px;LINE-HEIGHT:20px;font-weight: 1500;" color="#000"  face="Arial Black"  size="4.5"><strong>
<b><b><?php echo $row678['name']; ?></b></strong></b></font></h3>
<strong><b>
<font style="letter-spacing: 2px;LINE-HEIGHT:20px;color:black;"  face="Arial Black" style="letter-spacing: 2px;LINE-HEIGHT:20px" size="2.5">
<strong><b><center>
<?php if($mode=='Cash A/C') { ?> CASH RECEIPT
<?php } else { ?> CHEQUE RECEIPT <?php } ?>
</font></strong></b></center>
  </font>
<tr>
<td colspan="3" ><center>--------------------------------------------------------------------</center></td></tr>
<tr>
<td width="50%"><strong><b><font style="letter-spacing: 2px;LINE-HEIGHT:20px"  face="Arial Black" size="2"><strong><b>A/C No  : <?php echo $row['hpl']; ?></strong></b></font> </td>
<td width="25%"  style="text-align:left;"><strong><b><font style="letter-spacing: 2px;LINE-HEIGHT:20px"  face="Arial Black" size="2"><strong><b>RCPT NO&nbsp;:</b></font></strong></td>
<td width="25%"  style="text-align:right;"><strong><b><font style="letter-spacing: 2px;LINE-HEIGHT:20px"  face="Arial Black" size="2"><strong><b><?php echo $row['roll']; ?></b></td>
</tr>
<tr>
<td colspan="3" width="100%"><strong><b><font style="letter-spacing: 2px;LINE-HEIGHT:20px"  face="Arial Black" size="2"><strong><b><?php echo $row['name']; ?></strong></b></font> </td>
</tr><tr>
<td width="50%"><strong><b><font style="letter-spacing: 2px;LINE-HEIGHT:20px"  face="Arial Black" size="2"><strong><b><?php echo $row22['vno']; ?></br>
DUES : <?php echo $row['status']; ?></strong></b></font> </td>


<td width="25%"  style="text-align:left;"><strong><b><font style="letter-spacing: 2px;LINE-HEIGHT:20px"  face="Arial Black" size="2"><strong><b><b>Date&nbsp;&nbsp;&nbsp;&nbsp;:</b></br>


</font></strong></td>
<td width="25%"  style="text-align:right;"><strong><b><font style="letter-spacing: 2px;LINE-HEIGHT:20px"  face="Arial Black" size="2"><strong><b>
<b><?php echo date('d/m/y', strtotime($row['paydate'])); ?></b></br>


</font></strong></td>
</tr>
<tr>
<td colspan="3" ><center>--------------------------------------------------------------------</center></td></tr>
<tr>
<td width="60%" colspan="2"><font style="letter-spacing: 2px;LINE-HEIGHT:20px;font-weight: 1500;"  face="Arial Black" color="black" size="2.5"><strong><b>PARTICULARS</BR></strong></b></font></td>

<td width="40%" style="text-align:right;"><font style="letter-spacing: 2px;LINE-HEIGHT:20px;font-weight: 1500;"  face="Arial Black" color="black" size="2.5"><strong><b>AMOUNT</BR></strong></b></font></td></tr>
<?php $dd = $row['urname'];
$ss = $row['hloan'];
$fff = $row['fine'];

$tot = $dd;
$tot = round($tot,0);
$mmm = $dd - $fff - $ss;
if($dd != NULL) { ?>
<tr>
<td width="60%" colspan="2"></br><font style="letter-spacing: 2px;LINE-HEIGHT:20px"  face="Arial Black" size="2.5"><strong><b>DUES (<?php echo $row['pass']; ?> + <?php echo $row['rno']; ?>)</strong></b> </font></td>

<td width="40%" style="text-align:right;"><font style="letter-spacing: 2px;LINE-HEIGHT:20px" align="right" face="Arial Black" size="4"><strong><b></BR><?php echo round($mmm,0); ?></strong></b></font></td></tr>
<?php } if(($ss != NULL)&&($ss != 0)) { ?>
<tr>
<td width="50%" colspan="2"></BR><font style="letter-spacing: 2px;LINE-HEIGHT:20px"  face="Arial Black" size="2.5"><strong><b>HAND LOAN</strong></b> </font> </td>

<td width="50%" style="text-align:right;"></BR><font style="letter-spacing: 2px;LINE-HEIGHT:20px" align="right" face="Arial Black" size="4"><strong><b><?php echo round($row['hloan'],0); ?></strong></b></font></td></tr> <?php } ?>

<?php if(($fff != NULL)&&($fff > 0)) { ?>
<tr>
<td width="50%" colspan="2"></BR><font style="letter-spacing: 2px;LINE-HEIGHT:20px"  face="Arial Black" size="2.5"><strong><b>Default</strong></b> </font> </td>

<td width="50%" style="text-align:right;"></BR><font style="letter-spacing: 2px;LINE-HEIGHT:20px"align="right"  face="Arial Black" size="4"><strong><b><?php echo round($row['fine'],0); ?></strong></b></font></td></tr> <?php } ?>

<tr>

<td width="50%" colspan="2"><font style="letter-spacing: 2px;LINE-HEIGHT:20px"  face="Arial Black" size="2.5"></BR><strong><b>Total</strong></b></font></td>

<td width="50%" style="text-align:right;"><font style="letter-spacing: 2px;LINE-HEIGHT:20px" align="right" face="Arial Black" size="4"></BR><strong><b><?php echo round($tot,0); ?></strong></b></font></td></tr>


	
<tr>
	 <td colspan="3" ><font style="letter-spacing: 2px;LINE-HEIGHT:20px"  face="Arial Black" size="2"><strong><b></br>( Rupees <?php	 echo convert_digit_to_words($tot); echo " Only."; ?> )</strong></b></font>
 </td>
 </tr>
 <tr>
<td colspan="3" ><center>--------------------------------------------------------------------</center></td></tr>
 <tr>
	<td colspan="3"  style="text-align:right;">
<font style="letter-spacing: 2px;LINE-HEIGHT:20px" SIZE="1"  face="Arial Black"> <strong><b>	<?php echo $row['remarks']; ?></strong></b></font>
	<H5><font style="letter-spacing: 2px;LINE-HEIGHT:20px" SIZE="3"  face="Arial Black">
	For <strong><b><?php echo $row678['name']; ?></br> </BR></font></H5></strong></b>
 </td>
 </tr>
 <tr>
	 <td colspan="3"   style="text-align:right;">
	
	 <font style="letter-spacing: 2px;LINE-HEIGHT:20px"  face="Arial Black"><strong><b>
(AUTHORITY)
</strong></b></font>
 </td>
 </tr>
 <tr>
	 <td tyle="text-align:left;">
	
	 <font style="letter-spacing: 2px;LINE-HEIGHT:20px"  face="Arial Black"><strong><b>
<?php echo $row['scode']; ?> 
</td> <td colspan="2"   style="text-align:right;">
- <b> <?php
 date_default_timezone_set('Asia/Kolkata');
 $date = date('h:i:s a m/d/y');
	 echo date('h:i:s a d/m/y', strtotime($date)); ?></b>
</strong></b></font>
 </td>
 </tr>

    </table></center>


    </table></center>

</body>
</html>