@extends('layouts.admin') @section('title', 'Daftar Produksi') @section('content') @php $breadcrumbs = [ ['label' => 'Dashboard', 'url' => route('admin.dashboard')], ['label' => 'Master', 'url' => '#'], ['label' => 'Produksi', 'url' => route('admin.productions.index')], ]; @endphp {{-- Quick Stats --}} @php $totalProductions = \App\Models\Production::count(); $unassignedCount = \App\Models\Production::whereNull('teknisi_id') ->whereNotIn('status', ['selesai', 'dibatalkan']) ->count(); $inProgressCount = \App\Models\Production::where('status', 'dalam_proses')->count(); $completedCount = \App\Models\Production::where('status', 'selesai')->count(); @endphp

Total Produksi

{{ $totalProductions }}

Belum Ditugaskan

{{ $unassignedCount }}

@if ($unassignedCount > 0)

Klik untuk lihat →

@endif

Dalam Proses

{{ $inProgressCount }}

Selesai

{{ $completedCount }}

Daftar Produksi

@if (request('search')) @endif
@if (request('search') || request('status') || request()->filled('teknisi'))
Filter Aktif: @if (request('search')) Pencarian: "{{ request('search') }}" @endif @if (request('status')) @php $statusLabels = [ 'menunggu' => 'Menunggu', 'dalam_proses' => 'Dalam Proses', 'selesai' => 'Selesai', 'dibatalkan' => 'Dibatalkan', ]; $statusLabel = $statusLabels[request('status')] ?? ucfirst(request('status')); @endphp Status: {{ $statusLabel }} @endif @if (request()->filled('teknisi')) Penugasan: {{ request('teknisi') === 'unassigned' ? 'Belum Ditugaskan' : 'Sudah Ditugaskan' }} @endif
@endif
@forelse ($productions as $production) @empty @endforelse
No Order Info Gambar Produk Status Planning Teknisi Pembayaran Periode Total Biaya Aksi
{{ $loop->iteration + $productions->firstItem() - 1 }}
#{{ $production->order->id }}
@php // Hitung jumlah bahan dan sparepart yang direvisi oleh teknisi $revisedMaterialsCount = $production->productionMaterials ->where('is_admin_suggested', true) ->whereNotNull('revised_by_teknisi_at') ->count(); $revisedSparepartsCount = $production->productionSpareparts ->where('is_admin_suggested', true) ->whereNotNull('revised_by_teknisi_at') ->count(); $totalRevised = $revisedMaterialsCount + $revisedSparepartsCount; @endphp @if ($totalRevised > 0)
{{ $totalRevised }}
@endif

{{ $production->order->customer_name ?? 'N/A' }}

@if ($totalRevised > 0) Revisi @endif

Order ID: {{ $production->order->id }}

@if ($production->product && $production->product->product_image) Gambar Produk @elseif ($production->product && $production->product->images && $production->product->images->count() > 0) Gambar Produk @else
@endif

{{ $production->product->product_title }}

Qty: {{ $production->order->quantity ?? 1 }} unit

Kategori: {{ $production->product->category_name }}

@php $statusConfig = [ 'menunggu' => [ 'bg' => 'bg-gray-100', 'text' => 'text-gray-700', 'icon' => 'fa-clock', ], 'dalam_proses' => [ 'bg' => 'bg-yellow-100', 'text' => 'text-yellow-700', 'icon' => 'fa-spinner', ], 'selesai' => [ 'bg' => 'bg-green-100', 'text' => 'text-green-700', 'icon' => 'fa-check-circle', ], 'dibatalkan' => [ 'bg' => 'bg-red-100', 'text' => 'text-red-700', 'icon' => 'fa-times-circle', ], ]; $config = $statusConfig[$production->status] ?? [ 'bg' => 'bg-gray-100', 'text' => 'text-gray-700', 'icon' => 'fa-question', ]; @endphp {{ ucfirst(str_replace('_', ' ', $production->status)) }} @if ($production->teknisi_id) @if ($production->planning_status === 'planning') Planning @elseif($production->planning_status === 'pending_approval') Pending @elseif($production->planning_status === 'approved') Approved @elseif($production->planning_status === 'rejected') Rejected @else {{ ucfirst($production->planning_status ?? 'N/A') }} @endif @else - @endif @if ($production->teknisi_id)
{{ strtoupper(substr($production->teknisi->name, 0, 1)) }}

{{ $production->teknisi->name }}

Kepala Produksi

@if ($production->assigned_at)

Ditugaskan: {{ $production->assigned_at->format('d/m/Y H:i') }}

@endif @else Belum Ditugaskan @endif
@php $paymentStatus = $production->order->status ?? 'menunggu'; $paymentMethod = strtolower($production->order->payment_method ?? 'transfer'); // Payment Status Config $paymentStatusConfig = [ 'selesai' => [ 'label' => 'Lunas', 'bg' => 'bg-green-100 dark:bg-green-900/40', 'text' => 'text-green-800 dark:text-green-300', 'icon' => 'fa-check-circle', ], 'diproses' => [ 'label' => 'Diproses', 'bg' => 'bg-blue-100 dark:bg-blue-900/40', 'text' => 'text-blue-800 dark:text-blue-300', 'icon' => 'fa-spinner', ], 'menunggu_verifikasi' => [ 'label' => 'Verifikasi', 'bg' => 'bg-yellow-100 dark:bg-yellow-900/40', 'text' => 'text-yellow-800 dark:text-yellow-300', 'icon' => 'fa-clock', ], 'menunggu' => [ 'label' => 'Menunggu', 'bg' => 'bg-gray-100 dark:bg-gray-700/50', 'text' => 'text-gray-700 dark:text-gray-300', 'icon' => 'fa-clock', ], ]; $statusConfig = $paymentStatusConfig[$paymentStatus] ?? [ 'label' => ucfirst(str_replace('_', ' ', $paymentStatus)), 'bg' => 'bg-gray-100 dark:bg-gray-700/50', 'text' => 'text-gray-700 dark:text-gray-300', 'icon' => 'fa-question', ]; // Payment Method Colors $paymentMethodColors = [ 'transfer' => 'bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300', 'qris' => 'bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-300', 'dp' => 'bg-purple-50 dark:bg-purple-900/20 text-purple-700 dark:text-purple-300', 'cod' => 'bg-orange-50 dark:bg-orange-900/20 text-orange-700 dark:text-orange-300', ]; $methodClass = $paymentMethodColors[$paymentMethod] ?? 'bg-gray-50 dark:bg-gray-700/30 text-gray-600 dark:text-gray-400'; @endphp
{{ $statusConfig['label'] }}
{{ strtoupper($paymentMethod) }}
{{ $production->start_date?->format('d/m/Y') ?? 'N/A' }}
@if ($production->end_date)
{{ $production->end_date->format('d/m/Y') }}
@endif
@php // Perhitungan yang benar: // - total_material_cost & total_sparepart_cost di DB sudah TOTAL (sudah dikalikan dengan order quantity) // - labor_cost di DB adalah TOTAL untuk semua produk $materialTotal = $production->total_material_cost ?? 0; // Sudah TOTAL di DB $sparepartTotal = $production->total_sparepart_cost ?? 0; // Sudah TOTAL di DB $directTotal = $materialTotal + $sparepartTotal; // Sudah TOTAL $laborTotal = $production->labor_cost ?? 0; // Sudah TOTAL di DB $actualTotal = $directTotal + $laborTotal; // Sudah TOTAL @endphp
Rp {{ number_format($actualTotal, 0, ',', '.') }}
Material: Rp {{ number_format($materialTotal, 0, ',', '.') }}
Sparepart: Rp {{ number_format($sparepartTotal, 0, ',', '.') }}
@if ($laborTotal > 0)
Upah: Rp {{ number_format($laborTotal, 0, ',', '.') }}
@endif
@if(in_array($production->status, ['dalam_proses', 'selesai'])) @endif @if (in_array($production->status, ['dalam_proses', 'menunggu']))
@csrf
@endif @if (!in_array($production->status, ['selesai', 'dibatalkan'])) @if (!$production->teknisi_id)
@csrf
@else
@csrf
@endif @endif @if ($production->status !== 'selesai')
@csrf @method('DELETE')
@endif

Belum ada data produksi

Produksi akan muncul setelah order diterima

@if ($productions->hasPages())
{{ $productions->onEachSide(1)->links() }}
@endif {{-- CSRF & Axios setup --}} @endsection