|
@@ -12,7 +12,7 @@ if ($act == 'postchk') {
|
|
|
$sqlStr = "";
|
|
|
if (isset($_POST['chkbox'])) {
|
|
|
foreach ($_POST['chkbox'] as $id) {
|
|
|
- $sqlStr .= ($sqlStr ? " OR id=" : " WHERE id=") . (int)$id;
|
|
|
+ $sqlStr .= ($sqlStr ? " OR id=" : " WHERE id=") . intval($id);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -20,11 +20,11 @@ if ($act == 'postchk') {
|
|
|
case "0":
|
|
|
case "1":
|
|
|
case "2":
|
|
|
- $sqlStr = "UPDATE customer SET cs_deal=" . (int)$chkact . $sqlStr;
|
|
|
+ $sqlStr = "UPDATE customer SET cs_deal=" . intval($chkact) . $sqlStr;
|
|
|
break;
|
|
|
default:
|
|
|
$chkact = str_replace('t', '', $chkact);
|
|
|
- $sqlStr = "UPDATE customer SET cs_belong=" . (int)$chkact . $sqlStr;
|
|
|
+ $sqlStr = "UPDATE customer SET cs_belong=" . intval($chkact) . $sqlStr;
|
|
|
}
|
|
|
|
|
|
$conn->query($sqlStr);
|
|
@@ -47,34 +47,47 @@ $filterStr = "";
|
|
|
$urlStr = "";
|
|
|
|
|
|
if (!empty($filterCountry)) {
|
|
|
- $filterStr .= " AND c.cs_country=" . (int)$filterCountry;
|
|
|
+ $filterStr .= " AND c.cs_country=" . intval($filterCountry);
|
|
|
$urlStr .= "&fliterCountry=" . $filterCountry;
|
|
|
}
|
|
|
|
|
|
if (!empty($filterQudao)) {
|
|
|
- $filterStr .= " AND c.cs_from=" . (int)$filterQudao;
|
|
|
+ $filterStr .= " AND c.cs_from=" . intval($filterQudao);
|
|
|
$urlStr .= "&fliterQudao=" . $filterQudao;
|
|
|
}
|
|
|
|
|
|
if (!empty($filterDeal)) {
|
|
|
- $filterStr .= " AND c.cs_deal=" . (int)$filterDeal;
|
|
|
+ $filterStr .= " AND c.cs_deal=" . intval($filterDeal);
|
|
|
$urlStr .= "&fliterDeal=" . $filterDeal;
|
|
|
}
|
|
|
|
|
|
if (!empty($filterBusiness)) {
|
|
|
- $filterStr .= " AND c.cs_type=" . (int)$filterBusiness;
|
|
|
+ $filterStr .= " AND c.cs_type=" . intval($filterBusiness);
|
|
|
$urlStr .= "&fliterBusiness=" . $filterBusiness;
|
|
|
}
|
|
|
|
|
|
if (!empty($filterContact)) {
|
|
|
switch ($filterContact) {
|
|
|
- case "1": $filterStr .= " AND cc.tel<>''"; break;
|
|
|
- case "2": $filterStr .= " AND cc.wechat<>''"; break;
|
|
|
- case "3": $filterStr .= " AND cc.whatsapp<>''"; break;
|
|
|
- case "4": $filterStr .= " AND cc.email<>''"; break;
|
|
|
- case "5": $filterStr .= " AND cc.linkedin<>''"; break;
|
|
|
- case "6": $filterStr .= " AND cc.facebook<>''"; break;
|
|
|
- default: $filterStr .= " AND cc.alibaba<>''";
|
|
|
+ case "1":
|
|
|
+ $filterStr .= " AND (cc.tel_1<>'' OR cc.tel_2<>'' OR cc.tel_3<>'')";
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ $filterStr .= " AND (cc.wechat_1<>'' OR cc.wechat_2<>'' OR cc.wechat_3<>'')";
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ $filterStr .= " AND (cc.whatsapp_1<>'' OR cc.whatsapp_2<>'' OR cc.whatsapp_3<>'')";
|
|
|
+ break;
|
|
|
+ case "4":
|
|
|
+ $filterStr .= " AND (cc.email_1<>'' OR cc.email_2<>'' OR cc.email_3<>'')";
|
|
|
+ break;
|
|
|
+ case "5":
|
|
|
+ $filterStr .= " AND (cc.linkedin_1<>'' OR cc.linkedin_2<>'' OR cc.linkedin_3<>'')";
|
|
|
+ break;
|
|
|
+ case "6":
|
|
|
+ $filterStr .= " AND (cc.facebook_1<>'' OR cc.facebook_2<>'' OR cc.facebook_3<>'')";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ $filterStr .= " AND (cc.alibaba_1<>'' OR cc.alibaba_2<>'' OR cc.alibaba_3<>'')";
|
|
|
}
|
|
|
$urlStr .= "&fliterContact=" . $filterContact;
|
|
|
}
|
|
@@ -194,21 +207,67 @@ $hrefstr = "?keys=" . $keys;
|
|
|
</div>
|
|
|
|
|
|
<?php
|
|
|
-$sqlStr = "SELECT c.id, c.cs_code, c.cs_from, c.cs_country, c.cs_type, c.cs_deal, c.cs_addtime,
|
|
|
- cc.tel as cs_tel, cc.email as cs_email, cc.whatsapp as cs_whatsapp, cc.wechat as cs_wechat,
|
|
|
- cc.linkedin as cs_linkedin, cc.facebook as cs_facebook, cc.alibaba as cs_alibaba,
|
|
|
- c.colortag, c.cs_note, c.cs_claimFrom, c.cs_belong, c.cs_chain
|
|
|
- FROM customer c
|
|
|
- LEFT JOIN customer_contact cc ON c.id = cc.customer_id
|
|
|
- WHERE (c.is_silent=1 OR (c.cs_deal=0 AND c.cs_belong=" . $_SESSION['employee_id'] . "))
|
|
|
- AND (c.cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
+// 使用GROUP BY和GROUP_CONCAT来聚合多个联系人的信息
|
|
|
+$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_addtime) as cs_addtime, MAX(c.colortag) as colortag,
|
|
|
+ MAX(c.cs_note) as cs_note, MAX(c.cs_claimFrom) as cs_claimFrom,
|
|
|
+ MAX(c.cs_belong) as cs_belong, MAX(c.cs_chain) as cs_chain,
|
|
|
+ GROUP_CONCAT(cc.contact_name SEPARATOR '<br>') as contact_names,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.tel_1, '') SEPARATOR '<br>') as tel_1,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.tel_2, '') SEPARATOR '<br>') as tel_2,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.tel_3, '') SEPARATOR '<br>') as tel_3,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.tel_1_format, '') SEPARATOR '<br>') as tel_1_format,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.tel_2_format, '') SEPARATOR '<br>') as tel_2_format,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.tel_3_format, '') SEPARATOR '<br>') as tel_3_format,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.email_1, '') SEPARATOR '<br>') as email_1,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.email_2, '') SEPARATOR '<br>') as email_2,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.email_3, '') SEPARATOR '<br>') as email_3,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.whatsapp_1, '') SEPARATOR '<br>') as whatsapp_1,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.whatsapp_2, '') SEPARATOR '<br>') as whatsapp_2,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.whatsapp_3, '') SEPARATOR '<br>') as whatsapp_3,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.whatsapp_1_format, '') SEPARATOR '<br>') as whatsapp_1_format,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.whatsapp_2_format, '') SEPARATOR '<br>') as whatsapp_2_format,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.whatsapp_3_format, '') SEPARATOR '<br>') as whatsapp_3_format,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.wechat_1, '') SEPARATOR '<br>') as wechat_1,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.wechat_2, '') SEPARATOR '<br>') as wechat_2,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.wechat_3, '') SEPARATOR '<br>') as wechat_3,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.linkedin_1, '') SEPARATOR '<br>') as linkedin_1,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.linkedin_2, '') SEPARATOR '<br>') as linkedin_2,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.linkedin_3, '') SEPARATOR '<br>') as linkedin_3,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.facebook_1, '') SEPARATOR '<br>') as facebook_1,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.facebook_2, '') SEPARATOR '<br>') as facebook_2,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.facebook_3, '') SEPARATOR '<br>') as facebook_3,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.alibaba_1, '') SEPARATOR '<br>') as alibaba_1,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.alibaba_2, '') SEPARATOR '<br>') as alibaba_2,
|
|
|
+ GROUP_CONCAT(DISTINCT NULLIF(cc.alibaba_3, '') SEPARATOR '<br>') as alibaba_3
|
|
|
+ FROM customer c
|
|
|
+ LEFT JOIN customer_contact cc ON c.id = cc.customer_id
|
|
|
+ WHERE (c.is_silent=1 OR (c.cs_deal=0 AND c.cs_belong=" . intval($_SESSION['employee_id']) . "))";
|
|
|
+
|
|
|
+// 添加搜索条件
|
|
|
+if (!empty($keyscode)) {
|
|
|
+ $sqlStr .= " AND (c.cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
OR cc.contact_name LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
- OR cc.email LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
- OR cc.wechat LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
- OR cc.tel_format LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
- OR cc.whatsapp_format LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
- OR c.cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%')" .
|
|
|
- $filterStr . " ORDER BY c.colortag DESC, c.id DESC";
|
|
|
+ OR cc.email_1 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
+ OR cc.email_2 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
+ OR cc.email_3 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
+ OR cc.wechat_1 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
+ OR cc.wechat_2 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
+ OR cc.wechat_3 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
+ OR cc.tel_1_format LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
+ OR cc.tel_2_format LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
+ OR cc.tel_3_format LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
+ OR cc.whatsapp_1_format LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
+ OR cc.whatsapp_2_format LIKE '%" . $conn->real_escape_string($keyscode) . "%'
|
|
|
+ OR cc.whatsapp_3_format LIKE '%" . $conn->real_escape_string($keyscode) . "%')";
|
|
|
+}
|
|
|
+
|
|
|
+// 添加其他筛选条件
|
|
|
+$sqlStr .= $filterStr;
|
|
|
+
|
|
|
+// 分组和排序
|
|
|
+$sqlStr .= " GROUP BY c.id ORDER BY MAX(c.colortag) DESC, c.id DESC";
|
|
|
|
|
|
$result = $conn->query($sqlStr);
|
|
|
|
|
@@ -242,19 +301,19 @@ if ($result && $result->num_rows > 0) {
|
|
|
</div>
|
|
|
<div class="col10">
|
|
|
<?php
|
|
|
- $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
|
|
|
+ $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . intval($row['cs_from']));
|
|
|
echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialcharsFix($qudaoRow['ch_name']) : '未填写';
|
|
|
?>
|
|
|
</div>
|
|
|
<div class="col10">
|
|
|
<?php
|
|
|
- $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
|
|
|
+ $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . intval($row['cs_country']));
|
|
|
echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialcharsFix($countryRow['countryName']) : '未填写';
|
|
|
?>
|
|
|
</div>
|
|
|
<div class="col10">
|
|
|
<?php
|
|
|
- $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id=" . (int)$row['cs_type']);
|
|
|
+ $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id=" . intval($row['cs_type']));
|
|
|
echo ($typeRow = $typeResult->fetch_assoc()) ? htmlspecialcharsFix($typeRow['businessType']) : '未填写';
|
|
|
?>
|
|
|
</div>
|
|
@@ -281,13 +340,69 @@ if ($result && $result->num_rows > 0) {
|
|
|
<div class="notepanel clear">
|
|
|
<div class="noteItem">联系方式</div>
|
|
|
<div class="lx">
|
|
|
- <div class="tel"><?= htmlspecialcharsFix($row['cs_tel']) ?></div>
|
|
|
- <div class="mail"><a href="mailto:<?= htmlspecialcharsFix($row['cs_email']) ?>"><?= htmlspecialcharsFix($row['cs_email']) ?></a></div>
|
|
|
- <div class="whatsapp"><?= htmlspecialcharsFix($row['cs_whatsapp']) ?></div>
|
|
|
- <div class="wechat"><?= htmlspecialcharsFix($row['cs_wechat']) ?></div>
|
|
|
- <div class="linkedin"><?= htmlspecialcharsFix($row['cs_linkedin']) ?></div>
|
|
|
- <div class="facebook"><?= htmlspecialcharsFix($row['cs_facebook']) ?></div>
|
|
|
- <div class="alibaba"><?= htmlspecialcharsFix($row['cs_alibaba']) ?></div>
|
|
|
+ <div class="tel">
|
|
|
+ <?php
|
|
|
+ $tels = [];
|
|
|
+ if (!empty($row['tel_1'])) $tels[] = htmlspecialcharsFix($row['tel_1']);
|
|
|
+ if (!empty($row['tel_2'])) $tels[] = htmlspecialcharsFix($row['tel_2']);
|
|
|
+ if (!empty($row['tel_3'])) $tels[] = htmlspecialcharsFix($row['tel_3']);
|
|
|
+ echo implode('<br>', $tels);
|
|
|
+ ?>
|
|
|
+ </div>
|
|
|
+ <div class="mail">
|
|
|
+ <?php
|
|
|
+ $emails = [];
|
|
|
+ if (!empty($row['email_1'])) $emails[] = '<a href="mailto:' . htmlspecialcharsFix($row['email_1']) . '">' . htmlspecialcharsFix($row['email_1']) . '</a>';
|
|
|
+ if (!empty($row['email_2'])) $emails[] = '<a href="mailto:' . htmlspecialcharsFix($row['email_2']) . '">' . htmlspecialcharsFix($row['email_2']) . '</a>';
|
|
|
+ if (!empty($row['email_3'])) $emails[] = '<a href="mailto:' . htmlspecialcharsFix($row['email_3']) . '">' . htmlspecialcharsFix($row['email_3']) . '</a>';
|
|
|
+ echo implode('<br>', $emails);
|
|
|
+ ?>
|
|
|
+ </div>
|
|
|
+ <div class="whatsapp">
|
|
|
+ <?php
|
|
|
+ $whatsapps = [];
|
|
|
+ if (!empty($row['whatsapp_1'])) $whatsapps[] = htmlspecialcharsFix($row['whatsapp_1']);
|
|
|
+ if (!empty($row['whatsapp_2'])) $whatsapps[] = htmlspecialcharsFix($row['whatsapp_2']);
|
|
|
+ if (!empty($row['whatsapp_3'])) $whatsapps[] = htmlspecialcharsFix($row['whatsapp_3']);
|
|
|
+ echo implode('<br>', $whatsapps);
|
|
|
+ ?>
|
|
|
+ </div>
|
|
|
+ <div class="wechat">
|
|
|
+ <?php
|
|
|
+ $wechats = [];
|
|
|
+ if (!empty($row['wechat_1'])) $wechats[] = htmlspecialcharsFix($row['wechat_1']);
|
|
|
+ if (!empty($row['wechat_2'])) $wechats[] = htmlspecialcharsFix($row['wechat_2']);
|
|
|
+ if (!empty($row['wechat_3'])) $wechats[] = htmlspecialcharsFix($row['wechat_3']);
|
|
|
+ echo implode('<br>', $wechats);
|
|
|
+ ?>
|
|
|
+ </div>
|
|
|
+ <div class="linkedin">
|
|
|
+ <?php
|
|
|
+ $linkedins = [];
|
|
|
+ if (!empty($row['linkedin_1'])) $linkedins[] = htmlspecialcharsFix($row['linkedin_1']);
|
|
|
+ if (!empty($row['linkedin_2'])) $linkedins[] = htmlspecialcharsFix($row['linkedin_2']);
|
|
|
+ if (!empty($row['linkedin_3'])) $linkedins[] = htmlspecialcharsFix($row['linkedin_3']);
|
|
|
+ echo implode('<br>', $linkedins);
|
|
|
+ ?>
|
|
|
+ </div>
|
|
|
+ <div class="facebook">
|
|
|
+ <?php
|
|
|
+ $facebooks = [];
|
|
|
+ if (!empty($row['facebook_1'])) $facebooks[] = htmlspecialcharsFix($row['facebook_1']);
|
|
|
+ if (!empty($row['facebook_2'])) $facebooks[] = htmlspecialcharsFix($row['facebook_2']);
|
|
|
+ if (!empty($row['facebook_3'])) $facebooks[] = htmlspecialcharsFix($row['facebook_3']);
|
|
|
+ echo implode('<br>', $facebooks);
|
|
|
+ ?>
|
|
|
+ </div>
|
|
|
+ <div class="alibaba">
|
|
|
+ <?php
|
|
|
+ $alibabas = [];
|
|
|
+ if (!empty($row['alibaba_1'])) $alibabas[] = htmlspecialcharsFix($row['alibaba_1']);
|
|
|
+ if (!empty($row['alibaba_2'])) $alibabas[] = htmlspecialcharsFix($row['alibaba_2']);
|
|
|
+ if (!empty($row['alibaba_3'])) $alibabas[] = htmlspecialcharsFix($row['alibaba_3']);
|
|
|
+ echo implode('<br>', $alibabas);
|
|
|
+ ?>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<div class="noteItem2">备注</div>
|
|
|
<div class="notecontent">
|
|
@@ -296,14 +411,17 @@ if ($result && $result->num_rows > 0) {
|
|
|
<?php
|
|
|
if (!empty($row['cs_chain'])) {
|
|
|
$myArray = explode(',', $row['cs_chain']);
|
|
|
- $sqlStr = "SELECT em_user FROM employee WHERE id=" . (int)$myArray[0];
|
|
|
- for ($j = 1; $j < count($myArray); $j++) {
|
|
|
- $sqlStr .= " UNION ALL SELECT em_user FROM employee WHERE id=" . (int)$myArray[$j];
|
|
|
- }
|
|
|
- $chainResult = $conn->query($sqlStr);
|
|
|
- while ($chainRow = $chainResult->fetch_assoc()) {
|
|
|
- echo htmlspecialcharsFix($chainRow['em_user']) . " > ";
|
|
|
+ $chainEmployees = [];
|
|
|
+
|
|
|
+ foreach ($myArray as $employeeId) {
|
|
|
+ $sqlStr = "SELECT em_user FROM employee WHERE id=" . intval($employeeId);
|
|
|
+ $chainResult = $conn->query($sqlStr);
|
|
|
+ if ($chainRow = $chainResult->fetch_assoc()) {
|
|
|
+ $chainEmployees[] = htmlspecialcharsFix($chainRow['em_user']);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ echo implode(" > ", $chainEmployees);
|
|
|
}
|
|
|
?>
|
|
|
</div>
|