<?php $__env->startSection('title', 'Laporan Void'); ?>
<?php $__env->startSection('page-title', 'Laporan Pembatalan (Void)'); ?>

<?php $__env->startSection('content'); ?>
<div class="space-y-6">
    
    <div class="bg-white p-4 rounded-2xl border border-slate-200 shadow-sm flex flex-wrap items-center justify-between gap-4">
        <form method="GET" class="flex flex-wrap items-center gap-3">
            <div class="flex items-center gap-2">
                <input type="date" name="start" value="<?php echo e($start->format('Y-m-d')); ?>" class="px-3 py-2 border rounded-xl text-sm outline-none focus:ring-2 focus:ring-blue-400">
                <span class="text-slate-400">s/d</span>
                <input type="date" name="end" value="<?php echo e($end->format('Y-m-d')); ?>" class="px-3 py-2 border rounded-xl text-sm outline-none focus:ring-2 focus:ring-blue-400">
            </div>
            <button type="submit" class="bg-slate-900 text-white px-5 py-2 rounded-xl text-sm font-bold hover:bg-slate-800 transition">Filter</button>
        </form>

        <div class="flex gap-4">
            <div class="text-center">
                <div class="text-xs text-slate-400 uppercase font-bold tracking-widest">Total Void</div>
                <div class="text-xl font-black text-red-600"><?php echo e($summary['total_count']); ?></div>
            </div>
            <div class="text-center border-l pl-4">
                <div class="text-xs text-slate-400 uppercase font-bold tracking-widest">Nilai Void</div>
                <div class="text-xl font-black text-slate-800">Rp <?php echo e(number_format($summary['total_amount'], 0, ',', '.')); ?></div>
            </div>
        </div>
    </div>

    
    <div class="bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
        <table class="w-full text-left border-collapse">
            <thead>
                <tr class="bg-slate-50 border-b border-slate-200">
                    <th class="px-6 py-4 text-[10px] font-bold text-slate-400 uppercase tracking-widest">Waktu Void</th>
                    <th class="px-6 py-4 text-[10px] font-bold text-slate-400 uppercase tracking-widest">No. Invoice</th>
                    <th class="px-6 py-4 text-[10px] font-bold text-slate-400 uppercase tracking-widest">Kasir</th>
                    <th class="px-6 py-4 text-[10px] font-bold text-slate-400 uppercase tracking-widest">Otoritas By</th>
                    <th class="px-6 py-4 text-[10px] font-bold text-slate-400 uppercase tracking-widest">Total</th>
                    <th class="px-6 py-4 text-[10px] font-bold text-slate-400 uppercase tracking-widest">Alasan</th>
                </tr>
            </thead>
            <tbody class="divide-y divide-slate-100">
                <?php $__empty_1 = true; $__currentLoopData = $transactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $trx): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr class="hover:bg-slate-50 transition border-b border-slate-50 last:border-0">
                    <td class="px-6 py-4 text-sm text-slate-600">
                        <div class="font-bold text-slate-800"><?php echo e($trx->voided_at->format('d M Y')); ?></div>
                        <div class="text-xs opacity-60"><?php echo e($trx->voided_at->format('H:i')); ?></div>
                    </td>
                    <td class="px-6 py-4">
                        <div class="flex items-center gap-2">
                            <button onclick="toggleDetail('void-<?php echo e($trx->id); ?>')" class="w-6 h-6 flex items-center justify-center rounded-lg bg-blue-50 text-blue-600 hover:bg-blue-600 hover:text-white transition text-[10px]">
                                <span id="icon-void-<?php echo e($trx->id); ?>">➕</span>
                            </button>
                            <span class="font-mono text-xs font-bold text-blue-600"><?php echo e($trx->invoice_number); ?></span>
                        </div>
                    </td>
                    <td class="px-6 py-4 text-sm font-medium text-slate-700">
                        <?php echo e($trx->voidedBy?->name ?? $trx->user->name); ?>

                    </td>
                    <td class="px-6 py-4">
                        <span class="px-2 py-1 bg-emerald-100 text-emerald-700 rounded-md text-[10px] font-bold uppercase">
                            <?php echo e($trx->authorizedBy?->name ?? 'Admin'); ?>

                        </span>
                    </td>
                    <td class="px-6 py-4 font-bold text-slate-400 line-through text-sm">
                        Rp <?php echo e(number_format($trx->grand_total, 0, ',', '.')); ?>

                    </td>
                    <td class="px-6 py-4">
                        <div class="text-xs text-slate-500 bg-slate-100 p-2 rounded-lg italic">
                            "<?php echo e($trx->void_reason); ?>"
                        </div>
                    </td>
                </tr>
                
                <tr id="void-<?php echo e($trx->id); ?>" class="hidden bg-slate-50/50">
                    <td colspan="6" class="px-6 py-4">
                        <div class="bg-white rounded-xl border border-slate-200 overflow-hidden shadow-sm">
                            <table class="w-full text-xs">
                                <thead class="bg-slate-50">
                                    <tr class="text-[9px] text-slate-400 uppercase tracking-widest border-b border-slate-100">
                                        <th class="px-4 py-2 text-left">Produk</th>
                                        <th class="px-4 py-2 text-center">Qty</th>
                                        <th class="px-4 py-2 text-right">Harga Satuan</th>
                                        <th class="px-4 py-2 text-right">Subtotal</th>
                                    </tr>
                                </thead>
                                <tbody class="divide-y divide-slate-50">
                                    <?php $__currentLoopData = $trx->items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td class="px-4 py-2 font-bold text-slate-700"><?php echo e($item->product_name); ?></td>
                                        <td class="px-4 py-2 text-center"><?php echo e($item->quantity); ?> <?php echo e($item->unit); ?></td>
                                        <td class="px-4 py-2 text-right">Rp <?php echo e(number_format($item->unit_price, 0, ',', '.')); ?></td>
                                        <td class="px-4 py-2 text-right font-medium">Rp <?php echo e(number_format($item->subtotal, 0, ',', '.')); ?></td>
                                    </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                                <tfoot class="bg-slate-50/50 font-bold">
                                    <tr>
                                        <td colspan="3" class="px-4 py-2 text-right text-slate-500">GRAND TOTAL VOID</td>
                                        <td class="px-4 py-2 text-right text-slate-900">Rp <?php echo e(number_format($trx->grand_total, 0, ',', '.')); ?></td>
                                    </tr>
                                </tfoot>
                            </table>
                        </div>
                    </td>
                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="6" class="px-6 py-12 text-center text-slate-400 italic">
                        Tidak ada data pembatalan pada periode ini.
                    </td>
                </tr>
                <?php endif; ?>
            </tbody>
        </table>
        
        <?php if($transactions->hasPages()): ?>
        <div class="px-6 py-4 border-t border-slate-100">
            <?php echo e($transactions->links()); ?>

        </div>
        <?php endif; ?>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
    function toggleDetail(id) {
        const el = document.getElementById(id);
        const icon = document.getElementById('icon-' + id);
        el.classList.toggle('hidden');
        icon.textContent = el.classList.contains('hidden') ? '➕' : '➖';
    }
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\pos-umkm\resources\views/reports/voids.blade.php ENDPATH**/ ?>