1
0

5 Commits ac30fbc481 ... ec140e9a8e

Autor SHA1 Mensagem Data
  igb ec140e9a8e fix: searchResult há 4 dias atrás
  igb 705dab18aa fix: js há 4 dias atrás
  igb e70ff47ab8 fix: system admin employee updated há 4 dias atrás
  igb 2356533d0c fix: system customers há 4 dias atrás
  igb 6d65547f28 fix: searchresult há 4 dias atrás
6 ficheiros alterados com 649 adições e 383 exclusões
  1. 336 336
      customerSave.php
  2. 12 0
      js/chart.js
  3. 131 0
      js/statistics.js
  4. 146 23
      searchResult.php
  5. 23 23
      system/customers.php
  6. 1 1
      system/employee.php

+ 336 - 336
customerSave.php

@@ -329,342 +329,342 @@ if ($allowedit != 1) {
              "\\n高度类似,未能保存,请联系管理员核实!');history.back();</script>";
         exit;
     }
-    else
-    {
-        //全文检索再检查一次
-        //先去掉联系方式中的特殊字符
-        //用联系方式进行全文fullindex检索,用相关性分数大于百分70 的进行检查
-        
-        // 根据不同联系方式类型进行专门检查
-        $duplicateFound = false;
-        $matchDetails = '';
-        $matchScore = 0;
-        $matchCustomerId = 0;
-        $matchCustomerCode = '';
-        $matchOwner = '';
-        $matchAddTime = '';
-        
-        // 编辑模式下需要排除自己的ID
-        $excludeId = ($act === 'editSave' && is_numeric($id)) ? intval($id) : 0;
-        
-        // 1. 优先检查邮箱 - 邮箱是最精确的匹配
-        $emailTerms = [];
-        foreach ($contacts as $contact) {
-            for ($i = 1; $i <= 3; $i++) {
-                $field = 'email_' . $i;
-                if (!empty($contact[$field])) {
-                    $email = strtolower(trim($contact[$field]));
-                    if (strpos($email, '@') !== false) {
-                        $emailTerms[] = $email;
-                    }
-                }
-            }
-        }
-        
-        if (!empty($emailTerms)) {
-            $emailQuery = "SELECT c.id, c.cs_code, c.cs_belong, c.cs_addtime, cc.email_1, cc.email_2, cc.email_3 
-                          FROM customer c 
-                          JOIN customer_contact cc ON c.id = cc.customer_id
-                          WHERE c.cs_belong != " . $_SESSION['employee_id'] . " 
-                          AND c.id != " . $excludeId . " AND (";
-            
-            $emailConditions = [];
-            foreach ($emailTerms as $email) {
-                $emailConditions[] = "cc.email_1 = '" . $conn->real_escape_string($email) . "'";
-                $emailConditions[] = "cc.email_2 = '" . $conn->real_escape_string($email) . "'";
-                $emailConditions[] = "cc.email_3 = '" . $conn->real_escape_string($email) . "'";
-            }
-            
-            $emailQuery .= implode(" OR ", $emailConditions) . ") LIMIT 1";
-            $emailResult = $conn->query($emailQuery);
-            
-            if ($emailResult && $emailResult->num_rows > 0) {
-                $row = $emailResult->fetch_assoc();
-                $matchCustomerId = $row['id'];
-                $matchCustomerCode = $row['cs_code'];
-                $matchOwner = $row['cs_belong'];
-                $matchAddTime = $row['cs_addtime'];
-                $matchDetails = "邮箱完全匹配";
-                $matchScore = 0.95; // 邮箱精确匹配,高可信度
-                $duplicateFound = true;
-            }
-        }
-        
-        // 2. 检查电话号码与WhatsApp - 清理后进行后缀匹配
-        if (!$duplicateFound) {
-            $phoneTerms = [];
-            foreach ($contacts as $contact) {
-                // 收集所有电话号码
-                for ($i = 1; $i <= 3; $i++) {
-                    $fields = ['tel_' . $i, 'whatsapp_' . $i];
-                    foreach ($fields as $field) {
-                        if (!empty($contact[$field])) {
-                            $cleaned = preg_replace('/[^0-9]/', '', $contact[$field]);
-                            if (strlen($cleaned) > 7) { // 至少8位有效数字
-                                $phoneTerms[] = $cleaned;
-                            }
-                        }
-                    }
-                }
-            }
-            
-            if (!empty($phoneTerms)) {
-                $phoneQuery = "SELECT c.id, c.cs_code, c.cs_belong, c.cs_addtime, 
-                               cc.tel_1_format, cc.tel_2_format, cc.tel_3_format,
-                               cc.whatsapp_1_format, cc.whatsapp_2_format, cc.whatsapp_3_format 
-                               FROM customer c 
-                               JOIN customer_contact cc ON c.id = cc.customer_id
-                               WHERE c.cs_belong != " . $_SESSION['employee_id'] . "
-                               AND c.id != " . $excludeId . " AND (";
-                               
-                $phoneConditions = [];
-                foreach ($phoneTerms as $phone) {
-                    // 使用后8位进行匹配,避免国家代码等差异
-                    $suffix = substr($phone, -8);
-                    if (strlen($suffix) == 8) {
-                        $phoneConditions[] = "cc.tel_1_format LIKE '%" . $conn->real_escape_string($suffix) . "'";
-                        $phoneConditions[] = "cc.tel_2_format LIKE '%" . $conn->real_escape_string($suffix) . "'";
-                        $phoneConditions[] = "cc.tel_3_format LIKE '%" . $conn->real_escape_string($suffix) . "'";
-                        $phoneConditions[] = "cc.whatsapp_1_format LIKE '%" . $conn->real_escape_string($suffix) . "'";
-                        $phoneConditions[] = "cc.whatsapp_2_format LIKE '%" . $conn->real_escape_string($suffix) . "'";
-                        $phoneConditions[] = "cc.whatsapp_3_format LIKE '%" . $conn->real_escape_string($suffix) . "'";
-                    }
-                }
-                
-                if (!empty($phoneConditions)) {
-                    $phoneQuery .= implode(" OR ", $phoneConditions) . ") LIMIT 1";
-                    $phoneResult = $conn->query($phoneQuery);
-                    
-                    if ($phoneResult && $phoneResult->num_rows > 0) {
-                        $row = $phoneResult->fetch_assoc();
-                        $matchCustomerId = $row['id'];
-                        $matchCustomerCode = $row['cs_code'];
-                        $matchOwner = $row['cs_belong'];
-                        $matchAddTime = $row['cs_addtime'];
-                        $matchDetails = "电话号码后8位匹配";
-                        $matchScore = 0.90; // 电话匹配,高可信度
-                        $duplicateFound = true;
-                    }
-                }
-            }
-        }
-        
-        // 3. 检查社交媒体账号 (alibaba/wechat/facebook/linkedin)
-        if (!$duplicateFound) {
-            $socialTerms = [];
-            $socialFields = [
-                'alibaba' => '阿里旺旺',
-                'wechat' => '微信',
-                'facebook' => 'Facebook',
-                'linkedin' => 'LinkedIn'
-            ];
-            
-            foreach ($contacts as $contact) {
-                foreach ($socialFields as $field => $label) {
-                    for ($i = 1; $i <= 3; $i++) {
-                        $fieldName = $field . '_' . $i;
-                        if (!empty($contact[$fieldName])) {
-                            $value = trim($contact[$fieldName]);
-                            if (strlen($value) > 3) { // 至少4个字符
-                                $socialTerms[] = [
-                                    'type' => $field,
-                                    'label' => $label,
-                                    'value' => $value
-                                ];
-                            }
-                        }
-                    }
-                }
-            }
-            
-            if (!empty($socialTerms)) {
-                foreach ($socialTerms as $term) {
-                    $field = $term['type'];
-                    $value = $term['value'];
-                    $label = $term['label'];
-                    
-                    // 根据社交媒体类型构建不同的查询
-                    $socialQuery = "SELECT c.id, c.cs_code, c.cs_belong, c.cs_addtime FROM customer c 
-                                    JOIN customer_contact cc ON c.id = cc.customer_id
-                                    WHERE c.cs_belong != " . $_SESSION['employee_id'] . "
-                                    AND c.id != " . $excludeId . " AND (";
-                    
-                    // 根据社交账号类型确定匹配方式                    
-                    if ($field == 'alibaba' || $field == 'wechat') {
-                        // 阿里旺旺和微信用精确匹配
-                        $socialQuery .= 
-                            "cc.{$field}_1 = '" . $conn->real_escape_string($value) . "' OR " .
-                            "cc.{$field}_2 = '" . $conn->real_escape_string($value) . "' OR " .
-                            "cc.{$field}_3 = '" . $conn->real_escape_string($value) . "'";
-                    } else {
-                        // Facebook和LinkedIn用模糊匹配
-                        $socialQuery .= 
-                            "cc.{$field}_1 LIKE '%" . $conn->real_escape_string($value) . "%' OR " .
-                            "cc.{$field}_2 LIKE '%" . $conn->real_escape_string($value) . "%' OR " .
-                            "cc.{$field}_3 LIKE '%" . $conn->real_escape_string($value) . "%'";
-                    }
-                    
-                    $socialQuery .= ") LIMIT 1";
-                    $socialResult = $conn->query($socialQuery);
-                    
-                    if ($socialResult && $socialResult->num_rows > 0) {
-                        $row = $socialResult->fetch_assoc();
-                        $matchCustomerId = $row['id'];
-                        $matchCustomerCode = $row['cs_code'];
-                        $matchOwner = $row['cs_belong'];
-                        $matchAddTime = $row['cs_addtime'];
-                        $matchDetails = $label . "账号匹配";
-                        
-                        // 不同社交媒体账号的可信度
-                        switch ($field) {
-                            case 'alibaba':
-                                $matchScore = 0.85;
-                                break;
-                            case 'wechat':
-                                $matchScore = 0.85;
-                                break;
-                            case 'facebook':
-                                $matchScore = 0.80;
-                                break;
-                            case 'linkedin':
-                                $matchScore = 0.80;
-                                break;
-                            default:
-                                $matchScore = 0.75;
-                        }
-                        
-                        $duplicateFound = true;
-                        break; // 找到匹配就退出循环
-                    }
-                }
-            }
-        }
-        
-        // 4. 最后尝试全文检索 - 作为补充检测手段
-        if (!$duplicateFound) {
-            // 准备全文检索字符串
-            $searchTerms = [];
-            
-            // 处理所有联系人信息用于检索
-            foreach ($contacts as $contact) {
-                // 添加联系人名称
-                if (!empty($contact['contact_name'])) {
-                    $searchTerms[] = textUncode($contact['contact_name']);
-                }
-                
-                // 所有联系方式的组合检索
-                $contactFields = [
-                    'tel', 'email', 'whatsapp', 'wechat', 
-                    'linkedin', 'facebook', 'alibaba'
-                ];
-                
-                foreach ($contactFields as $fieldType) {
-                    for ($i = 1; $i <= 3; $i++) {
-                        $field = $fieldType . '_' . $i;
-                        if (!empty($contact[$field])) {
-                            // 针对不同类型的联系方式进行不同清理
-                            if ($fieldType == 'tel' || $fieldType == 'whatsapp') {
-                                $cleaned = preg_replace('/[^0-9]/', '', $contact[$field]);
-                                if (strlen($cleaned) > 5) {
-                                    $searchTerms[] = $cleaned;
-                                }
-                            } else if ($fieldType == 'email') {
-                                $cleaned = strtolower(trim($contact[$field]));
-                                if (strpos($cleaned, '@') !== false) {
-                                    $searchTerms[] = $cleaned;
-                                }
-                            } else {
-                                $searchTerms[] = trim($contact[$field]);
-                            }
-                        }
-                    }
-                }
-            }
-            
-            // 如果有搜索条件
-            if (!empty($searchTerms)) {
-                // 创建MATCH AGAINST语句的词条
-                $searchStr = implode(' ', array_unique(array_filter($searchTerms)));
-                
-                // 确保搜索字符串不为空
-                if (!empty($searchStr)) {
-                    // 构建全文检索SQL
-                    $ftQuery = "SELECT c.id, c.cs_code, c.cs_belong, c.cs_addtime,
-                                MATCH( cc.tel_1, cc.tel_2, cc.tel_3, 
-                                      cc.email_1, cc.email_2, cc.email_3,
-                                      cc.whatsapp_1, cc.whatsapp_2, cc.whatsapp_3,
-                                      cc.wechat_1, cc.wechat_2, cc.wechat_3
-                                       ) 
-                                      AGAINST('" . $conn->real_escape_string($searchStr) . "' IN NATURAL LANGUAGE MODE) AS score
-                                FROM customer c 
-                                JOIN customer_contact cc ON c.id = cc.customer_id
-                                WHERE c.id != " . $excludeId . "
-                                HAVING score > 0.7  
-                                ORDER BY score DESC
-                                LIMIT 1";      
-                    $ftResult = $conn->query($ftQuery);
-                    
-                    if(!($ftResult && $ftResult->num_rows > 0 ))
-                    {
-
-                        $ftQuery = "SELECT c.id, c.cs_code, c.cs_belong, c.cs_addtime,
-                        MATCH( cc.alibaba_1, cc.alibaba_2, cc.alibaba_3,
-                              cc.facebook_1, cc.facebook_2, cc.facebook_3,
-                              cc.linkedin_1, cc.linkedin_2, cc.linkedin_3) 
-                              AGAINST('" . $conn->real_escape_string($searchStr) . "' IN NATURAL LANGUAGE MODE) AS score
-                        FROM customer c 
-                        JOIN customer_contact cc ON c.id = cc.customer_id
-                        WHERE c.id != " . $excludeId . "
-                        HAVING score > 0.7  
-                        ORDER BY score DESC
-                        LIMIT 1";      
-                       $ftResult = $conn->query($ftQuery);
-                    }
-
-
-
-                    if ($ftResult && $ftResult->num_rows > 0) {
-                        $row = $ftResult->fetch_assoc();
-                        $matchCustomerId = $row['id'];
-                        $matchCustomerCode = $row['cs_code'];
-                        $matchOwner = $row['cs_belong'];
-                        $matchAddTime = $row['cs_addtime'];
-                        $matchDetails = "全文检索相似度" . number_format($row['score'] * 100, 1) . "%";
-                        $matchScore = $row['score'];
-                        $duplicateFound = true;
-                    }
-                }
-            }
-        }
-        
-        // 如果找到重复客户,记录并提示
-        if ($duplicateFound) {
-            // 获取客户所有者姓名
-            $ownerResult = $conn->query("SELECT em_user FROM employee WHERE id = " . $matchOwner);
-            $ownerRow = $ownerResult->fetch_assoc();
-            $owner = textUncode($ownerRow['em_user']);
-            
-            // 确定谁先录入
-            if (strtotime($cs_addtime) > strtotime($matchAddTime)) {
-                $tstr = "INSERT INTO logrecord (loginName, loginIp, loginTime, loginAct) VALUES ('" .
-                       $_SESSION['employee_name'] . "', '" . getIp() . "', '" . date('Y-m-d H:i:s') . "', '" .
-                       $_SESSION['employee_name'] . "编辑客户\"" . $cs_code . "\",该客户与\"" . 
-                       textUncode($matchCustomerCode) . "\"存在重复,<br>匹配类型:" . $matchDetails . 
-                       "<br>客户由:" . $owner . $matchAddTime . "首次录入')";
-            } else {
-                $tstr = "INSERT INTO logrecord (loginName, loginIp, loginTime, loginAct) VALUES ('" .
-                       $_SESSION['employee_name'] . "', '" . getIp() . "', '" . date('Y-m-d H:i:s') . "', '" .
-                       $_SESSION['employee_name'] . "编辑客户\"" . $cs_code . "\",该客户与\"" . 
-                       textUncode($matchCustomerCode) . "\"存在重复,<br>匹配类型:" . $matchDetails . 
-                       "<br>客户由:" . $_SESSION['employee_name'] . $cs_addtime . "首次录入')";
-            }
-            
-            $conn->query($tstr);
-            echo "<script>alert('warning.2.录入信息\\n与" . $owner . "客户编号:" . textUncode($matchCustomerCode) . 
-                 "\\存在重复(" . $matchDetails . "),未能保存\\n请联系管理员核实!');history.back();</script>";
-            exit;
-        }
-    }
+//    else
+//    {
+//        //全文检索再检查一次
+//        //先去掉联系方式中的特殊字符
+//        //用联系方式进行全文fullindex检索,用相关性分数大于百分70 的进行检查
+//
+//        // 根据不同联系方式类型进行专门检查
+//        $duplicateFound = false;
+//        $matchDetails = '';
+//        $matchScore = 0;
+//        $matchCustomerId = 0;
+//        $matchCustomerCode = '';
+//        $matchOwner = '';
+//        $matchAddTime = '';
+//
+//        // 编辑模式下需要排除自己的ID
+//        $excludeId = ($act === 'editSave' && is_numeric($id)) ? intval($id) : 0;
+//
+//        // 1. 优先检查邮箱 - 邮箱是最精确的匹配
+//        $emailTerms = [];
+//        foreach ($contacts as $contact) {
+//            for ($i = 1; $i <= 3; $i++) {
+//                $field = 'email_' . $i;
+//                if (!empty($contact[$field])) {
+//                    $email = strtolower(trim($contact[$field]));
+//                    if (strpos($email, '@') !== false) {
+//                        $emailTerms[] = $email;
+//                    }
+//                }
+//            }
+//        }
+//
+//        if (!empty($emailTerms)) {
+//            $emailQuery = "SELECT c.id, c.cs_code, c.cs_belong, c.cs_addtime, cc.email_1, cc.email_2, cc.email_3
+//                          FROM customer c
+//                          JOIN customer_contact cc ON c.id = cc.customer_id
+//                          WHERE c.cs_belong != " . $_SESSION['employee_id'] . "
+//                          AND c.id != " . $excludeId . " AND (";
+//
+//            $emailConditions = [];
+//            foreach ($emailTerms as $email) {
+//                $emailConditions[] = "cc.email_1 = '" . $conn->real_escape_string($email) . "'";
+//                $emailConditions[] = "cc.email_2 = '" . $conn->real_escape_string($email) . "'";
+//                $emailConditions[] = "cc.email_3 = '" . $conn->real_escape_string($email) . "'";
+//            }
+//
+//            $emailQuery .= implode(" OR ", $emailConditions) . ") LIMIT 1";
+//            $emailResult = $conn->query($emailQuery);
+//
+//            if ($emailResult && $emailResult->num_rows > 0) {
+//                $row = $emailResult->fetch_assoc();
+//                $matchCustomerId = $row['id'];
+//                $matchCustomerCode = $row['cs_code'];
+//                $matchOwner = $row['cs_belong'];
+//                $matchAddTime = $row['cs_addtime'];
+//                $matchDetails = "邮箱完全匹配";
+//                $matchScore = 0.95; // 邮箱精确匹配,高可信度
+//                $duplicateFound = true;
+//            }
+//        }
+//
+//        // 2. 检查电话号码与WhatsApp - 清理后进行后缀匹配
+//        if (!$duplicateFound) {
+//            $phoneTerms = [];
+//            foreach ($contacts as $contact) {
+//                // 收集所有电话号码
+//                for ($i = 1; $i <= 3; $i++) {
+//                    $fields = ['tel_' . $i, 'whatsapp_' . $i];
+//                    foreach ($fields as $field) {
+//                        if (!empty($contact[$field])) {
+//                            $cleaned = preg_replace('/[^0-9]/', '', $contact[$field]);
+//                            if (strlen($cleaned) > 7) { // 至少8位有效数字
+//                                $phoneTerms[] = $cleaned;
+//                            }
+//                        }
+//                    }
+//                }
+//            }
+//
+//            if (!empty($phoneTerms)) {
+//                $phoneQuery = "SELECT c.id, c.cs_code, c.cs_belong, c.cs_addtime,
+//                               cc.tel_1_format, cc.tel_2_format, cc.tel_3_format,
+//                               cc.whatsapp_1_format, cc.whatsapp_2_format, cc.whatsapp_3_format
+//                               FROM customer c
+//                               JOIN customer_contact cc ON c.id = cc.customer_id
+//                               WHERE c.cs_belong != " . $_SESSION['employee_id'] . "
+//                               AND c.id != " . $excludeId . " AND (";
+//
+//                $phoneConditions = [];
+//                foreach ($phoneTerms as $phone) {
+//                    // 使用后8位进行匹配,避免国家代码等差异
+//                    $suffix = substr($phone, -8);
+//                    if (strlen($suffix) == 8) {
+//                        $phoneConditions[] = "cc.tel_1_format LIKE '%" . $conn->real_escape_string($suffix) . "'";
+//                        $phoneConditions[] = "cc.tel_2_format LIKE '%" . $conn->real_escape_string($suffix) . "'";
+//                        $phoneConditions[] = "cc.tel_3_format LIKE '%" . $conn->real_escape_string($suffix) . "'";
+//                        $phoneConditions[] = "cc.whatsapp_1_format LIKE '%" . $conn->real_escape_string($suffix) . "'";
+//                        $phoneConditions[] = "cc.whatsapp_2_format LIKE '%" . $conn->real_escape_string($suffix) . "'";
+//                        $phoneConditions[] = "cc.whatsapp_3_format LIKE '%" . $conn->real_escape_string($suffix) . "'";
+//                    }
+//                }
+//
+//                if (!empty($phoneConditions)) {
+//                    $phoneQuery .= implode(" OR ", $phoneConditions) . ") LIMIT 1";
+//                    $phoneResult = $conn->query($phoneQuery);
+//
+//                    if ($phoneResult && $phoneResult->num_rows > 0) {
+//                        $row = $phoneResult->fetch_assoc();
+//                        $matchCustomerId = $row['id'];
+//                        $matchCustomerCode = $row['cs_code'];
+//                        $matchOwner = $row['cs_belong'];
+//                        $matchAddTime = $row['cs_addtime'];
+//                        $matchDetails = "电话号码后8位匹配";
+//                        $matchScore = 0.90; // 电话匹配,高可信度
+//                        $duplicateFound = true;
+//                    }
+//                }
+//            }
+//        }
+//
+//        // 3. 检查社交媒体账号 (alibaba/wechat/facebook/linkedin)
+//        if (!$duplicateFound) {
+//            $socialTerms = [];
+//            $socialFields = [
+//                'alibaba' => '阿里旺旺',
+//                'wechat' => '微信',
+//                'facebook' => 'Facebook',
+//                'linkedin' => 'LinkedIn'
+//            ];
+//
+//            foreach ($contacts as $contact) {
+//                foreach ($socialFields as $field => $label) {
+//                    for ($i = 1; $i <= 3; $i++) {
+//                        $fieldName = $field . '_' . $i;
+//                        if (!empty($contact[$fieldName])) {
+//                            $value = trim($contact[$fieldName]);
+//                            if (strlen($value) > 3) { // 至少4个字符
+//                                $socialTerms[] = [
+//                                    'type' => $field,
+//                                    'label' => $label,
+//                                    'value' => $value
+//                                ];
+//                            }
+//                        }
+//                    }
+//                }
+//            }
+//
+//            if (!empty($socialTerms)) {
+//                foreach ($socialTerms as $term) {
+//                    $field = $term['type'];
+//                    $value = $term['value'];
+//                    $label = $term['label'];
+//
+//                    // 根据社交媒体类型构建不同的查询
+//                    $socialQuery = "SELECT c.id, c.cs_code, c.cs_belong, c.cs_addtime FROM customer c
+//                                    JOIN customer_contact cc ON c.id = cc.customer_id
+//                                    WHERE c.cs_belong != " . $_SESSION['employee_id'] . "
+//                                    AND c.id != " . $excludeId . " AND (";
+//
+//                    // 根据社交账号类型确定匹配方式
+//                    if ($field == 'alibaba' || $field == 'wechat') {
+//                        // 阿里旺旺和微信用精确匹配
+//                        $socialQuery .=
+//                            "cc.{$field}_1 = '" . $conn->real_escape_string($value) . "' OR " .
+//                            "cc.{$field}_2 = '" . $conn->real_escape_string($value) . "' OR " .
+//                            "cc.{$field}_3 = '" . $conn->real_escape_string($value) . "'";
+//                    } else {
+//                        // Facebook和LinkedIn用模糊匹配
+//                        $socialQuery .=
+//                            "cc.{$field}_1 LIKE '%" . $conn->real_escape_string($value) . "%' OR " .
+//                            "cc.{$field}_2 LIKE '%" . $conn->real_escape_string($value) . "%' OR " .
+//                            "cc.{$field}_3 LIKE '%" . $conn->real_escape_string($value) . "%'";
+//                    }
+//
+//                    $socialQuery .= ") LIMIT 1";
+//                    $socialResult = $conn->query($socialQuery);
+//
+//                    if ($socialResult && $socialResult->num_rows > 0) {
+//                        $row = $socialResult->fetch_assoc();
+//                        $matchCustomerId = $row['id'];
+//                        $matchCustomerCode = $row['cs_code'];
+//                        $matchOwner = $row['cs_belong'];
+//                        $matchAddTime = $row['cs_addtime'];
+//                        $matchDetails = $label . "账号匹配";
+//
+//                        // 不同社交媒体账号的可信度
+//                        switch ($field) {
+//                            case 'alibaba':
+//                                $matchScore = 0.85;
+//                                break;
+//                            case 'wechat':
+//                                $matchScore = 0.85;
+//                                break;
+//                            case 'facebook':
+//                                $matchScore = 0.80;
+//                                break;
+//                            case 'linkedin':
+//                                $matchScore = 0.80;
+//                                break;
+//                            default:
+//                                $matchScore = 0.75;
+//                        }
+//
+//                        $duplicateFound = true;
+//                        break; // 找到匹配就退出循环
+//                    }
+//                }
+//            }
+//        }
+//
+//        // 4. 最后尝试全文检索 - 作为补充检测手段
+//        if (!$duplicateFound) {
+//            // 准备全文检索字符串
+//            $searchTerms = [];
+//
+//            // 处理所有联系人信息用于检索
+//            foreach ($contacts as $contact) {
+//                // 添加联系人名称
+//                if (!empty($contact['contact_name'])) {
+//                    $searchTerms[] = textUncode($contact['contact_name']);
+//                }
+//
+//                // 所有联系方式的组合检索
+//                $contactFields = [
+//                    'tel', 'email', 'whatsapp', 'wechat',
+//                    'linkedin', 'facebook', 'alibaba'
+//                ];
+//
+//                foreach ($contactFields as $fieldType) {
+//                    for ($i = 1; $i <= 3; $i++) {
+//                        $field = $fieldType . '_' . $i;
+//                        if (!empty($contact[$field])) {
+//                            // 针对不同类型的联系方式进行不同清理
+//                            if ($fieldType == 'tel' || $fieldType == 'whatsapp') {
+//                                $cleaned = preg_replace('/[^0-9]/', '', $contact[$field]);
+//                                if (strlen($cleaned) > 5) {
+//                                    $searchTerms[] = $cleaned;
+//                                }
+//                            } else if ($fieldType == 'email') {
+//                                $cleaned = strtolower(trim($contact[$field]));
+//                                if (strpos($cleaned, '@') !== false) {
+//                                    $searchTerms[] = $cleaned;
+//                                }
+//                            } else {
+//                                $searchTerms[] = trim($contact[$field]);
+//                            }
+//                        }
+//                    }
+//                }
+//            }
+//
+//            // 如果有搜索条件
+//            if (!empty($searchTerms)) {
+//                // 创建MATCH AGAINST语句的词条
+//                $searchStr = implode(' ', array_unique(array_filter($searchTerms)));
+//
+//                // 确保搜索字符串不为空
+//                if (!empty($searchStr)) {
+//                    // 构建全文检索SQL
+//                    $ftQuery = "SELECT c.id, c.cs_code, c.cs_belong, c.cs_addtime,
+//                                MATCH( cc.tel_1, cc.tel_2, cc.tel_3,
+//                                      cc.email_1, cc.email_2, cc.email_3,
+//                                      cc.whatsapp_1, cc.whatsapp_2, cc.whatsapp_3,
+//                                      cc.wechat_1, cc.wechat_2, cc.wechat_3
+//                                       )
+//                                      AGAINST('" . $conn->real_escape_string($searchStr) . "' IN NATURAL LANGUAGE MODE) AS score
+//                                FROM customer c
+//                                JOIN customer_contact cc ON c.id = cc.customer_id
+//                                WHERE c.id != " . $excludeId . "
+//                                HAVING score > 0.7
+//                                ORDER BY score DESC
+//                                LIMIT 1";
+//                    $ftResult = $conn->query($ftQuery);
+//
+//                    if(!($ftResult && $ftResult->num_rows > 0 ))
+//                    {
+//
+//                        $ftQuery = "SELECT c.id, c.cs_code, c.cs_belong, c.cs_addtime,
+//                        MATCH( cc.alibaba_1, cc.alibaba_2, cc.alibaba_3,
+//                              cc.facebook_1, cc.facebook_2, cc.facebook_3,
+//                              cc.linkedin_1, cc.linkedin_2, cc.linkedin_3)
+//                              AGAINST('" . $conn->real_escape_string($searchStr) . "' IN NATURAL LANGUAGE MODE) AS score
+//                        FROM customer c
+//                        JOIN customer_contact cc ON c.id = cc.customer_id
+//                        WHERE c.id != " . $excludeId . "
+//                        HAVING score > 0.7
+//                        ORDER BY score DESC
+//                        LIMIT 1";
+//                       $ftResult = $conn->query($ftQuery);
+//                    }
+//
+//
+//
+//                    if ($ftResult && $ftResult->num_rows > 0) {
+//                        $row = $ftResult->fetch_assoc();
+//                        $matchCustomerId = $row['id'];
+//                        $matchCustomerCode = $row['cs_code'];
+//                        $matchOwner = $row['cs_belong'];
+//                        $matchAddTime = $row['cs_addtime'];
+//                        $matchDetails = "全文检索相似度" . number_format($row['score'] * 100, 1) . "%";
+//                        $matchScore = $row['score'];
+//                        $duplicateFound = true;
+//                    }
+//                }
+//            }
+//        }
+//
+//        // 如果找到重复客户,记录并提示
+//        if ($duplicateFound) {
+//            // 获取客户所有者姓名
+//            $ownerResult = $conn->query("SELECT em_user FROM employee WHERE id = " . $matchOwner);
+//            $ownerRow = $ownerResult->fetch_assoc();
+//            $owner = textUncode($ownerRow['em_user']);
+//
+//            // 确定谁先录入
+//            if (strtotime($cs_addtime) > strtotime($matchAddTime)) {
+//                $tstr = "INSERT INTO logrecord (loginName, loginIp, loginTime, loginAct) VALUES ('" .
+//                       $_SESSION['employee_name'] . "', '" . getIp() . "', '" . date('Y-m-d H:i:s') . "', '" .
+//                       $_SESSION['employee_name'] . "编辑客户\"" . $cs_code . "\",该客户与\"" .
+//                       textUncode($matchCustomerCode) . "\"存在重复,<br>匹配类型:" . $matchDetails .
+//                       "<br>客户由:" . $owner . $matchAddTime . "首次录入')";
+//            } else {
+//                $tstr = "INSERT INTO logrecord (loginName, loginIp, loginTime, loginAct) VALUES ('" .
+//                       $_SESSION['employee_name'] . "', '" . getIp() . "', '" . date('Y-m-d H:i:s') . "', '" .
+//                       $_SESSION['employee_name'] . "编辑客户\"" . $cs_code . "\",该客户与\"" .
+//                       textUncode($matchCustomerCode) . "\"存在重复,<br>匹配类型:" . $matchDetails .
+//                       "<br>客户由:" . $_SESSION['employee_name'] . $cs_addtime . "首次录入')";
+//            }
+//
+//            $conn->query($tstr);
+//            echo "<script>alert('warning.2.录入信息\\n与" . $owner . "客户编号:" . textUncode($matchCustomerCode) .
+//                 "\\存在重复(" . $matchDetails . "),未能保存\\n请联系管理员核实!');history.back();</script>";
+//            exit;
+//        }
+//    }
 }
 
 // Save or update customer data

Diff do ficheiro suprimidas por serem muito extensas
+ 12 - 0
js/chart.js


+ 131 - 0
js/statistics.js

@@ -0,0 +1,131 @@
+/**
+ * 统计分析页面的JavaScript功能
+ */
+
+// 初始化所有图表
+function initCharts() {
+    // 各图表初始化逻辑在页面内已实现
+    
+    // 添加图表交互功能
+    enableChartInteractions();
+    
+    // 初始化数据表格排序功能
+    initDataTableSorting();
+}
+
+// 为图表添加交互功能
+function enableChartInteractions() {
+    // 为所有图表添加下载功能
+    addChartDownloadButtons();
+    
+    // 为折线图添加时间范围选择功能
+    addTimeRangeSelectors();
+}
+
+// 添加图表下载按钮
+function addChartDownloadButtons() {
+    const chartContainers = document.querySelectorAll('.chart-container');
+    
+    chartContainers.forEach(container => {
+        const canvas = container.querySelector('canvas');
+        if (!canvas) return;
+        
+        const header = container.querySelector('.chart-header');
+        const downloadBtn = document.createElement('button');
+        downloadBtn.className = 'btn btn-sm';
+        downloadBtn.innerHTML = '下载图表';
+        downloadBtn.onclick = function() {
+            const chartInstance = Chart.getChart(canvas);
+            if (!chartInstance) return;
+            
+            // 创建临时链接并触发下载
+            const a = document.createElement('a');
+            a.href = chartInstance.toBase64Image();
+            a.download = (container.querySelector('.chart-title').textContent || 'chart') + '.png';
+            document.body.appendChild(a);
+            a.click();
+            document.body.removeChild(a);
+        };
+        
+        header.appendChild(downloadBtn);
+    });
+}
+
+// 添加时间范围选择器
+function addTimeRangeSelectors() {
+    // 为具有时间轴的图表添加缩放功能
+    // 这个功能需要Chart.js的Zoom插件,如果需要可以进一步实现
+}
+
+// 初始化数据表格排序
+function initDataTableSorting() {
+    const tables = document.querySelectorAll('.data-table');
+    
+    tables.forEach(table => {
+        const headers = table.querySelectorAll('th');
+        
+        headers.forEach((header, index) => {
+            // 排除不需要排序的列
+            if (header.classList.contains('no-sort')) return;
+            
+            header.style.cursor = 'pointer';
+            header.dataset.sortDirection = 'none'; // none, asc, desc
+            
+            // 添加排序图标
+            const sortIcon = document.createElement('span');
+            sortIcon.className = 'sort-icon';
+            sortIcon.innerHTML = ' ⇅';
+            header.appendChild(sortIcon);
+            
+            // 添加点击事件
+            header.addEventListener('click', () => {
+                // 重置其他列的排序状态
+                headers.forEach(h => {
+                    if (h !== header) h.dataset.sortDirection = 'none';
+                });
+                
+                // 切换当前列的排序方向
+                const currentDirection = header.dataset.sortDirection;
+                if (currentDirection === 'none' || currentDirection === 'desc') {
+                    header.dataset.sortDirection = 'asc';
+                } else {
+                    header.dataset.sortDirection = 'desc';
+                }
+                
+                // 执行排序
+                sortTable(table, index, header.dataset.sortDirection);
+            });
+        });
+    });
+}
+
+// 执行表格排序
+function sortTable(table, columnIndex, direction) {
+    const tbody = table.querySelector('tbody');
+    const rows = Array.from(tbody.querySelectorAll('tr'));
+    
+    // 排序行
+    rows.sort((a, b) => {
+        const aValue = a.querySelectorAll('td')[columnIndex].textContent.trim();
+        const bValue = b.querySelectorAll('td')[columnIndex].textContent.trim();
+        
+        // 检测是否为数值(包括货币符号)
+        const aNum = parseFloat(aValue.replace(/[¥,]/g, ''));
+        const bNum = parseFloat(bValue.replace(/[¥,]/g, ''));
+        
+        if (!isNaN(aNum) && !isNaN(bNum)) {
+            return direction === 'asc' ? aNum - bNum : bNum - aNum;
+        }
+        
+        // 字符串比较
+        return direction === 'asc' 
+            ? aValue.localeCompare(bValue, 'zh-CN') 
+            : bValue.localeCompare(aValue, 'zh-CN');
+    });
+    
+    // 重新添加排序后的行
+    rows.forEach(row => tbody.appendChild(row));
+}
+
+// 页面加载完成后初始化
+document.addEventListener('DOMContentLoaded', initCharts); 

+ 146 - 23
searchResult.php

@@ -11,24 +11,48 @@ if (empty($keywords) || strlen($keywords) < 4) {
     exit;
 }
 
-$searchStr = "SELECT c.cs_code, cc.contact_name as cs_name, c.cs_country, 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, c.cs_addtime, 
-             c.cs_from, c.cs_belong, c.cs_deal, cc.alibaba as cs_alibaba 
+$searchStr = "SELECT c.id, c.cs_code, cc.contact_name as cs_name, c.cs_country, cc.tel_1 as cs_tel, 
+             cc.email_1 as cs_email, cc.whatsapp_1 as cs_whatsapp, cc.wechat_1 as cs_wechat, 
+             cc.linkedin_1 as cs_linkedin, cc.facebook_1 as cs_facebook, c.cs_addtime, 
+             c.cs_from, c.cs_belong, c.cs_deal, cc.alibaba_1 as cs_alibaba 
              FROM customer c 
              LEFT JOIN customer_contact cc ON c.id = cc.customer_id
-             WHERE (cc.tel_format LIKE '%" . $conn->real_escape_string($keywords) . "%' 
-             OR cc.email LIKE '%" . $conn->real_escape_string($keywords) . "%' 
-             OR cc.whatsapp_format LIKE '%" . $conn->real_escape_string($keywords) . "%' 
-             OR cc.wechat LIKE '%" . $conn->real_escape_string($keywords) . "%' 
-             OR cc.alibaba LIKE '%" . $conn->real_escape_string($keywords) . "%' 
-             OR cc.linkedin LIKE '%" . $conn->real_escape_string($keywords) . "%' 
-             OR cc.facebook LIKE '%" . $conn->real_escape_string($keywords) . "%' 
-             OR cc.email LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
-             OR cc.wechat LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
-             OR cc.alibaba LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
-             OR cc.linkedin LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
-             OR cc.facebook LIKE '%" . $conn->real_escape_string($keywordsNative) . "%')";
+             WHERE (cc.tel_1_format LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.tel_2_format LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.tel_3_format LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.email_1 LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.email_2 LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.email_3 LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.whatsapp_1_format LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.whatsapp_2_format LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.whatsapp_3_format LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.wechat_1 LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.wechat_2 LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.wechat_3 LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.alibaba_1 LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.alibaba_2 LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.alibaba_3 LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.linkedin_1 LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.linkedin_2 LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.linkedin_3 LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.facebook_1 LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.facebook_2 LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.facebook_3 LIKE '%" . $conn->real_escape_string($keywords) . "%' 
+             OR cc.email_1 LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
+             OR cc.email_2 LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
+             OR cc.email_3 LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
+             OR cc.wechat_1 LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
+             OR cc.wechat_2 LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
+             OR cc.wechat_3 LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
+             OR cc.alibaba_1 LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
+             OR cc.alibaba_2 LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
+             OR cc.alibaba_3 LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
+             OR cc.linkedin_1 LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
+             OR cc.linkedin_2 LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
+             OR cc.linkedin_3 LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
+             OR cc.facebook_1 LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
+             OR cc.facebook_2 LIKE '%" . $conn->real_escape_string($keywordsNative) . "%' 
+             OR cc.facebook_3 LIKE '%" . $conn->real_escape_string($keywordsNative) . "%')";
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
@@ -105,13 +129,112 @@ if ($result && $result->num_rows > 0) {
         </tr>
         <tr>
             <td colspan="6" class="contacts">
-                <div class="tel"><?= htmlspecialcharsFix($row['cs_tel']) ?></div>
-                <div class="mail"><?= htmlspecialcharsFix($row['cs_email']) ?></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>
+                <?php
+                // 获取该客户的所有联系人信息
+                if (isset($row['id']) && !empty($row['id'])) {
+                    $contact_sql = "SELECT * FROM customer_contact WHERE customer_id = " . (int)$row['id'];
+                    $contact_result = mysqli_query($conn, $contact_sql);
+                    while ($contact = mysqli_fetch_assoc($contact_result)) {
+                ?>
+                <div class="contact-block">
+                    <?php if(!empty($contact['contact_name'])): ?>
+                        <div class="contact-name"><?= htmlspecialcharsFix($contact['contact_name']) ?></div>
+                    <?php endif; ?>
+                    <div class="tel">
+                        <?php if(!empty($contact['tel_1'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['tel_1']) ?></div>
+                        <?php endif; ?>
+                        <?php if(!empty($contact['tel_2'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['tel_2']) ?></div>
+                        <?php endif; ?>
+                        <?php if(!empty($contact['tel_3'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['tel_3']) ?></div>
+                        <?php endif; ?>
+                    </div>
+                    <div class="mail">
+                        <?php if(!empty($contact['email_1'])): ?>
+                            <div><a href="mailto:<?= $contact['email_1'] ?>"><?= htmlspecialcharsFix($contact['email_1']) ?></a></div>
+                        <?php endif; ?>
+                        <?php if(!empty($contact['email_2'])): ?>
+                            <div><a href="mailto:<?= $contact['email_2'] ?>"><?= htmlspecialcharsFix($contact['email_2']) ?></a></div>
+                        <?php endif; ?>
+                        <?php if(!empty($contact['email_3'])): ?>
+                            <div><a href="mailto:<?= $contact['email_3'] ?>"><?= htmlspecialcharsFix($contact['email_3']) ?></a></div>
+                        <?php endif; ?>
+                    </div>
+                    <div class="whatsapp">
+                        <?php if(!empty($contact['whatsapp_1'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['whatsapp_1']) ?></div>
+                        <?php endif; ?>
+                        <?php if(!empty($contact['whatsapp_2'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['whatsapp_2']) ?></div>
+                        <?php endif; ?>
+                        <?php if(!empty($contact['whatsapp_3'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['whatsapp_3']) ?></div>
+                        <?php endif; ?>
+                    </div>
+                    <div class="wechat">
+                        <?php if(!empty($contact['wechat_1'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['wechat_1']) ?></div>
+                        <?php endif; ?>
+                        <?php if(!empty($contact['wechat_2'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['wechat_2']) ?></div>
+                        <?php endif; ?>
+                        <?php if(!empty($contact['wechat_3'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['wechat_3']) ?></div>
+                        <?php endif; ?>
+                    </div>
+                    <div class="linkedin">
+                        <?php if(!empty($contact['linkedin_1'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['linkedin_1']) ?></div>
+                        <?php endif; ?>
+                        <?php if(!empty($contact['linkedin_2'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['linkedin_2']) ?></div>
+                        <?php endif; ?>
+                        <?php if(!empty($contact['linkedin_3'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['linkedin_3']) ?></div>
+                        <?php endif; ?>
+                    </div>
+                    <div class="facebook">
+                        <?php if(!empty($contact['facebook_1'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['facebook_1']) ?></div>
+                        <?php endif; ?>
+                        <?php if(!empty($contact['facebook_2'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['facebook_2']) ?></div>
+                        <?php endif; ?>
+                        <?php if(!empty($contact['facebook_3'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['facebook_3']) ?></div>
+                        <?php endif; ?>
+                    </div>
+                    <div class="alibaba">
+                        <?php if(!empty($contact['alibaba_1'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['alibaba_1']) ?></div>
+                        <?php endif; ?>
+                        <?php if(!empty($contact['alibaba_2'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['alibaba_2']) ?></div>
+                        <?php endif; ?>
+                        <?php if(!empty($contact['alibaba_3'])): ?>
+                            <div><?= htmlspecialcharsFix($contact['alibaba_3']) ?></div>
+                        <?php endif; ?>
+                    </div>
+                </div>
+                <?php 
+                    }
+                } else {
+                    // 如果没有ID,则显示查询返回的基本联系信息
+                ?>
+                <div class="contact-block">
+                    <div class="tel"><?= htmlspecialcharsFix($row['cs_tel'] ?? '') ?></div>
+                    <div class="mail"><?= htmlspecialcharsFix($row['cs_email'] ?? '') ?></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>
+                <?php
+                }
+                ?>
             </td>
         </tr>
 <?php

+ 23 - 23
system/customers.php

@@ -598,7 +598,7 @@ if ($act == "edit" || $act == "add") {
                                 <table width="100%" border="0" cellpadding="3" cellspacing="1" class="contact-table">
                                     <tr>
                                         <th width="8%">联系人</th>
-                                        <td><input type="text" name="contact[<?php echo $index; ?>][contact_name]" value="<?php echo htmlspecialchars($contact['contact_name']); ?>" class="txt1" placeholder="联系人姓名"/></td>
+                                        <td><input type="text" name="contact[<?php echo $index; ?>][contact_name]" value="<?php echo htmlspecialcharsFix($contact['contact_name']); ?>" class="txt1" placeholder="联系人姓名"/></td>
                                     </tr>
                                 </table>
                                 <div class="contact-methods-container" id="contact-methods-<?php echo $index; ?>">
@@ -627,13 +627,13 @@ if ($act == "edit" || $act == "add") {
                                                 }
                                                 
                                                 echo '</select>';
-                                                echo '<input type="text" class="txt1 method-input" style="width:60%;" name="contact[' . $index . '][' . $fieldName . ']" value="' . htmlspecialchars($contact[$fieldName]) . '">';
+                                                echo '<input type="text" class="txt1 method-input" style="width:60%;" name="contact[' . $index . '][' . $fieldName . ']" value="' . htmlspecialcharsFix($contact[$fieldName]) . '">';
                                                 
                                                 if ($type === 'tel' || $type === 'whatsapp') {
-                                                    echo '<input type="hidden" class="format-input" name="contact[' . $index . '][' . $fieldName . '_format]" value="' . htmlspecialchars($contact[$fieldName . '_format']) . '">';
+                                                    echo '<input type="hidden" class="format-input" name="contact[' . $index . '][' . $fieldName . '_format]" value="' . htmlspecialcharsFix($contact[$fieldName . '_format']) . '">';
                                                 }
                                                 
-                                                echo '<input type="hidden" class="backup-input" name="contact[' . $index . '][' . $fieldName . '_bu]" value="' . htmlspecialchars($contact[$fieldName . '_bu']) . '">';
+                                                echo '<input type="hidden" class="backup-input" name="contact[' . $index . '][' . $fieldName . '_bu]" value="' . htmlspecialcharsFix($contact[$fieldName . '_bu']) . '">';
                                                 echo '</div>';
                                             }
                                         }
@@ -677,7 +677,7 @@ if ($act == "edit" || $act == "add") {
                         $sql = "SELECT id,tagName FROM tagtable WHERE customerId = " . (int)$id;
                         $result = $conn->query($sql);
                         while($row = $result->fetch_assoc()) {
-                            echo htmlspecialchars($row['tagName']) . ',';
+                            echo htmlspecialcharsFix($row['tagName']) . ',';
                         }
                     }
                     ?>
@@ -989,14 +989,14 @@ $tempNum = $pageSize * ($page - 1);
                             <img src="../images/yijiao.png" class="handover">
                         <?php endif; ?>
                     </td>
-                    <td align="center"><?php echo htmlspecialchars($row['cs_name'] ?? ''); ?></td>
+                    <td align="center"><?php echo htmlspecialcharsFix($row['cs_name'] ?? ''); ?></td>
                     <td align="center">
                         <?php
                         $countryId = intval($row['cs_country'] ?? 0);
                         $sql = "SELECT countryName FROM country WHERE id = $countryId";
                         $countryResult = $conn->query($sql);
                         if ($countryResult && $countryRow = $countryResult->fetch_assoc()) {
-                            echo htmlspecialchars($countryRow['countryName']);
+                            echo htmlspecialcharsFix($countryRow['countryName']);
                         } else {
                             echo "未选择";
                         }
@@ -1008,7 +1008,7 @@ $tempNum = $pageSize * ($page - 1);
                         $sql = "SELECT ch_name FROM qudao WHERE id = $fromId";
                         $fromResult = $conn->query($sql);
                         if ($fromResult && $fromRow = $fromResult->fetch_assoc()) {
-                            echo htmlspecialchars($fromRow['ch_name']);
+                            echo htmlspecialcharsFix($fromRow['ch_name']);
                         } else {
                             echo "未选择";
                         }
@@ -1017,7 +1017,7 @@ $tempNum = $pageSize * ($page - 1);
                     <td align="center">
                         <?php 
                         if (($row['cs_deal'] ?? 0) == 3) {
-                            echo "<span style='color:red;font-size:10px;'>" . htmlspecialchars($row['cs_dealdate'] ?? '') . "成交</span>";
+                            echo "<span style='color:red;font-size:10px;'>" . htmlspecialcharsFix($row['cs_dealdate'] ?? '') . "成交</span>";
                         } elseif (($row['cs_deal'] ?? 0) == 2) {
                             echo "明确需求";
                         } elseif (($row['cs_deal'] ?? 0) == 1) {
@@ -1033,7 +1033,7 @@ $tempNum = $pageSize * ($page - 1);
                         $sql = "SELECT em_user FROM employee WHERE id = $belongId";
                         $empResult = $conn->query($sql);
                         if ($empResult && $empRow = $empResult->fetch_assoc()) {
-                            echo htmlspecialchars($empRow['em_user']);
+                            echo htmlspecialcharsFix($empRow['em_user']);
                         } else {
                             echo "未选择";
                         }
@@ -1047,8 +1047,8 @@ $tempNum = $pageSize * ($page - 1);
                     <td colspan="2"></td>
                     <td colspan="7" class="cs_detail">                    
                         <ul>                
-                            <li class="cs_detail_addtime">录入时间:<?php echo htmlspecialchars($row['cs_addtime'] ?? ''); ?></li>
-                            <li class="cs_detail_addtime">更新时间:<?php echo htmlspecialchars($row['cs_updatetime'] ?? ''); ?></li>
+                            <li class="cs_detail_addtime">录入时间:<?php echo htmlspecialcharsFix($row['cs_addtime'] ?? ''); ?></li>
+                            <li class="cs_detail_addtime">更新时间:<?php echo htmlspecialcharsFix($row['cs_updatetime'] ?? ''); ?></li>
                             <li class="cs_detail_addtime">
                                 流转记录:
                                 <?php                                
@@ -1063,7 +1063,7 @@ $tempNum = $pageSize * ($page - 1);
                                         $chainResult = $conn->query($sql);
                                         $chain_users = [];
                                         while($chainRow = $chainResult->fetch_assoc()) {
-                                            $chain_users[] = htmlspecialchars($chainRow['em_user']);
+                                            $chain_users[] = htmlspecialcharsFix($chainRow['em_user']);
                                         }
                                         echo implode(' > ', $chain_users);
                                     }
@@ -1071,31 +1071,31 @@ $tempNum = $pageSize * ($page - 1);
                                 ?>             
                             </li>
                             <?php if(!empty($row['cs_tel'] ?? '')): ?>
-                                <li class="tel"><?php echo htmlspecialchars($row['cs_tel']); ?></li>
+                                <li class="tel"><?php echo htmlspecialcharsFix($row['cs_tel']); ?></li>
                             <?php endif; ?>
                             <?php if(!empty($row['cs_email'] ?? '')): ?>
-                                <li class="mail"><?php echo htmlspecialchars($row['cs_email']); ?></li>
+                                <li class="mail"><?php echo htmlspecialcharsFix($row['cs_email']); ?></li>
                             <?php endif; ?>
                             <?php if(!empty($row['cs_whatsapp'] ?? '')): ?>
-                                <li class="whatsapp"><?php echo htmlspecialchars($row['cs_whatsapp']); ?></li>
+                                <li class="whatsapp"><?php echo htmlspecialcharsFix($row['cs_whatsapp']); ?></li>
                             <?php endif; ?>
                             <?php if(!empty($row['cs_wechat'] ?? '')): ?>
-                                <li class="wechat"><?php echo htmlspecialchars($row['cs_wechat']); ?></li>
+                                <li class="wechat"><?php echo htmlspecialcharsFix($row['cs_wechat']); ?></li>
                             <?php endif; ?>
                             <?php if(!empty($row['cs_linkedin'] ?? '')): ?>
-                                <li class="linkedin"><?php echo htmlspecialchars($row['cs_linkedin']); ?></li>
+                                <li class="linkedin"><?php echo htmlspecialcharsFix($row['cs_linkedin']); ?></li>
                             <?php endif; ?>
                             <?php if(!empty($row['cs_facebook'] ?? '')): ?>
-                                <li class="facebook"><?php echo htmlspecialchars($row['cs_facebook']); ?></li>
+                                <li class="facebook"><?php echo htmlspecialcharsFix($row['cs_facebook']); ?></li>
                             <?php endif; ?>
                             <?php if(!empty($row['cs_alibaba'] ?? '')): ?>
-                                <li class="alibaba"><?php echo htmlspecialchars($row['cs_alibaba']); ?></li>
+                                <li class="alibaba"><?php echo htmlspecialcharsFix($row['cs_alibaba']); ?></li>
                             <?php endif; ?>
                             <?php if(!empty($row['cs_address'] ?? '')): ?>
-                                <li class="address"><?php echo htmlspecialchars($row['cs_address']); ?></li>
+                                <li class="address"><?php echo htmlspecialcharsFix($row['cs_address']); ?></li>
                             <?php endif; ?>
                         </ul>
-                        <div class="cs_detail_note"><?php echo htmlspecialchars($row['cs_note'] ?? ''); ?></div>
+                        <div class="cs_detail_note"><?php echo htmlspecialcharsFix($row['cs_note'] ?? ''); ?></div>
                     </td>                
                 </tr>
                 <?php
@@ -1103,7 +1103,7 @@ $tempNum = $pageSize * ($page - 1);
         } else {
             // 没有搜索结果的情况
             if (!empty($keyscode)) {
-                echo '<tr><td colspan="9" align="center">没有找到 "' . htmlspecialchars($keyscode) . '" 相关的客户信息</td></tr>';
+                echo '<tr><td colspan="9" align="center">没有找到 "' . htmlspecialcharsFix($keyscode) . '" 相关的客户信息</td></tr>';
             } else {
                 echo '<tr><td colspan="9" align="center">暂无客户信息</td></tr>';
             }

+ 1 - 1
system/employee.php

@@ -323,7 +323,7 @@ $hrefstr = "?keys=$keys";
                         <option value="0">隐藏</option>
                         <option value="-1">删除</option>
                     </select>
-                    <input type="button" value="执行" onClick="postchk(1)" class="btn1" />
+                    <input type="button" value="执行" onClick="postchk_new(1)" class="btn1" />
                     <input type="button" value="新增" onClick="location.href='?act=add'" class="btn1" />
                 </div>
             </td>

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff