<?php $__env->startSection('title', 'Daftar Invoice'); ?>
<?php $__env->startSection('page-title', 'Invoice'); ?>

<?php $__env->startSection('content'); ?>
<div class="d-flex justify-content-between align-items-center mb-3">
    <h5 class="mb-0 fw-bold">Daftar Invoice</h5>
    <a href="<?php echo e(route('invoices.create')); ?>" class="btn btn-primary">
        <i class="bi bi-plus-lg"></i> Buat Invoice
    </a>
</div>


<div class="card mb-3">
    <div class="card-body py-2">
        <form method="GET" class="row g-2 align-items-end">
            <div class="col-md-3">
                <input type="text" name="search" value="<?php echo e(request('search')); ?>" class="form-control form-control-sm" placeholder="Cari no. invoice / pelanggan...">
            </div>
            <div class="col-md-2">
                <select name="status" class="form-select form-select-sm">
                    <option value="">Semua Status</option>
                    <option value="draft" <?php if(request('status')=='draft'): echo 'selected'; endif; ?>>Draft</option>
                    <option value="sent" <?php if(request('status')=='sent'): echo 'selected'; endif; ?>>Terkirim</option>
                    <option value="paid" <?php if(request('status')=='paid'): echo 'selected'; endif; ?>>Lunas</option>
                    <option value="cancelled" <?php if(request('status')=='cancelled'): echo 'selected'; endif; ?>>Dibatalkan</option>
                </select>
            </div>
            <div class="col-md-2">
                <input type="date" name="date_from" value="<?php echo e(request('date_from')); ?>" class="form-control form-control-sm" placeholder="Dari">
            </div>
            <div class="col-md-2">
                <input type="date" name="date_to" value="<?php echo e(request('date_to')); ?>" class="form-control form-control-sm" placeholder="Sampai">
            </div>
            <div class="col-md-3 d-flex gap-1">
                <button type="submit" class="btn btn-sm btn-secondary">Filter</button>
                <a href="<?php echo e(route('invoices.index')); ?>" class="btn btn-sm btn-outline-secondary">Reset</a>
            </div>
        </form>
    </div>
</div>

<div class="card">
    <div class="card-body p-0">
        <div class="table-responsive">
            <table class="table table-hover align-middle mb-0">
                <thead class="table-light">
                    <tr>
                        <th>No. Invoice</th>
                        <th>Pelanggan</th>
                        <th>Tgl Invoice</th>
                        <th>Jatuh Tempo</th>
                        <th class="text-end">Total</th>
                        <th>Status</th>
                        <th class="text-center">Aksi</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('invoices.show', $inv)); ?>" class="fw-semibold text-decoration-none"><?php echo e($inv->invoice_number); ?></a></td>
                        <td><?php echo e($inv->customer->name); ?></td>
                        <td><?php echo e($inv->invoice_date->format('d/m/Y')); ?></td>
                        <td><?php echo e($inv->due_date?->format('d/m/Y') ?? '-'); ?></td>
                        <td class="text-end fw-semibold">Rp <?php echo e(number_format($inv->total, 0, ',', '.')); ?></td>
                        <td><span class="badge badge-<?php echo e($inv->status); ?>"><?php echo e($inv->status_label); ?></span></td>
                        <td class="text-center">
                            <div class="btn-group btn-group-sm">
                                <a href="<?php echo e(route('invoices.show', $inv)); ?>" class="btn btn-outline-primary" title="Detail"><i class="bi bi-eye"></i></a>
                                <a href="<?php echo e(route('invoices.print', $inv)); ?>" class="btn btn-outline-secondary" target="_blank" title="Cetak"><i class="bi bi-printer"></i></a>
                                <?php if($inv->status !== 'paid'): ?>
                                    <a href="<?php echo e(route('invoices.edit', $inv)); ?>" class="btn btn-outline-warning" title="Edit"><i class="bi bi-pencil"></i></a>
                                <?php endif; ?>
                                <?php if(!$inv->receipt && $inv->status !== 'cancelled'): ?>
                                    <a href="<?php echo e(route('receipts.create', ['invoice_id' => $inv->id])); ?>" class="btn btn-outline-success" title="Buat Tanda Terima"><i class="bi bi-check2-square"></i></a>
                                <?php endif; ?>
                            </div>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr><td colspan="7" class="text-center text-muted py-5">Belum ada invoice</td></tr>
                <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>
    <?php if($invoices->hasPages()): ?>
        <div class="card-footer"><?php echo e($invoices->links()); ?></div>
    <?php endif; ?>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\MAMP\htdocs\suminvo\resources\views/invoices/index.blade.php ENDPATH**/ ?>