Browse Source

fleat: tag update

igb 3 weeks ago
parent
commit
d671a0bf18
5 changed files with 459 additions and 83 deletions
  1. 141 34
      subCustomers.php
  2. 186 14
      subTag.php
  3. 19 13
      subTagClound.php
  4. 104 12
      tag.php
  5. 9 10
      tagClound.php

+ 141 - 34
subCustomers.php

@@ -46,34 +46,34 @@ $filterStr = "";
 $urlStr = "";
 
 if (!empty($filterCountry)) {
-    $filterStr .= " AND cs_country=" . (int)$filterCountry;
+    $filterStr .= " AND c.cs_country=" . (int)$filterCountry;
     $urlStr .= "&fliterCountry=" . $filterCountry;
 }
 
 if (!empty($filterQudao)) {
-    $filterStr .= " AND cs_from=" . (int)$filterQudao;
+    $filterStr .= " AND c.cs_from=" . (int)$filterQudao;
     $urlStr .= "&fliterQudao=" . $filterQudao;
 }
 
 if (!empty($filterDeal)) {
-    $filterStr .= " AND cs_deal=" . (int)$filterDeal;
+    $filterStr .= " AND c.cs_deal=" . (int)$filterDeal;
     $urlStr .= "&fliterDeal=" . $filterDeal;
 }
 
 if (!empty($filterBusiness)) {
-    $filterStr .= " AND cs_type=" . (int)$filterBusiness;
+    $filterStr .= " AND c.cs_type=" . (int)$filterBusiness;
     $urlStr .= "&fliterBusiness=" . $filterBusiness;
 }
 
 if (!empty($filterContact)) {
     switch ($filterContact) {
-        case "1": $filterStr .= " AND cs_tel<>''"; break;
-        case "2": $filterStr .= " AND cs_wechat<>''"; break;
-        case "3": $filterStr .= " AND cs_whatsapp<>''"; break;
-        case "4": $filterStr .= " AND cs_email<>''"; break;
-        case "5": $filterStr .= " AND cs_linkedin<>''"; break;
-        case "6": $filterStr .= " AND cs_facebook<>''"; break;
-        default: $filterStr .= " AND cs_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;
+        case "7": $filterStr .= " AND (cc.alibaba_1 != '' OR cc.alibaba_2 != '' OR cc.alibaba_3 != '')"; break;
     }
     $urlStr .= "&fliterContact=" . $filterContact;
 }
@@ -170,11 +170,8 @@ $hrefstr = "?keys=" . $keys;
                 </select>
             </div>
             <div class="inputSearch">
-                <input type="text" id="keys" class="inputTxt" 
-                       value="<?= empty($keyscode) ? '请输入搜索关键词' : htmlspecialcharsFix($keyscode) ?>" 
-                       onFocus="if(this.value == '<?= empty($keyscode) ? '请输入搜索关键词' : htmlspecialcharsFix($keyscode) ?>'){this.value='';}" 
-                       onBlur="if(this.value == ''){this.value='<?= empty($keyscode) ? '请输入搜索关键词' : htmlspecialcharsFix($keyscode) ?>';}" 
-                       onKeyDown="if(event.keyCode==13){location.href='?Keys='+escape(document.getElementById('keys').value)}" />
+                <input type="text" id="keys" class="inputTxt" placeholder="请输入搜索关键词"
+                       value="<?= empty($keyscode) ? '' : htmlspecialcharsFix($keyscode) ?>"/>
                 <input type="button" id="searchgo" class="searchgo" value="go" 
                        onClick="location.href='?Keys='+escape(document.getElementById('keys').value)" />
             </div>
@@ -194,17 +191,57 @@ $hrefstr = "?keys=" . $keys;
             </div>
 
 <?php
-$sqlStr = "SELECT id, cs_code, cs_from, cs_country, cs_type, cs_deal, cs_addtime, cs_tel, cs_email, 
-           cs_whatsapp, cs_wechat, cs_linkedin, cs_facebook, cs_alibaba, cs_belong, cs_note, cs_claimFrom 
-           FROM customer 
-           WHERE (cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-           OR cs_name LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-           OR cs_email LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-           OR cs_wechat LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-           OR cs_tel LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
-           OR cs_whatsapp LIKE '%" . $conn->real_escape_string($keyscode) . "%') 
-           AND cs_belong IN (SELECT id FROM employee WHERE em_role=" . $_SESSION['employee_id'] . ")" . 
-           $filterStr . " ORDER BY cs_state DESC, id DESC";
+$sqlStr = "SELECT c.id, c.cs_code, c.cs_from, c.cs_country, c.cs_type, c.cs_deal, c.cs_addtime, c.cs_belong, 
+           c.cs_note, c.cs_claimFrom, 
+           cc.id as contact_id, cc.contact_name,
+           cc.tel_1, cc.tel_1_format, cc.tel_1_bu,
+           cc.tel_2, cc.tel_2_format, cc.tel_2_bu,
+           cc.tel_3, cc.tel_3_format, cc.tel_3_bu,
+           cc.email_1, cc.email_1_bu,
+           cc.email_2, cc.email_2_bu,
+           cc.email_3, cc.email_3_bu,
+           cc.whatsapp_1, cc.whatsapp_1_format, cc.whatsapp_1_bu,
+           cc.whatsapp_2, cc.whatsapp_2_format, cc.whatsapp_2_bu,
+           cc.whatsapp_3, cc.whatsapp_3_format, cc.whatsapp_3_bu,
+           cc.wechat_1, cc.wechat_1_bu,
+           cc.wechat_2, cc.wechat_2_bu,
+           cc.wechat_3, cc.wechat_3_bu,
+           cc.linkedin_1, cc.linkedin_1_bu,
+           cc.linkedin_2, cc.linkedin_2_bu,
+           cc.linkedin_3, cc.linkedin_3_bu,
+           cc.facebook_1, cc.facebook_1_bu,
+           cc.facebook_2, cc.facebook_2_bu,
+           cc.facebook_3, cc.facebook_3_bu,
+           cc.alibaba_1, cc.alibaba_1_bu,
+           cc.alibaba_2, cc.alibaba_2_bu,
+           cc.alibaba_3, cc.alibaba_3_bu
+           FROM customer c 
+           LEFT JOIN customer_contact cc ON c.id = cc.customer_id
+           WHERE (c.cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
+           OR cc.contact_name LIKE '%" . $conn->real_escape_string($keyscode) . "%' 
+           OR cc.tel_1 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
+           OR cc.tel_2 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
+           OR cc.tel_3 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
+           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.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) . "%'
+           OR cc.linkedin_1 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
+           OR cc.linkedin_2 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
+           OR cc.linkedin_3 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
+           OR cc.facebook_1 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
+           OR cc.facebook_2 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
+           OR cc.facebook_3 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
+           OR cc.alibaba_1 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
+           OR cc.alibaba_2 LIKE '%" . $conn->real_escape_string($keyscode) . "%'
+           OR cc.alibaba_3 LIKE '%" . $conn->real_escape_string($keyscode) . "%') 
+           AND c.cs_belong IN (SELECT id FROM employee WHERE em_role=" . $_SESSION['employee_id'] . ")" . 
+           $filterStr . " ORDER BY c.cs_state DESC, c.id DESC";
 
 $result = $conn->query($sqlStr);
 
@@ -279,13 +316,83 @@ 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 if(!empty($row['tel_1'])): ?>
+                        <div><?= htmlspecialcharsFix($row['tel_1']) ?></div>
+                    <?php endif; ?>
+                    <?php if(!empty($row['tel_2'])): ?>
+                        <div><?= htmlspecialcharsFix($row['tel_2']) ?></div>
+                    <?php endif; ?>
+                    <?php if(!empty($row['tel_3'])): ?>
+                        <div><?= htmlspecialcharsFix($row['tel_3']) ?></div>
+                    <?php endif; ?>
+                </div>
+                <div class="mail">
+                    <?php if(!empty($row['email_1'])): ?>
+                        <div><a href="mailto:<?= htmlspecialcharsFix($row['email_1']) ?>"><?= htmlspecialcharsFix($row['email_1']) ?></a></div>
+                    <?php endif; ?>
+                    <?php if(!empty($row['email_2'])): ?>
+                        <div><a href="mailto:<?= htmlspecialcharsFix($row['email_2']) ?>"><?= htmlspecialcharsFix($row['email_2']) ?></a></div>
+                    <?php endif; ?>
+                    <?php if(!empty($row['email_3'])): ?>
+                        <div><a href="mailto:<?= htmlspecialcharsFix($row['email_3']) ?>"><?= htmlspecialcharsFix($row['email_3']) ?></a></div>
+                    <?php endif; ?>
+                </div>
+                <div class="whatsapp">
+                    <?php if(!empty($row['whatsapp_1'])): ?>
+                        <div><?= htmlspecialcharsFix($row['whatsapp_1']) ?></div>
+                    <?php endif; ?>
+                    <?php if(!empty($row['whatsapp_2'])): ?>
+                        <div><?= htmlspecialcharsFix($row['whatsapp_2']) ?></div>
+                    <?php endif; ?>
+                    <?php if(!empty($row['whatsapp_3'])): ?>
+                        <div><?= htmlspecialcharsFix($row['whatsapp_3']) ?></div>
+                    <?php endif; ?>
+                </div>
+                <div class="wechat">
+                    <?php if(!empty($row['wechat_1'])): ?>
+                        <div><?= htmlspecialcharsFix($row['wechat_1']) ?></div>
+                    <?php endif; ?>
+                    <?php if(!empty($row['wechat_2'])): ?>
+                        <div><?= htmlspecialcharsFix($row['wechat_2']) ?></div>
+                    <?php endif; ?>
+                    <?php if(!empty($row['wechat_3'])): ?>
+                        <div><?= htmlspecialcharsFix($row['wechat_3']) ?></div>
+                    <?php endif; ?>
+                </div>
+                <div class="linkedin">
+                    <?php if(!empty($row['linkedin_1'])): ?>
+                        <div><?= htmlspecialcharsFix($row['linkedin_1']) ?></div>
+                    <?php endif; ?>
+                    <?php if(!empty($row['linkedin_2'])): ?>
+                        <div><?= htmlspecialcharsFix($row['linkedin_2']) ?></div>
+                    <?php endif; ?>
+                    <?php if(!empty($row['linkedin_3'])): ?>
+                        <div><?= htmlspecialcharsFix($row['linkedin_3']) ?></div>
+                    <?php endif; ?>
+                </div>
+                <div class="facebook">
+                    <?php if(!empty($row['facebook_1'])): ?>
+                        <div><?= htmlspecialcharsFix($row['facebook_1']) ?></div>
+                    <?php endif; ?>
+                    <?php if(!empty($row['facebook_2'])): ?>
+                        <div><?= htmlspecialcharsFix($row['facebook_2']) ?></div>
+                    <?php endif; ?>
+                    <?php if(!empty($row['facebook_3'])): ?>
+                        <div><?= htmlspecialcharsFix($row['facebook_3']) ?></div>
+                    <?php endif; ?>
+                </div>
+                <div class="alibaba">
+                    <?php if(!empty($row['alibaba_1'])): ?>
+                        <div><?= htmlspecialcharsFix($row['alibaba_1']) ?></div>
+                    <?php endif; ?>
+                    <?php if(!empty($row['alibaba_2'])): ?>
+                        <div><?= htmlspecialcharsFix($row['alibaba_2']) ?></div>
+                    <?php endif; ?>
+                    <?php if(!empty($row['alibaba_3'])): ?>
+                        <div><?= htmlspecialcharsFix($row['alibaba_3']) ?></div>
+                    <?php endif; ?>
+                </div>
             </div>
             <div class="noteItem2">备注</div>
             <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>

+ 186 - 14
subTag.php

@@ -1,6 +1,19 @@
 <?php
 require_once 'conn.php';
 checkLogin();
+
+// 获取URL参数
+$tagName = $_GET['tagName'] ?? '';
+$employeeId = $_GET['employeeId'] ?? 0;
+
+if (empty($employeeId) || !is_numeric($employeeId)) {
+    $employeeId = 0;
+}
+
+if (empty($tagName)) {
+    header('Location: customers.php');
+    exit;
+}
 ?>
 <!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml">
@@ -25,26 +38,185 @@ checkLogin();
 <body class="clear">
 <?php // require_once 'panel.php'; ?>
 <div id="man_zone">
-    <?php
-    $result = $conn->query("SELECT id, em_user FROM employee WHERE em_role=" . $_SESSION['employee_id']);
-    while ($row = $result->fetch_assoc()) {
-    ?>
-    <div class="tagclound">
-        <h1 class="tagCloundHead2"><?= htmlspecialcharsFix($row['em_user']) ?>的客户画像:</h1>
-        <div class="tagArea">
+    <div class="fastSelect clear">
+        <h1>标签:<?= htmlspecialcharsFix($tagName) ?></h1>
+    </div>
+
+    <div width="100%" border="0" cellpadding="3" cellspacing="1" class="table2">
+        <div class="theader">
+            <div class="col2">序号</div>
+            <div class="col3">客户编号</div>
+            <div class="col4">渠道来源</div>
+            <div class="col5">区域</div>
+            <div class="col6">客户类型</div>
+            <div class="col7">跟进阶段</div>
+            <div class="col8">录入时间</div>
+            <div class="col10">操作</div>
+        </div>
+
         <?php
-        $tagResult = $conn->query("SELECT tagName, COUNT(id) as count FROM tagtable WHERE employeeId=" . (int)$row['id'] . " GROUP BY tagName");
-        while ($tagRow = $tagResult->fetch_assoc()) {
+        // 组合查询SQL,使用LEFT JOIN获取联系人信息
+        $sqlStr = "SELECT c.id, c.cs_code, c.cs_from, c.cs_country, c.cs_type, c.cs_deal, c.cs_addtime, c.cs_note,
+                  cc.id as contact_id, cc.contact_name,
+                  cc.tel_1, cc.tel_1_format, cc.tel_1_bu,
+                  cc.tel_2, cc.tel_2_format, cc.tel_2_bu,
+                  cc.tel_3, cc.tel_3_format, cc.tel_3_bu,
+                  cc.email_1, cc.email_1_bu,
+                  cc.email_2, cc.email_2_bu,
+                  cc.email_3, cc.email_3_bu,
+                  cc.whatsapp_1, cc.whatsapp_1_format, cc.whatsapp_1_bu,
+                  cc.whatsapp_2, cc.whatsapp_2_format, cc.whatsapp_2_bu,
+                  cc.whatsapp_3, cc.whatsapp_3_format, cc.whatsapp_3_bu,
+                  cc.wechat_1, cc.wechat_1_bu,
+                  cc.wechat_2, cc.wechat_2_bu,
+                  cc.wechat_3, cc.wechat_3_bu,
+                  cc.linkedin_1, cc.linkedin_1_bu,
+                  cc.linkedin_2, cc.linkedin_2_bu,
+                  cc.linkedin_3, cc.linkedin_3_bu,
+                  cc.facebook_1, cc.facebook_1_bu,
+                  cc.facebook_2, cc.facebook_2_bu,
+                  cc.facebook_3, cc.facebook_3_bu,
+                  cc.alibaba_1, cc.alibaba_1_bu,
+                  cc.alibaba_2, cc.alibaba_2_bu,
+                  cc.alibaba_3, cc.alibaba_3_bu
+                  FROM customer c
+                  LEFT JOIN customer_contact cc ON c.id = cc.customer_id
+                  WHERE c.cs_belong=" . (int)$employeeId . " 
+                  AND c.id IN (SELECT customerId FROM tagtable WHERE tagName='" . $conn->real_escape_string($tagName) . "')";
+
+        $result = $conn->query($sqlStr);
+        $tempNum = 0;
+
+        if ($result && $result->num_rows > 0) {
+            while ($row = $result->fetch_assoc()) {
+                $tempNum++;
         ?>
-            <a href="subTag.php?employeeId=<?= $row['id'] ?>&tagName=<?= urlencode($tagRow['tagName']) ?>"><?= htmlspecialcharsFix($tagRow['tagName']) ?>(<?= $tagRow['count'] ?>)</a>
+                <div class="tline">
+                    <div class="col2"><?= $tempNum ?></div>
+                    <div class="col3 slidepanel"><?= htmlspecialcharsFix($row['cs_code']) ?></div>
+                    <div class="col4">
+                        <?php
+                        $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
+                        echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialcharsFix($qudaoRow['ch_name']) : '未填写';
+                        ?>
+                    </div>
+                    <div class="col5">
+                        <?php
+                        $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
+                        echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialcharsFix($countryRow['countryName']) : '未填写';
+                        ?>
+                    </div>
+                    <div class="col6">
+                        <?php
+                        $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id=" . (int)$row['cs_type']);
+                        echo ($typeRow = $typeResult->fetch_assoc()) ? htmlspecialcharsFix($typeRow['businessType']) : '未填写';
+                        ?>
+                    </div>
+                    <div class="col7">
+                        <?php
+                        if ($row['cs_deal'] == 3) {
+                            echo "<span style='color:red;'>成交</span>";
+                        } elseif ($row['cs_deal'] == 2) {
+                            echo "明确需求";
+                        } elseif ($row['cs_deal'] == 1) {
+                            echo "背景调查";
+                        } else {
+                            echo "无响应";
+                        }
+                        ?>
+                    </div>
+                    <div class="col8"><?= $row['cs_addtime'] ?></div>
+                    <div class="col10"><a href="customerEdit.php?id=<?= $row['id'] ?>" class="ico_edit ico">修改</a></div>
+                </div>
+                <div class="notepanel clear">
+                    <div class="noteItem">联系方式</div>
+                    <div class="lx">
+                        <div class="tel">
+                            <?php if(!empty($row['tel_1'])): ?>
+                                <div><?= htmlspecialcharsFix($row['tel_1']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['tel_2'])): ?>
+                                <div><?= htmlspecialcharsFix($row['tel_2']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['tel_3'])): ?>
+                                <div><?= htmlspecialcharsFix($row['tel_3']) ?></div>
+                            <?php endif; ?>
+                        </div>
+                        <div class="mail">
+                            <?php if(!empty($row['email_1'])): ?>
+                                <div><a href="mailto:<?= htmlspecialcharsFix($row['email_1']) ?>"><?= htmlspecialcharsFix($row['email_1']) ?></a></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['email_2'])): ?>
+                                <div><a href="mailto:<?= htmlspecialcharsFix($row['email_2']) ?>"><?= htmlspecialcharsFix($row['email_2']) ?></a></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['email_3'])): ?>
+                                <div><a href="mailto:<?= htmlspecialcharsFix($row['email_3']) ?>"><?= htmlspecialcharsFix($row['email_3']) ?></a></div>
+                            <?php endif; ?>
+                        </div>
+                        <div class="whatsapp">
+                            <?php if(!empty($row['whatsapp_1'])): ?>
+                                <div><?= htmlspecialcharsFix($row['whatsapp_1']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['whatsapp_2'])): ?>
+                                <div><?= htmlspecialcharsFix($row['whatsapp_2']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['whatsapp_3'])): ?>
+                                <div><?= htmlspecialcharsFix($row['whatsapp_3']) ?></div>
+                            <?php endif; ?>
+                        </div>
+                        <div class="wechat">
+                            <?php if(!empty($row['wechat_1'])): ?>
+                                <div><?= htmlspecialcharsFix($row['wechat_1']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['wechat_2'])): ?>
+                                <div><?= htmlspecialcharsFix($row['wechat_2']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['wechat_3'])): ?>
+                                <div><?= htmlspecialcharsFix($row['wechat_3']) ?></div>
+                            <?php endif; ?>
+                        </div>
+                        <div class="linkedin">
+                            <?php if(!empty($row['linkedin_1'])): ?>
+                                <div><?= htmlspecialcharsFix($row['linkedin_1']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['linkedin_2'])): ?>
+                                <div><?= htmlspecialcharsFix($row['linkedin_2']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['linkedin_3'])): ?>
+                                <div><?= htmlspecialcharsFix($row['linkedin_3']) ?></div>
+                            <?php endif; ?>
+                        </div>
+                        <div class="facebook">
+                            <?php if(!empty($row['facebook_1'])): ?>
+                                <div><?= htmlspecialcharsFix($row['facebook_1']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['facebook_2'])): ?>
+                                <div><?= htmlspecialcharsFix($row['facebook_2']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['facebook_3'])): ?>
+                                <div><?= htmlspecialcharsFix($row['facebook_3']) ?></div>
+                            <?php endif; ?>
+                        </div>
+                        <div class="alibaba">
+                            <?php if(!empty($row['alibaba_1'])): ?>
+                                <div><?= htmlspecialcharsFix($row['alibaba_1']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['alibaba_2'])): ?>
+                                <div><?= htmlspecialcharsFix($row['alibaba_2']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['alibaba_3'])): ?>
+                                <div><?= htmlspecialcharsFix($row['alibaba_3']) ?></div>
+                            <?php endif; ?>
+                        </div>
+                    </div>
+                    <div class="noteItem2">备注</div>
+                    <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>
+                </div>
         <?php
+            }
         }
         ?>
-        </div>
     </div>
-    <?php
-    }
-    ?>
 </div>
 </body>
 </html>

+ 19 - 13
subTagClound.php

@@ -25,27 +25,33 @@ checkLogin();
 <body class="clear">
 <?php // require_once 'panel.php'; ?>
 <div id="man_zone">
+<?php
+// 获取所有em_role等于当前用户employee_id的员工
+$employeeResult = $conn->query("SELECT id, em_user FROM employee WHERE em_role=" . $_SESSION['employee_id']);
+
+if ($employeeResult) {
+    while ($employeeRow = $employeeResult->fetch_assoc()) {
+?>
     <div class="tagclound">
-        <h1 class="tagCloundHead">自定义标签云</h1>
+        <h1 class="tagCloundHead2"><?= htmlspecialcharsFix($employeeRow['em_user']) ?>的客户画像:</h1>
         <div class="tagArea">
         <?php
-        $result = $conn->query("SELECT tagName, COUNT(DISTINCT c.cs_code) as count 
-                               FROM tagtable 
-                               LEFT JOIN customer c ON tagtable.customerId=c.id 
-                               WHERE employeeId=" . $_SESSION['employee_id'] . " 
-                               GROUP BY tagName");
+        // 对每个员工,查询其添加的所有标签
+        $tagResult = $conn->query("SELECT tagName, COUNT(id) as count FROM tagtable WHERE employeeId=" . $employeeRow['id'] . " GROUP BY tagName");
         
-        while ($row = $result->fetch_assoc()) {
-        ?>
-            <a href="tag.php?tagName=<?= urlencode($row['tagName']) ?>" style="font-size:16px;">
-                <?= htmlspecialcharsFix($row['tagName']) ?>(<?= $row['count'] ?>)
-            </a>
-        <?php
+        if ($tagResult) {
+            while ($tagRow = $tagResult->fetch_assoc()) {
+                echo '<a href="subTag.php?employeeId=' . $employeeRow['id'] . '&tagName=' . urlencode($tagRow['tagName']) . '">' . 
+                     htmlspecialcharsFix($tagRow['tagName']) . '(' . $tagRow['count'] . ')</a>';
+            }
         }
         ?>
-            <a href="nullTag.php">无标签客户</a>
         </div>
     </div>
+<?php
+    }
+}
+?>
 </div>
 </body>
 </html>

+ 104 - 12
tag.php

@@ -79,11 +79,33 @@ while ($row = $result->fetch_assoc()) {
             </div>
 
             <?php
-            $sqlStr = "SELECT id, cs_code, cs_from, cs_country, cs_type, cs_deal, cs_addtime, cs_tel, cs_email, 
-                      cs_whatsapp, cs_wechat, cs_linkedin, cs_facebook, cs_alibaba, cs_note 
-                      FROM customer 
-                      WHERE cs_belong=" . $_SESSION['employee_id'] . " 
-                      AND id IN (SELECT customerId FROM tagtable WHERE tagName='" . $conn->real_escape_string($tagName) . "')";
+            $sqlStr = "SELECT c.id, c.cs_code, c.cs_from, c.cs_country, c.cs_type, c.cs_deal, c.cs_addtime, c.cs_note,
+                      cc.id as contact_id, cc.contact_name,
+                      cc.tel_1, cc.tel_1_format, cc.tel_1_bu,
+                      cc.tel_2, cc.tel_2_format, cc.tel_2_bu,
+                      cc.tel_3, cc.tel_3_format, cc.tel_3_bu,
+                      cc.email_1, cc.email_1_bu,
+                      cc.email_2, cc.email_2_bu,
+                      cc.email_3, cc.email_3_bu,
+                      cc.whatsapp_1, cc.whatsapp_1_format, cc.whatsapp_1_bu,
+                      cc.whatsapp_2, cc.whatsapp_2_format, cc.whatsapp_2_bu,
+                      cc.whatsapp_3, cc.whatsapp_3_format, cc.whatsapp_3_bu,
+                      cc.wechat_1, cc.wechat_1_bu,
+                      cc.wechat_2, cc.wechat_2_bu,
+                      cc.wechat_3, cc.wechat_3_bu,
+                      cc.linkedin_1, cc.linkedin_1_bu,
+                      cc.linkedin_2, cc.linkedin_2_bu,
+                      cc.linkedin_3, cc.linkedin_3_bu,
+                      cc.facebook_1, cc.facebook_1_bu,
+                      cc.facebook_2, cc.facebook_2_bu,
+                      cc.facebook_3, cc.facebook_3_bu,
+                      cc.alibaba_1, cc.alibaba_1_bu,
+                      cc.alibaba_2, cc.alibaba_2_bu,
+                      cc.alibaba_3, cc.alibaba_3_bu
+                      FROM customer c
+                      LEFT JOIN customer_contact cc ON c.id = cc.customer_id
+                      WHERE c.cs_belong=" . $_SESSION['employee_id'] . " 
+                      AND c.id IN (SELECT customerId FROM tagtable WHERE tagName='" . $conn->real_escape_string($tagName) . "')";
 
             $result = $conn->query($sqlStr);
             $tempNum = 0;
@@ -126,13 +148,83 @@ while ($row = $result->fetch_assoc()) {
                 <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 if(!empty($row['tel_1'])): ?>
+                                <div><?= htmlspecialcharsFix($row['tel_1']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['tel_2'])): ?>
+                                <div><?= htmlspecialcharsFix($row['tel_2']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['tel_3'])): ?>
+                                <div><?= htmlspecialcharsFix($row['tel_3']) ?></div>
+                            <?php endif; ?>
+                        </div>
+                        <div class="mail">
+                            <?php if(!empty($row['email_1'])): ?>
+                                <div><a href="mailto:<?= htmlspecialcharsFix($row['email_1']) ?>"><?= htmlspecialcharsFix($row['email_1']) ?></a></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['email_2'])): ?>
+                                <div><a href="mailto:<?= htmlspecialcharsFix($row['email_2']) ?>"><?= htmlspecialcharsFix($row['email_2']) ?></a></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['email_3'])): ?>
+                                <div><a href="mailto:<?= htmlspecialcharsFix($row['email_3']) ?>"><?= htmlspecialcharsFix($row['email_3']) ?></a></div>
+                            <?php endif; ?>
+                        </div>
+                        <div class="whatsapp">
+                            <?php if(!empty($row['whatsapp_1'])): ?>
+                                <div><?= htmlspecialcharsFix($row['whatsapp_1']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['whatsapp_2'])): ?>
+                                <div><?= htmlspecialcharsFix($row['whatsapp_2']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['whatsapp_3'])): ?>
+                                <div><?= htmlspecialcharsFix($row['whatsapp_3']) ?></div>
+                            <?php endif; ?>
+                        </div>
+                        <div class="wechat">
+                            <?php if(!empty($row['wechat_1'])): ?>
+                                <div><?= htmlspecialcharsFix($row['wechat_1']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['wechat_2'])): ?>
+                                <div><?= htmlspecialcharsFix($row['wechat_2']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['wechat_3'])): ?>
+                                <div><?= htmlspecialcharsFix($row['wechat_3']) ?></div>
+                            <?php endif; ?>
+                        </div>
+                        <div class="linkedin">
+                            <?php if(!empty($row['linkedin_1'])): ?>
+                                <div><?= htmlspecialcharsFix($row['linkedin_1']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['linkedin_2'])): ?>
+                                <div><?= htmlspecialcharsFix($row['linkedin_2']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['linkedin_3'])): ?>
+                                <div><?= htmlspecialcharsFix($row['linkedin_3']) ?></div>
+                            <?php endif; ?>
+                        </div>
+                        <div class="facebook">
+                            <?php if(!empty($row['facebook_1'])): ?>
+                                <div><?= htmlspecialcharsFix($row['facebook_1']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['facebook_2'])): ?>
+                                <div><?= htmlspecialcharsFix($row['facebook_2']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['facebook_3'])): ?>
+                                <div><?= htmlspecialcharsFix($row['facebook_3']) ?></div>
+                            <?php endif; ?>
+                        </div>
+                        <div class="alibaba">
+                            <?php if(!empty($row['alibaba_1'])): ?>
+                                <div><?= htmlspecialcharsFix($row['alibaba_1']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['alibaba_2'])): ?>
+                                <div><?= htmlspecialcharsFix($row['alibaba_2']) ?></div>
+                            <?php endif; ?>
+                            <?php if(!empty($row['alibaba_3'])): ?>
+                                <div><?= htmlspecialcharsFix($row['alibaba_3']) ?></div>
+                            <?php endif; ?>
+                        </div>
                     </div>
                     <div class="noteItem2">备注</div>
                     <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>

+ 9 - 10
tagClound.php

@@ -29,18 +29,17 @@ checkLogin();
         <h1 class="tagCloundHead">自定义标签云</h1>
         <div class="tagArea">
         <?php
-        $result = $conn->query("SELECT tagName, COUNT(DISTINCT cs_code) as count 
-                               FROM tagtable 
-                               LEFT JOIN customer ON tagtable.customerId=customer.id 
-                               WHERE employeeId=" . $_SESSION['employee_id'] . " 
+        $result = $conn->query("SELECT tagName, COUNT(DISTINCT c.cs_code) as count 
+                               FROM tagtable t
+                               LEFT JOIN customer c ON t.customerId = c.id 
+                               WHERE t.employeeId = " . $_SESSION['employee_id'] . " 
                                GROUP BY tagName");
         
-        while ($row = $result->fetch_assoc()) {
-        ?>
-            <a href="tag.php?tagName=<?= urlencode($row['tagName']) ?>" style="font-size:16px;">
-                <?= htmlspecialcharsFix($row['tagName']) ?>(<?= $row['count'] ?>)
-            </a>
-        <?php
+        if ($result) {
+            while ($row = $result->fetch_assoc()) {
+                echo '<a href="tag.php?tagName=' . urlencode($row['tagName']) . '" style="font-size:16px;">' . 
+                     htmlspecialcharsFix($row['tagName']) . '(' . $row['count'] . ')</a>';
+            }
         }
         ?>
             <a href="nullTag.php">无标签客户</a>