@extends('layouts.main') {{-- Asumsi layout user --}} @section('title', 'Detail Order #' . $order->id) @section('content')

Detail Pesanan

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

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

@if($order->production) @php $production = $order->production; @endphp
@include('shared.partials.production-timeline', ['production' => $production, 'showEstimate' => true]) @php $hasPendingApproval = $order->production->planning_status === 'pending_approval' || $order->production->completion_status === 'pending_approval'; $planningPendingTooLong = false; $completionPendingTooLong = false; if ($order->production->planning_status === 'pending_approval' && $order->production->submitted_at) { $daysPending = now()->diffInDays($order->production->submitted_at); $planningPendingTooLong = $daysPending > 3; } if ($order->production->completion_status === 'pending_approval' && $order->production->completed_at) { $daysPending = now()->diffInDays($order->production->completed_at); $completionPendingTooLong = $daysPending > 2; } @endphp @if($hasPendingApproval)
@if($planningPendingTooLong || $completionPendingTooLong) @else @endif

@if($planningPendingTooLong || $completionPendingTooLong) Menunggu Persetujuan (Lebih Lama dari Biasa) @else Menunggu Persetujuan @endif

@if($order->production->planning_status === 'pending_approval') @if($planningPendingTooLong) Planning produksi sudah menunggu persetujuan supervisor selama {{ now()->diffInDays($order->production->submitted_at) }} hari. @if($order->production->submitted_at) (Disubmit: {{ $order->production->submitted_at->format('d M Y') }}) @endif
Jika sudah lebih dari 3 hari, silakan hubungi customer service untuk follow-up. @else Planning produksi sedang menunggu persetujuan supervisor. @if($order->production->submitted_at) (Disubmit: {{ $order->production->submitted_at->format('d M Y') }}) @endif Kami akan memproses segera setelah disetujui. @endif @elseif($order->production->completion_status === 'pending_approval') @if($completionPendingTooLong) Produksi telah selesai dan menunggu persetujuan final selama {{ now()->diffInDays($order->production->completed_at) }} hari. @if($order->production->completed_at) (Selesai: {{ $order->production->completed_at->format('d M Y') }}) @endif
Jika sudah lebih dari 2 hari, silakan hubungi customer service untuk follow-up. @else Produksi telah selesai dan sedang menunggu persetujuan final dari supervisor. @if($order->production->completed_at) (Selesai: {{ $order->production->completed_at->format('d M Y') }}) @endif Produk akan segera siap setelah disetujui. @endif @endif

@if($planningPendingTooLong || $completionPendingTooLong) @endif
@endif
@elseif($order->order_status === 'diterima' && $order->status === 'selesai')

Pembayaran Selesai

Pembayaran Anda sudah selesai. Pesanan sedang dipersiapkan untuk masuk tahap produksi.
Kami akan segera menghubungi Anda ketika produksi dimulai.

@endif

Informasi Pesanan

Detail pesanan Anda

Produk

{{ $order->product->product_title ?? 'N/A' }}

Quantity

{{ $order->quantity }} unit

Total Harga

{{ $order->formatted_total_price }}

Metode Pembayaran

{{ ucfirst($order->payment_method) }}

@if($order->payment_method === 'dp') @php // Hitung informasi pembayaran DP $dpPercentage = $order->dp_percentage ?? 30.00; $dpAmount = $order->total_price * ($dpPercentage / 100); // Cek receivable untuk melihat pembayaran yang sudah dilakukan // Receivable adalah sumber data yang paling akurat untuk pembayaran DP $paidAmount = 0; $remainingAmount = $order->total_price; if ($order->receivable) { // Gunakan data dari receivable (paling akurat) $paidAmount = $order->receivable->paid_amount ?? 0; $remainingAmount = $order->receivable->remaining_amount ?? $order->total_price; } else { // Jika belum ada receivable, hitung berdasarkan status payment if ($order->status === 'diproses' || $order->status === 'selesai') { // DP sudah dibayar (minimal DP amount) // Tapi karena tidak ada receivable, kita asumsikan hanya DP yang dibayar $paidAmount = $dpAmount; $remainingAmount = $order->total_price - $dpAmount; } else { // DP belum dibayar $paidAmount = 0; $remainingAmount = $order->total_price; } } // Pastikan remaining amount tidak negatif if ($remainingAmount < 0) { $remainingAmount = 0; } // Format currency $formattedDpAmount = 'Rp' . number_format($dpAmount, 0, ',', '.'); $formattedPaidAmount = 'Rp' . number_format($paidAmount, 0, ',', '.'); $formattedRemainingAmount = 'Rp' . number_format($remainingAmount, 0, ',', '.'); $formattedTotalPrice = $order->formatted_total_price; @endphp

Informasi Pembayaran DP

Rincian pembayaran Down Payment

Total Harga

{{ $formattedTotalPrice }}

DP ({{ number_format($dpPercentage, 0) }}%)

{{ $formattedDpAmount }}

Sudah Dibayar

{{ $formattedPaidAmount }}

Sisa Pembayaran

{{ $formattedRemainingAmount }}

@if($remainingAmount > 0 && $order->status !== 'selesai')

Selesaikan pembayaran sisa segera setelah produksi selesai untuk mempercepat pengiriman.

@endif
@endif

Status Pesanan

Informasi status terbaru

Status Pesanan

Status persetujuan pesanan

{{ $order->order_status_label }}
@if($order->order_status === 'ditolak' && $order->rejection_reason)

Alasan Penolakan Pesanan

{{ $order->rejection_reason }}

@if($order->rejected_at)

Ditolak pada: {{ $order->rejected_at->format('d M Y, H:i') }}

@endif

Jika Anda memiliki pertanyaan atau ingin mengajukan ulang pesanan, silakan hubungi customer service kami.

@endif

Status Pembayaran

Status pembayaran pesanan

{{ $order->status_label }}

Status Produksi

Status pembuatan produk

{{ $order->production_status_label }}
@if ($order->product)

Detail Produk

Produk yang dipesan

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

Nama Produk

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

Harga Satuan

{{ $order->product->formatted_price ?? 'N/A' }}

@if($order->product->product_description)

Deskripsi

{{ $order->product->product_description }}

@endif
@endif

Aksi

Tindakan cepat

@if ($order->payment_method === 'midtrans' && $order->status !== 'selesai' && $order->midtrans_status !== 'settlement') @endif @if ($order->payment_method === 'transfer') @php // Cek apakah proof_file ada dan tidak kosong $hasProofFile = !empty($order->proof_file); // Jika ada proof_file, cek apakah file benar-benar ada di storage $proofExists = false; if ($hasProofFile) { try { $proofExists = \Illuminate\Support\Facades\Storage::disk('uploads')->exists($order->proof_file); } catch (\Exception $e) { $proofExists = false; } } @endphp @if (!$proofExists) Upload Bukti Pembayaran @else @php // Selalu gunakan route orders.proof untuk keamanan dan konsistensi // Route ini akan serve file melalui Laravel dengan authorization check try { $proofUrl = route('orders.proof', $order->id); } catch (\Exception $e) { // Fallback jika route tidak ditemukan (misalnya cache belum di-clear) // Gunakan direct URL ke uploads dengan path yang benar (file disimpan di disk 'uploads') $proofUrl = asset('uploads/' . $order->proof_file); } @endphp Lihat Bukti Pembayaran @endif @endif @if ($order->payment_method === 'dp') @php // Cek apakah proof_file ada dan tidak kosong $hasProofFile = !empty($order->proof_file); // Jika ada proof_file, cek apakah file benar-benar ada di storage $proofExists = false; if ($hasProofFile) { try { $proofExists = \Illuminate\Support\Facades\Storage::disk('uploads')->exists($order->proof_file); } catch (\Exception $e) { $proofExists = false; } } @endphp @if (!$proofExists) Upload Bukti Pembayaran DP @else @php // Selalu gunakan route orders.proof untuk keamanan dan konsistensi try { $proofUrl = route('orders.proof', $order->id); } catch (\Exception $e) { $proofUrl = asset('uploads/' . $order->proof_file); } @endphp Lihat Bukti Pembayaran DP @endif @endif Belanja Lagi
@if (isset($order->shipping_address))

Alamat Pengiriman

Informasi pengiriman produk

{{ $order->shipping_address }}

@endif
@if(config('midtrans.client_key')) @else @endif @if (session('success')) @endif @if (session('error')) @endif @endsection