ifnex/04_Laravel/resources/views/pdfs/invoice.blade.php
Kazem Alghasi 5874568c63 feat(shipment): implement PDF generation for AWB, invoice, and labels
Introduce PDF generation capabilities for shipments using laravel-dompdf.
This includes a new service layer, dedicated controller, and routes
to handle the generation of Air Waybills (AWB), Invoices, and Shipping
Labels.

- Add `PdfService` to encapsulate PDF generation logic.
- Add `ShipmentPdfController` to handle PDF download requests.
- Integrate `barryvdh/laravel-dompdf` dependency.
- Add Filament header actions to view shipment pages for quick PDF access.
- Update order success view to provide direct download links for documents.
- Add label methods to `ShipmentDirection` and `ShipmentType` enums.
- Update project status documentation to reflect initial PDF implementation.
2026-08-04 09:20:23 +03:30

125 lines
7.4 KiB
PHP

<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: DejaVu Sans, sans-serif; font-size: 11px; direction: rtl; text-align: right; }
.container { padding: 20px; }
.header { text-align: center; margin-bottom: 20px; border-bottom: 2px solid #f37021; padding-bottom: 10px; }
.header h1 { color: #f37021; font-size: 20px; margin-bottom: 5px; }
.header .meta { display: flex; justify-content: space-between; font-size: 10px; color: #666; }
.section { margin-bottom: 15px; border: 1px solid #ddd; padding: 10px; }
.section-title { font-weight: bold; color: #f37021; margin-bottom: 8px; font-size: 12px; border-bottom: 1px solid #eee; padding-bottom: 3px; }
.row { display: flex; margin-bottom: 4px; }
.label { width: 130px; font-weight: bold; color: #555; }
.value { flex: 1; }
.two-col { display: flex; gap: 20px; }
.col { flex: 1; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { border: 1px solid #ddd; padding: 6px; text-align: right; font-size: 10px; }
th { background-color: #f5f5f5; font-weight: bold; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.total { font-weight: bold; color: #f37021; }
.footer { margin-top: 20px; border-top: 1px solid #ddd; padding-top: 10px; font-size: 9px; color: #666; }
.declaration { font-size: 9px; color: #666; margin-top: 15px; line-height: 1.5; }
.awb-box { background-color: #f9f9f9; padding: 5px 10px; display: inline-block; border: 1px dashed #f37021; }
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>INVOICE / فاکتور</h1>
<div class="meta">
<span>DATE: {{ $shipment->created_at?->format('Y-m-d') }}</span>
<span class="awb-box">INVOICE NO: {{ $shipment->awb_no }}</span>
</div>
</div>
<div class="two-col">
<div class="col section">
<div class="section-title">SHIPPER / فرستنده</div>
<div class="row"><span class="label">Name:</span><span class="value">{{ $shipper['name'] }}</span></div>
<div class="row"><span class="label">Company:</span><span class="value">{{ $shipper['company'] }}</span></div>
<div class="row"><span class="label">Contact:</span><span class="value">{{ $shipper['phone'] }}</span></div>
<div class="row"><span class="label">Address:</span><span class="value">{{ $shipper['address'] }}</span></div>
<div class="row"><span class="label">City/Zip:</span><span class="value">{{ $shipper['city'] }} {{ $shipper['zip'] }}</span></div>
<div class="row"><span class="label">Email:</span><span class="value">{{ $shipper['email'] }}</span></div>
</div>
<div class="col section">
<div class="section-title">CONSIGNEE / گیرنده</div>
<div class="row"><span class="label">Name:</span><span class="value">{{ $receiver['name'] }}</span></div>
<div class="row"><span class="label">Company:</span><span class="value">{{ $receiver['company'] }}</span></div>
<div class="row"><span class="label">Contact:</span><span class="value">{{ $receiver['phone'] }}</span></div>
<div class="row"><span class="label">Address:</span><span class="value">{{ $receiver['address'] }}</span></div>
<div class="row"><span class="label">City/Zip:</span><span class="value">{{ $receiver['city'] }} {{ $receiver['zip'] }}</span></div>
<div class="row"><span class="label">Email:</span><span class="value">{{ $receiver['email'] }}</span></div>
</div>
</div>
<div class="section">
<div class="section-title">SHIPMENT DETAILS</div>
<div class="row">
<div style="width: 50%">
<div class="row"><span class="label">Weight:</span><span class="value">{{ $shipment->weight }} kg</span></div>
<div class="row"><span class="label">Volumetric:</span><span class="value">{{ $shipment->volumetric_weight }} kg</span></div>
<div class="row"><span class="label">Dimensions:</span><span class="value">{{ $shipment->dimensions }}</span></div>
<div class="row"><span class="label">Service:</span><span class="value">{{ $shipment->type?->label() }}</span></div>
<div class="row"><span class="label">Direction:</span><span class="value">{{ $shipment->direction?->label() }}</span></div>
</div>
<div style="width: 50%">
<div class="row"><span class="label">From:</span><span class="value">{{ $shipment->fromCountry?->name }}</span></div>
<div class="row"><span class="label">To:</span><span class="value">{{ $shipment->toCountry?->name }}</span></div>
<div class="row"><span class="label">Forwarder:</span><span class="value">{{ $shipment->forwarder }}</span></div>
<div class="row"><span class="label">Reason:</span><span class="value">{{ $shipment->reason_for_export ?: 'N/A' }}</span></div>
</div>
</div>
</div>
<div class="section">
<div class="section-title">CONTENT / محموله</div>
<p style="margin-bottom: 10px;">{{ $shipment->reason_for_export ?: 'General Goods' }}</p>
<table>
<thead>
<tr>
<th style="width: 40px">No</th>
<th>Description</th>
<th style="width: 100px">H.S. Code</th>
<th style="width: 70px">Qty</th>
<th style="width: 90px">Unit Price (USD)</th>
<th style="width: 100px">Total (USD)</th>
</tr>
</thead>
<tbody>
@forelse($items as $item)
<tr>
<td class="text-center">{{ $item->row_number }}</td>
<td>{{ $item->description }}</td>
<td class="text-center">{{ $item->hs_code }}</td>
<td class="text-center">{{ $item->quantity }}</td>
<td class="text-center">{{ number_format($item->unit_price, 2) }}</td>
<td class="text-center">{{ number_format($item->total_usd, 2) }}</td>
</tr>
@empty
<tr><td colspan="6" class="text-center">No items</td></tr>
@endforelse
</tbody>
</table>
<div style="margin-top: 10px; text-align: left;">
<strong>TOTAL INVOICE AMOUNT IN USD: {{ number_format($invoice_total_usd, 2) }}</strong>
</div>
</div>
<div class="declaration">
I HEREBY STATE THAT THE ABOVE INFORMATION IS TRUE AND CORRECT TO THE BEST OF MY KNOWLEDGE.
</div>
<div class="footer">
IFNEX Logistics We Deliver Value | AWB: {{ $shipment->awb_no }} | Generated on {{ now()->format('Y-m-d H:i') }}
</div>
</div>
</body>
</html>