@php
$ordersCount = count($orders_data ?? []);
$titleOrder = $ordersCount === 1 ? ($orders_data[0]['order_no'] ?? 'Report') : ($ordersCount > 1 ? "({$ordersCount} Orders)" : ($meta['order_no'] ?? 'Report'));
@endphp
📄 Preview Dokumen: Batch Decision
@if(count($docsList) === 1)
(Order: {{ $docsList[0]['order_no'] }})
@else
({{ count($docsList) }} Order Terpilih)
@endif
@php
$currentUser = auth()->user();
$userRoles = $currentUser ? (method_exists($currentUser, 'getRolesListAttribute') ? $currentUser->roles_list : array_map('trim', explode(',', $currentUser->idroles ?? ''))) : [];
$isCurrentUserAdmin = $currentUser && ($currentUser->username === 'msjit' || (method_exists($currentUser, 'isMsjIt') && $currentUser->isMsjIt()) || in_array('admins', $userRoles) || in_array('admbat', $userRoles));
@endphp
@if($isCurrentUserAdmin)
@php
$excelParams = request()->query();
$excelParams['print_process_order'] = $allOrdersStr;
$excelParams['order_no'] = $allOrdersStr;
@endphp
📊 Download Excel ({{ count($docsList) }} Order)
@endif
@endif
@foreach($docsList as $docIndex => $doc)
@php
$mMeta = $doc['meta'] ?? [];
$mOverview = $doc['overview'] ?? [];
$mInspeksi = $doc['inspeksi'] ?? [];
$mNonConf = $doc['non_conf'] ?? [];
$mNonConforming = $doc['non_conforming'] ?? [];
$mDecision = $doc['decision'] ?? [];
$mOffGrade = $doc['off_grade_batches'] ?? collect([]);
@endphp
{{-- 1. HEADER LOGO & COMPANY --}}
@php
$logoPath = public_path('storage/logo_msj_full.png');
$logoSrc = file_exists($logoPath) ? 'data:image/png;base64,' . base64_encode(file_get_contents($logoPath)) : asset('storage/logo_msj_full.png');
@endphp
{{-- 2. DOCUMENT TITLE --}}
BATCH DECISION
{{-- 3. METADATA SECTION (2 COLUMNS) --}}
{{-- 4. MIDDLE SECTION: SUMMARY BOXES --}}
{{-- ROW 1: Overview & Qty Inspeksi (Left) vs Approval & Keputusan (Right) --}}
{{-- LEFT COLUMN TOP --}}
|
{{-- Overview Box --}}
Overview
| Grade A/B |
{{ $mOverview['grade_ab'] ?? 0 }} |
| Grade C |
{{ $mOverview['grade_c'] ?? 0 }} |
| Grade D |
{{ ($mOverview['grade_d'] ?? 0) > 0 ? $mOverview['grade_d'] : '0' }} |
| Qty Produksi |
{{ ($mOverview['grade_ab'] ?? 0) + ($mOverview['grade_c'] ?? 0) + ($mOverview['grade_d'] ?? 0) }} |
{{-- Qty Inspeksi Box --}}
Qty Inspeksi
| Cek OK |
{{ $mInspeksi['cek_ok'] ?? 0 }} |
| Cek Not OK |
{{ $mInspeksi['cek_not_ok'] ?? 0 }} |
| Actual Cek |
{{ $mInspeksi['actual_cek'] ?? 0 }} |
|
{{-- RIGHT COLUMN TOP --}}
{{-- Spacer to align horizontally with Overview table --}}
{{-- Tanda Tangan / Approval Box --}}
| Dibuat |
Mengetahui |
Disetujui |
|
|
|
|
| Petugas QC |
Line Control |
Supervisor |
{{-- Keputusan Box --}}
Keputusan
|
[ ] Hold / Re-inspeksi
|
[ ] Rework Keseluruhan
|
|
[ ] OK / Release
|
[ ] Rework Sebagian
|
|
{{-- ROW 2: Inspeksi Data & Frekuensi Non Conforming (Left) vs Catatan Box (Right) --}}
{{-- LEFT COLUMN BOTTOM --}}
|
{{-- Inspeksi Data Box --}}
Inspeksi Data
| Frekuensi Non Conformities |
Ac |
Re |
| Critical |
{{ ($mNonConf['critical'] ?? 0) > 0 ? $mNonConf['critical'] : '' }} |
{{ $mNonConf['critical_ac'] ?? 0 }} |
{{ $mNonConf['critical_re'] ?? 0 }} |
| Major |
{{ ($mNonConf['major'] ?? 0) > 0 ? $mNonConf['major'] : '' }} |
{{ $mNonConf['major_ac'] ?? 0 }} |
{{ $mNonConf['major_re'] ?? 1 }} |
| Minor |
{{ ($mNonConf['minor'] ?? 0) > 0 ? $mNonConf['minor'] : '' }} |
{{ $mNonConf['minor_ac'] ?? 0 }} |
{{ $mNonConf['minor_re'] ?? 1 }} |
{{-- Frekuensi Non Conforming Box --}}
| Frekuensi Non Conforming |
Ac / Re |
% |
| OK |
{{ $mNonConforming['ok'] ?? 0 }} |
{{ ($mNonConforming['ac'] ?? 0) }} / {{ ($mNonConforming['re'] ?? 1) }} |
{{ number_format($mNonConforming['pct_ok'] ?? 0, 2, ',', '.') }} % |
| Not OK |
{{ $mNonConforming['not_ok'] ?? 0 }} |
|
{{-- RIGHT COLUMN BOTTOM --}}
{{-- Catatan Box --}}
Catatan
|
{{-- 5. DETAIL PRODUK OFF GRADE TABLE --}}
Detail Produk Off Grade
| No |
Roll |
Jumbo |
P(m) |
L(m) |
W(kg) |
Grd |
Remark |
Condition |
@forelse($mOffGrade as $index => $item)
| {{ $loop->iteration }} |
{{ $item->batch_no }} |
{{ $item->jumbo_roll ?? '-' }} |
{{ $item->length !== null ? number_format($item->length > 100 ? $item->length / 1000 : $item->length, 3, ',', '.') : '-' }}
|
{{ $item->width !== null ? number_format($item->width > 100 ? $item->width / 1000 : $item->width, 3, ',', '.') : '-' }}
|
{{ ($item->weight ?? $item->quantity) !== null ? number_format((float) ($item->weight ?? $item->quantity), 3, ',', '.') : '-' }}
|
{{ $item->validation_grade ?? '-' }} |
@php
$remarkText = (!empty($item->ddtext) && !in_array(strtoupper(trim($item->ddtext)), ['QC', 'PRD', 'MKT'], true))
? $item->ddtext
: ((!empty($item->validation_remark) && !in_array(strtoupper(trim($item->validation_remark)), ['QC', 'PRD', 'MKT'], true))
? $item->validation_remark
: (!empty($item->ddtext) ? $item->ddtext : 'Prop off spec'));
@endphp
{{ $remarkText }} |
{{ $item->validation_condition ?? '-' }} |
@empty
|
Tidak ada produk off-grade untuk order ini.
|
@endforelse
{{-- 6. FOOTER --}}
{{-- Page break for mPDF when multiple orders --}}
@if(!empty($is_pdf) && $is_pdf && !$loop->last)