筛选条件

序号
源客户
目标客户
关系类型
状态
创建人
更新时间
操作
real_escape_string($keys) . '%'; $whereClause .= " AND (c1.cs_code LIKE '$searchKeys' OR c1.cs_company LIKE '$searchKeys' OR c2.cs_code LIKE '$searchKeys' OR c2.cs_company LIKE '$searchKeys' OR cr.description LIKE '$searchKeys')"; } if (!empty($fliterRelationType)) { $whereClause .= " AND cr.relationship_type = '" . $conn->real_escape_string($fliterRelationType) . "'"; } if (isset($fliterStatus) && $fliterStatus !== '') { $whereClause .= " AND cr.relationship_status = '" . $conn->real_escape_string($fliterStatus) . "'"; } // 分页设置 $page = (int)$page; $perpage = 20; // 每页显示条数 $start = ($page - 1) * $perpage; // 计算总记录数 $countQuery = "SELECT COUNT(*) as total FROM customer_relationship cr JOIN customer c1 ON cr.source_customer_id = c1.id JOIN customer c2 ON cr.target_customer_id = c2.id $whereClause"; $result = $conn->query($countQuery); $row = $result->fetch_assoc(); $totalRecords = $row['total']; $totalPages = ceil($totalRecords / $perpage); if ($totalPages < 1) $totalPages = 1; // 验证当前页码 if ($page < 1) $page = 1; if ($page > $totalPages) $page = $totalPages; // 获取关系列表 $query = "SELECT cr.*, c1.cs_code as source_code, c1.cs_company as source_company, c2.cs_code as target_code, 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 $start, $perpage"; $result = $conn->query($query); if ($result->num_rows > 0) { $tempNum = ($page - 1) * $perpage; while ($row = $result->fetch_assoc()) { $tempNum++; // 获取关系类型描述 $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 ? '启用' : '停用'; ?>
当前暂无客户关系记录
'; } else { echo '
没有找到匹配的客户关系记录,点击返回
'; } } ?>
1) { $pageName = "?Keys=$keys$urlStr&"; $pageLen = 3; if ($page > 1) { echo "首页"; echo "上一页"; } if ($pageLen * 2 + 1 >= $totalPages) { $startPage = 1; $endPage = $totalPages; } else { if ($page <= $pageLen + 1) { $startPage = 1; $endPage = $pageLen * 2 + 1; } else { $startPage = $page - $pageLen; $endPage = $page + $pageLen; } if ($page + $pageLen > $totalPages) { $startPage = $totalPages - $pageLen * 2; $endPage = $totalPages; } } for ($i = $startPage; $i <= $endPage; $i++) { if ($i == $page) { echo "$i"; } else { echo "$i"; } } if ($page < $totalPages) { if ($totalPages - $page > $pageLen) { echo "...$totalPages"; } echo "下一页"; echo "尾页"; } } ?>