{{-- Shared, faithful port of the Sample Request Import email BODY used by FIVE legacy MailHandler methods (public/referenceonly/mailhandler.php): 1. sendEmailSampleRequestImportToPM L973 (body L1031-1180) 2. sendEmailGoodsReceiptToPMMM L1193 (body L1240-1393) 3. sendEmailSampleRequestImportToCEO L1408 (body L1470-1620) 4. sendEmailSampleRequestImportGoodsReceipt L1634 (body L1700-1852) 5. sendEmailSampleRequestImportToUserRevise L1866 (body L1916-2016) ALL five share the Header table and the "History Sample Import" table byte-for-byte. They DIVERGE in the Details table + Minimum-Stock presence, gated here by flags: Variant $detailVariant RemarkPM RemarkMM $showMinStock ------------------------- ----------------- -------- -------- ------------- 1 ToPM (L1031) 'standard' false false true 2 GoodsReceiptToPMMM (1240) 'goodsReceiptPMMM' (n/a - own table) false 3 ToCEO (L1470) 'standard' true false true 4 GoodsReceipt (L1700) 'standard' true true true 5 ToUserRevise (L1916) 'standard' true true false NOTE / caveats vs the orchestration brief: * The brief said ONLY GoodsReceiptToPMMM omits Minimum Stock. In fact ToUserRevise (L1916-2016) ALSO has no Minimum-Stock section - so BOTH pass $showMinStock=false. * GoodsReceiptToPMMM (L1240-1393) does NOT render "standard minus Min-Stock": it uses a WHOLLY different Details table (columns: ID, ReqCompany[+sales], ProductName, Quantity, ReceiveQty[goods-receipt lots], RemarkPM, RemarkMM, Project, Description, Remarks - no per-detail Status/History columns). Represented here via $detailVariant='goodsReceiptPMMM' + the extra $goodsReceipt contract (see below). It cannot be faithfully rendered by the standard detail loop. * Legacy uses purple TEXT headings () for THIS email family - NOT the filled
banners used by sample-order-revised.blade.php / quotation-document.blade.php. Reproduced faithfully. * Cosmetic-only divergences from raw legacy (rendered output identical): dropped the long  -run spacer padding inside cells (house style, cf. reference blades); header rows use " : " (ToPM style) where 4 variants emitted " :"; added the missing the legacy Min-Stock loop omitted (malformed-tag bug, browser auto-closed). * All values {{ }} auto-escaped (safer than legacy raw concat). Null-safe ?-> mirrors the legacy LEFT JOINs (missing lookups render empty). Legacy applied strip_tags() to header scalars; auto-escaping supersedes that. The two places legacy deliberately emits markup - the per-detail history {name} and the Min-Stock lot {lot} - keep the literal tag around an escaped {{ }} value. ============================ VARIABLE CONTRACT ============================ $import : SampleRequestImport (header row). Uses: $import->ID -> str_pad 6 '0' (Sample Import No.) $import->Tanggal (Request Date) $import->principal?->PrincipalName (Principal; belongsTo principal) $import->Addresses (Address) $import->userIDInput?->Nama (Creator; belongsTo userIDInput) $import->requestFrom?->FromName (Request From; belongsTo requestFrom -> SampleRequestImportFrom) $import->sampleRequestStatus?->SampleRequestStatusName (Status; belongsTo sampleRequestStatus) $import->delivery?->DeliveryName (Delivery; belongsTo delivery) $import->Remark (Comment) $details : Collection. Per row uses: $d->ID $d->sampleRequestDetailStatus?->SampleRequestStatusName (Status; belongsTo sampleRequestDetailStatus) $d->reqCompany?->CompanyName (ReqCompany; belongsTo reqCompany -> Company) $d->reqCompany?->userIDSales?->Nama (goodsReceiptPMMM sales-name; Company->userIDSales->Nama) $d->BarangName (ProductName - the detail's own column) $d->Quantity (number_format 2 ',' '.') $d->satuan?->SatuanName (Satuan; belongsTo satuan) $d->QuantityReceived (goodsReceiptPMMM ReceiveQty header line) $d->Remark (Remarks) $d->Description $d->Project $d->RemarkPM $d->RemarkMM $detailHistory : array keyed by detail ID => Collection. Per assignment $a uses: $a->Tanggal $a->sampleRequestDetailStatus?->SampleRequestStatusName (belongsTo sampleRequestDetailStatus) $a->user?->Nama (belongsTo user) $a->Remark $history : Collection (header-level history). Per row uses: $a->ID $a->sampleRequestStatus?->SampleRequestStatusName (belongsTo sampleRequestStatus) $a->Tanggal $a->user?->Nama (belongsTo user) $a->Comment $minStock : array (computed by the future Mailable from samplerequestimportdetail JOIN barang / barangstockmin / baranglists). Each row is an array: [ 'namaBarang' => string, (barang.NamaBarang) 'lots' => [ [ 'lotNumber'=>string, 'quantity'=>numeric, 'satuan'=>string, 'keterangan'=>?string, 'tanggalMasuk'=>?string ], ... ], (baranglists, Qty>0) 'qtyMinimum' => ?numeric, (barangstockmin.QuantityMinimum; '' or 0 => "-") 'satuan' => ?string ] (satuan of the min-stock row) $goodsReceipt : array keyed by detail ID => array of receipt rows (ONLY for $detailVariant='goodsReceiptPMMM'; from samplerequestimportgoodsreceipt JOIN satuan/baranglists). Each receipt is an array: [ 'lotNumber'=>string, 'quantityReceived'=>numeric, 'satuan'=>string, 'expiryDate'=>?string, 'tanggalMasuk'=>?string, 'keterangan'=>?string ] Flags: $showMinStock (bool, default true), $showRemarkPM (bool, default false), $showRemarkMM (bool, default false), $detailVariant (string, default 'standard'). ========================================================================== --}} @php $showMinStock = $showMinStock ?? true; $showRemarkPM = $showRemarkPM ?? false; $showRemarkMM = $showRemarkMM ?? false; $detailVariant = $detailVariant ?? 'standard'; $details = $details ?? collect(); $detailHistory = $detailHistory ?? []; $history = $history ?? collect(); $minStock = $minStock ?? []; $goodsReceipt = $goodsReceipt ?? []; $num2 = fn ($v) => number_format((float) $v, 2, ',', '.'); $num0 = fn ($v) => number_format((float) $v, 0, ',', '.'); $fmtDate = fn ($v) => filled($v) ? \Illuminate\Support\Carbon::parse($v)->format('d-m-Y') : ''; @endphp Sample Request Import - Colorindo Chemtra {{-- Header --}}
Sample Import No.   : {{ str_pad((string) $import?->ID, 6, '0', STR_PAD_LEFT) }}
Request Date   : {{ $import?->Tanggal }}
Principal   : {{ $import?->principal?->PrincipalName }}
Address   : {{ $import?->Addresses }}
Creator   : {{ $import?->userIDInput?->Nama }}
Request From   : {{ $import?->requestFrom?->FromName }}
Status   : {{ $import?->sampleRequestStatus?->SampleRequestStatusName }}
Delivery   : {{ $import?->delivery?->DeliveryName }}
Comment   : {{ $import?->Remark }}
{{-- Details --}}

Details

@if ($detailVariant === 'goodsReceiptPMMM') {{-- Variant 2: GoodsReceiptToPMMM (legacy L1289-1360) - distinct table --}} @foreach ($details as $d) @endforeach
ID ReqCompany ProductName Quantity ReceiveQty RemarkPM RemarkMM Project Description Remarks
{{ $d->ID }} @if (filled($d->reqCompany?->CompanyName)){{ $d->reqCompany->CompanyName }}
({{ $d->reqCompany->userIDSales?->Nama }})@endif
{{ $d->BarangName }} {{ $num2($d->Quantity) }} {{ $d->satuan?->SatuanName }} @php $grs = $goodsReceipt[$d->ID] ?? []; @endphp @if (count($grs) > 0) {{ $num0($d->QuantityReceived) }} {{ $d->satuan?->SatuanName }}
@foreach ($grs as $gr) - {{ $gr['lotNumber'] ?? '' }} ( {{ $num0($gr['quantityReceived'] ?? 0) }} {{ $gr['satuan'] ?? '' }} )
@if (filled($gr['expiryDate'] ?? null))ExpDate : {{ $fmtDate($gr['expiryDate']) }}@endif
@if (filled($gr['tanggalMasuk'] ?? null))Receive Date : {{ $fmtDate($gr['tanggalMasuk']) }}@endif
@if (filled($gr['keterangan'] ?? null))Remark : {{ $gr['keterangan'] }}@endif
@endforeach @else There is no receipt of goods @endif
{{ $d->RemarkPM }} {{ $d->RemarkMM }} {{ $d->Project }} {{ $d->Description }} {{ $d->Remark }}
@else {{-- Variants 1,3,4,5: standard details table (legacy L1056, L1495, L1725, L1941) --}} @if ($showRemarkPM)@endif @if ($showRemarkMM)@endif @foreach ($details as $d) @if ($showRemarkPM)@endif @if ($showRemarkMM)@endif @endforeach
ID Status ReqCompany ProductName Quantity Satuan Remarks Description ProjectRemarkPMRemarkMMHistory
{{ $d->ID }} {{ $d->sampleRequestDetailStatus?->SampleRequestStatusName }} {{ $d->reqCompany?->CompanyName }} {{ $d->BarangName }} {{ $num2($d->Quantity) }} {{ $d->satuan?->SatuanName }} {{ $d->Remark }} {{ $d->Description }} {{ $d->Project }}{{ $d->RemarkPM }}{{ $d->RemarkMM }} @foreach (($detailHistory[$d->ID] ?? []) as $a) {{ $a->Tanggal }} | {{ $a->sampleRequestDetailStatus?->SampleRequestStatusName }} | {{ $a->user?->Nama }} | {{ $a->Remark }}
@endforeach
@endif
@if ($showMinStock) {{-- Minimum Stock (legacy L1107-1149) - omitted by GoodsReceiptToPMMM & ToUserRevise --}}

Minimum Stock

@foreach ($minStock as $row) @endforeach
Nama Barang Quantity Qty Minimum
{{ $row['namaBarang'] ?? '' }} @foreach (($row['lots'] ?? []) as $lot) - {{ $lot['lotNumber'] ?? '' }} ({{ $lot['quantity'] ?? '' }} {{ $lot['satuan'] ?? '' }})@if (filled($lot['keterangan'] ?? null))
Keterangan : {{ $lot['keterangan'] }}
@endif @if (filled($lot['tanggalMasuk'] ?? null))
TanggalMasuk : {{ $lot['tanggalMasuk'] }}
@endif
@endforeach
@if (blank($row['qtyMinimum'] ?? null) || (string) ($row['qtyMinimum'] ?? '') === '0')-@else{{ $row['qtyMinimum'] }} {{ $row['satuan'] ?? '' }}@endif
@endif {{-- History Sample Import (legacy L1158-1177) - shared by all five --}}

History Sample Import

@foreach ($history as $a) @endforeach
ID Status Tanggal User Comment
{{ $a->ID }} {{ $a->sampleRequestStatus?->SampleRequestStatusName }} {{ $a->Tanggal }} {{ $a->user?->Nama }} {{ $a->Comment }}