<?php
/** PSI 供应商列表（面料商/辅料商/成衣加工厂/OEM） */
?>
<div class="page-head">
    <h1>供应商管理</h1>
    <a class="btn-primary" href="<?php echo site_url('PSI/suppliers/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></tr></thead>
        <tbody>
        <?php foreach ($suppliers as $s): ?>
            <tr>
                <td><?php echo e($s['id']); ?></td>
                <td><?php echo e($s['name']); ?></td>
                <td><?php echo e($s['type'] ?? ''); ?></td>
                <td><?php echo e($s['grade'] ?? ''); ?></td>
                <td><?php echo e($s['contact'] ?? ''); ?></td>
                <td><?php echo e($s['phone'] ?? ''); ?></td>
                <td><?php echo e($s['country'] ?? ''); ?></td>
                <td><?php echo ($s['ontime_rate'] !== '' && (float)$s['ontime_rate'] != 0) ? e($s['ontime_rate']) . '%' : '—'; ?></td>
                <td><?php echo ($s['qc_rate'] !== '' && (float)$s['qc_rate'] != 0) ? e($s['qc_rate']) . '%' : '—'; ?></td>
                <td><?php echo e(mb_substr($s['remark'] ?? '', 0, 30)); ?></td>
                <td class="row-actions">
                    <a href="<?php echo site_url('PSI/suppliers/edit/' . $s['id']); ?>">编辑</a>
                    <a href="<?php echo site_url('PSI/suppliers/destroy/' . $s['id']); ?>" data-confirm="确认删除？">删除</a>
                </td>
            </tr>
        <?php endforeach; ?>
        <?php if (empty($suppliers)): ?><tr><td colspan="11" class="muted">暂无供应商</td></tr><?php endif; ?>
        </tbody>
    </table>
</div>
