| @@ -1,8 +1,19 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $companyName = (string) ($company_name ?? ''); |
| 4 | 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 | + })); | |
| 5 | 16 | $companyEmail = (string) ($company_email ?? ''); |
| 6 | 17 | $companyPhone = (string) ($company_phone ?? ''); |
| 7 | 18 | |
| 8 | 19 | $customerName = (string) ($customer_name ?? ''); |
| @@ -90,8 +101,17 @@ | ||
| 90 | 101 | } |
| 91 | 102 | return $out; |
| 92 | 103 | }; |
| 93 | 104 | |
| 105 | + | |
| 106 | +// Optional logo + header colour supplied by the White Label module. | |
| 107 | +// Unbranded sites keep this document's original header colour and show no logo. | |
| 108 | +$pdfBranding = function_exists('yatra_get_pdf_branding') | |
| 109 | + ? yatra_get_pdf_branding('#1e40af') | |
| 110 | + : ['logo_url' => '', 'header_color' => '#1e40af']; | |
| 111 | +$brandLogoUrl = (string) ($pdfBranding['logo_url'] ?? ''); | |
| 112 | +$brandHeaderColor = (string) ($pdfBranding['header_color'] ?? '#1e40af'); | |
| 113 | + | |
| 94 | 114 | ?><!DOCTYPE html> |
| 95 | 115 | <html lang="en"> |
| 96 | 116 | <head> |
| 97 | 117 | <meta charset="UTF-8"> |
| @@ -146,9 +166,10 @@ | ||
| 146 | 166 | .avoid-break { page-break-inside: avoid; } |
| 147 | 167 | |
| 148 | 168 | .header { width: 100%; border-collapse: collapse; } |
| 149 | 169 | .header td { vertical-align: top; } |
| 150 | - .brand { background: #1e40af; color: #fff; padding: 6mm 6mm; } | |
| 170 | + .brand { background: <?php echo htmlspecialchars($brandHeaderColor, ENT_QUOTES, 'UTF-8'); ?>; color: #fff; padding: 6mm 6mm; } | |
| 171 | + .brand-logo { max-height: 18mm; max-width: 60mm; margin-bottom: 3mm; } | |
| 151 | 172 | .brand h1 { font-size: 18px; font-weight: 700; margin: 0; } |
| 152 | 173 | .brand p { font-size: 11px; margin-top: 4px; } |
| 153 | 174 | |
| 154 | 175 | .itinerary-number { background: #f3f4f6; padding: 4mm 6mm; border-bottom: 2px solid #1e40af; margin-top: 2mm; } |
| @@ -285,9 +306,12 @@ | ||
| 285 | 306 | <table class="header"> |
| 286 | 307 | <tr> |
| 287 | 308 | <td style="width: 60%;"> |
| 288 | 309 | <div class="brand"> |
| 289 | - <h1><?php echo htmlspecialchars($companyName ?: __('Travel Company', 'yatra'), ENT_QUOTES, 'UTF-8'); ?></h1> | |
| 310 | + <?php if ($brandLogoUrl !== ''): ?> | |
| 311 | + <img class="brand-logo" src="<?php echo htmlspecialchars($brandLogoUrl, ENT_QUOTES, 'UTF-8'); ?>" alt=""> | |
| 312 | + <?php endif; ?> | |
| 313 | + <h1><?php echo htmlspecialchars($companyName ?: __('Travel Company', 'yatra'), ENT_QUOTES, 'UTF-8'); ?></h1> | |
| 290 | 314 | <p><?php esc_html_e('Travel Itinerary Document', 'yatra'); ?></p> |
| 291 | 315 | </div> |
| 292 | 316 | </td> |
| 293 | 317 | <td style="width: 40%;"> |