Maintenance Tools
@extends('layouts.admin') @section('title', 'Detail Produksi - Admin') @section('content') @php $orderQty = $production->quantity ?? $production->order->quantity ?? 1; $materialTotal = $production->total_material_cost ?? 0; $sparepartTotal = $production->total_sparepart_cost ?? 0; $directTotal = $materialTotal + $sparepartTotal; $laborTotal = $production->labor_cost ?? 0; $actualTotal = $directTotal + $laborTotal; $totalCost = $actualTotal; @endphp
Order #{{ $production->order->id ?? 'N/A' }} · {{ $production->order->customer_name ?? 'N/A' }}
Maintenance Tools
Pilih teknisi yang akan mengerjakan produksi ini.
Teknisi: {{ $production->teknisi->name ?? 'N/A' }} @if($production->assigned_at) ({{ $production->assigned_at->format('d M Y H:i') }}) @endif
{{ $pendingRequests->count() }} request baru dari teknisi perlu ditinjau
| Item | Tipe | Jumlah | Satuan | Harga/Unit | Total | Stok | Status Ketersediaan | Alasan | Diminta Oleh | 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 * $orderQty; $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) }} |
{{ $request->requester->name ?? 'N/A' }}
{{ $request->created_at->format('d/m/Y H:i') }} |
Dikelompokkan berdasarkan usulan pertama, kedua, ketiga @if($pendingRequests->count() > 0) · Item pending juga ada di notifikasi di atas @endif
| Item | Tipe | Jumlah | Satuan | Harga/Unit | Total | Stok | Status Ketersediaan | Alasan | Status | Aksi |
|---|---|---|---|---|---|---|---|---|---|---|
|
{{ $request->item_name_display }}
@if($request->status === 'pending')
Pending
@endif
@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 * $orderQty; $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 }} |
Admin bisa input bahan dan sparepart sebagai "suggested" untuk teknisi.
Ada item yang belum dikirim ke teknisi
{{ $production->productionMaterials->count() + $production->productionSpareparts->count() }} item · {{ $orderQty }} unit produk
Belum ada bahan atau sparepart ditambahkan
Teknisi akan menginput bahan dan sparepart setelah ditugaskan
Upah untuk {{ $orderQty }} unit
@if($production->servicePackage)
{{ $production->servicePackage->name }}
@endif
Rp {{ number_format($laborTotal, 0, ',', '.') }}
Per unit: Rp {{ number_format($laborTotal / max($orderQty, 1), 0, ',', '.') }}
@if($production->labor_package_count && $production->labor_package_count != $orderQty)Jumlah paket: {{ $production->labor_package_count }}
@endifLangsung: 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($orderQty, 1), 0, ',', '.') }}
{{ $production->notes }}
Belum ada catatan
@endif{{ $production->notes }}