vb_book/app/Views/invoice_pdf_template.php
2024-12-26 19:16:10 +05:30

449 lines
19 KiB
PHP
Executable File

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,opsz,wght@0,6..12,200..1000;1,6..12,200..1000&display=swap" rel="stylesheet">
<style>
@page {
size: 148mm 210mm;
/* Width Height */
}
/* Add your CSS styles here to format the invoice for mPDF */
/* td { */
/* display: flex;
*/
/* align-items: flex-start; */
/* } */
body {
/* font-family: 'Times New Roman', Times, sans-serif; */
font-size: 10px;
color: black !important;
/* font-size: 8pt; */
}
/* Style for the table containing - business details */
table.business-details-table {
width: 100%;
margin-left: -16px !important;
}
/* Style for the business color badge */
.business-badge-container {
background: #D9103F;
width: 21px;
height: 60px;
top: 16px;
}
/* Style for the business logo */
.business-logo-container {
/* width: 50%; */
width: 150px;
height: 35.71px;
top: 28px;
left: 31px;
gap: 0px;
opacity: 0px;
}
/* Style for the business address */
.business-address-container {
/* width: 50%; */
width: 261px;
height: 28px;
top: 32px;
left: 320px;
gap: 0px;
opacity: 0px;
font-size: 10px;
font-weight: 400;
line-height: 13.64px;
text-align: right;
padding-right: 10px;
}
img.business-logo {
max-width: 200px;
/* Adjust the size of the logo */
}
/* Style for the table containing - addresses details */
table.addresses-table {
width: 100%;
font-size: 10px;
font-weight: 400;
line-height: 13.64px;
text-align: left;
}
/* Style for the billing addresses */
.billing-address-container {
width: 134px;
height: 108px;
top: 90px;
left: 16px;
gap: 0px;
opacity: 0px;
}
/* Style for the shipping addresses */
.shipping-address-container {
width: 134px;
height: 108px;
top: 90px;
left: 186px;
gap: 0px;
opacity: 0px;
}
/* Style for the invoice information */
.invoice-info-container {
width: 117px;
height: 58px;
top: 90px;
left: 418px;
gap: 0px;
opacity: 0px;
}
/* Style for the table containing - invoice-related details */
table.invoice-related-table {
width: 100%;
border-collapse: collapse;
}
/* Style for the table containing - invoice-related details header footer */
table.invoice-related-table th,
table.invoice-related-table td {
border: none;
/* Remove borders from all cells in the invoice items table */
padding: 8px;
font-size: 10px;
}
/* Style for the table containing - invoice-related details header */
table.invoice-related-table th {
background-color: #D9103F;
color: #FFFFFF;
font-weight: bold;
}
/* Style for the table containing - invoice-related details table row alternative color */
table.invoice-related-table tr:nth-child(even) {
background-color: #FFEAEF;
}
/* Define your CSS styles here */
.summary-table {
width: 100%;
border-collapse: collapse;
vertical-align: top;
}
/* Style for the table containing - summary-invoice subtotal-table details */
.subtotal-table {
width: 100%;
border-collapse: collapse;
}
/* Style for the notes and terms information */
.notes-container,
.terms-container {
font-size: 10px;
margin-top: 30px;
margin-bottom:30px;
}
/* Style for the table containing - footer-table details */
table.footer-table {
font-size: 10px;
font-weight: 400;
line-height: 13.64px;
color: #989898;
}
#pdfPreviewModal table td{
font-size: 10px;
}
table h4{
font-size: 12px;
}
table small{
font-size: 10px;
}
/* Common Style for all */
p {
margin-top: 0;
margin-bottom: 0rem;
}
@media screen {
.business-address-container,table.addresses-table, table.footer-table, table td, table.invoice-related-table th, table.invoice-related-table td {
font-family:'Calibri';
}
}
@media print {
body{
font-family:'Times-Roman', sans-serif;
font-size: 10px;
}
table td, table.invoice-related-table th, table.invoice-related-table td{
font-family:'Times-Roman', sans-serif;
font-size: 10px;
}
.terms-container{
margin-top:30px!important;
}
}
</style>
</head>
<body>
<!-- table containing - business details -->
<table class="business-details-table mt-1">
<?php foreach ($data as $value) : ?>
<tr>
<td class="business-badge-container">
</td>
<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>
<td class="business-address-container">
<p><?= $value->company_address . ',' . $value->company_city . ($value->company_postal_code ? " - " . $value->company_postal_code : "") ?></p>
<p><?= $value->company_email . ' | ' . $value->company_mobile_no ?></p>
</td>
</tr>
<?php endforeach; ?>
</table>
<!-- table containing - business details ends -->
<!-- table containing - addresses details -->
<table class="addresses-table mt-1">
<tr>
<td class="billing-address-container" style="vertical-align: top;">
<?php foreach ($data as $value) : ?>
<b>BILLING TO :</b><br>
<b><?= isset($value->customer_biller_name) && trim($value->customer_biller_name) !== '' ? $value->customer_biller_name : $value->customer_name ?></b><br>
<?php if ($value->customer_bill_address && ($value->baddr_id !== null || $value->baddr_id !== '')) { ?>
<?= $value->customer_bill_address ? $value->customer_bill_address . "," : "" ?><br>
<?= $value->customer_bill_city ? $value->customer_bill_city : "" ?>&nbsp;<?= $value->customer_bill_state ? $value->customer_bill_state : "" ?>
<?= $value->customer_bill_postal_code ? " - " . $value->customer_bill_postal_code : ""; ?>
<?= $value->customer_bill_country ? $value->customer_bill_country . "." : $value->bcountry ?><br>
<?php } else if ($value->baddr_id === null || $value->baddr_id === '') {
echo $value->billing_address ? '<p style="white-space: pre-line">' . $value->billing_address . '</p>' : '';
} ?>
<?= $value->bmobile ? "Phone : +91" . $value->bmobile . "." : ($value->mobile_no ? "Phone : +91" . $value->mobile_no . "." : "") ?><br>
<?= $value->bemail ? "Email : " . $value->bemail . "." : ($value->email ? "Email : " . $value->email . "." : "" ) ?>
<?php endforeach; ?>
</td>
<td class="shipping-address-container" style="vertical-align: top;">
<?php foreach ($data as $value) : ?>
<b>SHIPPING TO :</b><br>
<b><?= isset($value->customer_shipper_name) && trim($value->customer_shipper_name) !== '' ? $value->customer_shipper_name : $value->customer_name ?></b><br>
<?php if ($value->customer_ship_address && ($value->saddr_id !== null || $value->saddr_id !== '')) { ?>
<?= $value->customer_ship_address ? $value->customer_ship_address . "," : "" ?><br>
<?= $value->customer_ship_city ? $value->customer_ship_city : "" ?>&nbsp;<?= $value->customer_ship_state ? $value->customer_bill_state : "" ?>
<?= $value->customer_ship_postal_code ? " - " . $value->customer_ship_postal_code : ""; ?>
<?= $value->customer_ship_country ? $value->customer_ship_country . "." : $value->scountry ?><br>
<?php } else if ($value->saddr_id === null || $value->saddr_id === '') {
echo $value->shipping_address ? '<p style="white-space: pre-line">' . $value->shipping_address . '</p>' : '';
} ?>
<?= $value->smobile ? "Phone : +91" . $value->smobile . "." : "" ?><br>
<?= $value->semail ? "Email : " . $value->semail . "." : "" ?>
<?php endforeach; ?>
</td>
<td class="invoice-info-container" style="vertical-align: top;">
<b>INVOICE :</b><br>
<?php foreach ($data as $value) : ?>
<?php echo ($value->wp_api_order_id) ? 'Order # ' . $value->invoice_number : 'Invoice No # ' . $value->invoice_number; ?><br>
<?php echo "Invoice Date :" . $value->formatted_invoice_date ?><br>
<?php if ($value->due_date) : echo "Due Date :". $value->formatted_due_date ?><br><?php endif; ?>
<?php if ($invoice_type === '2') : ?>
<?php foreach ($invoiceItems as $item) : ?>
From Subscription : <?= date('d/m/y', strtotime($item->from_subscription)) ?><br>
To Subscription : <?= date('d/m/y', strtotime($item->to_subscription)) ?><br>
<?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
</td>
</tr>
</table>
<!-- table containing - addresses details ends -->
<!-- table containing - invoice details -->
<table class="invoice-related-table">
<thead>
<tr>
<th>S.no</th>
<th style="text-align: left;">Item Name</th>
<th style="text-align: left;">Qty</th>
<th style="text-align: left;">Rate(₹)</th>
<th style="text-align: left;">Total(₹)</th>
</tr>
</thead>
<tbody>
<?php $serialNumber = 1; ?>
<?php foreach ($invoiceItems as $item) : ?>
<tr>
<td style="text-align: center; vertical-align: top;">
<?= $serialNumber++; ?>
</td>
<td><?= $item->title ?><br>
<span><?php if ($item->description != '') { ?><span style="font-size:6pt"><?php echo $item->description ?></span><?php } ?></span>
</td>
<td style="text-align: start;"><?= $item->quantity ?></td>
<td style="text-align: start;"><?= number_format($item->unit_price, 2, '.', ',') ?></td>
<td style="text-align: start;"><?= number_format($item->subtotal, 2, '.', ',') ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<!-- table containing - invoice details ends -->
<!-- table containing - summary details -->
<table class="summary-table mt-1" style="width: 100%;">
<?php if (!empty($data)) : ?>
<tr>
<td colspan="6" style="width: 60%; vertical-align: top; display:flex;">
<?php foreach ($data as $value) : ?>
<div class="notes-container">
<?php if (!empty($value->reason)) : ?>
<div style="text-align: left !important;">
<h6>Reason</h6>
<?php echo nl2br($value->reason); ?>
</div>
<?php else : ?><div style="text-align: left !important;"><p>&nbsp;&nbsp; </p></div>
<?php endif; ?>
<?php if (!empty($value->notes)) : ?>
<div style="text-align: left !important;">
<h6>Notes</h6>
<?php echo nl2br($value->notes); ?>
</div>
<?php else : ?><div style="text-align: left !important;"><p>&nbsp;&nbsp; </p></div>
<?php endif; ?>
<?php if (!empty($value->payment_note)) : ?>
<div style="text-align: left !important;">
<h6>Payment Notes</h6>
<?php echo nl2br($value->payment_note); ?>
</div>
<?php else : ?><div style="text-align: left !important;"><p>&nbsp;&nbsp; </p></div>
<?php endif; ?>
<?php if (!empty($value->terms)) : ?>
<pre style="font-family: 'Calibri; font-size: 12px; text-align: left;">
<?= $row->terms ?>
</pre>
<?php else : ?><div style="text-align: left !important;"><p>&nbsp;&nbsp; </p></div>
<?php endif; ?>
</div>
<br>
<?php endforeach; ?>
</td>
<td colspan="6" style="width: 30%; vertical-align: top;">
<table class="subtotal-table" style="margin-top:20px;">
<?php foreach ($data as $value) : ?>
<tr>
<td align="left">Subtotal</td>
<td align="left"><?= '₹' . number_format($value->subtotal, 2, '.', ',') ?></td>
</tr>
<?php
if ($value->dis_type == "%") {
$dis_value = ($value->subtotal * $value->discount) / 100;
$dis_percent = '(' . $value->discount . $value->dis_type . ')';
} else {
$dis_value = $value->discount ? $value->discount : 0;
$dis_percent = '';
}
?>
<tr>
<td align="left">Discount<?= $dis_percent; ?></td>
<td align="left"><?= $dis_value ? "₹-" . number_format($dis_value, 2, '.', ',') : "₹" . number_format(0, 2, '.', ',') ?></td>
</tr>
<?php if (!empty($value->shipping_label)) : ?>
<tr>
<td align="left"><?= ucwords($value->shipping_label) ?></td>
<td align="left" ><?= "₹" . number_format($value->shipping_charge, 2, '.', ',') ?></td>
</tr>
<tr>
<?php
$sign = ($value->total_amount >= $value->exact_total_amount) ? '₹' : '₹-';
$difference = abs($value->exact_total_amount - $value->total_amount);
?>
<td align="left">Rounding</td>
<td align="left" ><?= $sign . number_format($difference, 2, '.', ',') ?></td>
</tr>
<?php endif; ?>
<tr>
<td align="left">Total</td>
<td align="left" ><?= "₹" . number_format($value->total_amount, 2, '.', ',') ?></td>
</tr>
<?php if ($value->status === 'Draft') : ?>
<tr>
<td align="left">Balance</td>
<tdalign="left" ><?= "₹" . number_format($value->total_amount, 2, '.', ',') ?></td>
</tr>
<?php endif; ?>
<?php if ($value->status === 'Approved') : ?>
<tr>
<td align="left">Paid</td>
<td align="left"><?= "₹" . number_format($value->total_amount, 2, '.', ',') ?></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</table>
</td>
</tr>
<?php endif; ?>
<tr>
<td colspan="6" style="width: 60%; vertical-align: top;">
<div>
<?php if ($value->status != 'Approved') : ?>
<h4>Bank Details</h4>
<?php echo nl2br($business['terms']); ?>
<?php else: ?>
<div style="color:white">
<h1 style="color: white; visibility: hidden;">Else if block.......... ..............</h1>
</div>
<?php endif?>
</div>
</td>
<td colspan="6" style="width: 50%; vertical-align: bottom;">
<div class="terms-container" style="margin-top:30px;">
<center>
<!-- <img src="<?php //echo base_url('public/uploads/default_sign_sm.png'); ?>" alt="Authorized Signatory" class="Authorized-Signatory"> -->
<!-- <div align = "right"> -->
<br> <p>Authorized Signatory</p>
<!-- </div> -->
</center>
</div>
</td>
</tr>
</table>
<!-- table containing - summary details ends -->
<!-- table containing - footer details -->
<table class="footer-table mt-3" width="100%">
<tr>
<td>
<center><small>WhatsApp No: 8939149466 | Email: contact@vijayabharathambooks.com | Website: www.vijayabharathambooks.com</small></center>
</td>
</tr>
</table>
<!-- table containing - footer details ends -->
<!-- <img src="https://cdn.pixabay.com/photo/2012/04/26/14/17/blue-42596_960_720.png" /> -->
</body>
</html>