searchResult.php 6.1 KB

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