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

<?php $__env->startSection('content'); ?>
<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">Warehouse Details</h6>
            <div class="d-flex gap-2">
                <a href="<?php echo e(route('warehouses.edit', $warehouse)); ?>" class="btn btn-primary">Edit</a>
                <a href="<?php echo e(route('warehouses.index')); ?>" class="btn btn-secondary">Back to List</a>
            </div>
        </div>

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

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

            <div class="col-md-6">
                <label class="form-label fw-bold">Type</label>
                <p class="form-control-plaintext">
                    <span class="badge bg-info"><?php echo e($warehouse->type_label); ?></span>
                </p>
            </div>

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

            <div class="col-md-6">
                <label class="form-label fw-bold">Physical Location</label>
                <p class="form-control-plaintext"><?php echo e($warehouse->location_display); ?></p>
            </div>

            <div class="col-md-6">
                <label class="form-label fw-bold">Site ID</label>
                <p class="form-control-plaintext"><?php echo e($warehouse->site_id ?: 'Not specified'); ?></p>
            </div>

            <div class="col-md-6">
                <label class="form-label fw-bold">Total Bins</label>
                <p class="form-control-plaintext">
                    <a href="<?php echo e(route('warehouse-bins.index')); ?>?warehouse=<?php echo e($warehouse->id); ?>" class="text-decoration-none">
                        <?php echo e($warehouse->total_bins); ?> bins
                    </a>
                </p>
            </div>

            <div class="col-md-6">
                <label class="form-label fw-bold">Total Locations</label>
                <p class="form-control-plaintext">
                    <a href="<?php echo e(route('locations.index')); ?>?warehouse=<?php echo e($warehouse->id); ?>" class="text-decoration-none">
                        <?php echo e($warehouse->total_locations); ?> locations
                    </a>
                </p>
            </div>

            <div class="col-md-6">
                <label class="form-label fw-bold">Stock Balances</label>
                <p class="form-control-plaintext"><?php echo e($warehouse->total_stock_balances); ?> items</p>
            </div>

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

        <?php if($warehouse->bins->count() > 0): ?>
        <div class="mt-4">
            <h6 class="card-title">Recent Bins</h6>
            <div class="table-responsive">
                <table class="table table-sm">
                    <thead>
                        <tr>
                            <th>Bin Code</th>
                            <th>Description</th>
                            <th>Status</th>
                            <th>Created</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $warehouse->bins->take(5); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $bin): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($bin->code); ?></td>
                            <td><?php echo e($bin->description ?: 'No description'); ?></td>
                            <td><?php echo $bin->status_badge; ?></td>
                            <td><?php echo e($bin->created_at->format('M d, Y')); ?></td>
                        </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            </div>
        </div>
        <?php endif; ?>

        <?php if($warehouse->locations->count() > 0): ?>
        <div class="mt-4">
            <h6 class="card-title">Recent Locations</h6>
            <div class="table-responsive">
                <table class="table table-sm">
                    <thead>
                        <tr>
                            <th>Location Name</th>
                            <th>Barcode</th>
                            <th>Created</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $warehouse->locations->take(5); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $location): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($location->name); ?></td>
                            <td><?php echo e($location->barcode ?: 'No barcode'); ?></td>
                            <td><?php echo e($location->created_at->format('M d, Y')); ?></td>
                        </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            </div>
        </div>
        <?php endif; ?>

        <?php if($warehouse->stockBalances->count() > 0): ?>
        <div class="mt-4">
            <h6 class="card-title">Recent Stock Balances</h6>
            <div class="table-responsive">
                <table class="table table-sm">
                    <thead>
                        <tr>
                            <th>Item</th>
                            <th>Quantity</th>
                            <th>Last Updated</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $warehouse->stockBalances; $__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->quantity ?? 'N/A'); ?></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; ?>
    </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\warehouses\show.blade.php ENDPATH**/ ?>