PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
← All changes | templates/pdf/invoice.php +88 -13 3.0.7 → 3.0.16 View file →
@@ -4,8 +4,19 @@
4 4 if ($companyName === '' && function_exists('yatra_get_brand_name')) {
5 5 $companyName = yatra_get_brand_name();
6 6 }
7 7 $companyAddress = (string) ($company_address ?? '');
8 +// Settings keep the business address in separate fields (street, city, state,
9 +// postcode, country); documents only ever printed the street, so everything after
10 +// it was missing and the address looked cut off at its last line. Prefer the
11 +// composed lines, falling back to the raw street for any caller not passing them.
12 +$companyAddressLines = (isset($company_address_lines) && is_array($company_address_lines))
13 + ? array_values(array_filter(array_map('strval', $company_address_lines), static function ($line) {
14 + return trim($line) !== '';
15 + }))
16 + : array_values(array_filter(preg_split('/\R/', $companyAddress) ?: [], static function ($line) {
17 + return trim($line) !== '';
18 + }));
8 19 $companyEmail = (string) ($company_email ?? '');
9 20 $companyPhone = (string) ($company_phone ?? '');
10 21
11 22 $customerName = (string) ($customer_name ?? '');
@@ -10,8 +21,16 @@
10 21
11 22 $customerName = (string) ($customer_name ?? '');
12 23 $customerEmail = (string) ($customer_email ?? '');
13 24
25 +// The customer's postal address, one entry per line. Absent on older callers,
26 +// so an empty list simply renders nothing.
27 +$customerAddressLines = (isset($customer_address_lines) && is_array($customer_address_lines))
28 + ? array_filter(array_map('strval', $customer_address_lines), static function ($line) {
29 + return trim($line) !== '';
30 + })
31 + : [];
32 +
14 33 $paymentRef = (string) ($payment_ref ?? '');
15 34 $paymentDate = (string) ($payment_date ?? '');
16 35 $paymentStatus = (string) ($payment_status ?? '');
17 36 $statusClass = (string) ($status_class ?? 'pending');
@@ -26,14 +45,28 @@
26 45 $bookingTotal = (string) ($booking_total ?? '0.00');
27 46 $amountPaid = (string) ($amount_paid ?? '0.00');
28 47 $amountDue = (string) ($amount_due ?? '0.00');
29 48
49 +// Structured payment instructions (e.g. bank-transfer details) provided by a
50 +// gateway via the yatra_invoice_payment_instructions filter. Shape:
51 +// ['title' => string, 'rows' => [['label'=>.., 'value'=>..], ...], 'note' => string]
52 +$paymentInstructions = (isset($payment_instructions) && is_array($payment_instructions)) ? $payment_instructions : [];
53 +
54 +
55 +// Optional logo + header colour supplied by the White Label module.
56 +// Unbranded sites keep this document's original header colour and show no logo.
57 +$pdfBranding = function_exists('yatra_get_pdf_branding')
58 + ? yatra_get_pdf_branding('#1e40af')
59 + : ['logo_url' => '', 'header_color' => '#1e40af'];
60 +$brandLogoUrl = (string) ($pdfBranding['logo_url'] ?? '');
61 +$brandHeaderColor = (string) ($pdfBranding['header_color'] ?? '#1e40af');
62 +
30 63 ?><!DOCTYPE html>
31 64 <html lang="en">
32 65 <head>
33 66 <meta charset="UTF-8">
34 67 <meta name="viewport" content="width=device-width, initial-scale=1.0">
35 - <title><?php echo esc_html__('Invoice', 'yatra'); ?> - <?php echo htmlspecialchars($paymentRef, ENT_QUOTES, 'UTF-8'); ?></title>
68 + <title><?php echo esc_html__('Invoice', 'yatra'); ?> - <?php echo htmlspecialchars($bookingRef !== '' ? $bookingRef : $paymentRef, ENT_QUOTES, 'UTF-8'); ?></title>
36 69 <style>
37 70 @page { size: A4 portrait; margin: 0mm; }
38 71 * { margin: 0; padding: 0; box-sizing: border-box; }
39 72 body { margin: 0; padding: 0; font-family: "Noto Sans Devanagari", "Noto Sans Arabic", "Noto Sans CJK", "DejaVu Sans", sans-serif; font-size: 12px; color: #111; }
@@ -40,9 +73,10 @@
40 73 .content { padding: 12mm 12mm 14mm 12mm; }
41 74
42 75 .header { width: 100%; border-collapse: collapse; }
43 76 .header td { vertical-align: top; }
44 - .brand { background: #1e40af; color: #fff; padding: 6mm 6mm; }
77 + .brand { background: <?php echo htmlspecialchars($brandHeaderColor, ENT_QUOTES, 'UTF-8'); ?>; color: #fff; padding: 6mm 6mm; }
78 + .brand-logo { max-height: 18mm; max-width: 60mm; margin-bottom: 3mm; }
45 79 .brand h1 { font-size: 18px; font-weight: 700; margin: 0; }
46 80 .brand p { font-size: 11px; margin-top: 4px; }
47 81
48 82 .panel { width: 100%; border: 1px solid #e5e7eb; border-collapse: collapse; margin-top: 6mm; margin-bottom: 6mm; }
@@ -57,8 +91,9 @@
57 91 .details .v-wrap { white-space: normal; }
58 92
59 93 .badge { display: inline-block; padding: 2px 10px; font-size: 10px; border-radius: 12px; border: 1px solid #e5e7eb; margin-left: 6px; vertical-align: middle; line-height: 1.4; }
60 94 .badge-paid { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
95 + .badge-partial { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
61 96 .badge-pending { background: #fef3c7; color: #92400e; border-color: #fde68a; }
62 97
63 98 .items { width: 100%; border-collapse: collapse; margin-top: 4mm; }
64 99 .items th { text-align: left; font-size: 10px; text-transform: uppercase; color: #6b7280; background: #f9fafb; border-bottom: 1px solid #e5e7eb; padding: 10px 12px; }
@@ -75,8 +110,11 @@
75 110 <body>
76 111 <table class="header">
77 112 <tr>
78 113 <td class="brand">
114 + <?php if ($brandLogoUrl !== ''): ?>
115 + <img class="brand-logo" src="<?php echo htmlspecialchars($brandLogoUrl, ENT_QUOTES, 'UTF-8'); ?>" alt="">
116 + <?php endif; ?>
79 117 <h1><?php echo htmlspecialchars($companyName, ENT_QUOTES, 'UTF-8'); ?></h1>
80 118 <p><?php esc_html_e('Payment Invoice', 'yatra'); ?></p>
81 119 </td>
82 120 </tr>
@@ -87,8 +125,11 @@
87 125 <tr>
88 126 <td style="width: 40%;">
89 127 <h3><?php esc_html_e('Invoice To', 'yatra'); ?></h3>
90 128 <div><strong><?php echo htmlspecialchars($customerName, ENT_QUOTES, 'UTF-8'); ?></strong></div>
129 + <?php foreach ($customerAddressLines as $addressLine): ?>
130 + <div class="muted"><?php echo htmlspecialchars($addressLine, ENT_QUOTES, 'UTF-8'); ?></div>
131 + <?php endforeach; ?>
91 132 <div class="muted"><?php echo htmlspecialchars($customerEmail, ENT_QUOTES, 'UTF-8'); ?></div>
92 133 </td>
93 134 <td style="width: 30%;">
94 135 <h3><?php esc_html_e('Invoice Details', 'yatra'); ?></h3>
@@ -94,9 +135,13 @@
94 135 <h3><?php esc_html_e('Invoice Details', 'yatra'); ?></h3>
95 136 <table class="details">
96 137 <tr>
97 138 <td class="k"><?php esc_html_e('Invoice #:', 'yatra'); ?></td>
98 - <td class="v-wrap"><?php echo htmlspecialchars($paymentRef, ENT_QUOTES, 'UTF-8'); ?></td>
139 + <?php // Always the booking reference — consistent whether the invoice is
140 + // downloaded from the confirmation page or after a payment. Previously
141 + // this used $paymentRef, which the post-payment path set to the payment
142 + // number (PAY-xxxxxx), so the invoice number changed per download. ?>
143 + <td class="v-wrap"><?php echo htmlspecialchars($bookingRef !== '' ? $bookingRef : $paymentRef, ENT_QUOTES, 'UTF-8'); ?></td>
99 144 </tr>
100 145 <tr>
101 146 <td class="k"><?php esc_html_e('Date:', 'yatra'); ?></td>
102 147 <td class="v"><?php echo htmlspecialchars($paymentDate, ENT_QUOTES, 'UTF-8'); ?></td>
@@ -109,11 +154,11 @@
109 154 </td>
110 155 <td style="width: 30%;">
111 156 <h3><?php esc_html_e('Company', 'yatra'); ?></h3>
112 157 <div><?php echo htmlspecialchars($companyName, ENT_QUOTES, 'UTF-8'); ?></div>
113 - <?php if ($companyAddress !== ''): ?>
114 - <div class="muted"><?php echo htmlspecialchars($companyAddress, ENT_QUOTES, 'UTF-8'); ?></div>
115 - <?php endif; ?>
158 + <?php foreach ($companyAddressLines as $companyAddressLine): ?>
159 + <div class="muted"><?php echo htmlspecialchars($companyAddressLine, ENT_QUOTES, 'UTF-8'); ?></div>
160 + <?php endforeach; ?>
116 161 <?php if ($companyEmail !== ''): ?>
117 162 <div class="muted"><?php echo htmlspecialchars($companyEmail, ENT_QUOTES, 'UTF-8'); ?></div>
118 163 <?php endif; ?>
119 164 <?php if ($companyPhone !== ''): ?>
@@ -139,9 +184,9 @@
139 184 <div class="muted"><?php esc_html_e('Payment via', 'yatra'); ?> <?php echo htmlspecialchars($paymentMethod, ENT_QUOTES, 'UTF-8'); ?></div>
140 185 </td>
141 186 <td><?php echo htmlspecialchars($bookingRef, ENT_QUOTES, 'UTF-8'); ?></td>
142 187 <td><?php echo htmlspecialchars($travelDate, ENT_QUOTES, 'UTF-8'); ?></td>
143 - <td class="right"><strong><?php echo $currencySymbol . htmlspecialchars($amount, ENT_QUOTES, 'UTF-8'); ?></strong></td>
188 + <td class="right"><strong><?php echo htmlspecialchars($amount, ENT_QUOTES, 'UTF-8'); ?></strong></td>
144 189 </tr>
145 190 </tbody>
146 191 </table>
147 192
@@ -148,33 +193,63 @@
148 193 <table class="totals">
149 194 <?php if (!empty($tax_breakdown)): ?>
150 195 <tr>
151 196 <td class="label"><?php esc_html_e('Subtotal', 'yatra'); ?></td>
152 - <td class="value"><?php echo $currencySymbol . htmlspecialchars($subtotal, ENT_QUOTES, 'UTF-8'); ?></td>
197 + <td class="value"><?php echo htmlspecialchars($subtotal, ENT_QUOTES, 'UTF-8'); ?></td>
153 198 </tr>
154 199 <?php foreach ($tax_breakdown as $tax): ?>
155 200 <tr>
156 201 <td class="label"><?php echo htmlspecialchars($tax['name'], ENT_QUOTES, 'UTF-8'); ?> (<?php echo htmlspecialchars($tax['rate'], ENT_QUOTES, 'UTF-8'); ?>%)</td>
157 - <td class="value"><?php echo $currencySymbol . htmlspecialchars($tax['amount'], ENT_QUOTES, 'UTF-8'); ?></td>
202 + <td class="value"><?php echo htmlspecialchars($tax['amount'], ENT_QUOTES, 'UTF-8'); ?></td>
158 203 </tr>
159 204 <?php endforeach; ?>
160 205 <?php endif; ?>
161 206 <tr>
162 207 <td class="label"><?php esc_html_e('Booking Total', 'yatra'); ?></td>
163 - <td class="value"><?php echo $currencySymbol . htmlspecialchars($bookingTotal, ENT_QUOTES, 'UTF-8'); ?></td>
208 + <td class="value"><?php echo htmlspecialchars($bookingTotal, ENT_QUOTES, 'UTF-8'); ?></td>
164 209 </tr>
165 210 <tr>
166 211 <td class="label"><?php esc_html_e('Total Paid', 'yatra'); ?></td>
167 - <td class="value"><?php echo $currencySymbol . htmlspecialchars($amountPaid, ENT_QUOTES, 'UTF-8'); ?></td>
212 + <td class="value"><?php echo htmlspecialchars($amountPaid, ENT_QUOTES, 'UTF-8'); ?></td>
168 213 </tr>
169 214 <tr>
170 215 <td class="label"><?php esc_html_e('Balance Due', 'yatra'); ?></td>
171 - <td class="value"><?php echo $currencySymbol . htmlspecialchars($amountDue, ENT_QUOTES, 'UTF-8'); ?></td>
216 + <td class="value"><?php echo htmlspecialchars($amountDue, ENT_QUOTES, 'UTF-8'); ?></td>
172 217 </tr>
173 218 <tr>
174 219 <td class="label grand"><?php esc_html_e('This Payment', 'yatra'); ?></td>
175 - <td class="value grand"><?php echo $currencySymbol . htmlspecialchars($amount, ENT_QUOTES, 'UTF-8'); ?></td>
220 + <td class="value grand"><?php echo htmlspecialchars($amount, ENT_QUOTES, 'UTF-8'); ?></td>
176 221 </tr>
177 222 </table>
223 +
224 + <?php if (!empty($paymentInstructions['rows']) && is_array($paymentInstructions['rows'])): ?>
225 + <table class="panel" style="margin-top: 6mm;">
226 + <tr>
227 + <td>
228 + <h3><?php echo htmlspecialchars((string) ($paymentInstructions['title'] ?? __('Payment Instructions', 'yatra')), ENT_QUOTES, 'UTF-8'); ?></h3>
229 + <table class="details">
230 + <?php foreach ($paymentInstructions['rows'] as $piRow): ?>
231 + <?php if (!is_array($piRow)) { continue; } ?>
232 + <tr>
233 + <?php
234 + // A gateway may supply its label with or without a
235 + // trailing colon (Bank Transfer reuses the colon-suffixed
236 + // strings from the confirmation page so a single
237 + // translation covers both). Normalise so neither form
238 + // renders "Label::".
239 + $piLabel = rtrim(trim((string) ($piRow['label'] ?? '')), ':');
240 + ?>
241 + <td class="k" style="width: 40mm;"><?php echo htmlspecialchars($piLabel, ENT_QUOTES, 'UTF-8'); ?>:</td>
242 + <td class="v-wrap"><?php echo htmlspecialchars((string) ($piRow['value'] ?? ''), ENT_QUOTES, 'UTF-8'); ?></td>
243 + </tr>
244 + <?php endforeach; ?>
245 + </table>
246 + <?php if (!empty($paymentInstructions['note'])): ?>
247 + <p class="muted" style="margin-top: 4mm;"><?php echo htmlspecialchars((string) $paymentInstructions['note'], ENT_QUOTES, 'UTF-8'); ?></p>
248 + <?php endif; ?>
249 + </td>
250 + </tr>
251 + </table>
252 + <?php endif; ?>
178 253 </div>
179 254 </body>
180 255 </html>