

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

<?php $__env->startSection('content'); ?>
    <div class="card">
        <div class="card-body">
            <!-- Search Form -->
            <form method="GET" action="<?php echo e(route('grns.index')); ?>" class="mb-3">
                <div class="row">
                    <div class="col-md-6">
                        <div class="input-group">
                            <input type="text" name="search" class="form-control" placeholder="Search by GRN number or supplier name..." value="<?php echo e($search ?? ''); ?>">
                            <button class="btn btn-outline-secondary" type="submit">
                                <i class="fas fa-search"></i>
                            </button>
                            <?php if($search ?? false): ?>
                                <a href="<?php echo e(route('grns.index')); ?>" class="btn btn-outline-danger">
                                    <i class="fas fa-times"></i>
                                </a>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
            </form>

            <div class="mb-3 text-end">
                <?php if(auth()->user() && auth()->user()->hasAccessTo('grns.create')): ?>
                    <a href="<?php echo e(route('grns.create')); ?>" class="btn btn-primary">Create GRN</a>
                <?php endif; ?>
            </div>
            <table class="table">
                <thead><tr><th>#</th><th>GRN Number</th><th>Supplier</th><th>Total</th><th>Date</th><th></th></tr></thead>
                <tbody>
                    <?php $__currentLoopData = $grns; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $g): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($g->id); ?></td>
                            <td><?php echo e($g->grn_number); ?></td>
                            <td><?php echo e(optional($g->supplier)->supplier_name ?? optional($g->supplier)->name ?? ''); ?></td>
                            <td><?php echo e(number_format($g->total,2)); ?></td>
                            <td><?php echo e($g->date_time && $g->date_time instanceof \Carbon\Carbon ? $g->date_time->format('Y-m-d H:i') : ($g->date_time ?: '-')); ?></td>
                            <td>
                                <?php if(auth()->user() && auth()->user()->hasAccessTo('grns.view')): ?>
                                    <a href="<?php echo e(route('grns.show', $g->id)); ?>" class="btn btn-sm btn-outline-secondary">View</a>
                                <?php endif; ?>
                                <?php if(auth()->user() && auth()->user()->hasAccessTo('grns.edit')): ?>
                                    <a href="<?php echo e(route('grns.edit', $g->id)); ?>" class="btn btn-sm btn-outline-primary">Edit</a>
                                <?php endif; ?>
                                <?php if(auth()->user() && auth()->user()->hasAccessTo('grns.delete')): ?>
                                    <form action="<?php echo e(route('grns.destroy', $g->id)); ?>" method="POST" style="display:inline"><?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?><button class="btn btn-sm btn-danger" onclick="return confirm('Delete?')">Delete</button></form>
                                <?php endif; ?>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>

            <?php echo e($grns->appends(request()->except('page'))->links()); ?>

        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\ONLINE SYSTEMS ORIGINALS\demo perera\test 06-05-2026\resources\views/grns/index.blade.php ENDPATH**/ ?>