<?php $__env->startSection('title', 'Purchase List'); ?>
<?php $__env->startSection('page_title', 'Purchase List'); ?>

<?php $__env->startSection('content'); ?>
<div class="page-shell">
    <div class="page-head">
        <div>
            <h1 class="page-title">Advanced Purchase System</h1>
            <div class="page-subtitle">Multi-item purchase, supplier payment and stock-in.</div>
        </div>
        <a href="<?php echo e(route('admin.purchases.create')); ?>" class="btn primary">Add Purchase</a>
    </div>

    <form class="filter-card" method="GET" action="<?php echo e(route('admin.purchases.index')); ?>">
        <div class="grid-4">
            <div>
                <label for="q">Search</label>
                <input type="text" id="q" name="q" value="<?php echo e(request('q')); ?>" placeholder="invoice / supplier / note">
            </div>

            <div class="form-actions" style="align-items:end;">
                <button class="btn primary" type="submit">Search</button>
                <a href="<?php echo e(route('admin.purchases.index')); ?>" class="btn btn-light">Reset</a>
            </div>
        </div>
    </form>

    <div class="card">
        <div class="table-wrap">
            <table class="table">
                <thead>
                    <tr>
                        <th>Invoice</th>
                        <th>Date</th>
                        <th>Supplier</th>
                        <th>Subtotal</th>
                        <th>Grand Total</th>
                        <th>Paid</th>
                        <th>Due</th>
                        <th class="text-end">Action</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $purchases; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $purchase): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td><?php echo e($purchase->invoice_no); ?></td>
                            <td><?php echo e($purchase->purchase_date); ?></td>
                            <td><?php echo e($purchase->supplier_name); ?></td>
                            <td>৳ <?php echo e(number_format((float) $purchase->subtotal, 2)); ?></td>
                            <td>৳ <?php echo e(number_format((float) $purchase->grand_total, 2)); ?></td>
                            <td>৳ <?php echo e(number_format((float) $purchase->paid_amount, 2)); ?></td>
                            <td>
                                <?php if(($purchase->due_amount ?? 0) > 0): ?>
                                    <span class="badge" style="background:#fee2e2;color:#991b1b;">৳ <?php echo e(number_format((float) $purchase->due_amount, 2)); ?></span>
                                <?php else: ?>
                                    <span class="badge" style="background:#dcfce7;color:#166534;">৳ <?php echo e(number_format((float) $purchase->due_amount, 2)); ?></span>
                                <?php endif; ?>
                            </td>
                            <td class="text-end" style="white-space:nowrap;">
                                <?php if(Route::has('admin.purchases.show')): ?>
                                    <a class="btn btn-light" href="<?php echo e(route('admin.purchases.show', $purchase)); ?>">View</a>
                                <?php endif; ?>
                                <a class="btn btn-light" href="<?php echo e(route('admin.purchases.edit', $purchase)); ?>">Edit</a>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="8">No purchase found.</td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>

        <div style="margin-top:14px;">
            <?php echo e($purchases->links()); ?>

        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH J:\xampp\htdocs\pos\resources\views/admin/purchases/index.blade.php ENDPATH**/ ?>