prepare($countQuery); if (!empty($params)) { $types = str_repeat('s', count($params)); $stmt->bind_param($types, ...$params); } $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_assoc(); $totalRecords = $row['total']; $totalPages = ceil($totalRecords / $perpage); // 获取关系列表 $query = "SELECT cr.*, c1.cs_company as source_company, c2.cs_company as target_company, e.em_user as creator FROM customer_relationship cr JOIN customer c1 ON cr.source_customer_id = c1.id JOIN customer c2 ON cr.target_customer_id = c2.id LEFT JOIN employee e ON cr.employee_id = e.id $whereClause ORDER BY cr.updated_at DESC LIMIT ?, ?"; $stmt = $conn->prepare($query); if (!empty($params)) { $params[] = $start; $params[] = $perpage; $types = str_repeat('s', count($params) - 2) . 'ii'; $stmt->bind_param($types, ...$params); } else { $stmt->bind_param('ii', $start, $perpage); } $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { // 获取关系类型描述 $relationType = ''; switch ($row['relationship_type']) { case 1: $relationType = '母公司-子公司'; break; case 2: $relationType = '供应商-客户'; break; case 3: $relationType = '合作伙伴'; break; case 4: $relationType = '竞争对手'; break; case 5: $relationType = '推荐人'; break; case 6: $relationType = '其他'; break; } $status = $row['relationship_status'] == 1 ? '启用' : '停用'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } } else { echo ''; } ?>
源客户 目标客户 关系类型 状态 创建人 创建时间 更新时间 操作
' . textDecode($row['source_company']) . '' . textDecode($row['target_company']) . '' . $relationType . '' . $status . '' . textDecode($row['creator']) . '' . $row['created_at'] . '' . $row['updated_at'] . ' 编辑 | 删除
没有找到客户关系记录
1) { echo '首页'; echo '上一页'; } // 显示5个页码,当前页在中间 $startPage = max(1, $page - 2); $endPage = min($totalPages, $page + 2); for ($i = $startPage; $i <= $endPage; $i++) { if ($i == $page) { echo '' . $i . ''; } else { echo '' . $i . ''; } } if ($page < $totalPages) { echo '下一页'; echo '末页'; } echo '第' . $page . '页/共' . $totalPages . '页'; ?>