@php use App\Support\Html; // Combined print/download packet: the letter followed by each referenced // document flagged "attach to print", each on its own page(s). Rendered as a // single dompdf pass (dompdf cannot merge pre-rendered PDF binaries), reusing // the letterhead band so the whole packet is branded consistently. $showBand = (bool) $letter->insert_letterhead; $accent = $setting?->primary_color ?: '#2e86ab'; $ink = '#1f2937'; $muted = '#6b7280'; $line = '#d5dde5'; $font = $setting?->font_family ? $setting->font_family.', Arial, sans-serif' : 'Arial, Helvetica, sans-serif'; $rainbowStops = [[46, 134, 171], [168, 25, 46], [255, 210, 63], [27, 27, 27], [255, 210, 63], [168, 25, 46], [46, 134, 171]]; $rainbow = []; $segs = count($rainbowStops) - 1; $steps = 72; for ($i = 0; $i < $steps; $i++) { $p = $i / ($steps - 1) * $segs; $idx = (int) min($segs - 1, floor($p)); $t = $p - $idx; [$a, $b] = [$rainbowStops[$idx], $rainbowStops[$idx + 1]]; $rainbow[] = sprintf('#%02x%02x%02x', (int) round($a[0] + ($b[0] - $a[0]) * $t), (int) round($a[1] + ($b[1] - $a[1]) * $t), (int) round($a[2] + ($b[2] - $a[2]) * $t)); } $mRight = (int) ($setting?->letter_margin_right ?? 44); $mLeft = (int) ($setting?->letter_margin_left ?? 44); $mTop = $showBand ? 158 : (int) ($setting?->letter_margin_top ?? 40); $mBottom = $showBand ? 96 : (int) ($setting?->letter_margin_bottom ?? 40); $position = in_array($setting?->letter_header_position, ['left', 'center', 'right'], true) ? $setting->letter_header_position : 'left'; $logoData = null; if ($showBand && $setting?->logo_path) { try { $logoFull = \Illuminate\Support\Facades\Storage::disk('public')->path($setting->logo_path); if (is_file($logoFull)) { $logoData = 'data:'.(mime_content_type($logoFull) ?: 'image/png').';base64,'.base64_encode(file_get_contents($logoFull)); } } catch (\Throwable $e) { $logoData = null; } } $companyName = $setting?->company_name ?: $letter->team?->name; $watermarkText = $setting?->letter_watermark_text ?: $companyName; $showWatermark = $showBand && $setting?->letter_watermark_enabled && $watermarkText; // $attachments: array of ['document' => Model, 'label', 'number', 'symbol']. $attachments = $attachments ?? []; @endphp
|
@if ($logoData) {{ $companyName }} @endif
@if ($setting?->address){{ str_replace(["\r\n", "\n"], ' · ', $setting->address) }}
@endif @if ($setting?->phone){{ $setting->phone }}@endif @if ($setting?->email) · {{ $setting->email }}@endif @if ($setting?->website) · {{ $setting->website }}@endif |
@else
@php
$logoCell = ''.($logoData ? ' '.e($companyName).' ').' | ';
$contactCell = ''; @endphp @if ($position === 'right'){!! $contactCell !!}{!! $logoCell !!}@else{!! $logoCell !!}{!! $contactCell !!}@endif @endif |
| @endforeach |