vb_book/app/Views/invoice_pdf_template.php
2023-09-28 18:31:07 +05:30

279 lines
8.7 KiB
PHP

<!DOCTYPE html>
<html>
<head>
<style>
/* Add your CSS styles here to format the invoice for mPDF */
body {
font-family: 'Times New Roman', Times, sans-serif;
font-size: 12px; /* Change this value to your desired font size */
}
/* Style for the main table with border */
table.main-table {
width: 100%;
border-collapse: collapse;
border: 1px solid black; /* Add a border around the entire invoice */
}
table.main-table th,
table.main-table td {
border: none; /* Remove borders from all cells inside the main table */
padding: 8px;
}
/* Style for the table containing business details */
table.business-details-table {
width: 100%;
border-collapse: collapse;
}
table.business-details-table td {
padding: 8px;
text-align: left;
}
/* Style for the business logo and title */
.business-logo-container {
text-align: center;
}
img.business-logo {
max-width: 200px; /* Adjust the size of the logo */
}
/* Style for the business name */
.business-name {
font-size: 16px;
font-weight: bold;
margin-top: 10px;
}
/* Style for the table containing invoice info */
table.invoice-info-table {
width: 100%;
}
table.invoice-info-table th,
table.invoice-info-table td {
text-align: right;
}
/* Style for the addresses table */
table.addresses-table {
width: 100%;
}
table.addresses-table th {
text-align: left;
}
/* Style for the billing and shipping addresses */
.billing-address, .shipping-address {
width: 50%;
}
/* Style for the invoice-related table */
table.invoice-related-table {
width: 100%;
border-collapse: collapse;
}
table.invoice-related-table th,
table.invoice-related-table td {
border: none; /* Remove borders from all cells in the invoice items table */
padding: 8px;
text-align: center; /* Center-align text in cells */
}
table.invoice-related-table th {
background-color: #f2f2f2;
font-weight: bold;
}
/* Style for the business stamp and terms */
.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; /* Add a border around the subtotal table */
}
.subtotal-table th,
.subtotal-table td {
border: none; /* Remove borders from cells inside the subtotal table */
padding: 8px;
text-align: right;
}
.subtotal-table th {
background-color: #f2f2f2;
font-weight: bold;
}
.subtotal-table td:last-child {
font-weight: bold; /* Make the last column (total values) bold */
}
td.invoice-number {
font-size: 18px; /* Increase font size to your desired value */
/* Highlight background color */
font-weight: bold; /* Make the text bold */
}
</style>
</head>
<body>
<table class="main-table">
<tr>
<td>
<table class="business-details-table">
<?php foreach ($data as $value) : ?>
<tr>
<td class="business-logo-container">
<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><?= $value->address ?>,<br><?= $value->city ?>, <?= $value->state ?>,</p>
<p><?= $value->postal_code ?></p><br>
<p><?= $value->email ?></p>
<p><?= $value->mobile_no ?></p>
</td>
</tr>
<?php endforeach; ?>
</table>
</td>
<td>
<table class="invoice-info-table">
<?php foreach ($data as $value) : ?>
<tr>
<th>Invoice # <?= $value->invoice_number ?></th>
</tr>
<tr>
<?php
// Assuming $value->invoice_date is in yyyy-mm-dd format
$invoiceDateParts = explode('-', $value->invoice_date);
if (count($invoiceDateParts) === 3) {
$formattedInvoiceDate = $invoiceDateParts[2] . '/' . $invoiceDateParts[1] . '/' . $invoiceDateParts[0];
} else {
$formattedInvoiceDate = 'Invalid Date'; // Handle invalid dates gracefully
}
?>
<th>Invoice Date : <?= $formattedInvoiceDate ?></th>
<!-- Display the formatted invoice date -->
<td></td>
</tr>
<tr>
<th>Order Number : <?= $value->order_number ?></th>
</tr>
<tr>
<?php $invoiceDateParts = explode('-', $value->due_date);
if (count($invoiceDateParts) === 3) {
$formattedDueDate = $invoiceDateParts[2] . '/' . $invoiceDateParts[1] . '/' . $invoiceDateParts[0];
} else {
$formattedDueDate = 'Invalid Date'; // Handle invalid dates gracefully
}
?>
<th>Due Date : <?= $formattedDueDate ?></th>
<!-- Display the formatted invoice date -->
</tr>
<?php endforeach; ?>
</table>
</td>
</tr>
</table>
<table class="addresses-table">
<tr>
<th class="billing-address">Billing Address</th>
<th class="shipping-address">Shipping Address</th>
</tr>
<tr>
<td class="billing-address">
<?php foreach ($data as $value) : ?>
<p><?= $value->customer_name ?><br><?= $value->billing_address ?></p>
<?php endforeach; ?>
</td>
<td class="shipping-address">
<?php foreach ($data as $value) : ?>
<p><?= $value->customer_name ?><br><?= $value->shipping_address ?></p>
<?php endforeach; ?>
</td>
</tr>
</table>
<br> <br>
<table class="invoice-related-table">
<thead>
<tr>
<th>Item Name</th>
<th>Qty</th>
<th>Rate</th>
<th>Tax</th>
<th>Discount</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php foreach ($invoiceItems as $item) : ?>
<tr>
<td><?= $item->title ?></td>
<td><?= $item->quantity ?></td>
<td>₹<?= number_format($item->unit_price, 2, '.', ',') ?></td>
<td><?= $item->tax ?></td>
<td>
<?php if ($item->discount_type === '%') : ?>
<?= $item->discount_amount ?>%
<?php elseif ($item->discount_type === '₹') : ?>
₹<?= number_format((float)$item->discount_amount, 2, '.', ',') ?>
<?php endif; ?>
</td>
<td>₹<?= number_format($item->subtotal, 2, '.', ',') ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<table class="subtotal-table">
<?php foreach ($data as $value) : ?>
<tr>
<td colspan="5" align="right">Subtotal : &nbsp;&nbsp;₹<?= number_format($value->subtotal, 2, '.', ',') ?></td>
</tr>
<tr>
<td colspan="5" align="right">TAX : &nbsp;&nbsp;₹<?= number_format($value->tax, 2, '.', ',') ?></td>
</tr>
<tr>
<td colspan="5" align="right">Discount : &nbsp;&nbsp;₹<?= number_format($value->discount, 2, '.', ',') ?></td>
</tr>
<tr>
<td colspan="5" align="right">Total : &nbsp;&nbsp;₹<?= number_format($value->subtotal, 2, '.', ',') ?></td>
</tr>
<?php endforeach; ?>
</table>
<div class="business-stamp">
<img src="https://static.vecteezy.com/system/resources/thumbnails/004/853/320/small/book-read-library-study-line-icon-illustration-logo-template-suitable-for-many-purposes-free-vector.jpg" alt="Business Logo" class="business-logo">
</div>
<div class="terms">
<p>Thank you!</p>
</div>
</body>
</html>