@extends('layouts.teknisi') @section('title', 'Detail Produksi - Teknisi') @section('content')
{{ $production->supervisor_feedback }}
{{ $production->productionMaterials->count() + $production->productionSpareparts->count() }} item · {{ $production->quantity ?? 1 }} unit produk
| Nama Item | Tipe | Jumlah | Satuan | Harga/Unit | Total | Stok | Status Ketersediaan | @if ($canEdit)Aksi | @elseif($canCheckReceived)Diterima | @endif
|---|---|---|---|---|---|---|---|---|---|
|
{{ $item['name'] }}
@if ($item['is_admin_suggested'])
Admin
@endif
@if ($item['revised_at'])
Direvisi
@endif
|
@if ($item['type'] === 'material') Bahan @else Sparepart @endif | {{ $item['quantity'] }} | {{ $item['unit'] }} | Rp {{ number_format($item['unit_cost'], 0, ',', '.') }} | Rp {{ number_format($item['total_cost'], 0, ',', '.') }} |
{{ $item['stock'] }}
Butuh: {{ $item['total_needed'] }}
|
@if ($item['stock_status'] === 'available')
@elseif($item['stock_status'] === 'insufficient')
@else
@endif
{{ $item['stock_status_label'] }}
@if ($item['stock_status'] !== 'available')
@if ($item['stock_status'] === 'insufficient')
Kurang: {{ $item['total_needed'] - $item['stock'] }}
{{ $item['unit'] }}
@else
Stok: 0
@endif
@endif
|
@if ($canEdit)
@if ($item['is_admin_suggested'])
@endif
|
@elseif($canCheckReceived)
@if ($item['stock_ok']) @else @endif | @endif
{{ $unavailableItems->count() }} item stok tidak mencukupi
Item dengan stok kurang tidak dapat di-checklist. Hubungi Admin untuk melakukan pembelian.
Belum ada bahan atau sparepart ditambahkan
Klik "Tambah Item" untuk menambahkan
Butuh bahan/sparepart yang tidak ada di sistem? Request ke Admin
{{ $request->item_name_display }}
{{ (int)$request->quantity }} {{ $request->unit }} • {{ Str::limit($request->reason, 40) }}
Dikelompokkan berdasarkan usulan pertama, kedua, ketiga
| Item | Tipe | Jumlah | Satuan | Harga/Unit | Total | Stok | Status Ketersediaan | Alasan | Status | Tanggal | Aksi |
|---|---|---|---|---|---|---|---|---|---|---|---|
|
{{ $request->item_name_display }}
@if ($request->is_new_item)
Item Baru
@endif
|
@if ($request->item_type === 'material') Bahan @else Sparepart @endif | @php $quantity = (int)$request->quantity; // Ambil harga: prioritas dari relasi material/sparepart, jika tidak ada cari di master berdasarkan nama, terakhir pakai estimated_price $estimatedPrice = 0; if ($request->item_type === 'material' && $request->material) { $estimatedPrice = $request->material->price ?? $request->estimated_price ?? 0; } elseif ($request->item_type === 'sparepart' && $request->sparepart) { $estimatedPrice = $request->sparepart->price ?? $request->estimated_price ?? 0; } else { // Item baru: coba cari di master barang berdasarkan nama if ($request->item_name) { if ($request->item_type === 'material') { // Coba exact match dulu $foundMaterial = \App\Models\Material::where('name', $request->item_name)->first(); // Jika tidak ada, coba partial match if (!$foundMaterial) { $foundMaterial = \App\Models\Material::where('name', 'LIKE', '%' . trim($request->item_name) . '%')->first(); } if ($foundMaterial) { $estimatedPrice = $foundMaterial->price ?? $request->estimated_price ?? 0; } else { $estimatedPrice = $request->estimated_price ?? 0; } } else { // Coba exact match dulu $foundSparepart = \App\Models\Sparepart::where('name', $request->item_name)->first(); // Jika tidak ada, coba partial match if (!$foundSparepart) { $foundSparepart = \App\Models\Sparepart::where('name', 'LIKE', '%' . trim($request->item_name) . '%')->first(); } if ($foundSparepart) { $estimatedPrice = $foundSparepart->price ?? $request->estimated_price ?? 0; } else { $estimatedPrice = $request->estimated_price ?? 0; } } } else { $estimatedPrice = $request->estimated_price ?? 0; } } $totalPrice = $quantity * $estimatedPrice; // Ambil stok terbaru dari database (fresh) $currentStock = 0; if ($request->item_type === 'material' && $request->material_id) { $material = \App\Models\Material::find($request->material_id); $currentStock = $material ? $material->stock : 0; } elseif ($request->item_type === 'sparepart' && $request->sparepart_id) { $sparepart = \App\Models\Sparepart::find($request->sparepart_id); $currentStock = $sparepart ? $sparepart->stock : 0; } $totalNeeded = $quantity * ($production->quantity ?? 1); $stockStatus = 'available'; $stockStatusLabel = 'Tersedia'; $stockStatusClass = 'bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300'; $stockStatusIcon = 'check-circle'; if ($currentStock < $totalNeeded) { if ($currentStock == 0) { $stockStatus = 'pending_purchase'; $stockStatusLabel = 'Perlu Pembelian'; $stockStatusClass = 'bg-red-100 dark:bg-red-900/40 text-red-700 dark:text-red-300'; $stockStatusIcon = 'times-circle'; } else { $stockStatus = 'insufficient'; $stockStatusLabel = 'Perlu Pembelian (Kurang)'; $stockStatusClass = 'bg-amber-100 dark:bg-amber-900/40 text-amber-700 dark:text-amber-300'; $stockStatusIcon = 'exclamation-triangle'; } } @endphp{{ $quantity }} | {{ $request->unit }} | @if($estimatedPrice > 0) Rp {{ number_format($estimatedPrice, 0, ',', '.') }} @else - @endif | @if($totalPrice > 0) Rp {{ number_format($totalPrice, 0, ',', '.') }} @else - @endif |
{{ $currentStock }}
Butuh: {{ $totalNeeded }}
|
{{ $stockStatusLabel }}
@if($stockStatus !== 'available')
@if($stockStatus === 'insufficient')
Kurang: {{ $totalNeeded - $currentStock }} {{ $request->unit }}
@else
Stok: 0
@endif
@endif
|
{{ Str::limit($request->reason, 50) }} |
@if ($request->status === 'pending')
@elseif($request->status === 'approved')
@elseif($request->status === 'rejected')
@elseif($request->status === 'purchased')
@elseif($request->status === 'sent')
@elseif($request->status === 'received')
@endif
{{ $request->status_label }}
@if (in_array($request->status, ['sent', 'purchased']) && in_array($production->status, ['menunggu', 'dalam_proses']))
|
{{ $request->requested_at->format('d/m/Y H:i') }} | @if (in_array($request->status, ['sent', 'purchased']) && in_array($production->status, ['menunggu', 'dalam_proses'])) @elseif($request->status === 'received') Sudah Dikonfirmasi @else - @endif |
Upah untuk {{ $production->quantity ?? 1 }} unit
Rp {{ number_format($laborTotal, 0, ',', '.') }}
Per unit: Rp {{ number_format($laborTotal / max($production->quantity ?? 1, 1), 0, ',', '.') }}
Langsung: Rp {{ number_format($directTotal, 0, ',', '.') }} @if ($laborTotal > 0) · Labor: Rp {{ number_format($laborTotal, 0, ',', '.') }} @endif
Rp {{ number_format($actualTotal, 0, ',', '.') }}
Per unit: Rp {{ number_format($actualTotal / max($production->quantity ?? 1, 1), 0, ',', '.') }}