<?php $__env->startSection('title', 'Invoices'); ?>
<?php $__env->startSection('page-title', 'Invoices'); ?>
<?php $__env->startSection('content'); ?>
<div class="content-card">
    <div class="content-card-header">
        <h3>All Invoices</h3>
        <a href="<?php echo e(route('admin.invoices.create')); ?>" class="btn btn-primary btn-sm">+ Create Invoice</a>
    </div>

    <form method="GET" class="row g-2 mb-3">
        <div class="col-md-3">
            <select name="status" class="form-select" onchange="this.form.submit()">
                <option value="">All Statuses</option>
                <option value="unpaid" <?php echo e(request('status')=='unpaid'?'selected':''); ?>>Unpaid</option>
                <option value="paid" <?php echo e(request('status')=='paid'?'selected':''); ?>>Paid</option>
                <option value="cancelled" <?php echo e(request('status')=='cancelled'?'selected':''); ?>>Cancelled</option>
                <option value="refunded" <?php echo e(request('status')=='refunded'?'selected':''); ?>>Refunded</option>
            </select>
        </div>
    </form>

    <div class="table-responsive">
    <table class="table">
        <thead><tr><th>#</th><th>User</th><th>Package</th><th>Amount</th><th>Status</th><th>Due</th><th>Actions</th></tr></thead>
        <tbody>
        <?php $__empty_1 = true; $__currentLoopData = $invoices; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $inv): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <tr>
                <td><a href="<?php echo e(route('admin.invoices.show', $inv)); ?>"><?php echo e($inv->invoice_number); ?></a></td>
                <td><?php echo e($inv->user->name ?? '—'); ?></td>
                <td><?php echo e($inv->package->name ?? '—'); ?></td>
                <td>$<?php echo e(number_format($inv->amount, 2)); ?></td>
                <td><span class="badge <?php echo e($inv->statusBadgeClass()); ?>"><?php echo e(ucfirst($inv->status)); ?></span></td>
                <td class="small"><?php echo e($inv->due_date?->format('M d, Y') ?? '—'); ?></td>
                <td>
                    <?php if($inv->isUnpaid()): ?>
                        <form action="<?php echo e(route('admin.invoices.markPaid', $inv)); ?>" method="POST" class="d-inline">
                            <?php echo csrf_field(); ?> <button class="btn btn-sm btn-success">Mark Paid</button>
                        </form>
                    <?php else: ?>
                        <form action="<?php echo e(route('admin.invoices.markUnpaid', $inv)); ?>" method="POST" class="d-inline">
                            <?php echo csrf_field(); ?> <button class="btn btn-sm btn-outline-warning">Mark Unpaid</button>
                        </form>
                    <?php endif; ?>
                    <form action="<?php echo e(route('admin.invoices.destroy', $inv)); ?>" method="POST" class="d-inline" onsubmit="return confirm('Delete invoice?')">
                        <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                        <button class="btn btn-sm btn-outline-danger">Del</button>
                    </form>
                </td>
            </tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <tr><td colspan="7" class="text-center text-muted py-3">No invoices.</td></tr>
        <?php endif; ?>
        </tbody>
    </table>
    </div>
    <?php echo e($invoices->links()); ?>

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

<?php echo $__env->make('layouts.dashboard', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp82\htdocs\blog\resources\views/admin/invoices/index.blade.php ENDPATH**/ ?>