427 lines
15 KiB
PHP
Executable File
427 lines
15 KiB
PHP
Executable File
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<style>
|
|
@page {
|
|
size: 148mm 210mm; /* Width Height */
|
|
}
|
|
/* Add your CSS styles here to format the invoice for mPDF */
|
|
body {
|
|
|
|
font-family: 'Times New Roman', Times, sans-serif;
|
|
|
|
font-size: 8pt;
|
|
/* Change this value to your desired font size */
|
|
}
|
|
|
|
.thank-you-line::before,
|
|
.thank-you-line::after {
|
|
content: '';
|
|
display: inline-block;
|
|
width: 20%;
|
|
border-top: 1px solid grey;
|
|
margin: 5px 5px;
|
|
}
|
|
|
|
/* Style for the main table with border */
|
|
table.main-table {
|
|
width: 100%;
|
|
margin-bottom: 1rem;
|
|
/* border-collapse: collapse; */
|
|
/* border: -0.5px 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%;
|
|
}
|
|
|
|
table.business-details-table td {
|
|
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%;
|
|
border-collapse: collapse;
|
|
}
|
|
|
|
table.invoice-info-table th,
|
|
table.invoice-info-table td {
|
|
text-align: right;
|
|
padding: 8px;
|
|
}
|
|
|
|
/* 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; */
|
|
background-color: #D0D0CD;
|
|
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 */
|
|
}
|
|
|
|
p {
|
|
margin-top: 0;
|
|
margin-bottom: 0rem;
|
|
}
|
|
@media print {
|
|
/* Apply styles only for print preview */
|
|
|
|
body {
|
|
margin: 0; /* Reset body margin for print */
|
|
font-size: 10pt; /* Adjust font size for better readability in print */
|
|
}
|
|
|
|
table.main-table {
|
|
margin-bottom: 0; /* Remove bottom margin for better page break */
|
|
}
|
|
|
|
.business-logo-container {
|
|
margin-bottom: 10px; /* Reduce space below logo for print */
|
|
}
|
|
|
|
.subtotal-table {
|
|
margin-top: 10px; /* Reduce top margin for print */
|
|
}
|
|
.invoice-info-table{
|
|
/* margin-left:50px; */
|
|
font-size:20px;
|
|
margin-right:300px;
|
|
}
|
|
.quantity , .unit_price{
|
|
align-content: flex-start;
|
|
}
|
|
.description{
|
|
font-size:6pt;
|
|
}
|
|
.serialNumber{
|
|
display:flex;
|
|
algin-items:flex-start;
|
|
}
|
|
|
|
}
|
|
</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->company_address ?>,<br>
|
|
<?= $value->company_city ?>,
|
|
<?= $value->company_state ?>
|
|
<?= $value->company_postal_code ? " - " . $value->company_postal_code : "" ?>.</p>
|
|
<p><?= $value->company_email ?></p>
|
|
<p><?= $value->company_mobile_no ?></p>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
</td>
|
|
<td style="padding: 8px!important">
|
|
<table class="invoice-info-table">
|
|
<?php foreach ($data as $value) : ?>
|
|
<tr>
|
|
<th><?php echo ($value->wp_api_order_id) ? 'Order # ' . $value->invoice_number : 'Invoice # ' . $value->invoice_number; ?></th>
|
|
</tr>
|
|
<tr>
|
|
<th>Invoice Date : <?= $value->formatted_invoice_date ?></th>
|
|
</tr>
|
|
|
|
<?php if ($value->due_date) : ?>
|
|
<tr>
|
|
<th>Due Date : <?= $value->formatted_due_date ?></th>
|
|
</tr>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($invoice_type === '2') : ?>
|
|
<?php foreach ($invoiceItems as $item) : ?>
|
|
<tr>
|
|
<th>From Subscription : <?= date('d/m/y', strtotime($item->from_subscription)) ?></th>
|
|
</tr>
|
|
<tr>
|
|
<th>To Subscription : <?= date('d/m/y', strtotime($item->to_subscription)) ?></th>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
<?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) : ?>
|
|
<?= $value->customer_name ?><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 : "" ?> <?= $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->mobile_no ? $value->mobile_no." ." : "" ?>
|
|
<?php endforeach; ?>
|
|
</td>
|
|
<td class="shipping-address">
|
|
<?php foreach ($data as $value) : ?>
|
|
<?= $value->customer_name ?><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 : "" ?> <?= $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->mobile_no ? $value->mobile_no." ." : "" ?>
|
|
<?php endforeach; ?>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br> <br>
|
|
<table class="invoice-related-table">
|
|
<thead style="border-top: 1px solid grey; border-bottom: 1px solid grey;">
|
|
<tr>
|
|
<th>S.no</th>
|
|
<th style="text-align: left;">Item Name</th>
|
|
<th>Qty</th>
|
|
<th>Rate</th>
|
|
|
|
<th>Total</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php $serialNumber = 1; ?>
|
|
<?php foreach ($invoiceItems as $item) : ?>
|
|
<tr>
|
|
<td class="serialNumber" style="display:flex;algin-items:flex-start">
|
|
<?= $serialNumber++; ?>
|
|
|
|
</td>
|
|
|
|
<td style="text-align: left;"><?= $item->title ?><br>
|
|
<span ><?php if($item->description != ''){?><span class="description" style="font-size:8pt"><?php echo $item->description ?></span><?php }?></span>
|
|
</td>
|
|
<td class="quantity" style="align-content: flex-start;"><?= $item->quantity ?></td>
|
|
<td class="unit_price" style="align-content: flex-start;">₹<?= number_format($item->unit_price, 2, '.', ',') ?></td>
|
|
|
|
|
|
<td style="align-content: flex-start;">₹<?= 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 : ₹<?= number_format($value->subtotal, 2, '.', ',') ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="5" align="right">Discount : <?= $value->discount ? "(-)" . number_format($value->discount, 2, '.', ',') : number_format(0, 2, '.', ',') ?></td>
|
|
</tr>
|
|
|
|
<!-- -->
|
|
<?php if ($value->shipping_label != '') : ?>
|
|
<tr>
|
|
<td colspan="5" align="right"><?= $value->shipping_label ?> : ₹<?= number_format($value->shipping_charge, 2, '.', ',') ?></td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
<tr>
|
|
|
|
<?php
|
|
$sign = ($value->total_amount >= $value->exact_total_amount) ? '+' : '-';
|
|
$difference = abs($value->exact_total_amount - $value->total_amount);
|
|
?>
|
|
|
|
<td colspan="5" align="right"> Rounding : <?= $sign . number_format($difference, 2, '.', ',') ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="5" align="right">Total : ₹<?= number_format($value->total_amount, 2, '.', ',') ?></td>
|
|
</tr>
|
|
<?php if ($value->status === 'Draft') : ?>
|
|
<!-- Set Balance if status is draft and paid is 0 -->
|
|
<tr>
|
|
<td colspan="5" align="right">Balance : ₹<?= number_format($value->total_amount, 2, '.', ',') ?></td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
<?php if ($value->status === 'Approved') : ?>
|
|
<tr>
|
|
<td colspan="5" align="right">Paid : ₹<?= number_format($value->total_amount, 2, '.', ',') ?></td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
|
|
<div class="business-stamp">
|
|
|
|
</div>
|
|
|
|
<?php foreach ($data as $value) : ?>
|
|
<div class="terms">
|
|
<!-- <if(!empty($value->notes)){
|
|
<br><p style="text-align: left !important;"><b>Notes:</b> $value->notes; ?></p>
|
|
} ?> -->
|
|
<?php if (!empty($value->reason)) { ?>
|
|
<br>
|
|
<p style="text-align: left !important;"><b>Reason:</b> <?= $value->reason; ?></p>
|
|
<?php } ?>
|
|
<?php foreach ($invoiceTerms as $row) :
|
|
if (!empty($row->terms)) { ?>
|
|
<br>
|
|
<pre style="font-family: 'Times New Roman', Times, sans-serif; font-size: 12px; text-align: left;">
|
|
<?= $row->terms ?>
|
|
</pre>
|
|
<?php }
|
|
endforeach; ?>
|
|
</div>
|
|
|
|
<br>
|
|
<div class="" style="margin-left: 9px;margin-top: -140px;">
|
|
<h4>Bank Details</h4>
|
|
|
|
<?php echo nl2br($business['terms']); ?>
|
|
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<!-- ... (your existing HTML template) -->
|
|
|
|
<!-- Add this to the end of your HTML template -->
|
|
|
|
|
|
<!-- <img src="https://cdn.pixabay.com/photo/2012/04/26/14/17/blue-42596_960_720.png" /> -->
|
|
|
|
<div>
|
|
<?php if ($data[0]->status === 'Draft') {
|
|
echo '<div class="watermark">Draft</div>';
|
|
|
|
}
|
|
if ($data[0]->status === 'Cancelled') {
|
|
echo '<div class="watermark">Cancelled</div>';
|
|
|
|
}
|
|
if ($data[0]->status === 'Void') {
|
|
echo '<div class="watermark">Void</div>';
|
|
|
|
}?>
|
|
</div>
|
|
</body>
|
|
|
|
</html>
|