

<?php $__env->startSection('title', 'Warehouse Bin Details'); ?>

<?php $__env->startSection('content'); ?>
<div class="page-content">
    <div class="row">
        <div class="col-md-12">
            <div class="page-title-box">
                <div class="page-title-right">
                    <ol class="breadcrumb m-0">
                        <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>">Dashboard</a></li>
                        <li class="breadcrumb-item"><a href="<?php echo e(route('warehouse-bins.index')); ?>">Warehouse Bins</a></li>
                        <li class="breadcrumb-item active"><?php echo e($warehouseBin->code); ?></li>
                    </ol>
                </div>
                <h4 class="page-title">Warehouse Bin Details</h4>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center mb-3">
                        <h6 class="card-title mb-0">Bin: <?php echo e($warehouseBin->code); ?></h6>
                        <div class="d-flex gap-2">
                            <a href="<?php echo e(route('warehouse-bins.edit', $warehouseBin)); ?>" class="btn btn-primary">Edit</a>
                            <a href="<?php echo e(route('warehouse-bins.index')); ?>" class="btn btn-secondary">Back to List</a>
                        </div>
                    </div>

                    <div class="row g-3">
                        <!-- Basic Information -->
                        <div class="col-12">
                            <h6 class="card-title">Basic Information</h6>
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-bold">Bin Code</label>
                            <p class="form-control-plaintext"><?php echo e($warehouseBin->code); ?></p>
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-bold">Full Code</label>
                            <p class="form-control-plaintext"><?php echo e($warehouseBin->full_code); ?></p>
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-bold">Warehouse</label>
                            <p class="form-control-plaintext">
                                <?php echo e($warehouseBin->warehouse->name ?? 'N/A'); ?> (<?php echo e($warehouseBin->warehouse->code ?? 'N/A'); ?>)
                            </p>
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-bold">Bin Type</label>
                            <p class="form-control-plaintext"><?php echo $warehouseBin->type_badge; ?></p>
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-bold">Status</label>
                            <p class="form-control-plaintext"><?php echo $warehouseBin->status_badge; ?></p>
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-bold">Created At</label>
                            <p class="form-control-plaintext"><?php echo e($warehouseBin->created_at->format('M d, Y H:i')); ?></p>
                        </div>

                        <div class="col-md-6">
                            <label class="form-label fw-bold">Last Updated</label>
                            <p class="form-control-plaintext"><?php echo e($warehouseBin->updated_at->format('M d, Y H:i')); ?></p>
                        </div>
                    </div>

                    <!-- Stock Information -->
                    <?php if($warehouseBin->stockBalances->count() > 0): ?>
                    <div class="mt-4">
                        <h6 class="card-title">Stock Balances</h6>
                        <div class="table-responsive">
                            <table class="table table-sm">
                                <thead>
                                    <tr>
                                        <th>Item</th>
                                        <th>Variation</th>
                                        <th>Quantity</th>
                                        <th>Reserved</th>
                                        <th>Available</th>
                                        <th>Last Updated</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $__currentLoopData = $warehouseBin->stockBalances->take(10); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $balance): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td><?php echo e($balance->item->name ?? 'N/A'); ?></td>
                                        <td><?php echo e($balance->itemVariation->name ?? 'N/A'); ?></td>
                                        <td><?php echo e($balance->quantity ?? 'N/A'); ?></td>
                                        <td><?php echo e($balance->reserved_quantity ?? 'N/A'); ?></td>
                                        <td><?php echo e(($balance->quantity ?? 0) - ($balance->reserved_quantity ?? 0)); ?></td>
                                        <td><?php echo e($balance->updated_at->format('M d, Y')); ?></td>
                                    </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <?php endif; ?>

                    <!-- Stock Ledger Entries -->
                    <?php if($warehouseBin->stockLedgerEntries->count() > 0): ?>
                    <div class="mt-4">
                        <h6 class="card-title">Recent Stock Movements</h6>
                        <div class="table-responsive">
                            <table class="table table-sm">
                                <thead>
                                    <tr>
                                        <th>Date</th>
                                        <th>Type</th>
                                        <th>Item</th>
                                        <th>Quantity</th>
                                        <th>Reference</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $__currentLoopData = $warehouseBin->stockLedgerEntries->take(10); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $entry): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td><?php echo e($entry->created_at->format('M d, Y')); ?></td>
                                        <td><?php echo e($entry->type ?? 'N/A'); ?></td>
                                        <td><?php echo e($entry->item->name ?? 'N/A'); ?></td>
                                        <td><?php echo e($entry->quantity ?? 'N/A'); ?></td>
                                        <td><?php echo e($entry->reference ?? 'N/A'); ?></td>
                                    </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <?php endif; ?>

                    <!-- Transfer Information -->
                    <?php if($warehouseBin->fromTransfers->count() > 0 || $warehouseBin->toTransfers->count() > 0): ?>
                    <div class="mt-4">
                        <h6 class="card-title">Stock Transfers</h6>
                        <div class="row">
                            <?php if($warehouseBin->fromTransfers->count() > 0): ?>
                            <div class="col-md-6">
                                <h6 class="text-danger">Outgoing Transfers</h6>
                                <div class="table-responsive">
                                    <table class="table table-sm">
                                        <thead>
                                            <tr>
                                                <th>Date</th>
                                                <th>To Bin</th>
                                                <th>Status</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php $__currentLoopData = $warehouseBin->fromTransfers->take(5); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $transfer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <tr>
                                                <td><?php echo e($transfer->created_at->format('M d, Y')); ?></td>
                                                <td><?php echo e($transfer->toBin->code ?? 'N/A'); ?></td>
                                                <td><?php echo e($transfer->status ?? 'N/A'); ?></td>
                                            </tr>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <?php endif; ?>

                            <?php if($warehouseBin->toTransfers->count() > 0): ?>
                            <div class="col-md-6">
                                <h6 class="text-success">Incoming Transfers</h6>
                                <div class="table-responsive">
                                    <table class="table table-sm">
                                        <thead>
                                            <tr>
                                                <th>Date</th>
                                                <th>From Bin</th>
                                                <th>Status</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php $__currentLoopData = $warehouseBin->toTransfers->take(5); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $transfer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <tr>
                                                <td><?php echo e($transfer->created_at->format('M d, Y')); ?></td>
                                                <td><?php echo e($transfer->fromBin->code ?? 'N/A'); ?></td>
                                                <td><?php echo e($transfer->status ?? 'N/A'); ?></td>
                                            </tr>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <?php endif; ?>
                        </div>
                    </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\habibcables-ERP\resources\views\warehouse_bins\show.blade.php ENDPATH**/ ?>