<?php $__env->startSection('title', $title); ?>
<?php $__env->startSection('content'); ?>
<div class="d-flex justify-content-between align-items-center mb-3 flex-wrap gap-2"><h1><?php echo e($title); ?></h1></div>
<form class="card card-body mb-3"><div class="row g-2"><div class="col-md-4"><input class="form-control" name="q" value="<?php echo e(request('q')); ?>" placeholder="Search <?php echo e(strtolower($title)); ?>"></div><div class="col-auto"><button class="btn btn-primary">Search</button></div></div></form>
<div class="row g-3">
    <div class="col-lg-4">
        <div class="card card-body">
            <h5><?php echo e($editItem ? 'Edit' : 'Add New'); ?> <?php echo e(rtrim($title, 's')); ?></h5>
            <form method="POST" enctype="multipart/form-data" action="<?php echo e($editItem ? route(str_replace('.index', '.update', $routeName), $editItem->id) : route(str_replace('.index', '.store', $routeName))); ?>">
                <?php echo csrf_field(); ?>
                <?php if($editItem): ?> <?php echo method_field('PUT'); ?> <?php endif; ?>
                <div class="mb-2"><label>Name</label><input class="form-control" name="name" value="<?php echo e(old('name', $editItem->name ?? '')); ?>" required></div>
                <div class="mb-2"><label>Code</label><input class="form-control" name="code" value="<?php echo e(old('code', $editItem->code ?? '')); ?>"></div>
                <?php if($title === 'Suppliers'): ?>
                    <div class="mb-2"><label>Phone</label><input class="form-control" name="phone" value="<?php echo e(old('phone', $editItem->phone ?? '')); ?>"></div>
                    <div class="mb-2"><label>Email</label><input class="form-control" name="email" value="<?php echo e(old('email', $editItem->email ?? '')); ?>"></div>
                    <div class="mb-2"><label>Contact Person</label><input class="form-control" name="contact_person" value="<?php echo e(old('contact_person', $editItem->contact_person ?? '')); ?>"></div>
                    <div class="mb-2"><label>Address</label><textarea class="form-control" name="address"><?php echo e(old('address', $editItem->address ?? '')); ?></textarea></div>
                    <div class="mb-2"><label>Opening Balance</label><input class="form-control" type="number" step="0.01" name="opening_balance" value="<?php echo e(old('opening_balance', $editItem->opening_balance ?? 0)); ?>"></div>
                    <div class="mb-2"><label>Rating</label><input class="form-control" type="number" min="1" max="5" name="rating" value="<?php echo e(old('rating', $editItem->rating ?? 5)); ?>"></div>
                    <div class="mb-2"><label>Notes</label><textarea class="form-control" name="notes"><?php echo e(old('notes', $editItem->notes ?? '')); ?></textarea></div>
                    <div class="mb-2"><label>Document Upload</label><input class="form-control" type="file" name="document"></div>
                <?php endif; ?>
                <div class="mb-2"><label>Status</label><select class="form-select" name="status"><option value="Active" <?php if(old('status', $editItem->status ?? 'Active') === 'Active'): echo 'selected'; endif; ?>>Active</option><option value="Inactive" <?php if(old('status', $editItem->status ?? 'Active') === 'Inactive'): echo 'selected'; endif; ?>>Inactive</option></select></div>
                <div class="d-flex gap-2"><button class="btn btn-primary"><?php echo e($editItem ? 'Update' : 'Save'); ?></button><?php if($editItem): ?><a class="btn btn-light" href="<?php echo e(route($routeName)); ?>">Cancel</a><?php endif; ?></div>
            </form>
        </div>
    </div>
    <div class="col-lg-8">
        <div class="card"><div class="table-responsive"><table class="table table-striped mb-0"><thead><tr><th>#</th><th>Name</th><th>Code</th><?php if($title==='Suppliers'): ?><th>Phone</th><th>Contact</th><?php endif; ?><th>Status</th><th>Action</th></tr></thead><tbody>
        <?php $__empty_1 = true; $__currentLoopData = $items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <tr><td><?php echo e($loop->iteration + ($items->firstItem() - 1)); ?></td><td><?php echo e($item->name); ?></td><td><?php echo e($item->code ?: '—'); ?></td><?php if($title==='Suppliers'): ?><td><?php echo e($item->phone ?: '—'); ?></td><td><?php echo e($item->contact_person ?: '—'); ?></td><?php endif; ?><td><?php echo e($item->status); ?></td><td class="d-flex gap-1 flex-wrap"><a class="btn btn-sm btn-outline-primary" href="<?php echo e(route($routeName, ['edit' => $item->id])); ?>">Edit</a><?php if($title==='Suppliers'): ?><a class="btn btn-sm btn-outline-secondary" href="<?php echo e(route('admin.suppliers.ledger',$item)); ?>">Ledger</a><a class="btn btn-sm btn-outline-info" href="<?php echo e(route('admin.suppliers.statement',$item)); ?>">Statement</a><?php endif; ?><form method="POST" action="<?php echo e(route(str_replace('.index', '.destroy', $routeName), $item->id)); ?>" onsubmit="return confirm('Delete this item?')"><?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?><button class="btn btn-sm btn-outline-danger">Delete</button></form></td></tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <tr><td colspan="<?php echo e($title==='Suppliers' ? 7 : 5); ?>">No data found.</td></tr>
        <?php endif; ?>
        </tbody></table></div></div>
        <div class="mt-3"><?php echo e($items->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/masters/index.blade.php ENDPATH**/ ?>