@extends('layouts.admin') @section('title', 'Detail Pesanan #' . $order->id) @section('content')

Detail Pesanan #{{ $order->id }}

Dibuat pada {{ $order->created_at->format('d M Y H:i') }}

@if ($order->product && $order->product->product_image)
{{ $order->product->product_title }}

{{ $order->product->product_title }}

Produk Pesanan

@endif

Informasi Customer

Nama: {{ $order->customer_name }}
Email: {{ $order->customer_email }}
Telepon: {{ $order->phone_number }}
Alamat: {{ $order->address }}

Detail Pesanan

Produk: {{ Str::limit($order->product->product_title ?? 'N/A', 30) }}
Quantity: {{ $order->quantity }}
Total: {{ $order->formatted_total_price }}
Bayar: {{ ucfirst($order->payment_method ?? '-') }}
@if($order->payment_method === 'dp')
DP:
{{ number_format($order->dp_percentage ?? 30.00, 0) }}%
@csrf @method('PATCH')
(15-50%)
@endif
Jenis: @php $otype = $order->order_type ?? 'beli_langsung'; @endphp {{ $otype === 'penawaran' ? 'Penawaran' : 'Beli Langsung' }}

Status

@csrf @method('PATCH')
@csrf @method('PATCH')
@if($order->order_status === 'ditolak' && $order->rejection_reason)

Alasan Penolakan:

{{ $order->rejection_reason }}

@if($order->rejected_at)

Ditolak pada: {{ $order->rejected_at->format('d M Y H:i') }} @if($order->rejectedBy) oleh {{ $order->rejectedBy->name }} @endif

@endif
@endif
@php $prodStatus = $order->production_status ?? 'menunggu'; $prodStatusLabels = [ 'menunggu' => 'Menunggu', 'dalam_proses' => 'Dalam Proses', 'selesai' => 'Selesai', 'dibatalkan' => 'Dibatalkan' ]; $prodStatusColors = [ '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' ]; @endphp
{{ $prodStatusLabels[$prodStatus] ?? 'Menunggu' }}

Status produksi diatur otomatis melalui workflow

Bukti Pembayaran

@php // Cek apakah file benar-benar ada di storage $proofExists = false; $fileUrl = null; $isImage = false; 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 = pathinfo($order->proof_file, PATHINFO_EXTENSION); $isImage = in_array(strtolower($extension), ['jpg', 'jpeg', 'png', 'gif', 'webp']); } } @endphp @if ($order->proof_file && $proofExists && $fileUrl)

File: {{ Str::limit(basename($order->proof_file), 30) }}

Uploaded: {{ $order->updated_at->format('d M Y H:i') }}

@if($isImage)
Bukti Pembayaran
@endif
@elseif($order->proof_file && !$proofExists)

File bukti pembayaran tidak ditemukan di storage

Path: {{ $order->proof_file }}

@else

Belum ada bukti pembayaran yang diunggah

@endif
@if($order->inquiry)

Spesifikasi Tambahan (Penawaran)

@php $raw = $order->inquiry->message ?? ''; $lines = preg_split("/(\r\n|\n|\r)/", $raw); $type = null; $addons = []; $hasAddonsLine = false; if (!empty($lines)) { $first = $lines[0] ?? ''; $second = $lines[1] ?? ''; if (substr($first, 0, 14) === '[REQUEST_TYPE]') { $type = trim(substr($first, 14)); } if (substr($second, 0, 8) === '[ADDONS]') { $hasAddonsLine = true; $matches = []; if (preg_match('/^\[ADDONS\]\s*(\[[\s\S]*\])$/', $second, $matches)) { $decoded = json_decode($matches[1], true); if (is_array($decoded)) { $addons = $decoded; } } } } $startIdx = 0; if ($type) { $startIdx++; } if ($hasAddonsLine) { $startIdx++; } if (!empty($lines) && isset($lines[$startIdx]) && trim($lines[$startIdx]) === '') { $startIdx++; } $plain = implode("\n", array_slice($lines, $startIdx)); $badgeText = $type === 'custom_addon' ? 'Custom Add-on' : ($type === 'custom_new' ? 'Custom Baru' : ($type ? 'Katalog' : null)); $badgeCls = $type === 'custom_addon' ? 'bg-yellow-100 dark:bg-yellow-900/40 text-yellow-700 dark:text-yellow-300' : ($type === 'custom_new' ? 'bg-red-100 dark:bg-red-900/40 text-red-700 dark:text-red-300' : 'bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300'); @endphp @if($badgeText) {{ $badgeText }} @endif
@php $materials = is_array($order->inquiry->materials_breakdown ?? null) ? $order->inquiry->materials_breakdown : []; $spareparts = is_array($order->inquiry->spareparts_breakdown ?? null) ? $order->inquiry->spareparts_breakdown : []; @endphp @if(!empty($addons))
Pilihan Tambahan
@php $preview = collect($addons)->map(function($a){ $name = is_array($a) ? ($a['name'] ?? ($a['label'] ?? '')) : ''; $value = is_array($a) ? ($a['value'] ?? ($a['selected'] ?? '')) : ''; return trim(($name ?: '-') . ': ' . ($value ?: '-')); })->implode("\n"); @endphp
{{ $preview }}
@endif @if(!empty($materials))
Bahan Tambahan
@foreach($materials as $m) @php $n = is_array($m) ? ($m['name'] ?? ($m['material_name'] ?? '')) : ''; $q = is_array($m) ? ($m['quantity'] ?? ($m['qty'] ?? '')) : ''; $u = is_array($m) ? ($m['unit'] ?? '') : ''; $c = is_array($m) ? ($m['unit_cost'] ?? ($m['cost'] ?? '')) : ''; @endphp
{{ $n ?: '-' }} — {{ $q ?: '-' }} {{ $u }}
@if($c !== '')
Rp {{ is_numeric($c) ? number_format($c, 0, ',', '.') : $c }}
@endif
@endforeach
@endif @if(!empty($spareparts))
Sparepart Tambahan
@foreach($spareparts as $s) @php $n = is_array($s) ? ($s['name'] ?? ($s['part_name'] ?? '')) : ''; $q = is_array($s) ? ($s['quantity'] ?? ($s['qty'] ?? '')) : ''; $u = is_array($s) ? ($s['unit'] ?? '') : ''; $c = is_array($s) ? ($s['unit_cost'] ?? ($s['cost'] ?? '')) : ''; @endphp
{{ $n ?: '-' }} — {{ $q ?: '-' }} {{ $u }}
@if($c !== '')
Rp {{ is_numeric($c) ? number_format($c, 0, ',', '.') : $c }}
@endif
@endforeach
@endif @if(trim($plain) !== '')
Catatan Customer

{{ $plain }}

@endif
@endif @endsection @section('styles') @endsection @push('scripts') @endpush