<?php
/** PSI 成品列表（降温服/成衣：款号/颜色/尺码/季节） */
?>
<div class="page-head">
    <h1>成品管理</h1>
    <a class="btn-primary" href="<?php echo site_url('PSI/products/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>尺码</th><th>季节</th><th>年份</th><th>库存</th><th>成本</th><th>售价</th><th>操作</th></tr></thead>
        <tbody>
        <?php foreach ($products as $p): ?>
            <tr>
                <td><?php echo e($p['id']); ?></td>
                <td><?php echo e($p['code'] ?? ''); ?></td>
                <td><b><?php echo e($p['style_no'] ?? ''); ?></b></td>
                <td><?php echo e($p['name']); ?></td>
                <td><?php echo e($p['spec'] ?? ''); ?></td>
                <td><?php echo e($p['unit'] ?? '件'); ?></td>
                <td><?php echo e($p['category'] ?? ''); ?></td>
                <td><?php echo e($p['color'] ?? ''); ?></td>
                <td><?php echo e($p['size_run'] ?? ''); ?></td>
                <td><?php echo e($p['season'] ?? ''); ?></td>
                <td><?php echo e($p['year'] ?? ''); ?></td>
                <td><b><?php echo e((float)($p['stock'] ?? 0)); ?></b></td>
                <td>¥<?php echo e(number_format((float)($p['cost'] ?? 0), 2)); ?></td>
                <td>¥<?php echo e(number_format((float)($p['price'] ?? 0), 2)); ?></td>
                <td class="row-actions">
                    <a href="<?php echo site_url('PSI/products/adjust/' . $p['id']); ?>">调整库存</a>
                    <a href="<?php echo site_url('PSI/products/edit/' . $p['id']); ?>">编辑</a>
                    <a href="<?php echo site_url('PSI/products/destroy/' . $p['id']); ?>" data-confirm="确认删除？">删除</a>
                </td>
            </tr>
        <?php endforeach; ?>
        <?php if (empty($products)): ?><tr><td colspan="15" class="muted">暂无成品，点击右上角新增</td></tr><?php endif; ?>
        </tbody>
    </table>
</div>
