搜索条件
real_escape_string($keyscode);
$sqlStr = "SELECT c.id,
MAX(c.cs_code) as cs_code,
MAX(c.cs_from) as cs_from,
MAX(c.cs_country) as cs_country,
MAX(c.cs_type) as cs_type,
MAX(c.cs_deal) as cs_deal,
MAX(c.cs_updatetime) as cs_updatetime,
MAX(c.cs_note) as cs_note,
MAX(c.cs_state) as cs_state,
MAX(c.cs_claimFrom) as cs_claimFrom,
MAX(c.cs_belongclient) as cs_belongclient,
GROUP_CONCAT(DISTINCT cc.id) as contact_ids,
GROUP_CONCAT(DISTINCT cc.contact_name) as contact_names,
GROUP_CONCAT(DISTINCT cc.tel_1) as tel_1_list,
GROUP_CONCAT(DISTINCT cc.tel_2) as tel_2_list,
GROUP_CONCAT(DISTINCT cc.tel_3) as tel_3_list,
GROUP_CONCAT(DISTINCT cc.email_1) as email_1_list,
GROUP_CONCAT(DISTINCT cc.email_2) as email_2_list,
GROUP_CONCAT(DISTINCT cc.email_3) as email_3_list,
GROUP_CONCAT(DISTINCT cc.whatsapp_1) as whatsapp_1_list,
GROUP_CONCAT(DISTINCT cc.whatsapp_2) as whatsapp_2_list,
GROUP_CONCAT(DISTINCT cc.whatsapp_3) as whatsapp_3_list,
GROUP_CONCAT(DISTINCT cc.wechat_1) as wechat_1_list,
GROUP_CONCAT(DISTINCT cc.wechat_2) as wechat_2_list,
GROUP_CONCAT(DISTINCT cc.wechat_3) as wechat_3_list,
GROUP_CONCAT(DISTINCT cc.linkedin_1) as linkedin_1_list,
GROUP_CONCAT(DISTINCT cc.linkedin_2) as linkedin_2_list,
GROUP_CONCAT(DISTINCT cc.linkedin_3) as linkedin_3_list,
GROUP_CONCAT(DISTINCT cc.facebook_1) as facebook_1_list,
GROUP_CONCAT(DISTINCT cc.facebook_2) as facebook_2_list,
GROUP_CONCAT(DISTINCT cc.facebook_3) as facebook_3_list,
GROUP_CONCAT(DISTINCT cc.alibaba_1) as alibaba_1_list,
GROUP_CONCAT(DISTINCT cc.alibaba_2) as alibaba_2_list,
GROUP_CONCAT(DISTINCT cc.alibaba_3) as alibaba_3_list
FROM customer c
LEFT JOIN customer_contact cc ON c.id = cc.customer_id
WHERE c.cs_deal<>3 AND c.cs_type<>2
AND DATEDIFF(NOW(), c.cs_updatetime) > 60
AND NOT EXISTS (
SELECT 1 FROM customer_contact
WHERE customer_id = c.id
AND wechat_1 LIKE 'wxid%'
)
AND c.cs_belongclient=0
AND c.cs_belong<>" . $employee_id . "
AND c.cs_belong IN (" . $memberStr . ")
AND (c.cs_code LIKE '%" . $escapedKeyscode . "%'
OR cc.contact_name LIKE '%" . $escapedKeyscode . "%'
OR cc.email_1 LIKE '%" . $escapedKeyscode . "%'
OR cc.email_2 LIKE '%" . $escapedKeyscode . "%'
OR cc.email_3 LIKE '%" . $escapedKeyscode . "%'
OR cc.wechat_1 LIKE '%" . $escapedKeyscode . "%'
OR cc.wechat_2 LIKE '%" . $escapedKeyscode . "%'
OR cc.wechat_3 LIKE '%" . $escapedKeyscode . "%'
OR cc.tel_1 LIKE '%" . $escapedKeyscode . "%'
OR cc.tel_2 LIKE '%" . $escapedKeyscode . "%'
OR cc.tel_3 LIKE '%" . $escapedKeyscode . "%'
OR cc.whatsapp_1 LIKE '%" . $escapedKeyscode . "%'
OR cc.whatsapp_2 LIKE '%" . $escapedKeyscode . "%'
OR cc.whatsapp_3 LIKE '%" . $escapedKeyscode . "%')" .
$filterStr . " GROUP BY c.id ORDER BY cs_state DESC, c.id DESC";
$result = $conn->query($sqlStr);
if ($result && $result->num_rows > 0) {
$pageSize = 20;
$page = empty($page) ? 1 : $page;
$page = ($page === 'end') ? ceil($result->num_rows / $pageSize) : $page;
$page = (!is_numeric($page) || $page < 1) ? 1 : (int)$page;
$totalPages = ceil($result->num_rows / $pageSize);
$page = ($page > $totalPages) ? $totalPages : $page;
$offset = $pageSize * ($page - 1);
$rows = [];
while ($row = $result->fetch_assoc()) {
$rows[] = $row;
}
$paginatedRows = array_slice($rows, $offset, $pageSize);
$tempNum = $offset;
foreach ($paginatedRows as $row) {
$tempNum++;
?>
= $tempNum ?>
= htmlspecialcharsFix($row['cs_code']) ?>
0): ?>
query("SELECT ch_name FROM qudao WHERE id=" . $cs_from);
echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialcharsFix($qudaoRow['ch_name']) : '未填写';
?>
query("SELECT countryName FROM country WHERE id=" . $cs_country);
echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialcharsFix($countryRow['countryName']) : '未填写';
?>
query("SELECT businessType FROM clienttype WHERE id=" . $cs_type);
echo ($typeRow = $typeResult->fetch_assoc()) ? htmlspecialcharsFix($typeRow['businessType']) : '未填写';
?>
= $row['cs_updatetime'] ?>
认领
联系方式
';
if (!empty($row['tel_1_list'])) echo htmlspecialcharsFix($row['tel_1_list']) . '
';
if (!empty($row['tel_2_list'])) echo htmlspecialcharsFix($row['tel_2_list']) . '
';
if (!empty($row['tel_3_list'])) echo htmlspecialcharsFix($row['tel_3_list']);
echo '
';
// 处理邮箱
echo '
';
// 处理WhatsApp
echo '
';
if (!empty($row['whatsapp_1_list'])) echo htmlspecialcharsFix($row['whatsapp_1_list']) . '
';
if (!empty($row['whatsapp_2_list'])) echo htmlspecialcharsFix($row['whatsapp_2_list']) . '
';
if (!empty($row['whatsapp_3_list'])) echo htmlspecialcharsFix($row['whatsapp_3_list']);
echo '
';
// 处理微信
echo '
';
if (!empty($row['wechat_1_list'])) echo htmlspecialcharsFix($row['wechat_1_list']) . '
';
if (!empty($row['wechat_2_list'])) echo htmlspecialcharsFix($row['wechat_2_list']) . '
';
if (!empty($row['wechat_3_list'])) echo htmlspecialcharsFix($row['wechat_3_list']);
echo '
';
// 处理LinkedIn
echo '
';
if (!empty($row['linkedin_1_list'])) echo htmlspecialcharsFix($row['linkedin_1_list']) . '
';
if (!empty($row['linkedin_2_list'])) echo htmlspecialcharsFix($row['linkedin_2_list']) . '
';
if (!empty($row['linkedin_3_list'])) echo htmlspecialcharsFix($row['linkedin_3_list']);
echo '
';
// 处理Facebook
echo '
';
if (!empty($row['facebook_1_list'])) echo htmlspecialcharsFix($row['facebook_1_list']) . '
';
if (!empty($row['facebook_2_list'])) echo htmlspecialcharsFix($row['facebook_2_list']) . '
';
if (!empty($row['facebook_3_list'])) echo htmlspecialcharsFix($row['facebook_3_list']);
echo '
';
// 处理阿里巴巴
echo '
';
if (!empty($row['alibaba_1_list'])) echo htmlspecialcharsFix($row['alibaba_1_list']) . '
';
if (!empty($row['alibaba_2_list'])) echo htmlspecialcharsFix($row['alibaba_2_list']) . '
';
if (!empty($row['alibaba_3_list'])) echo htmlspecialcharsFix($row['alibaba_3_list']);
echo '
';
?>
备注
= htmlUnCode($row['cs_note']) ?>