nhance/app/Views/invoice_template.php
2025-11-21 16:19:36 +05:30

430 lines
11 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Agent Commission Invoice</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
font-size: 12px;
color: #333;
background: #fff;
}
/* Page Setup for DOMPDF */
@page {
size: A4;
margin: 10mm;
}
/* .invoice-container {
width: 100%;
max-width: 210mm;
margin: 0 auto;
padding: 10mm;
background: #fff;
} */
.invoice-container {
width: 180mm; /* reduced from 210mm */
max-width: 180mm;
margin: 0 auto;
padding: 8mm; /* reduced padding */
background: #fff;
}
/* Header */
.invoice-header {
border-bottom: 3px solid #2c3e50;
padding-bottom: 15px;
margin-bottom: 20px;
}
.header-top {
width: 100%;
display: table;
}
.header-top > div {
display: table-cell;
vertical-align: top;
width: 50%;
}
.company-info h1 {
color: #2c3e50;
font-size: 24px;
margin-bottom: 5px;
}
.company-info p {
color: #666;
font-size: 11px;
line-height: 1.4;
}
.invoice-title {
text-align: right;
}
.invoice-title h2 {
font-size: 32px;
color: #e74c3c;
margin-bottom: 5px;
}
.invoice-title p {
font-size: 11px;
color: #666;
}
/* Invoice Info (converted grid to table layout) */
.invoice-info {
width: 100%;
display: table;
margin-bottom: 25px;
background: #f8f9fa;
border-radius: 5px;
}
.invoice-info > div {
display: table-cell;
width: 50%;
vertical-align: top;
padding: 15px;
}
.info-section h3 {
font-size: 13px;
color: #2c3e50;
margin-bottom: 10px;
padding-bottom: 5px;
border-bottom: 2px solid #3498db;
}
.info-row {
width: 100%;
display: table;
padding: 5px 0;
font-size: 11px;
}
.info-row span {
display: table-cell;
}
.info-label {
font-weight: 600;
color: #555;
}
.info-value {
color: #333;
font-weight: 500;
text-align: right;
}
/* Table */
.invoice-table {
width: 100%;
border-collapse: collapse;
margin-bottom: 10px;
margin-top: -16px;
}
.invoice-table thead {
display: table-header-group;
background: #2c3e50;
color: #fff;
}
.invoice-table thead th {
padding: 12px 8px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.5px;
text-align: left;
}
.invoice-table td {
padding: 10px 8px;
font-size: 11px;
border-bottom: 1px solid #e0e0e0;
}
.invoice-table tbody tr:nth-child(even) {
background: #f8f9fa;
}
/* Text alignment */
.text-right {
text-align: right;
}
.text-center {
text-align: center;
}
/* Summary Section */
.invoice-summary {
width: 100%;
text-align: right;
margin-top: 20px;
}
.summary-box {
width: 300px;
border: 2px solid #2c3e50;
border-radius: 5px;
display: inline-block;
}
.summary-row {
width: 100%;
display: table;
padding: 10px 15px;
border-bottom: 1px solid #e0e0e0;
}
.summary-row span {
display: table-cell;
}
.summary-row:last-child {
background: #2c3e50;
color: #fff;
font-weight: bold;
font-size: 14px;
}
.summary-label {
font-weight: 600;
}
/* Footer */
.invoice-footer {
border-top: 2px solid #2c3e50;
padding-top: 15px;
margin-top: 30px;
}
.footer-content {
width: 100%;
display: table;
}
.footer-section {
display: table-cell;
width: 50%;
vertical-align: top;
font-size: 10px;
color: #666;
}
.footer-section h4 {
font-size: 12px;
color: #2c3e50;
margin-bottom: 8px;
}
.footer-section p {
line-height: 1.6;
margin-bottom: 5px;
}
/* Signature */
.signature-section {
margin-top: 40px;
text-align: right;
}
.signature-line {
border-top: 2px solid #333;
width: 200px;
margin-left: auto;
padding-top: 10px;
font-size: 11px;
font-weight: 600;
}
/* Page break support */
.page-break {
page-break-after: always;
}
/* Row breaking prevention */
.invoice-table tr {
page-break-inside: avoid;
}
/* Optional hide */
.hide-header .invoice-header {
display: none;
}
.hide-footer .invoice-footer {
display: none;
}
</style>
</head>
<body>
<div class="invoice-container" id="invoiceContent">
<!-- Invoice Header (Can be toggled) -->
<div class="invoice-header">
<div class="header-top">
<div class="company-info">
<h1><?= $broker_company_name ?? 'Broker Company Name' ?></h1>
<p><?= $broker_address ?? 'Company Address Line 1' ?><br>
<?= $broker_city ?? 'City' ?>, <?= $broker_state ?? 'State' ?> - <?= $broker_pincode ?? 'PIN' ?><br>
Email: <?= $broker_email ?? 'email@company.com' ?> | Phone: <?= $broker_phone ?? '+91-XXXXXXXXXX' ?></p>
</div>
<div class="invoice-title">
<p>Commission Statement</p>
</div>
</div>
</div>
<!-- Invoice Information -->
<div class="invoice-info">
<div class="info-section">
<h3>Invoice Details</h3>
<div class="info-row">
<span class="info-label">Invoice Number:</span>
<span class="info-value"><?= $invoice_number ?? 'INV-2024-0001' ?></span>
</div>
<div class="info-row">
<span class="info-label">Invoice Date:</span>
<span class="info-value"><?= $invoice_date ?? date('d-M-Y') ?></span>
</div>
<div class="info-row">
<span class="info-label">Period:</span>
<span class="info-value"><?= $period ?? 'January 2024' ?></span>
</div>
</div>
<div class="info-section">
<h3>Agent Information</h3>
<div class="info-row">
<span class="info-label">Agent Name:</span>
<span class="info-value"><?= $agent_name ?? 'Agent Name' ?></span>
</div>
<div class="info-row">
<span class="info-label">Agent Code:</span>
<span class="info-value"><?= $agent_code ?? 'AGT-0001' ?></span>
</div>
<div class="info-row">
<span class="info-label">No. of Policies:</span>
<span class="info-value"><?= $total_policies ?? '0' ?></span>
</div>
<div class="info-row">
<span class="info-label">Policies Till Date:</span>
<span class="info-value"><?= $policies_till_date ?? '0' ?></span>
</div>
</div>
</div>
<!-- Policy Details Table -->
<table class="invoice-table">
<thead>
<tr>
<th style="width: 5%;">Sr.</th>
<th style="width: 15%;">Policy No.</th>
<th style="width: 25%;">Customer Name</th>
<th style="width: 15%;" class="text-right">Premium (₹)</th>
<th style="width: 15%;" class="text-center">Issue Date</th>
<th style="width: 15%;" class="text-right">Commission (₹)</th>
</tr>
</thead>
<tbody>
<?php
$serial = 1;
$total_premium = 0;
$total_commission = 0;
$records_per_page = 25; // Adjust based on page size
foreach($policies as $index => $policy):
$total_premium += $policy['premium'];
$total_commission += $policy['commission'];
// Add page break after certain records
$page_break_class = (($serial % $records_per_page) == 0 && $serial != count($policies)) ? 'page-break' : '';
?>
<tr class="<?= $page_break_class ?>">
<td class="text-center"><?= $serial ?></td>
<td><?= $policy['policy_no'] ?></td>
<td><?= $policy['customer_name'] ?></td>
<td class="text-right"><?= number_format($policy['premium'], 2) ?></td>
<td class="text-center"><?= date('d-M-Y', strtotime($policy['issue_date'])) ?></td>
<td class="text-right"><?= number_format($policy['commission'], 2) ?></td>
</tr>
<?php
// Insert page header for continuation pages
if($page_break_class && $serial != count($policies)):
?>
<tr class="page-header">
<td colspan="6">
<h3>Invoice #<?= $invoice_number ?? 'INV-2024-0001' ?> - Continued</h3>
</td>
</tr>
<?php
endif;
$serial++;
endforeach;
?>
</tbody>
</table>
<!-- Summary Section -->
<div class="invoice-summary">
<div class="summary-box">
<div class="summary-row">
<span class="summary-label">Total Premium:</span>
<span>₹ <?= number_format($total_premium, 2) ?></span>
</div>
<div class="summary-row">
<span class="summary-label">Total Policies:</span>
<span><?= count($policies) ?></span>
</div>
<div class="summary-row">
<span class="summary-label">Total Commission:</span>
<span>₹ <?= number_format($total_commission, 2) ?></span>
</div>
</div>
</div>
<!-- Invoice Footer (Can be toggled) -->
<div class="invoice-footer">
<div class="footer-content">
<div class="footer-section">
<h4>Payment Terms</h4>
<p>Payment due within 15 days of invoice date.</p>
<p>Bank Transfer Details:</p>
<p><strong>Bank:</strong> <?= $bank_name ?? 'Bank Name' ?></p>
<p><strong>Account No:</strong> <?= $account_number ?? 'XXXXXXXXXXXX' ?></p>
<p><strong>IFSC:</strong> <?= $ifsc_code ?? 'XXXXXX' ?></p>
</div>
<div class="footer-section">
<h4>Notes</h4>
<p>Commission calculated as per agreed terms.</p>
<p>This is a computer-generated invoice.</p>
<p>For queries, contact: <?= $contact_email ?? 'accounts@company.com' ?></p>
</div>
</div>
<div class="signature-section">
<div class="signature-line">
Authorized Signatory
</div>
</div>
</div>
</div>
</body>
</html>