<?php
/** CRM 跟进记录列表 */
$wayLabel = ['tel' => '电话', 'wechat' => '微信', 'visit' => '拜访', 'email' => '邮件', 'other' => '其他'];
?>
<div class="page-head">
    <h1>跟进记录</h1>
    <a class="btn-primary" href="<?php echo site_url('CRM/followups/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></tr></thead>
        <tbody>
        <?php foreach ($follows as $f): ?>
            <tr>
                <td><?php echo e($f['id']); ?></td>
                <td><?php echo e($f['created_at'] ?? ''); ?></td>
                <td><?php echo e($cmap[$f['customer_id']] ?? ('#' . $f['customer_id'])); ?></td>
                <td><?php echo e($wayLabel[$f['way'] ?? ''] ?? $f['way'] ?? ''); ?></td>
                <td><?php echo e(mb_substr($f['content'] ?? '', 0, 40)); ?></td>
                <td><?php echo e($f['result'] ?? ''); ?></td>
                <td><?php echo e($f['next_at'] ?? ''); ?></td>
                <td><?php echo e($f['owner'] ?? ''); ?></td>
                <td class="row-actions">
                    <a href="<?php echo site_url('CRM/followups/edit/' . $f['id']); ?>">编辑</a>
                    <a href="<?php echo site_url('CRM/followups/destroy/' . $f['id']); ?>" data-confirm="确认删除？">删除</a>
                </td>
            </tr>
        <?php endforeach; ?>
        <?php if (empty($follows)): ?><tr><td colspan="9" class="muted">暂无跟进记录</td></tr><?php endif; ?>
        </tbody>
    </table>
</div>
