| 1 |
<?php |
| 2 |
|
| 3 |
$companyName = (string) ($company_name ?? ''); |
| 4 |
$companyAddress = (string) ($company_address ?? ''); |
| 5 |
// Settings keep the business address in separate fields (street, city, state, |
| 6 |
// postcode, country); documents only ever printed the street, so everything after |
| 7 |
// it was missing and the address looked cut off at its last line. Prefer the |
| 8 |
// composed lines, falling back to the raw street for any caller not passing them. |
| 9 |
$companyAddressLines = (isset($company_address_lines) && is_array($company_address_lines)) |
| 10 |
? array_values(array_filter(array_map('strval', $company_address_lines), static function ($line) { |
| 11 |
return trim($line) !== ''; |
| 12 |
})) |
| 13 |
: array_values(array_filter(preg_split('/\R/', $companyAddress) ?: [], static function ($line) { |
| 14 |
return trim($line) !== ''; |
| 15 |
})); |
| 16 |
$companyEmail = (string) ($company_email ?? ''); |
| 17 |
$companyPhone = (string) ($company_phone ?? ''); |
| 18 |
|
| 19 |
$customerName = (string) ($customer_name ?? ''); |
| 20 |
$customerEmail = (string) ($customer_email ?? ''); |
| 21 |
|
| 22 |
$bookingRef = (string) ($booking_ref ?? ''); |
| 23 |
$bookingDate = (string) ($booking_date ?? ''); |
| 24 |
$bookingStatus = (string) ($booking_status ?? ''); |
| 25 |
$statusClass = (string) ($status_class ?? 'pending'); |
| 26 |
|
| 27 |
$tripTitle = (string) ($trip_title ?? ''); |
| 28 |
$tripDuration = (string) ($trip_duration ?? ''); |
| 29 |
$tripDifficulty = (string) ($trip_difficulty ?? ''); |
| 30 |
|
| 31 |
$travelDate = (string) ($travel_date ?? ''); |
| 32 |
$returnDate = (string) ($return_date ?? ''); |
| 33 |
|
| 34 |
$currencySymbol = (string) ($currency_symbol ?? ''); |
| 35 |
$totalAmount = (string) ($total_amount ?? '0.00'); |
| 36 |
$amountPaid = (string) ($amount_paid ?? '0.00'); |
| 37 |
$amountDue = (string) ($amount_due ?? '0.00'); |
| 38 |
|
| 39 |
$travelerCount = (int) ($traveler_count ?? 1); |
| 40 |
$departureLocation = (string) ($departure_location ?? ''); |
| 41 |
$destination = (string) ($destination ?? ''); |
| 42 |
|
| 43 |
|
| 44 |
// Optional logo + header colour supplied by the White Label module. |
| 45 |
// Unbranded sites keep this document's original header colour and show no logo. |
| 46 |
$pdfBranding = function_exists('yatra_get_pdf_branding') |
| 47 |
? yatra_get_pdf_branding('#059669') |
| 48 |
: ['logo_url' => '', 'header_color' => '#059669']; |
| 49 |
$brandLogoUrl = (string) ($pdfBranding['logo_url'] ?? ''); |
| 50 |
$brandHeaderColor = (string) ($pdfBranding['header_color'] ?? '#059669'); |
| 51 |
|
| 52 |
?><!DOCTYPE html> |
| 53 |
<html lang="en"> |
| 54 |
<head> |
| 55 |
<meta charset="UTF-8"> |
| 56 |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 57 |
<title><?php echo esc_html__('Travel Voucher', 'yatra'); ?> - <?php echo htmlspecialchars($bookingRef, ENT_QUOTES, 'UTF-8'); ?></title> |
| 58 |
<style> |
| 59 |
@page { size: A4 portrait; margin: 0mm; } |
| 60 |
* { margin: 0; padding: 0; box-sizing: border-box; } |
| 61 |
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; } |
| 62 |
.content { padding: 12mm 12mm 14mm 12mm; } |
| 63 |
|
| 64 |
.header { width: 100%; border-collapse: collapse; } |
| 65 |
.header td { vertical-align: top; } |
| 66 |
.brand { background: <?php echo htmlspecialchars($brandHeaderColor, ENT_QUOTES, 'UTF-8'); ?>; color: #fff; padding: 6mm 6mm; } |
| 67 |
.brand-logo { max-height: 18mm; max-width: 60mm; margin-bottom: 3mm; } |
| 68 |
.brand h1 { font-size: 20px; font-weight: 700; margin: 0; } |
| 69 |
.brand p { font-size: 12px; margin-top: 4px; font-weight: 400; } |
| 70 |
|
| 71 |
.voucher-number { background: #f3f4f6; padding: 4mm 6mm; border-bottom: 2px solid #059669; } |
| 72 |
.voucher-number .number { font-size: 16px; font-weight: 700; color: #059669; } |
| 73 |
|
| 74 |
.panel { width: 100%; border: 1px solid #e5e7eb; border-collapse: collapse; margin-top: 6mm; margin-bottom: 6mm; } |
| 75 |
.panel td { padding: 5mm 5mm; vertical-align: top; } |
| 76 |
.panel h3 { font-size: 11px; text-transform: uppercase; color: #6b7280; margin-bottom: 8px; letter-spacing: 0.5px; } |
| 77 |
.muted { color: #6b7280; } |
| 78 |
|
| 79 |
.trip-info { background: #f9fafb; border-left: 4px solid #059669; padding: 6mm; margin: 6mm 0; } |
| 80 |
.trip-info h4 { color: #059669; font-size: 14px; margin-bottom: 4mm; } |
| 81 |
|
| 82 |
.details { width: 100%; border-collapse: collapse; } |
| 83 |
.details td { padding: 1.5mm 0; vertical-align: top; } |
| 84 |
.details .k { width: 20mm; white-space: nowrap; font-weight: 700; padding-right: 3mm; } |
| 85 |
.details .v { white-space: nowrap; } |
| 86 |
.details .v-wrap { white-space: normal; } |
| 87 |
|
| 88 |
.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; } |
| 89 |
.badge-confirmed { background: #d1fae5; color: #065f46; border-color: #a7f3d0; } |
| 90 |
.badge-pending { background: #fef3c7; color: #92400e; border-color: #fde68a; } |
| 91 |
.badge-cancelled { background: #fee2e2; color: #991b1b; border-color: #fecaca; } |
| 92 |
|
| 93 |
.travelers { width: 100%; border-collapse: collapse; margin-top: 4mm; } |
| 94 |
.travelers th { text-align: left; font-size: 10px; text-transform: uppercase; color: #6b7280; background: #f9fafb; border-bottom: 1px solid #e5e7eb; padding: 10px 12px; } |
| 95 |
.travelers td { border-bottom: 1px solid #e5e7eb; padding: 12px; vertical-align: top; } |
| 96 |
.right { text-align: right; } |
| 97 |
|
| 98 |
.totals { width: 100%; border-collapse: collapse; margin-top: 6mm; } |
| 99 |
.totals td { padding: 7px 12px; } |
| 100 |
.totals .label { color: #374151; } |
| 101 |
.totals .value { text-align: right; } |
| 102 |
.totals .grand { font-weight: 700; color: #059669; border-top: 2px solid #059669; padding-top: 12px; } |
| 103 |
|
| 104 |
.footer { margin-top: 8mm; padding-top: 6mm; border-top: 1px solid #e5e7eb; font-size: 10px; color: #6b7280; text-align: center; } |
| 105 |
</style> |
| 106 |
</head> |
| 107 |
<body> |
| 108 |
<table class="header"> |
| 109 |
<tr> |
| 110 |
<td class="brand"> |
| 111 |
<?php if ($brandLogoUrl !== ''): ?> |
| 112 |
<img class="brand-logo" src="<?php echo htmlspecialchars($brandLogoUrl, ENT_QUOTES, 'UTF-8'); ?>" alt=""> |
| 113 |
<?php endif; ?> |
| 114 |
<h1><?php echo htmlspecialchars($companyName, ENT_QUOTES, 'UTF-8'); ?></h1> |
| 115 |
<p><?php esc_html_e('Travel Voucher', 'yatra'); ?></p> |
| 116 |
</td> |
| 117 |
</tr> |
| 118 |
</table> |
| 119 |
|
| 120 |
<div class="voucher-number"> |
| 121 |
<div class="number"><?php esc_html_e('Voucher #', 'yatra'); ?><?php echo htmlspecialchars($bookingRef, ENT_QUOTES, 'UTF-8'); ?></div> |
| 122 |
</div> |
| 123 |
|
| 124 |
<div class="content"> |
| 125 |
<table class="panel"> |
| 126 |
<tr> |
| 127 |
<td style="width: 40%;"> |
| 128 |
<h3><?php esc_html_e('Traveler Information', 'yatra'); ?></h3> |
| 129 |
<div><strong><?php echo htmlspecialchars($customerName, ENT_QUOTES, 'UTF-8'); ?></strong></div> |
| 130 |
<div class="muted"><?php echo htmlspecialchars($customerEmail, ENT_QUOTES, 'UTF-8'); ?></div> |
| 131 |
<div class="muted"><?php esc_html_e('Travelers:', 'yatra'); ?> <?php echo (int) $traveler_count; ?></div> |
| 132 |
</td> |
| 133 |
<td style="width: 30%;"> |
| 134 |
<h3><?php esc_html_e('Booking Details', 'yatra'); ?></h3> |
| 135 |
<table class="details"> |
| 136 |
<tr> |
| 137 |
<td class="k"><?php esc_html_e('Booking #:', 'yatra'); ?></td> |
| 138 |
<td class="v-wrap"><?php echo htmlspecialchars($bookingRef, ENT_QUOTES, 'UTF-8'); ?></td> |
| 139 |
</tr> |
| 140 |
<tr> |
| 141 |
<td class="k"><?php esc_html_e('Date:', 'yatra'); ?></td> |
| 142 |
<td class="v"><?php echo htmlspecialchars($bookingDate, ENT_QUOTES, 'UTF-8'); ?></td> |
| 143 |
</tr> |
| 144 |
<tr> |
| 145 |
<td class="k"><?php esc_html_e('Status:', 'yatra'); ?></td> |
| 146 |
<td class="v"><span class="badge badge-<?php echo htmlspecialchars($statusClass, ENT_QUOTES, 'UTF-8'); ?>"><?php echo htmlspecialchars($bookingStatus, ENT_QUOTES, 'UTF-8'); ?></span></td> |
| 147 |
</tr> |
| 148 |
</table> |
| 149 |
</td> |
| 150 |
<td style="width: 30%;"> |
| 151 |
<h3><?php esc_html_e('Company', 'yatra'); ?></h3> |
| 152 |
<div><?php echo htmlspecialchars($companyName, ENT_QUOTES, 'UTF-8'); ?></div> |
| 153 |
<?php foreach ($companyAddressLines as $companyAddressLine): ?> |
| 154 |
<div class="muted"><?php echo htmlspecialchars($companyAddressLine, ENT_QUOTES, 'UTF-8'); ?></div> |
| 155 |
<?php endforeach; ?> |
| 156 |
<?php if ($companyEmail !== ''): ?> |
| 157 |
<div class="muted"><?php echo htmlspecialchars($companyEmail, ENT_QUOTES, 'UTF-8'); ?></div> |
| 158 |
<?php endif; ?> |
| 159 |
<?php if ($companyPhone !== ''): ?> |
| 160 |
<div class="muted"><?php echo htmlspecialchars($companyPhone, ENT_QUOTES, 'UTF-8'); ?></div> |
| 161 |
<?php endif; ?> |
| 162 |
</td> |
| 163 |
</tr> |
| 164 |
</table> |
| 165 |
|
| 166 |
<div class="trip-info"> |
| 167 |
<h4><?php echo htmlspecialchars($tripTitle, ENT_QUOTES, 'UTF-8'); ?></h4> |
| 168 |
<table class="details"> |
| 169 |
<tr> |
| 170 |
<td class="k"><?php esc_html_e('Duration:', 'yatra'); ?></td> |
| 171 |
<td class="v"><?php echo htmlspecialchars($tripDuration, ENT_QUOTES, 'UTF-8'); ?></td> |
| 172 |
</tr> |
| 173 |
<?php if ($tripDifficulty !== ''): ?> |
| 174 |
<tr> |
| 175 |
<td class="k"><?php esc_html_e('Difficulty:', 'yatra'); ?></td> |
| 176 |
<td class="v"><?php echo htmlspecialchars($tripDifficulty, ENT_QUOTES, 'UTF-8'); ?></td> |
| 177 |
</tr> |
| 178 |
<?php endif; ?> |
| 179 |
<?php if ($departureLocation !== ''): ?> |
| 180 |
<tr> |
| 181 |
<td class="k"><?php esc_html_e('Departure:', 'yatra'); ?></td> |
| 182 |
<td class="v"><?php echo htmlspecialchars($departureLocation, ENT_QUOTES, 'UTF-8'); ?></td> |
| 183 |
</tr> |
| 184 |
<?php endif; ?> |
| 185 |
<?php if ($destination !== ''): ?> |
| 186 |
<tr> |
| 187 |
<td class="k"><?php esc_html_e('Destination:', 'yatra'); ?></td> |
| 188 |
<td class="v"><?php echo htmlspecialchars($destination, ENT_QUOTES, 'UTF-8'); ?></td> |
| 189 |
</tr> |
| 190 |
<?php endif; ?> |
| 191 |
<tr> |
| 192 |
<td class="k"><?php esc_html_e('Travel Date:', 'yatra'); ?></td> |
| 193 |
<td class="v"><?php echo htmlspecialchars($travelDate, ENT_QUOTES, 'UTF-8'); ?></td> |
| 194 |
</tr> |
| 195 |
<?php if ($returnDate !== ''): ?> |
| 196 |
<tr> |
| 197 |
<td class="k"><?php esc_html_e('Return Date:', 'yatra'); ?></td> |
| 198 |
<td class="v"><?php echo htmlspecialchars($returnDate, ENT_QUOTES, 'UTF-8'); ?></td> |
| 199 |
</tr> |
| 200 |
<?php endif; ?> |
| 201 |
</table> |
| 202 |
</div> |
| 203 |
|
| 204 |
<table class="totals"> |
| 205 |
<tr> |
| 206 |
<td class="label"><?php esc_html_e('Total Amount', 'yatra'); ?></td> |
| 207 |
<td class="value"><?php echo htmlspecialchars($totalAmount, ENT_QUOTES, 'UTF-8'); ?></td> |
| 208 |
</tr> |
| 209 |
<tr> |
| 210 |
<td class="label"><?php esc_html_e('Amount Paid', 'yatra'); ?></td> |
| 211 |
<td class="value"><?php echo htmlspecialchars($amountPaid, ENT_QUOTES, 'UTF-8'); ?></td> |
| 212 |
</tr> |
| 213 |
<tr> |
| 214 |
<td class="label"><?php esc_html_e('Balance Due', 'yatra'); ?></td> |
| 215 |
<td class="value"><?php echo htmlspecialchars($amountDue, ENT_QUOTES, 'UTF-8'); ?></td> |
| 216 |
</tr> |
| 217 |
</table> |
| 218 |
</div> |
| 219 |
|
| 220 |
<div class="footer"> |
| 221 |
<p><?php esc_html_e('This voucher confirms your booking and should be presented at check-in. Please keep it safe for your travel records.', 'yatra'); ?></p> |
| 222 |
<p><?php esc_html_e('For questions or changes, contact us at', 'yatra'); ?> <?php echo htmlspecialchars($companyEmail, ENT_QUOTES, 'UTF-8'); ?> <?php esc_html_e('or call', 'yatra'); ?> <?php echo htmlspecialchars($companyPhone, ENT_QUOTES, 'UTF-8'); ?></p> |
| 223 |
</div> |
| 224 |
</body> |
| 225 |
</html> |
| 226 |
|