<?php
/** PSI 库存流水 */
?>
<div class="page-head">
    <h1>库存流水</h1>
    <p class="sub">所有采购入库 / 销售出库 / 手动调整 的变动记录</p>
</div>
<div class="panel">
    <table class="tbl">
        <thead><tr><th>时间</th><th>类型</th><th>名称</th><th>方向</th><th>数量</th><th>批次/缸号</th><th>关联单号</th></tr></thead>
        <tbody>
        <?php foreach ($moves as $mv): ?>
            <tr>
                <td><?php echo e($mv['created_at'] ?? ''); ?></td>
                <td><?php echo $mv['item_type'] === 'product' ? '成品' : '物料'; ?></td>
                <td><?php echo e($nameMap[($mv['item_type'] ?? 'product') . ':' . ($mv['item_id'] ?? 0)] ?? ('#' . ($mv['item_id'] ?? ''))); ?></td>
                <td>
                    <?php if (($mv['direction'] ?? '') === 'in'): ?><span class="tag-in">入库 +</span>
                    <?php else: ?><span class="tag-out">出库 -</span><?php endif; ?>
                </td>
                <td><?php echo e((float)($mv['qty'] ?? 0)); ?></td>
                <td><?php echo e($mv['batch_no'] ?? ''); ?></td>
                <td><?php echo e($mv['ref_no'] ?? ''); ?></td>
            </tr>
        <?php endforeach; ?>
        <?php if (empty($moves)): ?><tr><td colspan="7" class="muted">暂无库存流水</td></tr><?php endif; ?>
        </tbody>
    </table>
</div>
