307 lines
14 KiB
PHP
Executable File
307 lines
14 KiB
PHP
Executable File
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<style>
|
||
/* Add your CSS styles here to format the invoice for mPDF */
|
||
body {font-family: 'Times New Roman', Times, sans-serif;font-size: 12px;}
|
||
table.main-table {width: 100%;border-collapse: collapse;border: -0.5px solid black;}
|
||
table.main-table th,table.main-table td {border: none;}
|
||
table.business-details-table {width: 100%;border-collapse: collapse;}
|
||
table.business-details-table td {padding: 8px;text-align: left;}
|
||
.business-logo-container {text-align: center;}
|
||
img.business-logo {max-width: 200px;}
|
||
.business-name {font-size: 16px;font-weight: bold;margin-top: 10px;}
|
||
table.invoice-info-table {width: 110%;}
|
||
/* table.invoice-info-table th,table.invoice-info-table td {text-align: right;} */
|
||
table.addresses-table {width: 100%;}
|
||
table.addresses-table th {text-align: left;padding-left: 8px;}
|
||
.billing-address {width: 50%;padding-left: 8px;}
|
||
table.invoice-related-table {width: 100%;border-collapse: collapse;}
|
||
table.invoice-related-table th,table.invoice-related-table td {border: none;padding: 8px;text-align: left;}
|
||
table.invoice-related-table th {background-color: #DAC2AD;font-weight: bold;}
|
||
table.invoice-related-table thead tr th{border: 0.5px solid black;}
|
||
table.invoice-related-table thead tr{border: 0.5px solid black;}
|
||
.business-stamp, .terms {text-align: center;margin-top: 20px;}
|
||
.subtotal-table {width: 100%;margin-top: 20px;}
|
||
.subtotal-table table {width: 100%;border-collapse: collapse;border: 1px solid black;}
|
||
.subtotal-table th,.subtotal-table td {border: none;padding: 8px;text-align: right;}
|
||
.subtotal-table th {background-color: #f2f2f2;font-weight: bold;}
|
||
.subtotal-table td:last-child {font-weight: bold; }
|
||
td.invoice-number {font-size: 18px;font-weight: bold; /* Make the text bold */}
|
||
p {margin-top: 0;margin-bottom: 0rem;}
|
||
.invoice-info-table {border-collapse: collapse;}
|
||
.invoice-info-table td {border: 1px solid black;}
|
||
.invoice-info-table tr:first-child td {border-top: none;}
|
||
.invoice-info-table tr:first-child td {border-right: none;}
|
||
.invoice-info-table tr td:nth-child(2) {border-left: none;}
|
||
.invoice-info-table tr:first-child td {border-bottom: none;}
|
||
.invoice-info-table tr:last-child td {border-bottom: none;}
|
||
.invoice-info-table tr td:first-child {border-left: none;}
|
||
.invoice-info-table tr td:last-child {border-right: none;}
|
||
.term_condition {border-collapse: collapse;width: 100%;}
|
||
.term_condition td {border: 0.5px solid black;padding: 8px;text-align: center;}
|
||
</style>
|
||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||
|
||
</head>
|
||
<body>
|
||
<h3 style="text-align:center;text-decoration: underline;">Tax Invoice</h3>
|
||
<table class="main-table">
|
||
<tr>
|
||
<td>
|
||
<table class="business-details-table">
|
||
|
||
<?php foreach ($sales as $value) : ?>
|
||
<tr>
|
||
<td class="business-logo-container"style="font-size: 16px;font-weight: bold;">
|
||
<?= $business['business_name'] ?>
|
||
<!-- <img src="https://vijayabharathambooks.com/wp-content/uploads/2021/09/vijaya-bharatham-logo-8pt.png" alt="Business Logo" class="business-logo"> -->
|
||
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<p style="margin-top: -15px;"><?= $value->company_address ?>,<br>
|
||
<?= $value->company_city ?>,
|
||
<?= $value->company_state ?>
|
||
<?= $value->company_postal_code ?>.<br>
|
||
|
||
<!-- <?= $value->company_mobile_no_1 ?>, <?= $value->company_mobile_no_2 ?> -->
|
||
</p>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<div style="margin-top: -20px;"><span>GSTIN: <?php echo $branch['gstno']?> </span><br>
|
||
<span>State Name: <?php echo $branch['state']?> , Code: <?php echo $branch['state_code']?> </span><br>
|
||
<span>Contact : <?php echo $branch['contact_1']?>, <?php echo $branch['contact_2']?></span><br>
|
||
<span>Email : <?php echo $branch['email']?></span><br><br>
|
||
<span ><b>Buyer (Bill To) </b> </span>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
|
||
|
||
|
||
|
||
</table>
|
||
</td>
|
||
<td>
|
||
<table class="invoice-info-table" >
|
||
<tbody >
|
||
<tr><?php $currentYear = date('y');
|
||
$nextYear = date('y', strtotime('+1 year'));
|
||
$yearRange = $currentYear . '-' . $nextYear;
|
||
|
||
$businessName = trim($business['business_name']);
|
||
$words = explode(' ', $businessName);
|
||
$initials = '';
|
||
foreach ($words as $word) {
|
||
$word = preg_replace("/[^A-Za-z]/", '', $word);
|
||
$initials .= strtoupper(substr($word, 0, 1));
|
||
}
|
||
|
||
|
||
?>
|
||
|
||
<td>Invoice No.</td><td><?= $initials ."/".$yearRange."/" . $saleOrderCount+1 ?></td>
|
||
</tr>
|
||
<tr>
|
||
<td>Date</td><td><?= date('Y-m-d', strtotime($sales[0]->created_at)) ?></td>
|
||
</tr>
|
||
<tr>
|
||
<td>Bike Make & Model</td><td><?php echo $bike_make['make'], $bike_model['model_name']; ?></td>
|
||
</tr>
|
||
<tr>
|
||
<td>Colour</td><td><?php echo $vehicle['colour']?></td>
|
||
</tr>
|
||
<tr>
|
||
<td>Register Number</td><td><?php echo $vehicle['reg_no']?></td>
|
||
</tr>
|
||
<tr>
|
||
<td>Contact Number</td><td><?php echo $vehicle['mobile_no']?></td>
|
||
</tr>
|
||
<tr>
|
||
<td>Sale Order No </td><td><?= $sales[0]->order_number ?></td>
|
||
</tr>
|
||
<tr>
|
||
<td>Payment Mode</td><td><?= (isset($sales[0]->mode_of_payment) && strlen($sales[0]->mode_of_payment) > 0) ? $sales[0]->mode_of_payment : "Not Done" ?></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
<table class="addresses-table" style="margin-top: -10px;">
|
||
<tr >
|
||
<td class="billing-address">
|
||
|
||
<?php foreach ($sales as $value) : ?>
|
||
<?= $value->client_name ?><br>
|
||
<?= $value->billing_address != '' ? $value->billing_address." , <br>" : ''; ?>
|
||
<?= $value->billing_city ?> <?= $value->billing_state." "?>
|
||
<?php if ($value->billing_postal_code!=0): ?>
|
||
<?= $value->billing_postal_code ?><br>
|
||
<?php endif; ?>
|
||
<?= $value->mobile_no." ." ?>
|
||
|
||
<?php endforeach; ?>
|
||
</td>
|
||
</tr>
|
||
</table><br><br>
|
||
<table class="invoice-related-table">
|
||
<thead>
|
||
<tr >
|
||
<th >S no</th>
|
||
<th >Description Of Goods</th>
|
||
<th>Rate</th>
|
||
<th >Quantity</th>
|
||
<th >Per</th>
|
||
<th >Taxable Amount</th>
|
||
<th >GST</th>
|
||
<th >CGST Amount</th>
|
||
<th >SGST Amount</th>
|
||
<th >Total Tax</th>
|
||
<th >Total</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php $serialNumber = 1; ?>
|
||
<?php $total_taxable_amount = 0; $total_CGST = 0; $total_SGST = 0; foreach ($items as $item) :
|
||
|
||
?>
|
||
<tr>
|
||
<?php $taxable_amount = $item->net_price * $item->qty;
|
||
$total_taxable_amount += $taxable_amount;
|
||
$cgst = ($taxable_amount * $item->tax / 100 ) /2;
|
||
$sgst = ($taxable_amount * $item->tax / 100 ) /2;
|
||
|
||
$total_CGST += $cgst;
|
||
$total_SGST += $sgst;
|
||
?>
|
||
<td style="border: 1px solid black;">
|
||
<?= $serialNumber++; ?>
|
||
</td>
|
||
<td style="border: 0.5px solid black;"><?= $item->product_name ?></td>
|
||
<td style="border: 0.5px solid black;"><?= $item->net_price; ?></td>
|
||
<td style="border: 0.5px solid black;"><?= $item->qty ?></td>
|
||
<td style="border: 0.5px solid black;">nos</td>
|
||
<td style="border: 0.5px solid black;"><?= $taxable_amount ?></td>
|
||
<td style="border: 0.5px solid black;"><?= $item->tax ?>%</td>
|
||
<td style="border: 0.5px solid black;"><?= $cgst ?></td>
|
||
<td style="border: 0.5px solid black;"><?= $sgst ?></td>
|
||
<td style="border: 0.5px solid black;"><?= $cgst + $sgst ?></td>
|
||
|
||
<td style="border: 0.5px solid black;"><?= $item->amount ?></td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
<tr>
|
||
<td colspan="7" style="border-top: 0.5px solid black;border-left: 0.5px solid black;"></td>
|
||
<td colspan="3" style="text-align:center;border: 0.5px solid black;">Subtotal</td>
|
||
<td style="border: 0.5px solid black;"><?= $sales[0]->subtotal ?></td>
|
||
</tr>
|
||
<tr>
|
||
<td colspan="7" style="border-left: 0.5px solid black;"></td>
|
||
<td colspan="3" style="text-align:center;border: 0.5px solid black;">CGST</td>
|
||
<td style="border: 0.5px solid black;"><?= $sales[0]->tax / 2 ?></td>
|
||
</tr>
|
||
<tr>
|
||
<td colspan="7" style="border-left: 0.5px solid black;"></td>
|
||
<td colspan="3" style="text-align:center;border: 0.5px solid black;">SGST</td>
|
||
<td style="border: 0.5px solid black;"><?= $sales[0]->tax / 2 ?></td>
|
||
</tr>
|
||
<tr>
|
||
<td colspan="7" style="border-left: 0.5px solid black;"></td>
|
||
<td colspan="3" style="text-align:center;border: 0.5px solid black;">Total</td>
|
||
<td style="border: 0.5px solid black;" id="total_amount"><?= $sales[0]->total ?></td>
|
||
</tr>
|
||
<tr>
|
||
<td colspan="7" style="border: 0.5px solid black;border-right: none;text-align: center;">Amount Chargeable (in words):
|
||
<?php
|
||
$formatter = new NumberFormatter("en", NumberFormatter::SPELLOUT);
|
||
$words = $formatter->format(round($sales[0]->subtotal + $sales[0]->tax));
|
||
?>
|
||
</td>
|
||
<td colspan="4" style="border: 0.5px solid black; border-left: none;text-align: center;">
|
||
<?php echo ucfirst($words); ?>
|
||
|
||
</td>
|
||
</tr>
|
||
|
||
<tr><td></td></tr>
|
||
<tr><td></td></tr>
|
||
<tr>
|
||
<td colspan="7" style="border: 0.5px solid black;"><p>Declaration: <br> We Declare that this invoice shows the actual price of the goods described and that all particulars are true and correct.<br><br>**This is computer generated bill and doesn’t require signature</p></td>
|
||
<td colspan="4" style="border: 0.5px solid black;text-align: center;"><p>for THE MECHANIC</p><br><br><br> Authorised Signatory</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<script>
|
||
function numberToWords(number) {
|
||
var words = {
|
||
'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': 'ninety'
|
||
};
|
||
|
||
var units = ['', 'thousand', 'million', 'billion', 'trillion', 'quadrillion'];
|
||
|
||
// Function to convert a number less than 1000 to words
|
||
function convertLessThan1000(num) {
|
||
if (num === 0) {
|
||
return '';
|
||
} else if (num < 20) {
|
||
return words[num] + ' ';
|
||
} else if (num < 100) {
|
||
return words[Math.floor(num / 10) * 10] + ' ' + convertLessThan1000(num % 10);
|
||
} else {
|
||
return words[Math.floor(num / 100)] + ' hundred ' + convertLessThan1000(num % 100);
|
||
}
|
||
}
|
||
|
||
// Function to convert a number to words
|
||
function convert(num) {
|
||
if (num === 0) {
|
||
return 'zero';
|
||
}
|
||
|
||
var result = '';
|
||
var i = 0;
|
||
|
||
while (num > 0) {
|
||
if (num % 1000 !== 0) {
|
||
result = convertLessThan1000(num % 1000) + units[i] + ' ' + result;
|
||
}
|
||
num = Math.floor(num / 1000);
|
||
i++;
|
||
}
|
||
|
||
return result.trim();
|
||
}
|
||
|
||
// Convert the number to words
|
||
return convert(number);
|
||
}
|
||
|
||
$(document).ready(function() {
|
||
// Calculate amount and update amount in words
|
||
console.log($('#total_amount').html());
|
||
// Call numberToWords function to get amount in words
|
||
var amountInWords = numberToWords($('#total_amount').html());
|
||
|
||
// Update the span with the amount in words
|
||
$('#amountInWords').html(amountInWords);
|
||
});
|
||
|
||
|
||
</script>
|
||
|
||
</body>
|
||
</html>
|