{{-- Komponen Tabel Gabungan Bahan & Sparepart Props: $production, $canEdit (boolean), $canCheckReceived (boolean), $showActions (boolean) --}} @php $orderQty = $production->quantity ?? $production->order->quantity ?? 1; $canEdit = $canEdit ?? false; $canCheckReceived = $canCheckReceived ?? false; $showActions = $showActions ?? false; // Gabungkan materials dan spareparts $allItems = collect(); foreach($production->productionMaterials as $pm) { $totalNeeded = $pm->quantity * $orderQty; $currentStock = $pm->material->stock ?? 0; $allItems->push([ 'id' => $pm->id, 'type' => 'material', 'type_label' => 'Bahan', 'name' => $pm->material->name ?? 'N/A', 'quantity' => $pm->quantity, 'unit' => $pm->unit, 'unit_cost' => $pm->unit_cost, 'total_cost' => $pm->total_cost, 'stock' => $currentStock, 'total_needed' => $totalNeeded, 'stock_ok' => $currentStock >= $totalNeeded, 'is_received' => $pm->is_received ?? false, 'is_admin_suggested' => $pm->is_admin_suggested ?? false, 'revised_at' => $pm->revised_by_teknisi_at, 'model' => $pm, ]); } foreach($production->productionSpareparts as $ps) { $totalNeeded = $ps->quantity * $orderQty; $currentStock = $ps->sparepart->stock ?? 0; $allItems->push([ 'id' => $ps->id, 'type' => 'sparepart', 'type_label' => 'Sparepart', 'name' => $ps->sparepart->name ?? 'N/A', 'quantity' => $ps->quantity, 'unit' => $ps->unit, 'unit_cost' => $ps->unit_cost, 'total_cost' => $ps->total_cost, 'stock' => $currentStock, 'total_needed' => $totalNeeded, 'stock_ok' => $currentStock >= $totalNeeded, 'is_received' => $ps->is_received ?? false, 'is_admin_suggested' => $ps->is_admin_suggested ?? false, 'revised_at' => $ps->revised_by_teknisi_at, 'model' => $ps, ]); } $totalCost = $allItems->sum('total_cost'); $totalMaterial = $production->productionMaterials->sum('total_cost'); $totalSparepart = $production->productionSpareparts->sum('total_cost'); @endphp
{{-- Header --}}

Daftar Bahan & Sparepart

{{ $allItems->count() }} item กค {{ $orderQty }} unit produk

Total Biaya

Rp {{ number_format($totalCost, 0, ',', '.') }}

{{-- Table --}} @if($allItems->count() > 0)
@if($canCheckReceived) @endif @if($showActions) @endif @foreach($allItems as $item) @if($canCheckReceived) @endif @if($showActions) @endif @endforeach
TerimaTipe Nama Item Jumlah Satuan Harga Satuan Total StokAksi
@if($item['type'] === 'material') Bahan @else Sparepart @endif
{{ $item['name'] }}
@if($item['is_admin_suggested']) Admin @endif @if($item['revised_at']) Direvisi @endif
{{ $item['quantity'] }} {{ $item['unit'] }} Rp {{ number_format($item['unit_cost'], 0, ',', '.') }} Rp {{ number_format($item['total_cost'], 0, ',', '.') }} @if($item['stock_ok']) {{ $item['stock'] }} @else {{ $item['stock'] }} @endif
@if($item['is_admin_suggested'] && $canEdit) @endif @if($canEdit) @endif
{{-- Footer Summary --}}
Bahan: Rp {{ number_format($totalMaterial, 0, ',', '.') }} Sparepart: Rp {{ number_format($totalSparepart, 0, ',', '.') }}
Total: Rp {{ number_format($totalCost, 0, ',', '.') }}
@else

Belum ada bahan atau sparepart

Data akan muncul setelah teknisi melakukan planning

@endif