<?php
    $progressLabel = fn (?string $status) => $status ? str_replace('_', ' ', $status) : 'belum diupdate';
    $progressTone = fn (?string $status) => match ($status) {
        'sudah_diambil_atau_diterima', 'siap_diambil_atau_dikirim' => 'bg-emerald-50 text-emerald-700 border-emerald-200',
        'sedang_dicuci', 'sedang_dikeringkan', 'sedang_finishing', 'sedang_dikemas' => 'bg-sky-50 text-sky-700 border-sky-200',
        default => 'bg-slate-50 text-slate-700 border-slate-200',
    };
?>

<?php if (isset($component)) { $__componentOriginale0f1cdd055772eb1d4a99981c240763e = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginale0f1cdd055772eb1d4a99981c240763e = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin-layout','data' => ['title' => ''.e($order->invoice_no).'','subtitle' => 'Detail nota, pembayaran, progress item, dan timeline pelanggan.']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['title' => ''.e($order->invoice_no).'','subtitle' => 'Detail nota, pembayaran, progress item, dan timeline pelanggan.']); ?>
<?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::processComponentKey($component); ?>

    <div class="grid gap-5 xl:grid-cols-[1fr_380px]">
        <div class="space-y-5">
            <section class="grid gap-4 md:grid-cols-4">
                <div class="rounded-lg bg-white p-4 shadow-sm">
                    <div class="text-xs uppercase text-slate-500">Pelanggan</div>
                    <div class="mt-1 font-semibold"><?php echo e($order->customer?->name ?? 'Walk-in'); ?></div>
                    <div class="text-sm text-slate-500"><?php echo e($order->customer?->phone); ?></div>
                </div>
                <div class="rounded-lg bg-white p-4 shadow-sm">
                    <div class="text-xs uppercase text-slate-500">Status</div>
                    <div class="mt-1 font-semibold"><?php echo e(str_replace('_', ' ', $order->status)); ?></div>
                    <div class="text-sm text-slate-500"><?php echo e($order->received_at?->format('d/m/Y H:i')); ?></div>
                </div>
                <div class="rounded-lg bg-white p-4 shadow-sm">
                    <div class="text-xs uppercase text-slate-500">Pembayaran</div>
                    <div class="mt-1 font-semibold"><?php echo e(strtoupper($order->payment_status)); ?></div>
                    <div class="text-sm text-slate-500">Sisa Rp <?php echo e(number_format($order->balance_due, 0, ',', '.')); ?></div>
                </div>
                <div class="rounded-lg bg-white p-4 shadow-sm">
                    <div class="text-xs uppercase text-slate-500">Estimasi</div>
                    <div class="mt-1 font-semibold"><?php echo e($order->estimated_done_at?->format('d/m/Y') ?? '-'); ?></div>
                    <div class="text-sm text-slate-500"><?php echo e($order->estimated_done_at?->format('H:i')); ?></div>
                </div>
            </section>

            <section class="rounded-lg bg-white p-5 shadow-sm">
                <div class="mb-4 flex items-center justify-between">
                    <h2 class="font-semibold">Item & Progress Per Item</h2>
                    <a class="rounded-md border px-3 py-1 text-sm" href="<?php echo e(route('orders.receipt', $order)); ?>">Cetak Nota</a>
                </div>
                <div class="space-y-3">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $order->details; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $detail): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                        <div class="rounded-md border p-4">
                            <div class="flex flex-col gap-3 md:flex-row md:items-start md:justify-between">
                                <div>
                                    <div class="font-semibold"><?php echo e($detail->product_name); ?> <?php echo e($detail->is_reward_free_item ? '(Reward)' : ''); ?></div>
                                    <div class="mt-1 text-sm text-slate-500">
                                        <?php echo e(rtrim(rtrim(number_format((float) $detail->quantity, 3, ',', '.'), '0'), ',')); ?>

                                        x Rp <?php echo e(number_format($detail->unit_price, 0, ',', '.')); ?>

                                        oleh <?php echo e($detail->staff?->name ?? '-'); ?>

                                    </div>
                                </div>
                                <div class="text-right">
                                    <div class="font-semibold">Rp <?php echo e(number_format($detail->line_total, 0, ',', '.')); ?></div>
                                    <span class="mt-1 inline-flex rounded-full border px-2 py-0.5 text-xs <?php echo e($progressTone($detail->progress_status)); ?>"><?php echo e($progressLabel($detail->progress_status)); ?></span>
                                </div>
                            </div>
                            <form method="post" action="<?php echo e(route('orders.details.progress', [$order, $detail])); ?>" class="mt-4 grid gap-3 md:grid-cols-[1fr_1fr_auto]">
                                <?php echo csrf_field(); ?>
                                <select name="progress_status" class="rounded-md border px-3 py-2 text-sm">
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = \App\Models\Order::PROGRESS_STATUSES; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $status): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                                        <option value="<?php echo e($status); ?>" <?php if($detail->progress_status === $status): echo 'selected'; endif; ?>><?php echo e(str_replace('_', ' ', $status)); ?></option>
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                                </select>
                                <input name="note" value="<?php echo e($detail->progress_note); ?>" placeholder="Catatan item" class="rounded-md border px-3 py-2 text-sm">
                                <button class="rounded-md bg-slate-900 px-4 py-2 text-sm font-medium text-white">Update Item</button>
                            </form>
                        </div>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                </div>
                <div class="mt-4 border-t pt-4 text-right">
                    <div class="text-sm text-slate-500">Grand total</div>
                    <div class="text-xl font-semibold">Rp <?php echo e(number_format($order->grand_total, 0, ',', '.')); ?></div>
                </div>
            </section>

            <section class="rounded-lg bg-white p-5 shadow-sm">
                <h2 class="font-semibold">Timeline Progress</h2>
                <ol class="mt-5 space-y-4">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $order->progressLogs->sortBy('created_at'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $log): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                        <li class="relative border-l-2 border-slate-200 pl-5">
                            <span class="absolute -left-[7px] top-1 h-3 w-3 rounded-full bg-slate-900"></span>
                            <div class="flex flex-col gap-1 md:flex-row md:items-center md:justify-between">
                                <div class="font-medium"><?php echo e($progressLabel($log->progress_status)); ?></div>
                                <div class="text-sm text-slate-500"><?php echo e($log->created_at->format('d/m/Y H:i')); ?></div>
                            </div>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($log->note): ?>
                                <div class="mt-1 text-sm text-slate-600"><?php echo e($log->note); ?></div>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </li>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                        <li class="text-sm text-slate-500">Belum ada timeline.</li>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </ol>
            </section>

            <section class="rounded-lg bg-white p-5 shadow-sm">
                <h2 class="font-semibold">Histori Pembayaran</h2>
                <div class="mt-3 divide-y text-sm">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $order->payments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $payment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                        <div class="grid gap-2 py-3 md:grid-cols-[1fr_auto]">
                            <div>
                                <div class="font-medium"><?php echo e(strtoupper($payment->method)); ?> <?php echo e($payment->reference ? '- '.$payment->reference : ''); ?></div>
                                <div class="text-slate-500"><?php echo e($payment->created_at->format('d/m/Y H:i')); ?> <?php echo e($payment->note ? '- '.$payment->note : ''); ?></div>
                            </div>
                            <div class="font-semibold">Rp <?php echo e(number_format($payment->amount, 0, ',', '.')); ?></div>
                        </div>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                        <div class="py-3 text-slate-500">Belum ada pembayaran.</div>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>
            </section>
        </div>

        <aside class="space-y-5">
            <form method="post" action="<?php echo e(route('orders.payments.store', $order)); ?>" class="rounded-lg bg-white p-5 shadow-sm">
                <?php echo csrf_field(); ?>
                <h2 class="font-semibold">Tambah Pembayaran</h2>
                <div class="mt-2 rounded-md bg-slate-50 p-3 text-sm">Sisa tagihan: <strong>Rp <?php echo e(number_format($order->balance_due, 0, ',', '.')); ?></strong></div>
                <label class="mt-4 block text-sm">Nominal<input name="amount" type="number" min="1" max="<?php echo e((int) $order->balance_due); ?>" value="<?php echo e((int) $order->balance_due); ?>" class="mt-1 w-full rounded-md border px-3 py-2"></label>
                <label class="mt-3 block text-sm">Metode<select name="method" class="mt-1 w-full rounded-md border px-3 py-2"><option value="cash">Cash</option><option value="transfer">Transfer</option><option value="qris">QRIS</option></select></label>
                <label class="mt-3 block text-sm">Referensi<input name="reference" placeholder="No. transfer / QRIS" class="mt-1 w-full rounded-md border px-3 py-2"></label>
                <label class="mt-3 block text-sm">Catatan<textarea name="note" class="mt-1 w-full rounded-md border px-3 py-2"></textarea></label>
                <button class="mt-4 w-full rounded-md bg-slate-900 px-4 py-2 font-medium text-white" <?php if($order->isPaid()): echo 'disabled'; endif; ?>><?php echo e($order->isPaid() ? 'Sudah Lunas' : 'Catat Pembayaran'); ?></button>
            </form>

            <form method="post" action="<?php echo e(route('orders.status', $order)); ?>" class="rounded-lg bg-white p-5 shadow-sm">
                <?php echo csrf_field(); ?>
                <h2 class="font-semibold">Update Status Inti</h2>
                <select name="status" class="mt-3 w-full rounded-md border px-3 py-2">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = \App\Models\Order::CORE_STATUSES; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $status): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                        <option value="<?php echo e($status); ?>" <?php if($order->status === $status): echo 'selected'; endif; ?>><?php echo e($status); ?></option>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                </select>
                <textarea name="note" placeholder="Catatan status" class="mt-3 w-full rounded-md border px-3 py-2"></textarea>
                <button class="mt-3 w-full rounded-md bg-slate-900 px-4 py-2 text-white">Simpan Status</button>
            </form>

            <form method="post" action="<?php echo e(route('orders.progress', $order)); ?>" class="rounded-lg bg-white p-5 shadow-sm">
                <?php echo csrf_field(); ?>
                <h2 class="font-semibold">Update Progress Pelanggan</h2>
                <select name="progress_status" class="mt-3 w-full rounded-md border px-3 py-2">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = \App\Models\Order::PROGRESS_STATUSES; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $status): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                        <option value="<?php echo e($status); ?>"><?php echo e(str_replace('_', ' ', $status)); ?></option>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                </select>
                <textarea name="note" placeholder="Catatan timeline" class="mt-3 w-full rounded-md border px-3 py-2"></textarea>
                <button class="mt-3 w-full rounded-md border px-4 py-2">Tambah Timeline</button>
            </form>

            <form method="post" action="<?php echo e(route('orders.whatsapp', $order)); ?>">
                <?php echo csrf_field(); ?>
                <button class="w-full rounded-md border bg-white px-4 py-2">Kirim Update WhatsApp</button>
            </form>
            <a class="block rounded-md border bg-white px-4 py-2 text-center" href="<?php echo e(route('orders.receipt', $order)); ?>">Cetak Nota</a>
            <a class="block rounded-md border bg-white px-4 py-2 text-center" href="<?php echo e(route('digital-forms.create', $order)); ?>">Form Pemeriksaan</a>
        </aside>
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginale0f1cdd055772eb1d4a99981c240763e)): ?>
<?php $attributes = $__attributesOriginale0f1cdd055772eb1d4a99981c240763e; ?>
<?php unset($__attributesOriginale0f1cdd055772eb1d4a99981c240763e); ?>
<?php endif; ?>
<?php if (isset($__componentOriginale0f1cdd055772eb1d4a99981c240763e)): ?>
<?php $component = $__componentOriginale0f1cdd055772eb1d4a99981c240763e; ?>
<?php unset($__componentOriginale0f1cdd055772eb1d4a99981c240763e); ?>
<?php endif; ?>
<?php /**PATH /Users/dedehermawan/Dokumen/project/laundry/resources/views/orders/show.blade.php ENDPATH**/ ?>