<?php defined('BASEPATH') OR exit('No direct script access allowed');

	$date = new DateTime($tDate);
	$number = $totAmount;
	$decimal = round($number - ($no = floor($number)), 2) * 100;
    $hundred = null;
    $digits_length = strlen($no);
    $i = 0;
    $str = array();
    $words = array(0 => '', 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 => 'ninety');
    $digits = array('', 'hundred','thousand','lakh', 'crore');
    while( $i < $digits_length ) {
        $divider = ($i == 2) ? 10 : 100;
        $number = floor($no % $divider);
        $no = floor($no / $divider);
        $i += $divider == 10 ? 1 : 2;
        if ($number) {
            $plural = (($counter = count($str)) && $number > 9) ? '' : null;
            $hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
            $str [] = ($number < 21) ? $words[$number].' '. $digits[$counter]. $plural.' '.$hundred:$words[floor($number / 10) * 10].' '.$words[$number % 10]. ' '.$digits[$counter].$plural.' '.$hundred;
        } else $str[] = null;
    }
    $result = implode('', array_reverse($str));
    $paise = ($decimal) ? ($words[$decimal / 10] . " " . $words[$decimal % 10]) . ' Paise' : '';

 ?>
<div class="trans">
	<table border="0" cellspacing="0" cellpadding="0" style="width:100%">
		<tr>
			<td style="width:33%;text-align:left;padding-left:10px;"> 
			</td>
			<td style="width:34%;">
				<div align="center" class="name"><b><?php echo get_company('name');?></b></div>
				<div align="center"><?php echo get_company('address1');?></div>
					<?php if (get_company('address2')) {
						echo '<div align="center">'.get_company('address2').'</div>';
					} ?> 
				<div align="center"><?php echo get_company('city');?></div>
				<div align="center"><?php echo get_company('zip');?></div>
				<div align="center"><?php echo get_company('phone');?></div>
			</td>
			<td style="width:33%;">
			</td>
		</tr>
	</table><br>
</div><br>
<div class="rece">
	<h1><?php echo $titleText; ?></h1>
</div><br>

	<table border="0" cellspacing="0" cellpadding="0" style="width:80%" align="center">
		<tr>
			<td style="width:32.5%;text-align:left;">&nbsp;Receipt No.&nbsp;<?php echo '#'.'&nbsp;'.'<b>'.$tNo.'</b>';?></td>
			<td style="width:32.5%;text-align:right;">&nbsp;<?php echo lang("Date")?>&nbsp;<b><?php echo $date->format('d/m/Y');?></b></td>
		</tr>	
	</table><br><br>
	<table class="tab" border="0" align="center" cellspacing="0" cellpadding="0" style="width:100%;border-collapse: collapse;">
		<tr>
			<td valign="top" style="width:30%;height:1%;padding: 2px;border-left: thin solid;border-top: thin solid;border-color: #D3D3D3;"></td>
			<td valign="top" align="left" style="width:5%;height:1%;border-top: thin solid;border-color: #D3D3D3;"></td>	
			<td valign="top" style="width:30%;height:1%;padding: 2px;border-top: thin solid;border-right: thin solid;border-color: #D3D3D3;"></td>
		</tr>
		<tr>
			<td valign="top" style="width:30%;height:2%;padding: 4px;border-left: thin solid;border-top: thin solid;border-color: #D3D3D3;">&nbsp;&nbsp;Amount Received from</td>
			<td valign="top" align="left" style="width:5%;border-top: thin solid;padding: 4px;border-color: #D3D3D3;height:2%;">:</td>	
			<td valign="top" style="width:30%;height:2%;padding: 4px;border-top: thin solid;border-right: thin solid;border-color: #D3D3D3;"><b><?php echo $conName;?></b><br><?php echo $address[0]['city'];?>,<?php echo $address[0]['country'];?></td>
		</tr>
		<tr>
			<td valign="top" style="width:30%;height:2%;padding: 4px;border-left: thin solid;border-color: #D3D3D3;">&nbsp;&nbsp;Sum of amount</td>
			<td valign="top" align="left" style="height:2%;width:5%;padding: 4px;border-color: #D3D3D3;">:</td>	
			<td valign="top" style="width:30%;height:2%;padding: 4px;border-right: thin solid;border-color: #D3D3D3;"><b>Rs.<?php echo $totAmount;?></b>&nbsp;&nbsp;(<?php if($paise) { echo $result . "Rupees and"."&nbsp;" . $paise.'&nbsp;'."only"; } else {echo $result . "Rupees only";}?>)</td>	
		</tr>
		<tr>
			<td valign="top" style="width:30%;height:2%;padding: 4px;border-left: thin solid;border-color: #D3D3D3;">&nbsp;&nbsp;Payment made By</td>
			<td valign="top" align="left" style="height:2%;width:5%;padding: 4px;border-color: #D3D3D3;">:</td>	
			<td valign="top" style="width:30%;height:2%;padding: 4px;border-right: thin solid;border-color: #D3D3D3;"><?php echo $paymentName;?></td>
		</tr>
		<tr>
			<td valign="top" style="width:30%;height:2%;padding: 4px;border-left: thin solid; border-color: #D3D3D3;">&nbsp;&nbsp;Remarks</td>
			<td valign="top" align="left" style="height:2%;width:5%;padding: 4px;border-color: #D3D3D3;">:</td>	
			<td valign="top" style="width:30%;height:2%;padding: 4px;border-right: thin solid;border-color: #D3D3D3;"><?php echo $notes;?></td>
		</tr>
		<tr>
			<td valign="top" style="width:30%;height:2%;padding: 5px;border-left: thin solid;border-top: thin solid; border-bottom: thin solid; border-right: thin solid;border-color: #D3D3D3;" colspan="3" align="center">With Thanks!</td>
		</tr>
	</table>
	<div style="width:82.8%;margin-top:100px;text-align:right">
		Authorized Signatory
	</div>
<style>
.rece{
	text-align:center;
}
.trans
{
	font-size:15px;
	width: 100%;
	min-height: 30%;
	margin: 0px;
}
/*.tab  {
	border-width: thin;
	border-spacing: 2px;
	border-style: none;
	border-color: black;
}*/
/*.tab tr td {
	margin-top:0px;
}*/
.name {
	font-size:20px;
}
.noBorder {
	border: 0;
}
</style>

