Browse Source

fleat: update customer phone check

igb 2 days ago
parent
commit
ee0b99e644
3 changed files with 32 additions and 26 deletions
  1. 8 8
      customerAdd.php
  2. 2 2
      customerEdit.php
  3. 22 16
      customerSave.php

+ 8 - 8
customerAdd.php

@@ -184,7 +184,7 @@ checkLogin();
         });
         
         // Update field names
-        select.attr('name', `contact[${contactIndex}][${type}_${count}]`);
+        select.attr('name', `contact[${contactIndex}][method_type_${count}]`);
         input.attr('name', `contact[${contactIndex}][${type}_${count}]`);
         
         // Add format field for tel and whatsapp
@@ -505,18 +505,18 @@ checkLogin();
         <table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
             <tbody>
                 <tr>
-                    <th width="8%">客户编号</th>
+                    <th width="8%" nowrap>客户编号</th>
                     <td>
                         <input type="text" id="cs_code" name="cs_code" value="" class="txt1" />
                         <input type="hidden" name="cs_addtime" value="<?= date('Y-m-d H:i:s') ?>" />
                     </td>
                 </tr>
                 <tr>
-                    <th width="8%">公司名称</th>
+                    <th width="8%" nowrap>公司名称</th>
                     <td><input type="text" id="cs_company" name="cs_company" value="" class="txt1" /></td>
                 </tr>
                 <tr>
-                    <th width="8%">地区/国家</th>
+                    <th width="8%" nowrap>地区/国家</th>
                     <td>
                         <div class="layui-input-inline">
                             <div class="layui-form-select ySearchSelect y1">
@@ -542,7 +542,7 @@ checkLogin();
                     </td>
                 </tr>
                 <tr>
-                    <th width="8%">来源</th>
+                    <th width="8%" nowrap>来源</th>
                     <td>
                         <select id="cs_from" name="cs_from">
                             <option value="0">请选择来源</option>
@@ -556,7 +556,7 @@ checkLogin();
                     </td>
                 </tr>
                 <tr>
-                    <th width="8%" valign="top">联系人信息</th>
+                    <th width="8%" valign="top" nowrap>联系人信息</th>
                     <td>
                         <button type="button" class="add-contact-btn">添加联系人</button>
                         
@@ -566,11 +566,11 @@ checkLogin();
                     </td>
                 </tr>
                 <tr>
-                    <th>地址</th>
+                    <th nowrap>地址</th>
                     <td><input type="text" id="cs_address" name="cs_address" value="" class="txt1" /></td>
                 </tr>
                 <tr>
-                    <th>业务类型</th>
+                    <th nowrap>业务类型</th>
                     <td>
                         <?php
                         $result = $conn->query("SELECT id, businessType FROM clienttype");

+ 2 - 2
customerEdit.php

@@ -480,7 +480,7 @@ if (!empty($id) && is_numeric($id)) {
         });
         
         // Update field names
-        select.attr('name', `contact[${contactIndex}][${type}_${count}]`);
+        select.attr('name', `contact[${contactIndex}][method_type_${count}]`);
         input.attr('name', `contact[${contactIndex}][${type}_${count}]`);
         
         // Add format field for tel and whatsapp
@@ -1268,7 +1268,7 @@ if (!empty($id) && is_numeric($id)) {
                                                 $fieldName = $type . '_' . $i;
                                                 if (!empty($contact[$fieldName])) {
                                                     echo '<div class="contact-method-row">';
-                                                    echo '<select class="method-select" name="contact[' . $index . '][' . $fieldName . ']" onchange="updateMethodSelectAndPlaceholder(this)">';
+                                                    echo '<select class="method-select" name="contact[' . $index . '][method_type_' . $i . ']" onchange="updateMethodSelectAndPlaceholder(this)">';
                                                     echo '<option value="">请选择联系方式</option>';
                                                     
                                                     foreach ($methodTypes as $optionType => $optionLabel) {

+ 22 - 16
customerSave.php

@@ -1,6 +1,9 @@
 <?php
 require_once 'conn.php';
 checkLogin();
+
+// 设置多字节字符编码
+mb_internal_encoding('UTF-8');
 ?>
 <!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">
@@ -184,12 +187,12 @@ foreach ($contacts as $contact) {
 
             if(!empty($tel_clean))
             {
-                $checkStr .= " OR cc.tel_1_format LIKE '%" . substr($tel_clean, -9) . "%'" .
-                            " OR cc.tel_2_format LIKE '%" . substr($tel_clean, -9) . "%'" .
-                        " OR cc.tel_3_format LIKE '%" . substr($tel_clean, -9) . "%'" .
-                        " OR cc.wechat_1 LIKE '%" . substr($tel_clean, -9) . "%'" .
-                        " OR cc.wechat_2 LIKE '%" . substr($tel_clean, -9) . "%'" .
-                        " OR cc.wechat_3 LIKE '%" . substr($tel_clean, -9) . "%'";
+                $checkStr .= " OR cc.tel_1_format LIKE '%" . mb_substr($tel_clean, -9) . "%'" .
+                            " OR cc.tel_2_format LIKE '%" . mb_substr($tel_clean, -9) . "%'" .
+                        " OR cc.tel_3_format LIKE '%" . mb_substr($tel_clean, -9) . "%'" .
+                        " OR cc.wechat_1 LIKE '%" . mb_substr($tel_clean, -9) . "%'" .
+                        " OR cc.wechat_2 LIKE '%" . mb_substr($tel_clean, -9) . "%'" .
+                        " OR cc.wechat_3 LIKE '%" . mb_substr($tel_clean, -9) . "%'";
                 $Dupli .= "电话" . $i . ":" . $contact[$tel_field] . " ";
             }
         }
@@ -218,12 +221,12 @@ foreach ($contacts as $contact) {
             $whatsapp_clean = preg_replace('/[^0-9]/', '', $whatsapp_format);
             if(!empty($whatsapp_clean))
             {
-                $checkStr .= " OR cc.whatsapp_1_format LIKE '%" . substr($whatsapp_clean, -9) . "%'" .
-                        " OR cc.whatsapp_2_format LIKE '%" . substr($whatsapp_clean, -9) . "%'" .
-                        " OR cc.whatsapp_3_format LIKE '%" . substr($whatsapp_clean, -9) . "%'" .
-                        " OR cc.tel_1_format LIKE '%" . substr($whatsapp_clean, -9) . "%'" .
-                        " OR cc.tel_2_format LIKE '%" . substr($whatsapp_clean, -9) . "%'" .
-                        " OR cc.tel_3_format LIKE '%" . substr($whatsapp_clean, -9) . "%'";
+                $checkStr .= " OR cc.whatsapp_1_format LIKE '%" . mb_substr($whatsapp_clean, -9) . "%'" .
+                        " OR cc.whatsapp_2_format LIKE '%" . mb_substr($whatsapp_clean, -9) . "%'" .
+                        " OR cc.whatsapp_3_format LIKE '%" . mb_substr($whatsapp_clean, -9) . "%'" .
+                        " OR cc.tel_1_format LIKE '%" . mb_substr($whatsapp_clean, -9) . "%'" .
+                        " OR cc.tel_2_format LIKE '%" . mb_substr($whatsapp_clean, -9) . "%'" .
+                        " OR cc.tel_3_format LIKE '%" . mb_substr($whatsapp_clean, -9) . "%'";
                 $Dupli .= "WhatsApp" . $i . ":" . $contact[$whatsapp_field] . " ";
             }
         }
@@ -275,15 +278,18 @@ foreach ($contacts as $contact) {
         $alibaba_field = 'alibaba_' . $i;
         if (!empty($contact[$alibaba_field])) {
             $alibaba = strtolower($contact[$alibaba_field]);
+          
             if (strlen($alibaba) < 10) {
                 $checkStr .= " OR LOWER(cc.alibaba_1) LIKE '" . $conn->real_escape_string($alibaba) . "'" .
                             " OR LOWER(cc.alibaba_2) LIKE '" . $conn->real_escape_string($alibaba) . "'" .
                             " OR LOWER(cc.alibaba_3) LIKE '" . $conn->real_escape_string($alibaba) . "'";
             } else {
-                $alibaba_clean = preg_replace('/[^0-9a-zA-Z]/', '', $alibaba);
-                $checkStr .= " OR LOWER(cc.alibaba_1) LIKE '%" . substr($alibaba_clean, -9) . "%'" .
-                            " OR LOWER(cc.alibaba_2) LIKE '%" . substr($alibaba_clean, -9) . "%'" .
-                            " OR LOWER(cc.alibaba_3) LIKE '%" . substr($alibaba_clean, -9) . "%'";
+                // 修改正则表达式,仅移除特殊符号,保留中文和英文字母数字
+                $alibaba_clean = preg_replace('/[^\p{Han}0-9a-zA-Z]/u', '', $alibaba);
+                
+                $checkStr .= " OR LOWER(cc.alibaba_1) LIKE '%" . mb_substr($alibaba_clean, -9) . "%'" .
+                            " OR LOWER(cc.alibaba_2) LIKE '%" . mb_substr($alibaba_clean, -9) . "%'" .
+                            " OR LOWER(cc.alibaba_3) LIKE '%" . mb_substr($alibaba_clean, -9) . "%'";
             }
             $Dupli .= "阿里旺旺" . $i . ":" . $contact[$alibaba_field] . " ";
         }