donation/app/Views/pdf_view.php
2020-12-01 12:13:44 +05:30

333 lines
9.2 KiB
PHP

<center><h2>RECEIPT</h2></center>
<div class="hover-btn">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-2"><a href="<?= base_url() ?>/Dashboard/edit_receipt/<?php foreach($receipt as $key){echo $key['receipt_id'];}?>">
<button class="btn btn-one">Edit Receipt</button></a></div>
<div class="col-md-2"><a href="<?= base_url() ?>/PdfController/download_receipt/<?php foreach($receipt as $key){echo $key['receipt_id'];}?>">
<button class="btn btn-two">Download</button></a></div>
<div class="col-md-2"><a href="<?= base_url() ?>/Dashboard/edit_receipt/<?php foreach($receipt as $key){echo $key['receipt_id'];}?>">
<button class="btn btn-three">Send Mail</button></a></div>
<div class="col-md-2"><a href="<?= base_url() ?>/Dashboard">
<button class="btn btn-four">Exit</button></a></div>
</div>
<table>
<tr>
</tr>
</table>
<!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;
}
.btn-two{
background: #5863db;
}
.btn-three{
background: #c41f26;
}
.btn-four{
background: #58cadb;
}
</style>
<style>
.invoice-box {
max-width: 800px;
margin: auto;
padding: 30px;
border: 1px solid #eee;
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;
margin-left: 30%;
}
.invoice-box table {
width: 100%;
line-height: inherit;
text-align: left;
}
.invoice-box table td {
padding: 5px;
vertical-align: top;
}
.invoice-box table tr td:nth-child(2) {
text-align: right;
}
.invoice-box table tr.top table td {
padding-bottom: 20px;
}
.invoice-box table tr.top table td.title {
font-size: 45px;
line-height: 45px;
color: #333;
}
.invoice-box table tr.information table td {
padding-bottom: 40px;
}
.invoice-box table tr.heading td {
background: #eee;
border-bottom: 1px solid #ddd;
font-weight: bold;
}
.invoice-box table tr.details td {
padding-bottom: 20px;
}
.invoice-box table tr.item td{
border-bottom: 1px solid #eee;
}
.invoice-box table tr.item.last td {
border-bottom: none;
}
.invoice-box table tr.total td:nth-child(2) {
border-top: 2px solid #eee;
font-weight: bold;
}
@media only screen and (max-width: 600px) {
.invoice-box table tr.top table td {
width: 100%;
display: block;
text-align: center;
}
.invoice-box table tr.information table td {
width: 100%;
display: block;
text-align: center;
}
}
/** RTL **/
.rtl {
direction: rtl;
font-family: Tahoma, 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
}
.rtl table {
text-align: right;
}
.rtl table tr td:nth-child(2) {
text-align: left;
}
.donation {
font-size: 30px;
}
</style>
</head>
<body>
<div class="invoice-box">
<table cellpadding="0" cellspacing="0">
<tr class="top">
<td colspan="2">
<table>
<tr>
<td class="title">
<p class="donation">DONATION RECEIPT</p>
</td>
<td>
Receipt No #: <?php foreach($receipt as $key){echo $key['receipt_id'];}?><br>
Created: <?php echo date("l jS \of F Y "); ?><br>
</td>
</tr>
</table>
</td>
</tr>
<tr class="information">
<tr>
<td>
<?= ucfirst($admindata['org_name']); ?><br>
<?= $admindata['address'] ?>,<?= $admindata['city'] ?>,<br>
<?= $admindata['state'] ?>-<?= $admindata['pin_code'] ?>.
</td>
<td>
Email :<?= $admindata['email'] ?><br>
Phone :<?= $admindata['phone'] ?>.<br>
</td>
</tr></tr>
<tr class="heading">
<td>
Donation Cause
</td>
<td>
<?= $causedata['cause_name']; ?>
</td>
</tr>
<tr class="item">
<td>
Donation Cause Validity
</td>
<td>
<?= $causedata['from_date']; ?>-to-<?= $causedata['to_date']; ?>
</td>
</tr>
<tr class="heading">
<td>
Payment Method
</td>
<td>
Check #
</td>
</tr>
<tr class="details">
<td>
Check
</td>
<td>
<?= $donordata['name'] ?><?php foreach($receipt as $key){echo $key['amount'];}?>
</td>
</tr>
<tr class="heading">
<td>
Item
</td>
<td>
Price
</td>
</tr>
<tr class="item">
<td>
Website design
</td>
<td>
$300.00
</td>
</tr>
<tr class="item">
<td>
Hosting (3 months)
</td>
<td>
$75.00
</td>
</tr>
<tr class="item last">
<td>
Domain name (1 year)
</td>
<td>
$10.00
</td>
</tr>
<tr class="total">
<td></td>
<td>
Total: $385.00
</td>
</tr>
</table>
</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;
}
?>
<!-- call the function here -->
<?php $amt_words=7787;
// nummeric value in variable
$get_amount= AmountInWords($amt_words);
echo $get_amount;
?>