<?php require_once 'conn.php'; checkLogin(); $keywordsNative = $_POST['keywords'] ?? ''; $keywords = str_replace(['+', ' ', '-', ')', '('], '', $keywordsNative); $keywords = textEncode($keywords); if (empty($keywords) || strlen($keywords) < 4) { echo "<script>alert('请至少输入4位数字或文字进行查找');window.location.href='/home.php';</script>"; exit; } $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_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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>管理区域</title> <link rel="stylesheet" href="css/common.css" type="text/css" /> <link rel="stylesheet" href="css/alert.css" type="text/css" /> <script src="system/js/jquery-1.7.2.min.js"></script> <script src="js/js.js"></script> <style> body { margin: 0; padding: 20px; background: #fff; } #man_zone { margin-left: 0; } </style> </head> <body class="clear"> <?php // require_once 'panel.php'; ?> <div id="man_zone"> <div class="searchForm resultSearch"> <form method="post" action="searchResult.php" accept-charset="UTF-8"> <input class="keywords" name="keywords" id="keyword" placeholder="请输入电话/邮箱/微信/WhatsApp.." value="<?= htmlspecialcharsFix($keywordsNative) ?>"> <input class="searchSubmit" type="submit" value="客户检索"> </form> </div> <table width="100%" class="resultForm"> <tr class="tableHead"> <td align="center">序号</td> <td align="center">客户编号</td> <td align="center">联系人</td> <td align="center">国家</td> <td align="center">来源</td> <td align="center">跟进阶段</td> <td align="center">录入日期</td> <td align="center">所属业务员</td> </tr> <?php $result = $conn->query($searchStr); if ($result && $result->num_rows > 0) { $i = 1; while ($row = $result->fetch_assoc()) { ?> <tr> <td align="center" rowspan="2"><?= $i ?></td> <td align="center"><?= htmlspecialcharsFix($row['cs_code']) ?></td> <td align="center"><?= htmlspecialcharsFix($row['cs_name']) ?></td> <td align="center"> <?php $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']); echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialcharsFix($countryRow['countryName']) : '未选择'; ?> </td> <td align="center"> <?php $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']); echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialcharsFix($qudaoRow['ch_name']) : '未选择'; ?> </td> <td align="center"> <?= ($row['cs_deal'] == 3) ? '<span class="highline">成交</span>' : '未成交' ?> </td> <td align="center"><?= $row['cs_addtime'] ?></td> <td align="center" rowspan="2"> <?php $employeeResult = $conn->query("SELECT em_user FROM employee WHERE id=" . (int)$row['cs_belong']); echo ($employeeRow = $employeeResult->fetch_assoc()) ? htmlspecialcharsFix($employeeRow['em_user']) : '系统出错'; ?> </td> </tr> <tr> <td colspan="6" class="contacts"> <?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 $i++; } } else { if (empty($keywords)) { ?> <tr> <td colspan="8" align="center">暂无相关记录,可录入该客户,<a href="/customerAdd.php" class="highline">点击录入客户数据</a></td> </tr> <?php } else { ?> <tr> <td colspan="8" align="center"> <a href="?">Sorry,没有找到"<?= htmlspecialcharsFix($keywords) ?>"相关的信息,点击返回</a> </td> </tr> <?php } } ?> </table> </div> </body> </html>