<?php
/** PSI 物料列表（面辅料） */
?>
<div class="page-head">
    <h1>物料管理</h1>
    <a class="btn-primary" href="<?php echo site_url('PSI/materials/create'); ?>">+ 新增物料</a>
</div>
<div class="panel">
    <table class="tbl">
        <thead><tr><th>ID</th><th>编码</th><th>名称</th><th>规格</th><th>单位</th><th>分类</th><th>颜色</th><th>成分</th><th>克重(g)</th><th>幅宽(cm)</th><th>缸号</th><th>库存</th><th>单价</th><th>供应商</th><th>操作</th></tr></thead>
        <tbody>
        <?php foreach ($materials as $m): ?>
            <tr>
                <td><?php echo e($m['id']); ?></td>
                <td><?php echo e($m['code'] ?? ''); ?></td>
                <td><?php echo e($m['name']); ?></td>
                <td><?php echo e($m['spec'] ?? ''); ?></td>
                <td><?php echo e($m['unit'] ?? '个'); ?></td>
                <td><?php echo e($m['category'] ?? ''); ?></td>
                <td><?php echo e($m['color'] ?? ''); ?></td>
                <td><?php echo e($m['composition'] ?? ''); ?></td>
                <td><?php echo e((float)($m['weight_gsm'] ?? 0)); ?></td>
                <td><?php echo e((float)($m['width_cm'] ?? 0)); ?></td>
                <td><?php echo e($m['batch_no'] ?? ''); ?></td>
                <td><b><?php echo e((float)($m['stock'] ?? 0)); ?></b></td>
                <td>¥<?php echo e(number_format((float)($m['price'] ?? 0), 2)); ?></td>
                <td><?php echo e($smap[$m['supplier_id']] ?? ''); ?></td>
                <td class="row-actions">
                    <a href="<?php echo site_url('PSI/materials/adjust/' . $m['id']); ?>">调整库存</a>
                    <a href="<?php echo site_url('PSI/materials/edit/' . $m['id']); ?>">编辑</a>
                    <a href="<?php echo site_url('PSI/materials/destroy/' . $m['id']); ?>" data-confirm="确认删除？">删除</a>
                </td>
            </tr>
        <?php endforeach; ?>
        <?php if (empty($materials)): ?><tr><td colspan="15" class="muted">暂无物料，点击右上角新增</td></tr><?php endif; ?>
        </tbody>
    </table>
</div>
