|
@@ -2,6 +2,13 @@
|
|
require_once('conn.php');
|
|
require_once('conn.php');
|
|
checkLogin("信息管理");
|
|
checkLogin("信息管理");
|
|
|
|
|
|
|
|
+// 辅助函数
|
|
|
|
+function numFormat($str) {
|
|
|
|
+ // 移除所有非数字字符
|
|
|
|
+ $formatted = preg_replace('/[^0-9]/', '', $str);
|
|
|
|
+ return $formatted;
|
|
|
|
+}
|
|
|
|
+
|
|
// Initialize variables
|
|
// Initialize variables
|
|
$urlStr = "";
|
|
$urlStr = "";
|
|
$act = $_GET['act'] ?? '';
|
|
$act = $_GET['act'] ?? '';
|
|
@@ -27,92 +34,49 @@ if ($act == "save") {
|
|
$cs_address = textEncode($_POST['cs_address'] ?? '');
|
|
$cs_address = textEncode($_POST['cs_address'] ?? '');
|
|
$allowedit = isset($_POST['allowedit']) ? 1 : 0;
|
|
$allowedit = isset($_POST['allowedit']) ? 1 : 0;
|
|
|
|
|
|
- // Contact fields
|
|
|
|
- $contact_name = textEncode($_POST['cs_name'] ?? '');
|
|
|
|
- $tel = textEncode($_POST['cs_tel'] ?? '');
|
|
|
|
- $email = textEncode($_POST['cs_email'] ?? '');
|
|
|
|
- $whatsapp = textEncode($_POST['cs_whatsapp'] ?? '');
|
|
|
|
- $wechat = textEncode($_POST['cs_wechat'] ?? '');
|
|
|
|
- $linkedin = textEncode($_POST['cs_linkedin'] ?? '');
|
|
|
|
- $facebook = textEncode($_POST['cs_facebook'] ?? '');
|
|
|
|
- $alibaba = textEncode($_POST['cs_alibaba'] ?? '');
|
|
|
|
-
|
|
|
|
- if ($isEdit) {
|
|
|
|
- $sql = "SELECT cs_chain FROM customer WHERE id=" . $id;
|
|
|
|
- $result = $conn->query($sql);
|
|
|
|
-
|
|
|
|
- if ($row = $result->fetch_assoc()) {
|
|
|
|
- $cs_chain = $row['cs_chain'];
|
|
|
|
- $chain_array = explode(',', $cs_chain);
|
|
|
|
- $last_item = end($chain_array);
|
|
|
|
-
|
|
|
|
- if ($last_item != $cs_belong) {
|
|
|
|
- $cs_chain .= ",$cs_belong";
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Update customer table
|
|
|
|
- $sql = "UPDATE customer SET
|
|
|
|
- cs_code='$cs_code',
|
|
|
|
- cs_company='$cs_company',
|
|
|
|
- cs_belong=$cs_belong,
|
|
|
|
- cs_country=$cs_country,
|
|
|
|
- cs_from=$cs_from,
|
|
|
|
- cs_state=$cs_state,
|
|
|
|
- cs_deal=$cs_deal,
|
|
|
|
- cs_note='$no_content',
|
|
|
|
- cs_address='$cs_address',
|
|
|
|
- allowedit=$allowedit,
|
|
|
|
- cs_chain='$cs_chain',
|
|
|
|
- cs_updatetime=NOW()
|
|
|
|
- WHERE id=$id";
|
|
|
|
- $conn->query($sql);
|
|
|
|
-
|
|
|
|
- // Check if contact exists for this customer
|
|
|
|
- $sql = "SELECT id FROM customer_contact WHERE customer_id=$id";
|
|
|
|
- $contact_result = $conn->query($sql);
|
|
|
|
|
|
+ // Begin transaction for all database operations
|
|
|
|
+ $conn->begin_transaction();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ if ($isEdit) {
|
|
|
|
+ // Get existing chain info
|
|
|
|
+ $sql = "SELECT cs_chain FROM customer WHERE id=$id";
|
|
|
|
+ $result = $conn->query($sql);
|
|
|
|
|
|
- if ($contact_result->num_rows > 0) {
|
|
|
|
- $contact_row = $contact_result->fetch_assoc();
|
|
|
|
- $contact_id = $contact_row['id'];
|
|
|
|
|
|
+ if ($row = $result->fetch_assoc()) {
|
|
|
|
+ $cs_chain = $row['cs_chain'];
|
|
|
|
+ $chain_array = explode(',', $cs_chain);
|
|
|
|
+ $last_item = end($chain_array);
|
|
|
|
|
|
- // Update existing contact
|
|
|
|
- $sql = "UPDATE customer_contact SET
|
|
|
|
- contact_name='$contact_name',
|
|
|
|
- tel='$tel',
|
|
|
|
- email='$email',
|
|
|
|
- whatsapp='$whatsapp',
|
|
|
|
- wechat='$wechat',
|
|
|
|
- linkedin='$linkedin',
|
|
|
|
- facebook='$facebook',
|
|
|
|
- alibaba='$alibaba',
|
|
|
|
- updated_at=NOW()
|
|
|
|
- WHERE id=$contact_id";
|
|
|
|
|
|
+ if ($last_item != $cs_belong) {
|
|
|
|
+ $cs_chain .= ",$cs_belong";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Update customer table
|
|
|
|
+ $sql = "UPDATE customer SET
|
|
|
|
+ cs_code='$cs_code',
|
|
|
|
+ cs_company='$cs_company',
|
|
|
|
+ cs_belong=$cs_belong,
|
|
|
|
+ cs_country=$cs_country,
|
|
|
|
+ cs_from=$cs_from,
|
|
|
|
+ cs_state=$cs_state,
|
|
|
|
+ cs_deal=$cs_deal,
|
|
|
|
+ cs_note='$no_content',
|
|
|
|
+ cs_address='$cs_address',
|
|
|
|
+ allowedit=$allowedit,
|
|
|
|
+ cs_chain='$cs_chain',
|
|
|
|
+ cs_updatetime=NOW()
|
|
|
|
+ WHERE id=$id";
|
|
$conn->query($sql);
|
|
$conn->query($sql);
|
|
- } else {
|
|
|
|
- // Create new contact for existing customer
|
|
|
|
- $sql = "INSERT INTO customer_contact (
|
|
|
|
- customer_id, contact_name, tel, email, whatsapp, wechat,
|
|
|
|
- linkedin, facebook, alibaba, created_at, updated_at
|
|
|
|
- ) VALUES (
|
|
|
|
- $id, '$contact_name', '$tel', '$email', '$whatsapp', '$wechat',
|
|
|
|
- '$linkedin', '$facebook', '$alibaba', NOW(), NOW()
|
|
|
|
- )";
|
|
|
|
|
|
+
|
|
|
|
+ // Delete existing contacts to replace with new ones
|
|
|
|
+ $sql = "DELETE FROM customer_contact WHERE customer_id=$id";
|
|
$conn->query($sql);
|
|
$conn->query($sql);
|
|
|
|
+ } else {
|
|
|
|
+ throw new Exception('不存在该客户');
|
|
}
|
|
}
|
|
-
|
|
|
|
- $page = $_GET['Page'] ?? '';
|
|
|
|
- $keys = urlencode($_GET['Keys'] ?? '');
|
|
|
|
- header("Location: ?keys=$keys&Page=$page$urlStr");
|
|
|
|
- exit;
|
|
|
|
} else {
|
|
} else {
|
|
- $output = "<script>alert('不存在该客户');history.back();</script>";
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- // Begin transaction
|
|
|
|
- $conn->begin_transaction();
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- // Insert into customer table
|
|
|
|
|
|
+ // Insert new customer
|
|
$sql = "INSERT INTO customer (
|
|
$sql = "INSERT INTO customer (
|
|
cs_code, cs_company, cs_belong, cs_country, cs_from,
|
|
cs_code, cs_company, cs_belong, cs_country, cs_from,
|
|
cs_state, cs_deal, cs_note, cs_address,
|
|
cs_state, cs_deal, cs_note, cs_address,
|
|
@@ -124,27 +88,64 @@ if ($act == "save") {
|
|
)";
|
|
)";
|
|
|
|
|
|
$conn->query($sql);
|
|
$conn->query($sql);
|
|
- $new_customer_id = $conn->insert_id;
|
|
|
|
-
|
|
|
|
- // Insert into customer_contact table
|
|
|
|
- $sql = "INSERT INTO customer_contact (
|
|
|
|
- customer_id, contact_name, tel, email, whatsapp, wechat,
|
|
|
|
- linkedin, facebook, alibaba, created_at, updated_at
|
|
|
|
- ) VALUES (
|
|
|
|
- $new_customer_id, '$contact_name', '$tel', '$email', '$whatsapp', '$wechat',
|
|
|
|
- '$linkedin', '$facebook', '$alibaba', NOW(), NOW()
|
|
|
|
- )";
|
|
|
|
- $conn->query($sql);
|
|
|
|
-
|
|
|
|
- // Commit transaction
|
|
|
|
- $conn->commit();
|
|
|
|
- header("Location: ?");
|
|
|
|
- exit;
|
|
|
|
- } catch (Exception $e) {
|
|
|
|
- // Rollback on failure
|
|
|
|
- $conn->rollback();
|
|
|
|
- $output = "<script>alert('保存失败: " . $e->getMessage() . "');history.back();</script>";
|
|
|
|
|
|
+ $id = $conn->insert_id;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Process contacts array
|
|
|
|
+ if (isset($_POST['contact']) && is_array($_POST['contact'])) {
|
|
|
|
+ foreach ($_POST['contact'] as $contact) {
|
|
|
|
+ if (empty($contact['contact_name'])) continue;
|
|
|
|
+
|
|
|
|
+ $contact_name = textEncode($contact['contact_name']);
|
|
|
|
+
|
|
|
|
+ // Initialize arrays for contact methods
|
|
|
|
+ $methods = ['tel', 'email', 'whatsapp', 'wechat', 'linkedin', 'facebook', 'alibaba'];
|
|
|
|
+ $fields = ['customer_id', 'contact_name'];
|
|
|
|
+ $values = [$id, "'$contact_name'"];
|
|
|
|
+
|
|
|
|
+ // Process each contact method (up to 3 entries each)
|
|
|
|
+ foreach ($methods as $method) {
|
|
|
|
+ for ($i = 1; $i <= 3; $i++) {
|
|
|
|
+ $field_base = $method . '_' . $i;
|
|
|
|
+ $value = textEncode($contact[$field_base] ?? '');
|
|
|
|
+ $fields[] = $field_base;
|
|
|
|
+ $values[] = "'$value'";
|
|
|
|
+
|
|
|
|
+ // Add format field for tel and whatsapp
|
|
|
|
+ if ($method == 'tel' || $method == 'whatsapp') {
|
|
|
|
+ $format_value = numFormat($value);
|
|
|
|
+ $fields[] = $field_base . '_format';
|
|
|
|
+ $values[] = "'$format_value'";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Add backup field
|
|
|
|
+ $bu_value = textEncode($contact[$field_base . '_bu'] ?? $value);
|
|
|
|
+ $fields[] = $field_base . '_bu';
|
|
|
|
+ $values[] = "'$bu_value'";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Create and execute insert statement for contact
|
|
|
|
+ $sql = "INSERT INTO customer_contact (" . implode(', ', $fields) . ", created_at, updated_at)
|
|
|
|
+ VALUES (" . implode(', ', $values) . ", NOW(), NOW())";
|
|
|
|
+
|
|
|
|
+ $conn->query($sql);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // Commit transaction
|
|
|
|
+ $conn->commit();
|
|
|
|
+
|
|
|
|
+ // Redirect after successful save
|
|
|
|
+ $page = $_GET['Page'] ?? '';
|
|
|
|
+ $keys = urlencode($_GET['Keys'] ?? '');
|
|
|
|
+ header("Location: ?keys=$keys&Page=$page$urlStr");
|
|
|
|
+ exit;
|
|
|
|
+
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
+ // Rollback on failure
|
|
|
|
+ $conn->rollback();
|
|
|
|
+ $output = "<script>alert('保存失败: " . $e->getMessage() . "');history.back();</script>";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -178,8 +179,265 @@ $(document).ready(function(){
|
|
upMediaUrl:"upload.php",
|
|
upMediaUrl:"upload.php",
|
|
upMediaExt:"wmv,avi,wma,mp3,mid"
|
|
upMediaExt:"wmv,avi,wma,mp3,mid"
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ // Remove contact
|
|
|
|
+ $(document).on('click', '.remove-contact-btn', function() {
|
|
|
|
+ var contactForm = $(this).closest('.contact-form');
|
|
|
|
+ contactForm.remove();
|
|
|
|
+
|
|
|
|
+ // Renumber remaining contacts
|
|
|
|
+ $('#contacts-container .contact-form').each(function(index) {
|
|
|
|
+ $(this).find('h3').text('联系人 #' + (index + 1));
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // Add contact form
|
|
|
|
+ $('.add-contact-btn').click(function() {
|
|
|
|
+ var contactsContainer = $('#contacts-container');
|
|
|
|
+ var contactIndex = contactsContainer.children('.contact-form').length;
|
|
|
|
+ var contactForm = `
|
|
|
|
+ <div class="contact-form" id="contact-form-${contactIndex}">
|
|
|
|
+ <div class="contact-header">
|
|
|
|
+ <button type="button" class="remove-contact-btn" data-index="${contactIndex}">删除</button>
|
|
|
|
+ <h3>联系人 #${contactIndex + 1}</h3>
|
|
|
|
+ </div>
|
|
|
|
+ <input type="hidden" name="contact[${contactIndex}][id]" value="">
|
|
|
|
+ <table width="100%" border="0" cellpadding="3" cellspacing="1" class="contact-table">
|
|
|
|
+ <tr>
|
|
|
|
+ <th width="8%">联系人</th>
|
|
|
|
+ <td><input type="text" name="contact[${contactIndex}][contact_name]" class="txt1" placeholder="联系人姓名"/></td>
|
|
|
|
+ </tr>
|
|
|
|
+ </table>
|
|
|
|
+ <div class="contact-methods-container" id="contact-methods-${contactIndex}">
|
|
|
|
+ <!-- Contact methods will be added here -->
|
|
|
|
+ </div>
|
|
|
|
+ <button type="button" class="add-method-btn" data-contact-index="${contactIndex}">添加联系方式</button>
|
|
|
|
+ </div>
|
|
|
|
+ `;
|
|
|
|
+ contactsContainer.append(contactForm);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // Add contact method
|
|
|
|
+ $(document).on('click', '.add-method-btn', function() {
|
|
|
|
+ var contactIndex = $(this).data('contact-index');
|
|
|
|
+ var methodsContainer = $('#contact-methods-' + contactIndex);
|
|
|
|
+
|
|
|
|
+ // Count existing methods by type
|
|
|
|
+ var methodCounts = {};
|
|
|
|
+ methodsContainer.find('select.method-select').each(function() {
|
|
|
|
+ var type = $(this).val();
|
|
|
|
+ if (type) {
|
|
|
|
+ methodCounts[type] = (methodCounts[type] || 0) + 1;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ var methodRow = `
|
|
|
|
+ <div class="contact-method-row">
|
|
|
|
+ <select class="method-select" onchange="updateMethodSelectAndPlaceholder(this)">
|
|
|
|
+ <option value="">请选择联系方式</option>
|
|
|
|
+ <option value="tel" ${(methodCounts.tel || 0) >= 3 ? 'disabled' : ''}>电话</option>
|
|
|
|
+ <option value="wechat" ${(methodCounts.wechat || 0) >= 3 ? 'disabled' : ''}>微信</option>
|
|
|
|
+ <option value="whatsapp" ${(methodCounts.whatsapp || 0) >= 3 ? 'disabled' : ''}>WhatsApp</option>
|
|
|
|
+ <option value="email" ${(methodCounts.email || 0) >= 3 ? 'disabled' : ''}>邮箱</option>
|
|
|
|
+ <option value="linkedin" ${(methodCounts.linkedin || 0) >= 3 ? 'disabled' : ''}>领英</option>
|
|
|
|
+ <option value="facebook" ${(methodCounts.facebook || 0) >= 3 ? 'disabled' : ''}>Facebook</option>
|
|
|
|
+ <option value="alibaba" ${(methodCounts.alibaba || 0) >= 3 ? 'disabled' : ''}>阿里巴巴</option>
|
|
|
|
+ </select>
|
|
|
|
+ <input type="text" class="txt1 method-input" style="width:60%;" placeholder="请选择联系方式类型">
|
|
|
|
+ <button type="button" class="remove-method-btn">删除</button>
|
|
|
|
+ </div>
|
|
|
|
+ `;
|
|
|
|
+
|
|
|
|
+ methodsContainer.append(methodRow);
|
|
|
|
+ updateMethodFields(methodsContainer.find('.contact-method-row:last-child'));
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // Remove contact method
|
|
|
|
+ $(document).on('click', '.remove-method-btn', function() {
|
|
|
|
+ var methodRow = $(this).closest('.contact-method-row');
|
|
|
|
+ var contactIndex = methodRow.closest('.contact-form').attr('id').split('-')[2];
|
|
|
|
+ var type = methodRow.find('select.method-select').val();
|
|
|
|
+ methodRow.remove();
|
|
|
|
+
|
|
|
|
+ // Update available options in other selects
|
|
|
|
+ updateAvailableMethodTypes(contactIndex);
|
|
|
|
+ });
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+// Update method fields based on selection
|
|
|
|
+function updateMethodFields(methodRow) {
|
|
|
|
+ var select = methodRow.find('select.method-select');
|
|
|
|
+ var input = methodRow.find('input.method-input');
|
|
|
|
+ var contactForm = methodRow.closest('.contact-form');
|
|
|
|
+ var contactIndex = contactForm.attr('id').split('-')[2];
|
|
|
|
+ var type = select.val();
|
|
|
|
+
|
|
|
|
+ if (!type) return;
|
|
|
|
+
|
|
|
|
+ // Count existing methods of this type
|
|
|
|
+ var count = 1;
|
|
|
|
+ contactForm.find('select.method-select').each(function() {
|
|
|
|
+ if ($(this).val() === type && $(this)[0] !== select[0]) {
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // Update field names
|
|
|
|
+ select.attr('name', `contact[${contactIndex}][${type}_${count}]`);
|
|
|
|
+ input.attr('name', `contact[${contactIndex}][${type}_${count}]`);
|
|
|
|
+
|
|
|
|
+ // Add format field for tel and whatsapp
|
|
|
|
+ if (type === 'tel' || type === 'whatsapp') {
|
|
|
|
+ if (!methodRow.find('.format-input').length) {
|
|
|
|
+ input.after(`<input type="hidden" class="format-input" name="contact[${contactIndex}][${type}_${count}_format]">`);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Add backup field
|
|
|
|
+ if (!methodRow.find('.backup-input').length) {
|
|
|
|
+ methodRow.append(`<input type="hidden" class="backup-input" name="contact[${contactIndex}][${type}_${count}_bu]">`);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Update available method types for a contact
|
|
|
|
+function updateAvailableMethodTypes(contactIndex) {
|
|
|
|
+ var methodsContainer = $('#contact-methods-' + contactIndex);
|
|
|
|
+
|
|
|
|
+ // Count methods by type
|
|
|
|
+ var methodCounts = {};
|
|
|
|
+ methodsContainer.find('select.method-select').each(function() {
|
|
|
|
+ var type = $(this).val();
|
|
|
|
+ if (type) {
|
|
|
|
+ methodCounts[type] = (methodCounts[type] || 0) + 1;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // Update all selects in this contact
|
|
|
|
+ methodsContainer.find('select.method-select').each(function() {
|
|
|
|
+ var currentValue = $(this).val();
|
|
|
|
+
|
|
|
|
+ $(this).find('option').each(function() {
|
|
|
|
+ var optionValue = $(this).val();
|
|
|
|
+ if (optionValue && optionValue !== currentValue) {
|
|
|
|
+ $(this).prop('disabled', (methodCounts[optionValue] || 0) >= 3);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Update placeholder and handle method fields
|
|
|
|
+function updateMethodSelectAndPlaceholder(selectElement) {
|
|
|
|
+ var methodRow = $(selectElement).closest('.contact-method-row');
|
|
|
|
+ updateMethodPlaceholder(selectElement);
|
|
|
|
+ updateMethodFields(methodRow);
|
|
|
|
+
|
|
|
|
+ var contactIndex = methodRow.closest('.contact-form').attr('id').split('-')[2];
|
|
|
|
+ updateAvailableMethodTypes(contactIndex);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function updateMethodPlaceholder(selectElement) {
|
|
|
|
+ var placeholder = "";
|
|
|
|
+ var value = $(selectElement).val();
|
|
|
|
+
|
|
|
|
+ switch(value) {
|
|
|
|
+ case "tel":
|
|
|
|
+ placeholder = "电话格式:区号+号码 如:+86 15012345678";
|
|
|
|
+ break;
|
|
|
|
+ case "wechat":
|
|
|
|
+ placeholder = "微信";
|
|
|
|
+ break;
|
|
|
|
+ case "whatsapp":
|
|
|
|
+ placeholder = "Whatsapp 格式:区号+号码 如:+86 15012345678";
|
|
|
|
+ break;
|
|
|
|
+ case "email":
|
|
|
|
+ placeholder = "邮件";
|
|
|
|
+ break;
|
|
|
|
+ case "linkedin":
|
|
|
|
+ placeholder = "领英链接";
|
|
|
|
+ break;
|
|
|
|
+ case "facebook":
|
|
|
|
+ placeholder = "Facebook";
|
|
|
|
+ break;
|
|
|
|
+ case "alibaba":
|
|
|
|
+ placeholder = "阿里巴巴";
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ placeholder = "请选择联系方式类型";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $(selectElement).next('.method-input').attr('placeholder', placeholder);
|
|
|
|
+}
|
|
</script>
|
|
</script>
|
|
|
|
+<style>
|
|
|
|
+ .contact-form {
|
|
|
|
+ margin-bottom: 10px;
|
|
|
|
+ padding: 8px;
|
|
|
|
+ background-color: #FFFFFF;
|
|
|
|
+ }
|
|
|
|
+ .contact-header {
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+ margin-bottom: 8px;
|
|
|
|
+ gap: 10px;
|
|
|
|
+ }
|
|
|
|
+ .contact-header h3 {
|
|
|
|
+ margin: 0;
|
|
|
|
+ order: 2;
|
|
|
|
+ flex-grow: 1;
|
|
|
|
+ }
|
|
|
|
+ .remove-contact-btn {
|
|
|
|
+ background-color: #f44336;
|
|
|
|
+ color: white;
|
|
|
|
+ border: none;
|
|
|
|
+ padding: 4px 8px;
|
|
|
|
+ cursor: pointer;
|
|
|
|
+ order: 1;
|
|
|
|
+ }
|
|
|
|
+ .add-contact-btn {
|
|
|
|
+ background-color: #4CAF50;
|
|
|
|
+ color: white;
|
|
|
|
+ border: none;
|
|
|
|
+ padding: 6px 12px;
|
|
|
|
+ margin-bottom: 10px;
|
|
|
|
+ cursor: pointer;
|
|
|
|
+ }
|
|
|
|
+ .contact-methods-container {
|
|
|
|
+ margin-top: 8px;
|
|
|
|
+ }
|
|
|
|
+ .contact-method-row {
|
|
|
|
+ margin-bottom: 6px;
|
|
|
|
+ padding: 6px;
|
|
|
|
+ border: 1px solid #eee;
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+ gap: 8px;
|
|
|
|
+ }
|
|
|
|
+ .add-method-btn {
|
|
|
|
+ background-color: #2196F3;
|
|
|
|
+ color: white;
|
|
|
|
+ border: none;
|
|
|
|
+ padding: 4px 8px;
|
|
|
|
+ margin-top: 4px;
|
|
|
|
+ cursor: pointer;
|
|
|
|
+ }
|
|
|
|
+ .remove-method-btn {
|
|
|
|
+ background-color: #f44336;
|
|
|
|
+ color: white;
|
|
|
|
+ border: none;
|
|
|
|
+ padding: 2px 4px;
|
|
|
|
+ cursor: pointer;
|
|
|
|
+ }
|
|
|
|
+ .method-select {
|
|
|
|
+ margin-right: 8px;
|
|
|
|
+ padding: 3px;
|
|
|
|
+ }
|
|
|
|
+ .contact-table {
|
|
|
|
+ margin-bottom: 6px;
|
|
|
|
+ }
|
|
|
|
+ .contact-table td, .contact-table th {
|
|
|
|
+ padding: 4px 6px;
|
|
|
|
+ }
|
|
|
|
+</style>
|
|
</head>
|
|
</head>
|
|
<body>
|
|
<body>
|
|
<div id="man_zone">
|
|
<div id="man_zone">
|
|
@@ -190,47 +448,26 @@ if ($act == "edit" || $act == "add") {
|
|
$id = $_GET['id'] ?? '';
|
|
$id = $_GET['id'] ?? '';
|
|
$isEdit = false;
|
|
$isEdit = false;
|
|
|
|
|
|
- // 初始化变量
|
|
|
|
- $cs_code = $cs_company = $cs_name = $cs_tel = $cs_telBu = '';
|
|
|
|
- $cs_wechat = $cs_wechatBu = $cs_whatsapp = $cs_whatsappBu = '';
|
|
|
|
- $cs_email = $cs_emailBu = $cs_linkedin = $cs_linkedinBu = '';
|
|
|
|
- $cs_facebook = $cs_facebookBu = $cs_alibaba = $cs_alibabaBu = '';
|
|
|
|
- $cs_address = $cs_addtime = $cs_updatetime = $cs_note = '';
|
|
|
|
- $cs_belong = $cs_country = $cs_from = $cs_state = $cs_deal = $allowedit = 0;
|
|
|
|
|
|
+ // Initialize variables
|
|
|
|
+ $cs_code = $cs_company = $cs_address = $cs_addtime = $cs_updatetime = $cs_note = '';
|
|
|
|
+ $cs_belong = $cs_country = $cs_from = $cs_state = $cs_deal = $allowedit = $cs_type = $cs_belongclient = 0;
|
|
|
|
+ $contacts = [];
|
|
|
|
|
|
if (!empty($id) && is_numeric($id)) {
|
|
if (!empty($id) && is_numeric($id)) {
|
|
$isEdit = true;
|
|
$isEdit = true;
|
|
|
|
|
|
// Join customer and customer_contact tables
|
|
// Join customer and customer_contact tables
|
|
- $sql = "SELECT c.*, cc.contact_name, cc.tel, cc.tel_bu, cc.email, cc.email_bu,
|
|
|
|
- cc.whatsapp, cc.whatsapp_bu, cc.wechat, cc.wechat_bu,
|
|
|
|
- cc.linkedin, cc.linkedin_bu, cc.facebook, cc.facebook_bu,
|
|
|
|
- cc.alibaba, cc.alibaba_bu
|
|
|
|
- FROM customer c
|
|
|
|
|
|
+ $sql = "SELECT c.*, cc.* FROM customer c
|
|
LEFT JOIN customer_contact cc ON c.id = cc.customer_id
|
|
LEFT JOIN customer_contact cc ON c.id = cc.customer_id
|
|
- WHERE c.id=$id";
|
|
|
|
|
|
+ WHERE c.id = $id";
|
|
$result = $conn->query($sql);
|
|
$result = $conn->query($sql);
|
|
|
|
|
|
if ($row = $result->fetch_assoc()) {
|
|
if ($row = $result->fetch_assoc()) {
|
|
|
|
+ // Basic customer info
|
|
$cs_code = textUncode($row['cs_code']);
|
|
$cs_code = textUncode($row['cs_code']);
|
|
$cs_company = textUncode($row['cs_company']);
|
|
$cs_company = textUncode($row['cs_company']);
|
|
- $cs_name = textUncode($row['contact_name']);
|
|
|
|
$cs_country = $row['cs_country'];
|
|
$cs_country = $row['cs_country'];
|
|
$cs_from = $row['cs_from'];
|
|
$cs_from = $row['cs_from'];
|
|
- $cs_tel = textUncode($row['tel']);
|
|
|
|
- $cs_telBu = textUncode($row['tel_bu']);
|
|
|
|
- $cs_wechat = textUncode($row['wechat']);
|
|
|
|
- $cs_wechatBu = textUncode($row['wechat_bu']);
|
|
|
|
- $cs_whatsapp = textUncode($row['whatsapp']);
|
|
|
|
- $cs_whatsappBu = textUncode($row['whatsapp_bu']);
|
|
|
|
- $cs_email = textUncode($row['email']);
|
|
|
|
- $cs_emailBu = textUncode($row['email_bu']);
|
|
|
|
- $cs_linkedin = textUncode($row['linkedin']);
|
|
|
|
- $cs_linkedinBu = textUncode($row['linkedin_bu']);
|
|
|
|
- $cs_facebook = textUncode($row['facebook']);
|
|
|
|
- $cs_facebookBu = textUncode($row['facebook_bu']);
|
|
|
|
- $cs_alibaba = textUncode($row['alibaba']);
|
|
|
|
- $cs_alibabaBu = textUncode($row['alibaba_bu']);
|
|
|
|
$cs_address = textUncode($row['cs_address']);
|
|
$cs_address = textUncode($row['cs_address']);
|
|
$cs_addtime = $row['cs_addtime'];
|
|
$cs_addtime = $row['cs_addtime'];
|
|
$cs_updatetime = $row['cs_updatetime'];
|
|
$cs_updatetime = $row['cs_updatetime'];
|
|
@@ -239,6 +476,35 @@ if ($act == "edit" || $act == "add") {
|
|
$cs_deal = $row['cs_deal'];
|
|
$cs_deal = $row['cs_deal'];
|
|
$cs_note = htmlUncode($row['cs_note']);
|
|
$cs_note = htmlUncode($row['cs_note']);
|
|
$allowedit = $row['allowedit'];
|
|
$allowedit = $row['allowedit'];
|
|
|
|
+ $cs_type = $row['cs_type'];
|
|
|
|
+ $cs_belongclient = $row['cs_belongclient'];
|
|
|
|
+
|
|
|
|
+ // Get all contacts for this customer
|
|
|
|
+ $contactSql = "SELECT * FROM customer_contact WHERE customer_id = $id";
|
|
|
|
+ $contactResult = $conn->query($contactSql);
|
|
|
|
+ while ($contactRow = $contactResult->fetch_assoc()) {
|
|
|
|
+ $contact = [
|
|
|
|
+ 'id' => $contactRow['id'],
|
|
|
|
+ 'contact_name' => textUncode($contactRow['contact_name']),
|
|
|
|
+ 'created_at' => $contactRow['created_at'],
|
|
|
|
+ 'updated_at' => $contactRow['updated_at']
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ // Process each contact method type (up to 3 entries each)
|
|
|
|
+ $methodTypes = ['tel', 'email', 'whatsapp', 'wechat', 'linkedin', 'facebook', 'alibaba'];
|
|
|
|
+ foreach ($methodTypes as $type) {
|
|
|
|
+ for ($i = 1; $i <= 3; $i++) {
|
|
|
|
+ $fieldBase = $type . '_' . $i;
|
|
|
|
+ $contact[$fieldBase] = textUncode($contactRow[$fieldBase]);
|
|
|
|
+ if ($type == 'tel' || $type == 'whatsapp') {
|
|
|
|
+ $contact[$fieldBase . '_format'] = textUncode($contactRow[$fieldBase . '_format']);
|
|
|
|
+ }
|
|
|
|
+ $contact[$fieldBase . '_bu'] = textUncode($contactRow[$fieldBase . '_bu']);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $contacts[] = $contact;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -259,10 +525,6 @@ if ($act == "edit" || $act == "add") {
|
|
<th width="8%">公司名称</th>
|
|
<th width="8%">公司名称</th>
|
|
<td><input type="text" id="cs_company" name="cs_company" value="<?php echo $cs_company; ?>" class="txt1" /></td>
|
|
<td><input type="text" id="cs_company" name="cs_company" value="<?php echo $cs_company; ?>" class="txt1" /></td>
|
|
</tr>
|
|
</tr>
|
|
- <tr>
|
|
|
|
- <th width="8%">联系人</th>
|
|
|
|
- <td><input type="text" id="cs_name" name="cs_name" value="<?php echo $cs_name; ?>" class="txt1" /></td>
|
|
|
|
- </tr>
|
|
|
|
<tr>
|
|
<tr>
|
|
<th width="8%">所属业务</th>
|
|
<th width="8%">所属业务</th>
|
|
<td>
|
|
<td>
|
|
@@ -310,7 +572,7 @@ if ($act == "edit" || $act == "add") {
|
|
?>
|
|
?>
|
|
</select>
|
|
</select>
|
|
</td>
|
|
</td>
|
|
- </tr>
|
|
|
|
|
|
+ </tr>
|
|
<tr>
|
|
<tr>
|
|
<th width="8%">录入时间</th>
|
|
<th width="8%">录入时间</th>
|
|
<td><?php echo $cs_addtime; ?></td>
|
|
<td><?php echo $cs_addtime; ?></td>
|
|
@@ -320,75 +582,136 @@ if ($act == "edit" || $act == "add") {
|
|
<td><?php echo $cs_updatetime; ?></td>
|
|
<td><?php echo $cs_updatetime; ?></td>
|
|
</tr>
|
|
</tr>
|
|
<tr>
|
|
<tr>
|
|
- <th width="8%" rowspan="7">联系方式</th>
|
|
|
|
- <td><input type="text" id="cs_tel" name="cs_tel" value="<?php echo $cs_tel ?? ''; ?>" class="txt5 tel" />备份:<?php echo $cs_telBu ?? ''; ?></td>
|
|
|
|
- </tr>
|
|
|
|
- <tr>
|
|
|
|
- <td><input type="text" id="cs_email" name="cs_email" value="<?php echo $cs_email ?? ''; ?>" class="txt5 mail" />备份:<?php echo $cs_emailBu ?? ''; ?></td>
|
|
|
|
- </tr>
|
|
|
|
- <tr>
|
|
|
|
- <td><input type="text" id="cs_whatsapp" name="cs_whatsapp" value="<?php echo $cs_whatsapp ?? ''; ?>" class="txt5 whatsapp" />备份:<?php echo $cs_whatsappBu ?? ''; ?></td>
|
|
|
|
- </tr>
|
|
|
|
- <tr>
|
|
|
|
- <td><input type="text" id="cs_wechat" name="cs_wechat" value="<?php echo $cs_wechat ?? ''; ?>" class="txt5 wechat" />备份:<?php echo $cs_wechatBu ?? ''; ?></td>
|
|
|
|
|
|
+ <th width="8%" valign="top">联系人信息</th>
|
|
|
|
+ <td>
|
|
|
|
+ <button type="button" class="add-contact-btn">添加联系人</button>
|
|
|
|
+ <div id="contacts-container">
|
|
|
|
+ <?php if (!empty($contacts)): ?>
|
|
|
|
+ <?php foreach ($contacts as $index => $contact): ?>
|
|
|
|
+ <div class="contact-form" id="contact-form-<?php echo $index; ?>">
|
|
|
|
+ <div class="contact-header">
|
|
|
|
+ <button type="button" class="remove-contact-btn" data-index="<?php echo $index; ?>">删除</button>
|
|
|
|
+ <h3>联系人 #<?php echo $index + 1; ?></h3>
|
|
|
|
+ </div>
|
|
|
|
+ <input type="hidden" name="contact[<?php echo $index; ?>][id]" value="<?php echo $contact['id']; ?>">
|
|
|
|
+ <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>
|
|
|
|
+ </tr>
|
|
|
|
+ </table>
|
|
|
|
+ <div class="contact-methods-container" id="contact-methods-<?php echo $index; ?>">
|
|
|
|
+ <?php
|
|
|
|
+ $methodTypes = [
|
|
|
|
+ 'tel' => '电话',
|
|
|
|
+ 'wechat' => '微信',
|
|
|
|
+ 'whatsapp' => 'WhatsApp',
|
|
|
|
+ 'email' => '邮箱',
|
|
|
|
+ 'linkedin' => '领英',
|
|
|
|
+ 'facebook' => 'Facebook',
|
|
|
|
+ 'alibaba' => '阿里巴巴'
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ foreach ($methodTypes as $type => $label) {
|
|
|
|
+ for ($i = 1; $i <= 3; $i++) {
|
|
|
|
+ $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 '<option value="">请选择联系方式</option>';
|
|
|
|
+
|
|
|
|
+ foreach ($methodTypes as $optionType => $optionLabel) {
|
|
|
|
+ $selected = ($optionType === $type) ? 'selected' : '';
|
|
|
|
+ echo '<option value="' . $optionType . '" ' . $selected . '>' . $optionLabel . '</option>';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ echo '</select>';
|
|
|
|
+ echo '<input type="text" class="txt1 method-input" style="width:60%;" name="contact[' . $index . '][' . $fieldName . ']" value="' . htmlspecialchars($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="backup-input" name="contact[' . $index . '][' . $fieldName . '_bu]" value="' . htmlspecialchars($contact[$fieldName . '_bu']) . '">';
|
|
|
|
+ echo '</div>';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ?>
|
|
|
|
+ </div>
|
|
|
|
+ <button type="button" class="add-method-btn" data-contact-index="<?php echo $index; ?>">添加联系方式</button>
|
|
|
|
+ </div>
|
|
|
|
+ <?php endforeach; ?>
|
|
|
|
+ <?php else: ?>
|
|
|
|
+ <div class="contact-form" id="contact-form-0">
|
|
|
|
+ <div class="contact-header">
|
|
|
|
+ <button type="button" class="remove-contact-btn" data-index="0">删除</button>
|
|
|
|
+ <h3>联系人 #1</h3>
|
|
|
|
+ </div>
|
|
|
|
+ <input type="hidden" name="contact[0][id]" value="">
|
|
|
|
+ <table width="100%" border="0" cellpadding="3" cellspacing="1" class="contact-table">
|
|
|
|
+ <tr>
|
|
|
|
+ <th width="8%">联系人</th>
|
|
|
|
+ <td><input type="text" name="contact[0][contact_name]" class="txt1" placeholder="联系人姓名"/></td>
|
|
|
|
+ </tr>
|
|
|
|
+ </table>
|
|
|
|
+ <div class="contact-methods-container" id="contact-methods-0">
|
|
|
|
+ <!-- Contact methods will be added here -->
|
|
|
|
+ </div>
|
|
|
|
+ <button type="button" class="add-method-btn" data-contact-index="0">添加联系方式</button>
|
|
|
|
+ </div>
|
|
|
|
+ <?php endif; ?>
|
|
|
|
+ </div>
|
|
|
|
+ </td>
|
|
</tr>
|
|
</tr>
|
|
- <tr>
|
|
|
|
- <td><input type="text" id="cs_linkedin" name="cs_linkedin" value="<?php echo $cs_linkedin ?? ''; ?>" class="txt5 linkedin" />备份:<?php echo $cs_linkedinBu ?? ''; ?></td>
|
|
|
|
- </tr>
|
|
|
|
- <tr>
|
|
|
|
- <td><input type="text" id="cs_facebook" name="cs_facebook" value="<?php echo $cs_facebook ?? ''; ?>" class="txt5 facebook" />备份:<?php echo $cs_facebookBu ?? ''; ?></td>
|
|
|
|
- </tr>
|
|
|
|
- <tr>
|
|
|
|
- <td><input type="text" id="cs_alibaba" name="cs_alibaba" value="<?php echo $cs_alibaba ?? ''; ?>" class="txt5 alibaba" />备份:<?php echo $cs_alibabaBu ?? ''; ?></td>
|
|
|
|
- </tr>
|
|
|
|
<tr>
|
|
<tr>
|
|
<th width="8%">地址</th>
|
|
<th width="8%">地址</th>
|
|
- <td><input type="text" id="cs_address" name="cs_address" value="<?php echo $cs_address ?? ''; ?>" class="txt1" /></td>
|
|
|
|
- </tr>
|
|
|
|
|
|
+ <td><input type="text" id="cs_address" name="cs_address" value="<?php echo $cs_address; ?>" class="txt1" /></td>
|
|
|
|
+ </tr>
|
|
<tr>
|
|
<tr>
|
|
<th width="8%">标签</th>
|
|
<th width="8%">标签</th>
|
|
<td>
|
|
<td>
|
|
<?php
|
|
<?php
|
|
- if($isEdit ?? false) {
|
|
|
|
|
|
+ if($isEdit) {
|
|
$sql = "SELECT id,tagName FROM tagtable WHERE customerId = ?";
|
|
$sql = "SELECT id,tagName FROM tagtable WHERE customerId = ?";
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->bind_param("i", $id);
|
|
$stmt->bind_param("i", $id);
|
|
$stmt->execute();
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
$result = $stmt->get_result();
|
|
while($row = $result->fetch_assoc()) {
|
|
while($row = $result->fetch_assoc()) {
|
|
- echo htmlspecialchars($row['tagName'] ?? '') . ',';
|
|
|
|
|
|
+ echo htmlspecialchars($row['tagName']) . ',';
|
|
}
|
|
}
|
|
$stmt->close();
|
|
$stmt->close();
|
|
}
|
|
}
|
|
- ?>
|
|
|
|
|
|
+ ?>
|
|
</td>
|
|
</td>
|
|
- </tr>
|
|
|
|
|
|
+ </tr>
|
|
<tr>
|
|
<tr>
|
|
<th width="8%">状态</th>
|
|
<th width="8%">状态</th>
|
|
<td>
|
|
<td>
|
|
- <label><input type="radio" name="cs_state" value="1" <?php if(($cs_state ?? 0)==1) echo 'checked="checked"'; ?> />有效</label>
|
|
|
|
- <label><input type="radio" name="cs_state" value="0" <?php if(($cs_state ?? 0)!=1) echo 'checked="checked"'; ?> />不再跟进</label>
|
|
|
|
|
|
+ <label><input type="radio" name="cs_state" value="1" <?php if($cs_state==1) echo 'checked="checked"'; ?> />有效</label>
|
|
|
|
+ <label><input type="radio" name="cs_state" value="0" <?php if($cs_state!=1) echo 'checked="checked"'; ?> />不再跟进</label>
|
|
</td>
|
|
</td>
|
|
</tr>
|
|
</tr>
|
|
<tr>
|
|
<tr>
|
|
<th width="8%">是否误报</th>
|
|
<th width="8%">是否误报</th>
|
|
<td>
|
|
<td>
|
|
- <label><input type="radio" name="allowedit" value="1" <?php if(($allowedit ?? 0)==1) echo 'checked="checked"'; ?> />审核通过</label>
|
|
|
|
- <label><input type="radio" name="allowedit" value="0" <?php if(($allowedit ?? 0)!=1) echo 'checked="checked"'; ?> />一般处理</label>
|
|
|
|
|
|
+ <label><input type="radio" name="allowedit" value="1" <?php if($allowedit==1) echo 'checked="checked"'; ?> />审核通过</label>
|
|
|
|
+ <label><input type="radio" name="allowedit" value="0" <?php if($allowedit!=1) echo 'checked="checked"'; ?> />一般处理</label>
|
|
</td>
|
|
</td>
|
|
- </tr>
|
|
|
|
|
|
+ </tr>
|
|
<tr>
|
|
<tr>
|
|
<th width="8%">是否成交</th>
|
|
<th width="8%">是否成交</th>
|
|
<td>
|
|
<td>
|
|
- <label><input type="radio" name="cs_deal" value="3" <?php if(($cs_deal ?? 0)==3) echo 'checked="checked"'; ?> />成交</label>
|
|
|
|
- <label><input type="radio" name="cs_deal" value="2" <?php if(($cs_deal ?? 0)==2) echo 'checked="checked"'; ?> />明确需求</label>
|
|
|
|
- <label><input type="radio" name="cs_deal" value="1" <?php if(($cs_deal ?? 0)==1) echo 'checked="checked"'; ?> />背景调查</label>
|
|
|
|
- <label><input type="radio" name="cs_deal" value="0" <?php if(($cs_deal ?? 0)==0) echo 'checked="checked"'; ?> />无响应</label>
|
|
|
|
|
|
+ <label><input type="radio" name="cs_deal" value="3" <?php if($cs_deal==3) echo 'checked="checked"'; ?> />成交</label>
|
|
|
|
+ <label><input type="radio" name="cs_deal" value="2" <?php if($cs_deal==2) echo 'checked="checked"'; ?> />明确需求</label>
|
|
|
|
+ <label><input type="radio" name="cs_deal" value="1" <?php if($cs_deal==1) echo 'checked="checked"'; ?> />背景调查</label>
|
|
|
|
+ <label><input type="radio" name="cs_deal" value="0" <?php if($cs_deal==0) echo 'checked="checked"'; ?> />无响应</label>
|
|
</td>
|
|
</td>
|
|
</tr>
|
|
</tr>
|
|
<tr>
|
|
<tr>
|
|
<th>内容</th>
|
|
<th>内容</th>
|
|
- <td><textarea id="no_content" name="no_content" class="txt2"><?php echo $cs_note ?? ''; ?></textarea></td>
|
|
|
|
|
|
+ <td><textarea id="no_content" name="no_content" class="txt2"><?php echo $cs_note; ?></textarea></td>
|
|
</tr>
|
|
</tr>
|
|
<tr>
|
|
<tr>
|
|
<th></th>
|
|
<th></th>
|
|
@@ -482,13 +805,13 @@ if (!empty($fliterEmployee)) {
|
|
|
|
|
|
if (!empty($fliterContact)) {
|
|
if (!empty($fliterContact)) {
|
|
switch($fliterContact) {
|
|
switch($fliterContact) {
|
|
- case "1": $filterStr .= " AND cc.tel<>''"; break;
|
|
|
|
- case "2": $filterStr .= " AND cc.wechat<>''"; break;
|
|
|
|
- case "3": $filterStr .= " AND cc.whatsapp<>''"; break;
|
|
|
|
- case "4": $filterStr .= " AND cc.email<>''"; break;
|
|
|
|
- case "5": $filterStr .= " AND cc.linkedin<>''"; break;
|
|
|
|
- case "6": $filterStr .= " AND cc.facebook<>''"; break;
|
|
|
|
- default: $filterStr .= " AND cc.alibaba<>''";
|
|
|
|
|
|
+ case "1": $filterStr .= " AND (cc.tel_1 != '' OR cc.tel_2 != '' OR cc.tel_3 != '')"; break;
|
|
|
|
+ case "2": $filterStr .= " AND (cc.wechat_1 != '' OR cc.wechat_2 != '' OR cc.wechat_3 != '')"; break;
|
|
|
|
+ case "3": $filterStr .= " AND (cc.whatsapp_1 != '' OR cc.whatsapp_2 != '' OR cc.whatsapp_3 != '')"; break;
|
|
|
|
+ case "4": $filterStr .= " AND (cc.email_1 != '' OR cc.email_2 != '' OR cc.email_3 != '')"; break;
|
|
|
|
+ case "5": $filterStr .= " AND (cc.linkedin_1 != '' OR cc.linkedin_2 != '' OR cc.linkedin_3 != '')"; break;
|
|
|
|
+ case "6": $filterStr .= " AND (cc.facebook_1 != '' OR cc.facebook_2 != '' OR cc.facebook_3 != '')"; break;
|
|
|
|
+ default: $filterStr .= " AND (cc.alibaba_1 != '' OR cc.alibaba_2 != '' OR cc.alibaba_3 != '')";
|
|
}
|
|
}
|
|
$urlStr .= "&fliterContact=$fliterContact";
|
|
$urlStr .= "&fliterContact=$fliterContact";
|
|
}
|
|
}
|
|
@@ -501,18 +824,30 @@ $ord = $_GET['Ord'] ?? '';
|
|
$sql = "SELECT c.id, c.cs_code, c.cs_company, c.cs_country, c.cs_address,
|
|
$sql = "SELECT c.id, c.cs_code, c.cs_company, c.cs_country, c.cs_address,
|
|
c.cs_from, c.cs_deal, c.cs_addtime, c.cs_updatetime, c.cs_belong, c.cs_note,
|
|
c.cs_from, c.cs_deal, c.cs_addtime, c.cs_updatetime, c.cs_belong, c.cs_note,
|
|
c.cs_claimFrom, c.cs_chain, c.cs_dealdate,
|
|
c.cs_claimFrom, c.cs_chain, c.cs_dealdate,
|
|
- cc.contact_name as cs_name, cc.tel as cs_tel, cc.email as cs_email,
|
|
|
|
- cc.whatsapp as cs_whatsapp, cc.wechat as cs_wechat, cc.linkedin as cs_linkedin,
|
|
|
|
- cc.facebook as cs_facebook, cc.alibaba as cs_alibaba
|
|
|
|
|
|
+ cc.contact_name as cs_name,
|
|
|
|
+ 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,
|
|
|
|
+ cc.alibaba_1 as cs_alibaba
|
|
FROM customer c
|
|
FROM customer c
|
|
LEFT JOIN customer_contact cc ON c.id = cc.customer_id
|
|
LEFT JOIN customer_contact cc ON c.id = cc.customer_id
|
|
WHERE (c.cs_code LIKE '%$keyscode%'
|
|
WHERE (c.cs_code LIKE '%$keyscode%'
|
|
OR cc.contact_name LIKE '%$keyscode%'
|
|
OR cc.contact_name LIKE '%$keyscode%'
|
|
- OR cc.wechat LIKE '%$keyscode%'
|
|
|
|
- OR cc.alibaba LIKE '%$keyscode%'
|
|
|
|
- OR cc.tel LIKE '%$keyscode%'
|
|
|
|
- OR cc.whatsapp LIKE '%$keyscode%'
|
|
|
|
- OR cc.email LIKE '%$keyscode%')
|
|
|
|
|
|
+ OR cc.tel_1 LIKE '%$keyscode%'
|
|
|
|
+ OR cc.tel_2 LIKE '%$keyscode%'
|
|
|
|
+ OR cc.tel_3 LIKE '%$keyscode%'
|
|
|
|
+ OR cc.wechat_1 LIKE '%$keyscode%'
|
|
|
|
+ OR cc.wechat_2 LIKE '%$keyscode%'
|
|
|
|
+ OR cc.wechat_3 LIKE '%$keyscode%'
|
|
|
|
+ OR cc.alibaba_1 LIKE '%$keyscode%'
|
|
|
|
+ OR cc.alibaba_2 LIKE '%$keyscode%'
|
|
|
|
+ OR cc.alibaba_3 LIKE '%$keyscode%'
|
|
|
|
+ OR cc.whatsapp_1_format LIKE '%$keyscode%'
|
|
|
|
+ OR cc.whatsapp_2_format LIKE '%$keyscode%'
|
|
|
|
+ OR cc.whatsapp_3_format LIKE '%$keyscode%'
|
|
|
|
+ OR cc.email_1 LIKE '%$keyscode%'
|
|
|
|
+ OR cc.email_2 LIKE '%$keyscode%'
|
|
|
|
+ OR cc.email_3 LIKE '%$keyscode%')
|
|
$filterStr
|
|
$filterStr
|
|
ORDER BY c.cs_updatetime DESC";
|
|
ORDER BY c.cs_updatetime DESC";
|
|
|
|
|
|
@@ -747,7 +1082,7 @@ $result = $conn->query($sql);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
?>
|
|
- </li>
|
|
|
|
|
|
+ </li>
|
|
<?php if(!empty($row['cs_tel'] ?? '')): ?>
|
|
<?php if(!empty($row['cs_tel'] ?? '')): ?>
|
|
<li class="tel"><?php echo htmlspecialchars($row['cs_tel']); ?></li>
|
|
<li class="tel"><?php echo htmlspecialchars($row['cs_tel']); ?></li>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|