@extends('layouts.admin') @section('title', 'Dashboard Admin - Daftar Pesanan') @section('content') @php $breadcrumbs = [ ['label' => 'Dashboard', 'url' => route('admin.dashboard')], ['label' => 'Pesanan', 'url' => route('admin.master.orders.index')], ]; @endphp

Daftar Pesanan

@if (!empty(request('search')) || !empty($search)) @endif
@if (request('search') || request('order_status') || request('payment_status') || request('production_status') || request('payment_method') || request('order_type'))
Filter Aktif: @if (request('search') || !empty($search)) Pencarian: "{{ request('search') ?? $search }}" @endif @if (request('order_status')) Status Pesanan: {{ ucfirst(request('order_status')) }} @endif @if (request('payment_status')) Status Bayar: {{ ucfirst(str_replace('_', ' ', request('payment_status'))) }} @endif @if (request('production_status')) Status Produksi: {{ ucfirst(str_replace('_', ' ', request('production_status'))) }} @endif @if (request('payment_method')) Metode: {{ strtoupper(request('payment_method')) }} @endif @if (request('order_type')) Jenis: {{ request('order_type') === 'penawaran' ? 'Penawaran' : 'Beli Langsung' }} @endif
@endif
@forelse ($orders as $order) @empty @endforelse
No ID Pesanan Nama Customer Jenis Pesanan Produk Quantity Total Harga Bukti Pembayaran Status Pesanan Status Pembayaran Status Produksi Pembayaran Piutang Status Sale Status Tanggal Aksi
{{ $loop->iteration + $orders->firstItem() - 1 }} #{{ $order->id }}
{{ $order->customer_name }} @if (!$order->is_read) @endif
@php $otype = $order->order_type ?? 'beli_langsung'; @endphp {{ $otype === 'penawaran' ? 'Penawaran' : 'Beli Langsung' }}
@if ($order->product && $order->product->product_image) {{ $order->product->product_title }} @else
@endif {{ Str::limit($order->product->product_title ?? 'N/A', 20) }}
{{ $order->quantity }} {{ $order->formatted_total_price ?? 'Rp ' . number_format($order->total_price, 0, ',', '.') }} @php // Gunakan Storage facade untuk pengecekan file yang lebih akurat // File bukti pembayaran disimpan di disk 'uploads' dalam folder 'proofs' $proofExists = false; $fileUrl = null; if ($order->proof_file) { // Cek apakah file ada di storage $proofExists = \Storage::disk('uploads')->exists($order->proof_file); if ($proofExists) { // Untuk admin, gunakan route admin khusus try { $fileUrl = route('admin.master.orders.proof', $order->id); } catch (\Exception $e) { // Fallback 1: coba route user biasa try { $fileUrl = route('orders.proof', $order->id); } catch (\Exception $e2) { // Fallback 2: gunakan asset() langsung $fileUrl = asset('uploads/' . $order->proof_file); } } } } $extension = $order->proof_file ? pathinfo($order->proof_file, PATHINFO_EXTENSION) : ''; $isImage = in_array(strtolower($extension), [ 'jpg', 'jpeg', 'png', 'gif', 'webp', ]); @endphp @if ($proofExists && $fileUrl)
@if ($isImage) Lihat @else Lihat @endif Download
@elseif($order->proof_file) File hilang @else Belum diupload @endif
@php $orderStatusClasses = [ 'menunggu' => 'bg-yellow-100 dark:bg-yellow-900/40 text-yellow-700 dark:text-yellow-300', 'diterima' => 'bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300', 'ditolak' => 'bg-red-100 dark:bg-red-900/40 text-red-700 dark:text-red-300', ]; @endphp
@csrf @method('PATCH')
@php $paymentStatusClasses = [ 'menunggu' => 'bg-yellow-100 dark:bg-yellow-900/40 text-yellow-700 dark:text-yellow-300', 'diproses' => 'bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300', 'selesai' => 'bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300', 'gagal' => 'bg-red-100 dark:bg-red-900/40 text-red-700 dark:text-red-300', 'dibatalkan' => 'bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-200', ]; @endphp
@csrf @method('PATCH')
@php $prodColors = [ 'menunggu' => 'bg-yellow-100 dark:bg-yellow-900/40 text-yellow-700 dark:text-yellow-300', 'dalam_proses' => 'bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300', 'selesai' => 'bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300', 'dibatalkan' => 'bg-red-100 dark:bg-red-900/40 text-red-700 dark:text-red-300', ]; $prodLabels = [ 'menunggu' => 'Menunggu', 'dalam_proses' => 'Dalam Proses', 'selesai' => 'Selesai', 'dibatalkan' => 'Dibatalkan', ]; @endphp {{ $prodLabels[$order->production_status] ?? 'Menunggu' }}
{{ ucfirst($order->payment_method ?? '-') }} @if ($order->payment_method === 'dp') DP: {{ number_format($order->dp_percentage ?? 30.0, 0) }}% @endif
@if ($order->payment_method === 'dp' && $order->receivable)
@if ($order->receivable->payment_status === 'pending') Belum Bayar @elseif($order->receivable->payment_status === 'partial') Bayar Sebagian @elseif($order->receivable->payment_status === 'paid') Lunas @elseif($order->receivable->payment_status === 'overdue') Jatuh Tempo @endif Piutang
@else - @endif
@if ($order->sale)
Sudah Jadi Sale Penjualan
@else Belum Jadi Sale @endif
@php $isRead = $order->is_read ?? false; @endphp @if ($isRead) Dibaca @else Belum Dibaca @endif {{ $order->created_at->format('d M Y H:i') }}
{{-- Tombol ke Menu Produksi: muncul jika order diterima & pembayaran selesai/diproses --}} @php $canGoToProduction = $order->order_status === 'diterima' && (($order->payment_method === 'transfer' && $order->status === 'selesai') || ($order->payment_method === 'dp' && in_array($order->status, ['selesai', 'diproses'])) || ($order->payment_method === 'cod' && $order->status === 'selesai')); @endphp @if ($canGoToProduction) @if ($order->production) @else @endif @endif @if (!$order->is_read) @endif

Belum ada pesanan

Mulai dengan menambahkan pesanan pertama

@if ($orders->hasPages())
{{ $orders->onEachSide(1)->links() }}
@endif
@endsection