<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?> <?php $__env->slot('header', null, []); ?> <div class="d-flex flex-wrap align-items-center justify-content-between gap-2"><div><h2 class="h4 mb-0">Inventory</h2><p class="text-muted mb-0">Stock, equipment issue/return and movement history</p></div><div class="d-flex gap-2"><a href="<?php echo e(route('admin.inventory.export')); ?>" class="btn btn-outline-success">Export CSV</a><?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('inventory.manage')): ?><button class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#transactionModal">Stock transaction</button><button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#itemModal">Add item</button><?php endif; ?></div></div> <?php $__env->endSlot(); ?>
<form class="card border-0 shadow-sm mb-3"><div class="card-body row g-2 align-items-end"><div class="col-md-6"><label class="form-label">Search item</label><input name="search" value="<?php echo e(request('search')); ?>" class="form-control" placeholder="SKU, name or category"></div><div class="col-md-2"><label class="form-label">Stock</label><select name="stock" class="form-select"><option value="">All</option><option value="low" <?php if(request('stock')==='low'): echo 'selected'; endif; ?>>Low stock</option></select></div><div class="col-md-2"><label class="form-label">Status</label><select name="status" class="form-select"><option value="">All</option><option value="1" <?php if(request('status')==='1'): echo 'selected'; endif; ?>>Active</option><option value="0" <?php if(request('status')==='0'): echo 'selected'; endif; ?>>Inactive</option></select></div><div class="col-md-2"><button class="btn btn-dark w-100">Filter</button></div></div></form>
<div class="row g-3 mb-4"><div class="col-6 col-xl-3"><div class="card border-0 shadow-sm h-100"><div class="card-body"><small class="text-muted">Items</small><div class="h3 mb-0"><?php echo e(number_format($summary['items'])); ?></div></div></div></div><div class="col-6 col-xl-3"><div class="card border-0 shadow-sm h-100"><div class="card-body"><small class="text-muted">Stock units</small><div class="h3 mb-0"><?php echo e(number_format($summary['stock'],2)); ?></div></div></div></div><div class="col-6 col-xl-3"><div class="card border-0 shadow-sm h-100"><div class="card-body"><small class="text-muted">Low stock</small><div class="h3 mb-0 text-danger"><?php echo e($summary['low']); ?></div></div></div></div><div class="col-6 col-xl-3"><div class="card border-0 shadow-sm h-100"><div class="card-body"><small class="text-muted">Stock value</small><div class="h3 mb-0"><?php echo e(app(\App\Services\CurrencyService::class)->format($summary['value'])); ?></div></div></div></div></div>
<div class="card border-0 shadow-sm mb-4"><div class="card-header bg-white"><h3 class="h5 mb-0">Item list</h3></div><div class="table-responsive"><table class="table table-hover align-middle mb-0"><thead><tr><th>SKU</th><th>Item</th><th>Category</th><th class="text-end">Purchase</th><th class="text-end">Sale</th><th class="text-end">Stock</th><th>Status / 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 class="<?php echo e((float)$item->stock_quantity <= (float)$item->minimum_stock ? 'table-warning':''); ?>"><td><code><?php echo e($item->sku); ?></code></td><td><strong><?php echo e($item->name); ?></strong><div class="small text-muted"><?php echo e($item->description); ?></div></td><td><?php echo e($item->category ?: '-'); ?></td><td class="text-end"><?php echo e(number_format($item->purchase_price,2)); ?></td><td class="text-end"><?php echo e(number_format($item->sale_price,2)); ?></td><td class="text-end fw-bold"><?php echo e(number_format($item->stock_quantity,2)); ?> <?php echo e($item->unit); ?></td><td><span class="badge <?php echo e($item->status?'bg-success':'bg-secondary'); ?>"><?php echo e($item->status?'Active':'Inactive'); ?></span> <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('inventory.manage')): ?><button class="btn btn-sm btn-outline-primary ms-1" data-bs-toggle="modal" data-bs-target="#editItem<?php echo e($item->id); ?>">Edit</button><div class="modal fade text-start" id="editItem<?php echo e($item->id); ?>" tabindex="-1"><div class="modal-dialog modal-lg"><form method="post" action="<?php echo e(route('admin.inventory.update',$item)); ?>" class="modal-content"><?php echo csrf_field(); ?> <?php echo method_field('PUT'); ?><div class="modal-header"><h5 class="modal-title">Edit <?php echo e($item->name); ?></h5><button type="button" class="btn-close" data-bs-dismiss="modal"></button></div><div class="modal-body row g-3"><div class="col-md-4"><label class="form-label">SKU</label><input name="sku" value="<?php echo e($item->sku); ?>" class="form-control" required></div><div class="col-md-8"><label class="form-label">Name</label><input name="name" value="<?php echo e($item->name); ?>" class="form-control" required></div><div class="col-md-4"><label class="form-label">Category</label><input name="category" value="<?php echo e($item->category); ?>" class="form-control"></div><div class="col-md-2"><label class="form-label">Unit</label><input name="unit" value="<?php echo e($item->unit); ?>" class="form-control" required></div><div class="col-md-3"><label class="form-label">Purchase</label><input name="purchase_price" value="<?php echo e($item->purchase_price); ?>" type="number" step=".01" min="0" class="form-control" required></div><div class="col-md-3"><label class="form-label">Sale</label><input name="sale_price" value="<?php echo e($item->sale_price); ?>" type="number" step=".01" min="0" class="form-control" required></div><div class="col-md-4"><label class="form-label">Minimum stock</label><input name="minimum_stock" value="<?php echo e($item->minimum_stock); ?>" type="number" step=".01" min="0" class="form-control" required></div><div class="col-md-4 d-flex align-items-end"><div class="form-check"><input type="hidden" name="status" value="0"><input class="form-check-input" type="checkbox" name="status" value="1" <?php if($item->status): echo 'checked'; endif; ?>><label class="form-check-label">Active</label></div></div><div class="col-12"><label class="form-label">Description</label><textarea name="description" class="form-control"><?php echo e($item->description); ?></textarea></div></div><div class="modal-footer"><button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button><button class="btn btn-primary">Update</button></div></form></div></div><?php endif; ?></td></tr><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><tr><td colspan="7" class="text-center py-4">No inventory items.</td></tr><?php endif; ?></tbody></table></div><div class="card-footer bg-white"><?php echo e($items->links()); ?></div></div>
<div class="card border-0 shadow-sm"><div class="card-header bg-white"><h3 class="h5 mb-0">Recent stock statement</h3></div><div class="table-responsive"><table class="table table-striped align-middle mb-0"><thead><tr><th>Date</th><th>Item</th><th>Type</th><th>Customer</th><th>Reference</th><th class="text-end">Qty</th><th class="text-end">Value</th><th>By</th></tr></thead><tbody><?php $__empty_1 = true; $__currentLoopData = $transactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $txn): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><tr><td><?php echo e($txn->transaction_date?->format('d M Y')); ?></td><td><?php echo e($txn->item?->name); ?></td><td><span class="badge <?php echo e(in_array($txn->type,['purchase','return','adjustment_in'])?'bg-success':'bg-warning text-dark'); ?>"><?php echo e(str_replace('_',' ',ucfirst($txn->type))); ?></span></td><td><?php echo e($txn->customer?->name ?? '-'); ?></td><td><?php echo e($txn->reference ?: '-'); ?></td><td class="text-end"><?php echo e(number_format($txn->quantity,2)); ?></td><td class="text-end"><?php echo e(number_format($txn->quantity*$txn->unit_price,2)); ?></td><td><?php echo e($txn->creator?->name ?? '-'); ?></td></tr><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><tr><td colspan="8" class="text-center py-4">No stock transactions.</td></tr><?php endif; ?></tbody></table></div></div>
<?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('inventory.manage')): ?>
<div class="modal fade" id="itemModal" tabindex="-1"><div class="modal-dialog modal-lg"><form method="post" action="<?php echo e(route('admin.inventory.store')); ?>" class="modal-content"><?php echo csrf_field(); ?><div class="modal-header"><h5 class="modal-title">Add inventory item</h5><button class="btn-close" data-bs-dismiss="modal" type="button"></button></div><div class="modal-body"><div class="row g-3"><div class="col-md-4"><label class="form-label">SKU *</label><input name="sku" class="form-control" required></div><div class="col-md-8"><label class="form-label">Item name *</label><input name="name" class="form-control" required></div><div class="col-md-4"><label class="form-label">Category</label><input name="category" class="form-control"></div><div class="col-md-4"><label class="form-label">Unit *</label><input name="unit" value="pcs" class="form-control" required></div><div class="col-md-4"><label class="form-label">Opening stock</label><input name="opening_stock" value="0" type="number" step="0.01" min="0" class="form-control"></div><div class="col-md-4"><label class="form-label">Purchase price</label><input name="purchase_price" value="0" type="number" step="0.01" min="0" class="form-control" required></div><div class="col-md-4"><label class="form-label">Sale price</label><input name="sale_price" value="0" type="number" step="0.01" min="0" class="form-control" required></div><div class="col-md-4"><label class="form-label">Low stock alert</label><input name="minimum_stock" value="0" type="number" step="0.01" min="0" class="form-control" required></div><div class="col-12"><label class="form-label">Description</label><textarea name="description" class="form-control"></textarea></div></div></div><div class="modal-footer"><button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Cancel</button><button class="btn btn-primary">Save item</button></div></form></div></div>
<div class="modal fade" id="transactionModal" tabindex="-1"><div class="modal-dialog modal-lg"><form method="post" action="<?php echo e(route('admin.inventory.transaction')); ?>" class="modal-content"><?php echo csrf_field(); ?><div class="modal-header"><h5 class="modal-title">Stock transaction</h5><button class="btn-close" data-bs-dismiss="modal" type="button"></button></div><div class="modal-body"><div class="row g-3"><div class="col-md-6"><label class="form-label">Item *</label><select name="inventory_item_id" class="form-select" required><option value="">Select</option><?php $__currentLoopData = $activeItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($item->id); ?>"><?php echo e($item->sku); ?> — <?php echo e($item->name); ?> (<?php echo e($item->stock_quantity); ?> <?php echo e($item->unit); ?>)</option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div><div class="col-md-6"><label class="form-label">Type *</label><select name="type" id="stockType" class="form-select" required><option value="purchase">Purchase / Stock in</option><option value="issue">Issue to customer</option><option value="return">Return from customer</option><option value="adjustment_in">Adjustment in</option><option value="adjustment_out">Adjustment out</option></select></div><div class="col-md-6"><label class="form-label">Customer</label><select name="customer_id" class="form-select"><option value="">Not applicable</option><?php $__currentLoopData = $customers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $customer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($customer->id); ?>"><?php echo e($customer->customer_code); ?> — <?php echo e($customer->name); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div><div class="col-md-3"><label class="form-label">Quantity *</label><input name="quantity" type="number" step="0.01" min="0.01" class="form-control" required></div><div class="col-md-3"><label class="form-label">Unit price</label><input name="unit_price" type="number" step="0.01" min="0" class="form-control"></div><div class="col-md-4"><label class="form-label">Date *</label><input name="transaction_date" type="date" value="<?php echo e(now()->toDateString()); ?>" class="form-control" required></div><div class="col-md-8"><label class="form-label">Reference</label><input name="reference" class="form-control" placeholder="Purchase invoice / device serial"></div><div class="col-12"><label class="form-label">Note</label><textarea name="note" class="form-control"></textarea></div></div></div><div class="modal-footer"><button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Cancel</button><button class="btn btn-primary">Save transaction</button></div></form></div></div>
<?php endif; ?>
<?php if($errors->any()): ?> <?php $__env->startPush('scripts'); ?><script>document.addEventListener('DOMContentLoaded',()=>Swal.fire({icon:'error',title:'Please check the form',html:<?php echo json_encode(implode('<br>', $errors->all()), 512) ?>}));</script><?php $__env->stopPush(); ?> <?php endif; ?>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH D:\herd\billing\laravel-app\resources\views/admin/inventory/index.blade.php ENDPATH**/ ?>