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 +61 -14 3.0.10 → 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');
@@ -31,14 +50,23 @@
31 50 // gateway via the yatra_invoice_payment_instructions filter. Shape:
32 51 // ['title' => string, 'rows' => [['label'=>.., 'value'=>..], ...], 'note' => string]
33 52 $paymentInstructions = (isset($payment_instructions) && is_array($payment_instructions)) ? $payment_instructions : [];
34 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 +
35 63 ?><!DOCTYPE html>
36 64 <html lang="en">
37 65 <head>
38 66 <meta charset="UTF-8">
39 67 <meta name="viewport" content="width=device-width, initial-scale=1.0">
40 - <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>
41 69 <style>
42 70 @page { size: A4 portrait; margin: 0mm; }
43 71 * { margin: 0; padding: 0; box-sizing: border-box; }
44 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; }
@@ -45,9 +73,10 @@
45 73 .content { padding: 12mm 12mm 14mm 12mm; }
46 74
47 75 .header { width: 100%; border-collapse: collapse; }
48 76 .header td { vertical-align: top; }
49 - .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; }
50 79 .brand h1 { font-size: 18px; font-weight: 700; margin: 0; }
51 80 .brand p { font-size: 11px; margin-top: 4px; }
52 81
53 82 .panel { width: 100%; border: 1px solid #e5e7eb; border-collapse: collapse; margin-top: 6mm; margin-bottom: 6mm; }
@@ -81,8 +110,11 @@
81 110 <body>
82 111 <table class="header">
83 112 <tr>
84 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; ?>
85 117 <h1><?php echo htmlspecialchars($companyName, ENT_QUOTES, 'UTF-8'); ?></h1>
86 118 <p><?php esc_html_e('Payment Invoice', 'yatra'); ?></p>
87 119 </td>
88 120 </tr>
@@ -93,8 +125,11 @@
93 125 <tr>
94 126 <td style="width: 40%;">
95 127 <h3><?php esc_html_e('Invoice To', 'yatra'); ?></h3>
96 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; ?>
97 132 <div class="muted"><?php echo htmlspecialchars($customerEmail, ENT_QUOTES, 'UTF-8'); ?></div>
98 133 </td>
99 134 <td style="width: 30%;">
100 135 <h3><?php esc_html_e('Invoice Details', 'yatra'); ?></h3>
@@ -100,9 +135,13 @@
100 135 <h3><?php esc_html_e('Invoice Details', 'yatra'); ?></h3>
101 136 <table class="details">
102 137 <tr>
103 138 <td class="k"><?php esc_html_e('Invoice #:', 'yatra'); ?></td>
104 - <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>
105 144 </tr>
106 145 <tr>
107 146 <td class="k"><?php esc_html_e('Date:', 'yatra'); ?></td>
108 147 <td class="v"><?php echo htmlspecialchars($paymentDate, ENT_QUOTES, 'UTF-8'); ?></td>
@@ -115,11 +154,11 @@
115 154 </td>
116 155 <td style="width: 30%;">
117 156 <h3><?php esc_html_e('Company', 'yatra'); ?></h3>
118 157 <div><?php echo htmlspecialchars($companyName, ENT_QUOTES, 'UTF-8'); ?></div>
119 - <?php if ($companyAddress !== ''): ?>
120 - <div class="muted"><?php echo htmlspecialchars($companyAddress, ENT_QUOTES, 'UTF-8'); ?></div>
121 - <?php endif; ?>
158 + <?php foreach ($companyAddressLines as $companyAddressLine): ?>
159 + <div class="muted"><?php echo htmlspecialchars($companyAddressLine, ENT_QUOTES, 'UTF-8'); ?></div>
160 + <?php endforeach; ?>
122 161 <?php if ($companyEmail !== ''): ?>
123 162 <div class="muted"><?php echo htmlspecialchars($companyEmail, ENT_QUOTES, 'UTF-8'); ?></div>
124 163 <?php endif; ?>
125 164 <?php if ($companyPhone !== ''): ?>
@@ -145,9 +184,9 @@
145 184 <div class="muted"><?php esc_html_e('Payment via', 'yatra'); ?> <?php echo htmlspecialchars($paymentMethod, ENT_QUOTES, 'UTF-8'); ?></div>
146 185 </td>
147 186 <td><?php echo htmlspecialchars($bookingRef, ENT_QUOTES, 'UTF-8'); ?></td>
148 187 <td><?php echo htmlspecialchars($travelDate, ENT_QUOTES, 'UTF-8'); ?></td>
149 - <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>
150 189 </tr>
151 190 </tbody>
152 191 </table>
153 192
@@ -154,32 +193,32 @@
154 193 <table class="totals">
155 194 <?php if (!empty($tax_breakdown)): ?>
156 195 <tr>
157 196 <td class="label"><?php esc_html_e('Subtotal', 'yatra'); ?></td>
158 - <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>
159 198 </tr>
160 199 <?php foreach ($tax_breakdown as $tax): ?>
161 200 <tr>
162 201 <td class="label"><?php echo htmlspecialchars($tax['name'], ENT_QUOTES, 'UTF-8'); ?> (<?php echo htmlspecialchars($tax['rate'], ENT_QUOTES, 'UTF-8'); ?>%)</td>
163 - <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>
164 203 </tr>
165 204 <?php endforeach; ?>
166 205 <?php endif; ?>
167 206 <tr>
168 207 <td class="label"><?php esc_html_e('Booking Total', 'yatra'); ?></td>
169 - <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>
170 209 </tr>
171 210 <tr>
172 211 <td class="label"><?php esc_html_e('Total Paid', 'yatra'); ?></td>
173 - <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>
174 213 </tr>
175 214 <tr>
176 215 <td class="label"><?php esc_html_e('Balance Due', 'yatra'); ?></td>
177 - <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>
178 217 </tr>
179 218 <tr>
180 219 <td class="label grand"><?php esc_html_e('This Payment', 'yatra'); ?></td>
181 - <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>
182 221 </tr>
183 222 </table>
184 223
185 224 <?php if (!empty($paymentInstructions['rows']) && is_array($paymentInstructions['rows'])): ?>
@@ -190,9 +229,17 @@
190 229 <table class="details">
191 230 <?php foreach ($paymentInstructions['rows'] as $piRow): ?>
192 231 <?php if (!is_array($piRow)) { continue; } ?>
193 232 <tr>
194 - <td class="k" style="width: 40mm;"><?php echo htmlspecialchars((string) ($piRow['label'] ?? ''), ENT_QUOTES, 'UTF-8'); ?>:</td>
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>
195 242 <td class="v-wrap"><?php echo htmlspecialchars((string) ($piRow['value'] ?? ''), ENT_QUOTES, 'UTF-8'); ?></td>
196 243 </tr>
197 244 <?php endforeach; ?>
198 245 </table>