donation/app/Views/view_receipt.php
2020-12-26 23:12:25 +05:30

322 lines
9.2 KiB
PHP

<center><h2>RECEIPT</h2></center>
<div class="hover-btn">
<center>
<a href="<?= base_url() ?>/edit_receipt/<?= $receipt['receipt_id'] ?>">
<button class="btn btn-one">Edit Receipt</button></a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="<?= base_url() ?>/PdfController/download_receipt/<?= $receipt['receipt_id'] ?>">
<button class="btn btn-two">Download</button></a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="<?= base_url() ?>/Send_mail/<?= $receipt['receipt_id'] ?>">
<button class="btn btn-three">Send Mail</button></a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="<?= base_url() ?>/Dashboard">
<button class="btn btn-four">Exit</button></a>
</center>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>A simple, clean, and responsive HTML invoice template</title>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<style>
.hover-btn button{
margin:10px;
color:#FFF;
padding:10px 40px;
}
.hover-btn button:hover{
background:#5a5a5a;
}
.btn-one{
background: #f11350;
width: 150px;
}
.btn-two{
background: #5863db;
width: 150px;
}
.btn-three{
background: #c41f26;
width: 150px;
}
.btn-four{
background: #58cadb;
width: 150px;
}
.mailfont{
font-size: 15px;
}
</style>
<style>
.invoice-box {
max-width: 800px;
margin: auto;
padding: 30px;
border: 1px solid black;
box-shadow: 0 0 10px rgba(0, 0, 0, .15);
font-size: 16px;
line-height: 24px;
font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
color: #555;
}
.donation {
font-size: 30px;
}
.date{
background: transparent;
border: none;
border-bottom: 1px solid #000000;
width: 20%;
}
.receiptno{
background: transparent;
border: none;
border-bottom: 1px solid #000000;
width: 12%;
}
.donatedby{
background: transparent;
border: none;
border-bottom: 1px solid #000000;
width: 75%;
}
.address{
background: transparent;
border: none;
border-bottom: 1px solid #000000;
width: 72%;
}
.city{
background: transparent;
border: none;
border-bottom: 1px solid #000000;
width: 31%;
}
.state{
background: transparent;
border: none;
border-bottom: 1px solid #000000;
width: 26%;
}
.pincode{
background: transparent;
border: none;
border-bottom: 1px solid #000000;
width: 13%;
}
.amt{
background: transparent;
border: none;
border-bottom: 1px solid #000000;
width: 50%;
}
.amtinword{
background: transparent;
border: none;
border-bottom: 1px solid #000000;
width: 71%;
}
.cause{
background: transparent;
border: none;
border-bottom: 1px solid #000000;
width: 58%;
}
</style>
</head>
<body>
<div class="invoice-box">
<div class="row">
<div class="col-md-4">
</br></br></br>
<center> <img src="<?=base_url()?>/public/assets/logo.jpg" alt="Girl in a jacket" width="100" height="100"></center> </br>
<center> <h3><?= $admindata['org_name'] ?></h3></center>
<center> <?= $admindata['address'] ?>,<?= $admindata['city'] ?>,</center>
<center> <?= $admindata['state'] ?>-<?= $admindata['pin_code'] ?>.</center>
<center class="mailfont"> Email :<?= $admindata['email'] ?></center>
<center class="mailfont"> GSTIN :<?= $admindata['gstin'] ?></center>
</div>
<div class="col-md-8">
<center> <h3>Donation Receipt</h3></center></br>
Date :&nbsp;&nbsp;<input type="text" class="date" value="<?= $receipt['date'] ?>" readonly>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Receipt No :&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" class="receiptno" value="&nbsp;&nbsp;&nbsp;<?= $receipt['receipt_id'] ?>" readonly> </br></br>
Donated by :&nbsp;&nbsp;&nbsp; <input type="text" class="donatedby" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?= $donordata['name'] ?>" readonly></br></br>
Street Address :&nbsp;&nbsp;<input type="text" class="address" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?= $donordata['address'] ?>" readonly> </br>
City :&nbsp;
<input type="text" class="city" value="<?= $donordata['city'] ?>" readonly>
State :&nbsp;<input type="text" class="state" value="<?= $donordata['state'] ?>" readonly>
Pin :&nbsp;<input type="text" class="pincode" value="<?= $donordata['pin_code'] ?>" readonly></br>
Amount Received By Charity : &nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" class="amt" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?= $receipt['amount'] ?>" readonly></br>
Amount in Words :
<!-- call the function here -->
<?php $amt_words= $receipt['amount'];
// nummeric value in variable
$get_amount= numberTowords($amt_words);
?><input type="text" class="amtinword" value="<?= $get_amount ?>" readonly> </br>
Discription of Donation : &nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" class="cause" value="<?= $causedata['cause_name']; ?>" readonly></br></br></br>
Authorized Signature : &nbsp;&nbsp;&nbsp;&nbsp;<img src="<?=base_url()?>/<?=$admindata['signature']?>.png" alt="Girl in a jacket" width="200" height="40">
</br></br>
<center class="mailfont">"Thank You For Your Donation"</center>
</div>
</div>
</div>
</body>
</html>
<?php
// Create a function for converting the amount in words
function AmountInWords(float $amount)
{
$amount_after_decimal = round($amount - ($num = floor($amount)), 2) * 100;
// Check if there is any number after decimal
$amt_hundred = null;
$count_length = strlen($num);
$x = 0;
$string = array();
$change_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');
$here_digits = array('', 'Hundred','Thousand','Lakh', 'Crore');
while( $x < $count_length ) {
$get_divider = ($x == 2) ? 10 : 100;
$amount = floor($num % $get_divider);
$num = floor($num / $get_divider);
$x += $get_divider == 10 ? 1 : 2;
if ($amount) {
$add_plural = (($counter = count($string)) && $amount > 9) ? 's' : null;
$amt_hundred = ($counter == 1 && $string[0]) ? ' and ' : null;
$string [] = ($amount < 21) ? $change_words[$amount].' '. $here_digits[$counter]. $add_plural.'
'.$amt_hundred:$change_words[floor($amount / 10) * 10].' '.$change_words[$amount % 10]. '
'.$here_digits[$counter].$add_plural.' '.$amt_hundred;
}
else $string[] = null;
}
$implode_to_Rupees = implode('', array_reverse($string));
$get_paise = ($amount_after_decimal > 0) ? "And " . ($change_words[$amount_after_decimal / 10] . "
" . $change_words[$amount_after_decimal % 10]) . ' Paise' : '';
return ($implode_to_Rupees ? $implode_to_Rupees . 'Rupees ' : '') . $get_paise;
}?>
<?php
function numberTowords($num)
{
$ones = 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",
"014" => "FOURTEEN"
);
$tens = array(
0 => "ZERO",
1 => "TEN",
2 => "TWENTY",
3 => "THIRTY",
4 => "FORTY",
5 => "FIFTY",
6 => "SIXTY",
7 => "SEVENTY",
8 => "EIGHTY",
9 => "NINETY"
);
$hundreds = array(
"HUNDRED",
"THOUSAND",
"MILLION",
"BILLION",
"TRILLION",
"QUARDRILLION"
); /*limit t quadrillion */
$num = number_format($num,2,".",",");
$num_arr = explode(".",$num);
$wholenum = $num_arr[0];
$decnum = $num_arr[1];
$whole_arr = array_reverse(explode(",",$wholenum));
krsort($whole_arr,1);
$rettxt = "";
foreach($whole_arr as $key => $i){
while(substr($i,0,1)=="0")
$i=substr($i,1,5);
if($i < 20){
/* echo "getting:".$i; */
$rettxt .= $ones[$i];
}elseif($i < 100){
if(substr($i,0,1)!="0") $rettxt .= $tens[substr($i,0,1)];
if(substr($i,1,1)!="0") $rettxt .= " ".$ones[substr($i,1,1)];
}else{
if(substr($i,0,1)!="0") $rettxt .= $ones[substr($i,0,1)]." ".$hundreds[0];
if(substr($i,1,1)!="0")$rettxt .= " ".$tens[substr($i,1,1)];
if(substr($i,2,1)!="0")$rettxt .= " ".$ones[substr($i,2,1)];
}
if($key > 0){
$rettxt .= " ".$hundreds[$key]." ";
}
}
if($decnum > 0){
$rettxt .= " and ";
if($decnum < 20){
$rettxt .= $ones[$decnum];
}elseif($decnum < 100){
$rettxt .= $tens[substr($decnum,0,1)];
$rettxt .= " ".$ones[substr($decnum,1,1)];
}
}
return $rettxt;
}
extract($_POST);
if(isset($convert))
{
echo "<p align=''>".numberTowords("$num")."</p>";
}
?>