searchResult.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. require_once 'conn.php';
  3. checkLogin();
  4. $keywordsNative = $_POST['keywords'] ?? '';
  5. $keywords = str_replace(['+', ' ', '-', ')', '('], '', $keywordsNative);
  6. $keywords = textEncode($keywords);
  7. if (empty($keywords) || strlen($keywords) < 4) {
  8. echo "<script>alert('请至少输入4位数字或文字进行查找');window.location.href='/home.php';</script>";
  9. exit;
  10. }
  11. $searchStr = "SELECT cs_code, cs_name, cs_country, cs_tel, cs_email, cs_whatsapp, cs_wechat, cs_linkedin,
  12. cs_facebook, cs_addtime, cs_from, cs_belong, cs_deal, cs_alibaba
  13. FROM customer
  14. WHERE (cs_telformat LIKE '%" . $conn->real_escape_string($keywords) . "%'
  15. OR cs_email LIKE '%" . $conn->real_escape_string($keywords) . "%'
  16. OR cs_whatsappformat LIKE '%" . $conn->real_escape_string($keywords) . "%'
  17. OR cs_wechat LIKE '%" . $conn->real_escape_string($keywords) . "%'
  18. OR cs_alibaba LIKE '%" . $conn->real_escape_string($keywords) . "%'
  19. OR cs_linkedin LIKE '%" . $conn->real_escape_string($keywords) . "%'
  20. OR cs_facebook LIKE '%" . $conn->real_escape_string($keywords) . "%'
  21. OR cs_email LIKE '%" . $conn->real_escape_string($keywordsNative) . "%'
  22. OR cs_wechat LIKE '%" . $conn->real_escape_string($keywordsNative) . "%'
  23. OR cs_alibaba LIKE '%" . $conn->real_escape_string($keywordsNative) . "%'
  24. OR cs_linkedin LIKE '%" . $conn->real_escape_string($keywordsNative) . "%'
  25. OR cs_facebook LIKE '%" . $conn->real_escape_string($keywordsNative) . "%')";
  26. ?>
  27. <!DOCTYPE html>
  28. <html xmlns="http://www.w3.org/1999/xhtml">
  29. <head>
  30. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  31. <title>管理区域</title>
  32. <link rel="stylesheet" href="css/common.css" type="text/css" />
  33. <link rel="stylesheet" href="css/alert.css" type="text/css" />
  34. <script src="system/js/jquery-1.7.2.min.js"></script>
  35. <script src="js/js.js"></script>
  36. </head>
  37. <body class="clear">
  38. <?php require_once 'panel.php'; ?>
  39. <div id="man_zone">
  40. <div class="searchForm resultSearch">
  41. <form method="post" action="searchResult.php" accept-charset="UTF-8">
  42. <input class="keywords" name="keywords" id="keyword" placeholder="请输入电话/邮箱/微信/WhatsApp.." value="<?= htmlspecialchars($keywordsNative) ?>">
  43. <input class="searchSubmit" type="submit" value="客户检索">
  44. </form>
  45. </div>
  46. <table width="100%" class="resultForm">
  47. <tr class="tableHead">
  48. <td align="center">序号</td>
  49. <td align="center">客户编号</td>
  50. <td align="center">联系人</td>
  51. <td align="center">国家</td>
  52. <td align="center">来源</td>
  53. <td align="center">跟进阶段</td>
  54. <td align="center">录入日期</td>
  55. <td align="center">所属业务员</td>
  56. </tr>
  57. <?php
  58. $result = $conn->query($searchStr);
  59. if ($result && $result->num_rows > 0) {
  60. $i = 1;
  61. while ($row = $result->fetch_assoc()) {
  62. ?>
  63. <tr>
  64. <td align="center" rowspan="2"><?= $i ?></td>
  65. <td align="center"><?= htmlspecialchars($row['cs_code']) ?></td>
  66. <td align="center"><?= htmlspecialchars($row['cs_name']) ?></td>
  67. <td align="center">
  68. <?php
  69. $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
  70. echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialchars($countryRow['countryName']) : '未选择';
  71. ?>
  72. </td>
  73. <td align="center">
  74. <?php
  75. $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
  76. echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialchars($qudaoRow['ch_name']) : '未选择';
  77. ?>
  78. </td>
  79. <td align="center">
  80. <?= ($row['cs_deal'] == 3) ? '<span class="highline">成交</span>' : '未成交' ?>
  81. </td>
  82. <td align="center"><?= $row['cs_addtime'] ?></td>
  83. <td align="center" rowspan="2">
  84. <?php
  85. $employeeResult = $conn->query("SELECT em_user FROM employee WHERE id=" . (int)$row['cs_belong']);
  86. echo ($employeeRow = $employeeResult->fetch_assoc()) ? htmlspecialchars($employeeRow['em_user']) : '系统出错';
  87. ?>
  88. </td>
  89. </tr>
  90. <tr>
  91. <td colspan="6" class="contacts">
  92. <div class="tel"><?= htmlspecialchars($row['cs_tel']) ?></div>
  93. <div class="mail"><?= htmlspecialchars($row['cs_email']) ?></div>
  94. <div class="whatsapp"><?= htmlspecialchars($row['cs_whatsapp']) ?></div>
  95. <div class="wechat"><?= htmlspecialchars($row['cs_wechat']) ?></div>
  96. <div class="linkedin"><?= htmlspecialchars($row['cs_linkedin']) ?></div>
  97. <div class="facebook"><?= htmlspecialchars($row['cs_facebook']) ?></div>
  98. <div class="alibaba"><?= htmlspecialchars($row['cs_alibaba']) ?></div>
  99. </td>
  100. </tr>
  101. <?php
  102. $i++;
  103. }
  104. } else {
  105. if (empty($keywords)) {
  106. ?>
  107. <tr>
  108. <td colspan="8" align="center">暂无相关记录,可录入该客户,<a href="/customerAdd.php" class="highline">点击录入客户数据</a></td>
  109. </tr>
  110. <?php
  111. } else {
  112. ?>
  113. <tr>
  114. <td colspan="8" align="center">
  115. <a href="?">Sorry,没有找到"<?= htmlspecialchars($keywords) ?>"相关的信息,点击返回</a>
  116. </td>
  117. </tr>
  118. <?php
  119. }
  120. }
  121. ?>
  122. </table>
  123. </div>
  124. </body>
  125. </html>