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

Serah Terima Order #{{ $order->id }}

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

@if($order->handover_status === 'confirmed')
Preview & Cetak
@endif
@if(session('success'))
{{ session('success') }}
@endif @if($errors->any())
@endif
@php $steps = [ ['key' => 'pending', 'label' => 'Persiapan', 'icon' => 'fa-box'], ['key' => 'ready', 'label' => 'Siap Kirim', 'icon' => 'fa-check'], ['key' => 'delivered', 'label' => 'Diserahkan', 'icon' => 'fa-truck'], ['key' => 'confirmed', 'label' => 'Selesai', 'icon' => 'fa-check-double'], ]; $currentIndex = array_search($order->handover_status ?? 'pending', array_column($steps, 'key')); if ($currentIndex === false) $currentIndex = 0; @endphp @foreach($steps as $index => $step)
@if($index > 0)
@endif @if($index < count($steps) - 1)
@endif
{{ $step['label'] }}
@endforeach
@if ($order->product && $order->product->product_image)
{{ $order->product->product_title }}

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

Produk Pesanan

@endif

Informasi Order

Produk: {{ $order->product->product_title ?? 'N/A' }}
Jumlah: {{ $order->quantity }} unit
Total: Rp {{ number_format($order->total_price, 0, ',', '.') }}
Teknisi: {{ $order->production->teknisi->name ?? 'N/A' }}

Informasi Customer

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

Status Serah Terima

@php $statusConfig = [ 'pending' => ['bg' => 'bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300', 'icon' => 'fa-clock'], 'ready' => ['bg' => 'bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300', 'icon' => 'fa-box'], 'delivered' => ['bg' => 'bg-amber-100 dark:bg-amber-900/40 text-amber-700 dark:text-amber-300', 'icon' => 'fa-truck'], 'confirmed' => ['bg' => 'bg-green-100 dark:bg-green-900/40 text-green-700 dark:text-green-300', 'icon' => 'fa-check-circle'], ]; $status = $statusConfig[$order->handover_status ?? 'pending'] ?? $statusConfig['pending']; @endphp
{{ $order->handover_status_label }}
@if($order->handover_at)

Diserahkan pada:

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

@endif @if($order->customer_confirmed_at)

Dikonfirmasi pada:

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

@endif
@if($order->handover_photos && count($order->handover_photos) > 0)

Foto Bukti Serah Terima

({{ count($order->handover_photos) }} foto)
@foreach($order->handover_photos as $index => $photo)
Foto Bukti Serah Terima {{ $index + 1 }}
@if($index === 0) Utama @else Foto {{ $index + 1 }} @endif
@endforeach
@if($order->handover_notes)

Catatan Serah Terima:

{!! nl2br(e($order->handover_notes)) !!}
@endif
@endif @if($order->production && ($order->production->result_photos || $order->production->test_results || $order->production->final_specifications))

Hasil Produksi

@if($order->production->result_photos && count($order->production->result_photos) > 0)

Foto Produk Jadi:

@foreach($order->production->result_photos as $photo) Hasil Produksi @endforeach
@endif @if($order->production->test_results)

Hasil Pengujian:

{!! nl2br(e($order->production->test_results)) !!}
@endif @if($order->production->final_specifications)

Spesifikasi Lengkap:

{!! nl2br(e($order->production->final_specifications)) !!}
@endif
@endif

Aksi Serah Terima

@if(!$order->handover_status || $order->handover_status === 'pending')
@csrf

Upload foto produk yang akan diserahkan (bisa multiple)

@elseif($order->handover_status === 'ready')
@csrf @if($order->handover_photos && count($order->handover_photos) > 0)

Foto yang sudah diupload:

@foreach($order->handover_photos as $photo) Handover Photo @endforeach
@endif
@elseif($order->handover_status === 'delivered')

Menunggu Konfirmasi Customer

Produk sudah diserahkan. Menunggu customer mengkonfirmasi penerimaan.

Link Konfirmasi untuk Customer:

@php // Format nomor telepon untuk WA (hilangkan 0 di depan, tambahkan 62) $phoneNumber = $order->phone_number ?? ''; $waNumber = ''; if ($phoneNumber) { // Hapus semua karakter non-digit $phoneNumber = preg_replace('/[^0-9]/', '', $phoneNumber); // Jika dimulai dengan 0, ganti dengan 62 if (substr($phoneNumber, 0, 1) === '0') { $waNumber = '62' . substr($phoneNumber, 1); } else { $waNumber = $phoneNumber; } } // Format pesan untuk WA $waMessage = urlencode("Halo " . $order->customer_name . ",\n\nProduk pesanan Anda (Order #" . $order->id . ") sudah siap untuk diserahkan.\n\nSilakan konfirmasi penerimaan melalui link berikut:\n" . route('user.orders.confirm-delivery', $order) . "\n\nTerima kasih."); // Format email $emailSubject = urlencode("Konfirmasi Serah Terima - Order #" . $order->id); $emailBody = urlencode("Halo " . $order->customer_name . ",\n\nProduk pesanan Anda (Order #" . $order->id . ") sudah siap untuk diserahkan.\n\nSilakan konfirmasi penerimaan melalui link berikut:\n" . route('user.orders.confirm-delivery', $order) . "\n\nTerima kasih."); @endphp @if($waNumber) Kirim ke WhatsApp @endif @if($order->customer_email) Kirim ke Email @endif
@if(!$waNumber && !$order->customer_email)

Nomor telepon dan email tidak tersedia. Silakan salin link secara manual.

@endif

Jika customer tidak dapat mengkonfirmasi melalui sistem:

@csrf
@elseif($order->handover_status === 'confirmed')

Serah Terima Selesai

Customer telah mengkonfirmasi penerimaan produk.

@if($order->customer_rating)

Rating Customer:

@for($i = 1; $i <= 5; $i++) @endfor
@endif @if($order->customer_feedback)

Feedback Customer:

{{ $order->customer_feedback }}

@endif @if($order->sale)

Penjualan Telah Dicatat

Sale ID: #{{ $order->sale->id }}

Tanggal Penjualan: {{ $order->sale->sale_date->format('d M Y') }}

Status: {{ $order->sale->status_label }}

@else

Catatan: Sale record belum dibuat. Pastikan status pembayaran dan produksi sudah selesai.

@endif
@endif
@endsection