@php use Illuminate\Support\Facades\Storage; $order = $installation->order; $item = $installation->orderItem; $customer = $order->customer ?? null; $settingClass = class_exists('App\\Models\\Setting') ? 'App\\Models\\Setting' : null; $shopName = config('app.name', 'Aplikasi Percetakan'); $shopAddress = ''; $shopPhone = ''; $shopEmail = ''; $shopLogo = ''; if ($settingClass) { $shopName = method_exists($settingClass, 'getShopName') ? $settingClass::getShopName() : $shopName; $shopAddress = method_exists($settingClass, 'getShopAddress') ? $settingClass::getShopAddress() : ''; $shopPhone = method_exists($settingClass, 'getShopPhone') ? $settingClass::getShopPhone() : ''; $shopEmail = method_exists($settingClass, 'getShopEmail') ? $settingClass::getShopEmail() : ''; $shopLogo = method_exists($settingClass, 'getShopLogo') ? $settingClass::getShopLogo() : ''; } $makeImageDataUri = function (?string $path, ?string $fallbackMime = 'image/png') { $path = trim((string) $path); if ($path === '' || !file_exists($path) || !is_file($path)) { return null; } $mime = mime_content_type($path) ?: $fallbackMime ?: 'image/png'; if (str_contains(strtolower($mime), 'svg')) { $mime = 'image/svg+xml'; } return 'data:' . $mime . ';base64,' . base64_encode(file_get_contents($path)); }; $logoDataUri = null; $logoRaw = trim((string) $shopLogo); $logoPathOnly = $logoRaw; if ($logoRaw && filter_var($logoRaw, FILTER_VALIDATE_URL)) { $logoPathOnly = parse_url($logoRaw, PHP_URL_PATH) ?: ''; } $logoPathOnly = trim((string) $logoPathOnly); $logoPathOnly = str_replace('\\', '/', $logoPathOnly); $logoPathOnly = preg_replace('#^https?://[^/]+/#i', '', $logoPathOnly); $logoPathOnly = ltrim($logoPathOnly, '/'); $logoStoragePath = preg_replace('#^(storage/|public/)#', '', $logoPathOnly); $logoCandidates = array_filter(array_unique([ $logoRaw && !filter_var($logoRaw, FILTER_VALIDATE_URL) ? public_path(ltrim($logoRaw, '/')) : null, $logoPathOnly ? public_path($logoPathOnly) : null, $logoPathOnly ? public_path('storage/' . preg_replace('#^(storage/|public/)#', '', $logoPathOnly)) : null, $logoStoragePath ? Storage::disk('public')->path($logoStoragePath) : null, public_path('logo.png'), public_path('logo.jpg'), public_path('logo.jpeg'), public_path('logo.webp'), public_path('logo-dark.png'), public_path('assets/logo.png'), public_path('assets/logo.jpg'), public_path('assets/images/logo.png'), public_path('assets/images/logo.jpg'), public_path('assets/images/logo-dark.png'), public_path('assets/img/logo.png'), public_path('images/logo.png'), public_path('images/logo.jpg'), public_path('storage/logo.png'), public_path('storage/logo.jpg'), public_path('storage/settings/logo.png'), public_path('storage/settings/logo.jpg'), ])); foreach ($logoCandidates as $candidate) { $logoDataUri = $makeImageDataUri($candidate, 'image/png'); if ($logoDataUri) { break; } } $photoData = []; foreach (($installation->photos ?? collect()) as $photo) { if (empty($photo->path)) continue; $photoPath = Storage::disk('public')->path($photo->path); $photoDataUri = $makeImageDataUri($photoPath, $photo->mime_type ?: 'image/jpeg'); if (!$photoDataUri) continue; $photoData[] = [ 'src' => $photoDataUri, 'caption' => $photo->caption ?: ($photo->original_name ?: 'Dokumentasi pekerjaan'), ]; } $bastNumber = $installation->bast_number ?: 'BAST-' . ($order->invoice_number ?? str_pad((string) $installation->id, 5, '0', STR_PAD_LEFT)); $handoverDate = optional($installation->finished_at ?: $installation->target_date ?: now())->translatedFormat('l, d F Y'); $receiverName = $installation->received_by_name ?: ($customer->contact_person ?? $order->customer_name ?? '-'); $receiverCompany = $installation->received_by_company ?: ($customer->company_name ?? $customer->contact_person ?? $order->customer_name ?? '-'); $handoverName = $installation->handover_by_name ?: (auth()->user()->name ?? $shopName); $location = $installation->location ?: ($customer->address ?? $order->customer_address ?? '-'); $itemName = trim(($item->product_name ?? 'Pemasangan Outdoor') . (!empty($item->material_name) ? ' - ' . $item->material_name : '')); $itemDetail = collect([ !empty($item->file_name) ? 'Nama File: ' . $item->file_name : null, !empty($item->size) ? 'Ukuran: ' . $item->size : null, !empty($item->qty) ? 'Qty: ' . $item->qty : null, !empty($installation->notes) ? 'Catatan: ' . $installation->notes : null, ])->filter()->implode(' | '); @endphp
@if($logoDataUri) @else
{{ $shopName }}
@endif
@if($shopAddress)
{{ $shopAddress }}
@endif @if($shopPhone || $shopEmail)
{{ $shopPhone }}{{ $shopPhone && $shopEmail ? ' | ' : '' }}{{ $shopEmail }}
@endif
{{ $bastNumber }}
Tanggal cetak: {{ optional($printedAt ?? now())->format('d/m/Y H:i') }}
Invoice: {{ $order->invoice_number ?? '-' }}
Berita Acara Serah Terima Barang
No: {{ $bastNumber }}
Pada hari {{ $handoverDate }}, kami yang bertanda tangan di bawah ini:
Pihak Pertama
Nama:{{ $handoverName }}
Jabatan:{{ $installation->handover_by_position ?: 'Petugas Pemasangan' }}
Instansi:{{ $shopName }}
Pihak Kedua
Nama:{{ $receiverName }}
Jabatan:{{ $installation->received_by_position ?: '-' }}
Instansi:{{ $receiverCompany }}
Lokasi:{{ $location }}
Pihak Pertama menyerahkan pekerjaan/barang kepada Pihak Kedua, dan Pihak Kedua telah menyatakan menerima pekerjaan/barang tersebut dengan rincian sebagai berikut:
No Nama Barang / Pekerjaan Keterangan
1
{{ $itemName ?: 'Pemasangan Outdoor' }}
@if($itemDetail)
{{ $itemDetail }}
@endif
Terselesaikan
Pada {{ optional($installation->finished_at ?: $installation->target_date ?: now())->format('d/m/Y') }}
Yang Menerima,
Pihak Kedua
{{ $receiverName }}
Yang Menyerahkan,
Pihak Pertama
{{ $handoverName }}
@if(count($photoData) > 0)
Dokumentasi
Foto proof pekerjaan pemasangan outdoor - {{ $order->invoice_number ?? $bastNumber }}
@foreach(array_chunk($photoData, 2) as $photoRow) @foreach($photoRow as $photo) @endforeach @if(count($photoRow) === 1) @endif @endforeach
Dokumentasi
{{ $photo['caption'] }}
@endif