silentCustomer.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <?php
  2. require_once 'conn.php';
  3. checkLogin();
  4. $act = $_GET['act'] ?? '';
  5. if ($act == 'postchk') {
  6. $keys = urlencode($_GET['Keys'] ?? '');
  7. $page = $_GET['Page'] ?? '';
  8. $chkact = $_POST['chkact'] ?? '';
  9. $sqlStr = "";
  10. if (isset($_POST['chkbox'])) {
  11. foreach ($_POST['chkbox'] as $id) {
  12. $sqlStr .= ($sqlStr ? " OR id=" : " WHERE id=") . (int)$id;
  13. }
  14. }
  15. switch ($chkact) {
  16. case "0":
  17. case "1":
  18. case "2":
  19. $sqlStr = "UPDATE Customer SET cs_deal=" . (int)$chkact . $sqlStr;
  20. break;
  21. default:
  22. $chkact = str_replace('t', '', $chkact);
  23. $sqlStr = "UPDATE Customer SET cs_belong=" . (int)$chkact . $sqlStr;
  24. }
  25. $conn->query($sqlStr);
  26. header("Location: ?Keys=" . $keys . "&Page=" . $page);
  27. exit;
  28. }
  29. $keys = $_GET['Keys'] ?? '';
  30. $keys = str_replace([' ', '+'], '', $keys);
  31. $keyscode = textEncode($keys);
  32. $page = $_GET['Page'] ?? '';
  33. $filterCountry = $_GET['fliterCountry'] ?? '';
  34. $filterQudao = $_GET['fliterQudao'] ?? '';
  35. $filterDeal = $_GET['fliterDeal'] ?? '';
  36. $filterBusiness = $_GET['fliterBusiness'] ?? '';
  37. $filterContact = $_GET['fliterContact'] ?? '';
  38. $filterStr = "";
  39. $urlStr = "";
  40. if (!empty($filterCountry)) {
  41. $filterStr .= " AND cs_country=" . (int)$filterCountry;
  42. $urlStr .= "&fliterCountry=" . $filterCountry;
  43. }
  44. if (!empty($filterQudao)) {
  45. $filterStr .= " AND cs_from=" . (int)$filterQudao;
  46. $urlStr .= "&fliterQudao=" . $filterQudao;
  47. }
  48. if (!empty($filterDeal)) {
  49. $filterStr .= " AND cs_deal=" . (int)$filterDeal;
  50. $urlStr .= "&fliterDeal=" . $filterDeal;
  51. }
  52. if (!empty($filterBusiness)) {
  53. $filterStr .= " AND cs_type=" . (int)$filterBusiness;
  54. $urlStr .= "&fliterBusiness=" . $filterBusiness;
  55. }
  56. if (!empty($filterContact)) {
  57. switch ($filterContact) {
  58. case "1": $filterStr .= " AND cs_tel<>''"; break;
  59. case "2": $filterStr .= " AND cs_wechat<>''"; break;
  60. case "3": $filterStr .= " AND cs_whatsapp<>''"; break;
  61. case "4": $filterStr .= " AND cs_email<>''"; break;
  62. case "5": $filterStr .= " AND cs_linkedin<>''"; break;
  63. case "6": $filterStr .= " AND cs_facebook<>''"; break;
  64. default: $filterStr .= " AND cs_alibaba<>''";
  65. }
  66. $urlStr .= "&fliterContact=" . $filterContact;
  67. }
  68. $keys = urlencode($keys);
  69. $hrefstr = "?keys=" . $keys;
  70. ?>
  71. <!DOCTYPE html>
  72. <html xmlns="http://www.w3.org/1999/xhtml">
  73. <head>
  74. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  75. <title>管理区域</title>
  76. <link rel="stylesheet" href="css/common.css" type="text/css" />
  77. <link rel="stylesheet" href="css/alert.css" type="text/css" />
  78. <script src="system/js/jquery-1.7.2.min.js"></script>
  79. <script src="js/js.js"></script>
  80. <style>
  81. body {
  82. margin: 0;
  83. padding: 20px;
  84. background: #fff;
  85. }
  86. #man_zone {
  87. margin-left: 0;
  88. }
  89. </style>
  90. </head>
  91. <body class="clear">
  92. <?php // require_once 'panel.php'; ?>
  93. <div id="man_zone">
  94. <form id="form1" method="post" action="?act=postchk&Keys=<?= $keys ?>&Page=<?= $page ?>" onSubmit="return false">
  95. <div class="fastSelect clear">
  96. <H1>静默客户</H1>
  97. <div class="selectItem">
  98. <label>区域</label>
  99. <select name="fliterCountry" class="filterSearch">
  100. <option value="">请选择国家地区</option>
  101. <?php
  102. $result = $conn->query("SELECT id, countryName FROM country");
  103. while ($row = $result->fetch_assoc()) {
  104. $selected = ($filterCountry == $row['id']) ? ' selected="selected"' : '';
  105. echo "<option value=\"{$row['id']}\"{$selected}>{$row['countryName']}</option>";
  106. }
  107. ?>
  108. </select>
  109. </div>
  110. <div class="selectItem">
  111. <label>来源渠道</label>
  112. <select name="fliterQudao" class="filterSearch">
  113. <option value="">请选择渠道</option>
  114. <?php
  115. $result = $conn->query("SELECT id, ch_name FROM qudao");
  116. while ($row = $result->fetch_assoc()) {
  117. $selected = ($filterQudao == $row['id']) ? ' selected="selected"' : '';
  118. echo "<option value=\"{$row['id']}\"{$selected}>{$row['ch_name']}</option>";
  119. }
  120. ?>
  121. </select>
  122. </div>
  123. <div class="selectItem">
  124. <label>跟进阶段</label>
  125. <select name="fliterDeal" class="filterSearch">
  126. <option value="">请选择</option>
  127. <option value="0"<?= ($filterDeal == "0") ? ' selected="selected"' : '' ?>>无响应</option>
  128. <option value="1"<?= ($filterDeal == "1") ? ' selected="selected"' : '' ?>>背景调查</option>
  129. <option value="2"<?= ($filterDeal == "2") ? ' selected="selected"' : '' ?>>明确需求</option>
  130. <option value="3"<?= ($filterDeal == "3") ? ' selected="selected"' : '' ?>>已成交</option>
  131. </select>
  132. </div>
  133. <div class="selectItem">
  134. <label>客户类型</label>
  135. <select name="fliterBusiness" class="filterSearch">
  136. <option value="">请选择</option>
  137. <?php
  138. $result = $conn->query("SELECT id, businessType FROM clientType");
  139. while ($row = $result->fetch_assoc()) {
  140. $selected = ($filterBusiness == $row['id']) ? ' selected="selected"' : '';
  141. echo "<option value=\"{$row['id']}\"{$selected}>{$row['businessType']}</option>";
  142. }
  143. ?>
  144. </select>
  145. </div>
  146. <div class="selectItem">
  147. <label>联系方式</label>
  148. <select name="fliterContact" class="filterSearch">
  149. <option value="">请选择</option>
  150. <option value="1"<?= ($filterContact == "1") ? ' selected="selected"' : '' ?>>电话</option>
  151. <option value="2"<?= ($filterContact == "2") ? ' selected="selected"' : '' ?>>微信</option>
  152. <option value="3"<?= ($filterContact == "3") ? ' selected="selected"' : '' ?>>WhatsApp</option>
  153. <option value="4"<?= ($filterContact == "4") ? ' selected="selected"' : '' ?>>邮箱</option>
  154. <option value="5"<?= ($filterContact == "5") ? ' selected="selected"' : '' ?>>领英</option>
  155. <option value="6"<?= ($filterContact == "6") ? ' selected="selected"' : '' ?>>Facebook</option>
  156. <option value="7"<?= ($filterContact == "7") ? ' selected="selected"' : '' ?>>阿里巴巴</option>
  157. </select>
  158. </div>
  159. <div class="inputSearch">
  160. <input type="text" id="keys" class="inputTxt"
  161. value="<?= empty($keyscode) ? '请输入搜索关键词' : htmlspecialchars($keyscode) ?>"
  162. onFocus="if(this.value == '<?= empty($keyscode) ? '请输入搜索关键词' : htmlspecialchars($keyscode) ?>'){this.value='';}"
  163. onBlur="if(this.value == ''){this.value='<?= empty($keyscode) ? '请输入搜索关键词' : htmlspecialchars($keyscode) ?>';}"
  164. onKeyDown="if(event.keyCode==13){location.href='?Keys='+escape(document.getElementById('keys').value)}" />
  165. <input type="button" id="searchgo" class="searchgo" value="go"
  166. onClick="location.href='?Keys='+escape(document.getElementById('keys').value)" />
  167. </div>
  168. </div>
  169. <div width="100%" border="0" cellpadding="3" cellspacing="1" class="table2 em<?= $_SESSION['employee_id'] ?>">
  170. <div class="theader">
  171. <div class="col2">序号</div>
  172. <div class="col3">客户编号</div>
  173. <div class="col10">渠道来源</div>
  174. <div class="col10">区域</div>
  175. <div class="col10">客户类型</div>
  176. <div class="col10">跟进阶段</div>
  177. <div class="col6">录入时间</div>
  178. <div class="col6">操作</div>
  179. </div>
  180. <?php
  181. $sqlStr = "SELECT id, cs_code, cs_from, cs_country, cs_type, cs_deal, cs_addtime, cs_tel, cs_email,
  182. cs_whatsapp, cs_wechat, cs_linkedin, cs_facebook, cs_alibaba, colortag, cs_note, cs_claimFrom,
  183. cs_belong, cs_chain
  184. FROM customer
  185. WHERE (is_silent=1 OR (cs_deal=0 AND cs_belong=" . $_SESSION['employee_id'] . "))
  186. AND (cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  187. OR cs_name LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  188. OR cs_email LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  189. OR cs_wechat LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  190. OR cs_telformat LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  191. OR cs_whatsappformat LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  192. OR cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%')" .
  193. $filterStr . " ORDER BY colortag DESC, id DESC";
  194. $result = $conn->query($sqlStr);
  195. if ($result && $result->num_rows > 0) {
  196. $pageSize = 20;
  197. $page = empty($page) ? 1 : $page;
  198. $page = ($page === 'end') ? ceil($result->num_rows / $pageSize) : $page;
  199. $page = (!is_numeric($page) || $page < 1) ? 1 : (int)$page;
  200. $totalPages = ceil($result->num_rows / $pageSize);
  201. $page = ($page > $totalPages) ? $totalPages : $page;
  202. $offset = $pageSize * ($page - 1);
  203. $rows = [];
  204. while ($row = $result->fetch_assoc()) {
  205. $rows[] = $row;
  206. }
  207. $paginatedRows = array_slice($rows, $offset, $pageSize);
  208. $tempNum = $offset;
  209. foreach ($paginatedRows as $row) {
  210. $tempNum++;
  211. ?>
  212. <div class="tline color<?= $row['colortag'] ?>">
  213. <div class="col2"><?= $tempNum ?></div>
  214. <div class="col3 slidepanel">
  215. <?= htmlspecialchars($row['cs_code']) ?>
  216. <?php if ($row['cs_claimFrom'] > 0): ?>
  217. <img src="../images/yijiao.png" class="handover" title="来自认领">
  218. <?php endif; ?>
  219. </div>
  220. <div class="col10">
  221. <?php
  222. $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
  223. echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialchars($qudaoRow['ch_name']) : '未填写';
  224. ?>
  225. </div>
  226. <div class="col10">
  227. <?php
  228. $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
  229. echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialchars($countryRow['countryName']) : '未填写';
  230. ?>
  231. </div>
  232. <div class="col10">
  233. <?php
  234. $typeResult = $conn->query("SELECT businessType FROM clientType WHERE id=" . (int)$row['cs_type']);
  235. echo ($typeRow = $typeResult->fetch_assoc()) ? htmlspecialchars($typeRow['businessType']) : '未填写';
  236. ?>
  237. </div>
  238. <div class="col10">
  239. <?php
  240. if ($row['cs_deal'] == 3) {
  241. echo "<span style='color:red;'>成交</span>";
  242. } elseif ($row['cs_deal'] == 2) {
  243. echo "明确需求";
  244. } elseif ($row['cs_deal'] == 1) {
  245. echo "背景调查";
  246. } else {
  247. echo "无响应";
  248. }
  249. ?>
  250. </div>
  251. <div class="col6"><?= $row['cs_addtime'] ?></div>
  252. <div class="col6">
  253. <?php if ($row['cs_belong'] == $_SESSION['employee_id']): ?>
  254. <a href="customerEdit.php?id=<?= $row['id'] ?>" class="ico_edit ico">修改</a>
  255. <?php endif; ?>
  256. </div>
  257. </div>
  258. <div class="notepanel clear">
  259. <div class="noteItem">联系方式</div>
  260. <div class="lx">
  261. <div class="tel"><?= htmlspecialchars($row['cs_tel']) ?></div>
  262. <div class="mail"><a href="mailto:<?= htmlspecialchars($row['cs_email']) ?>"><?= htmlspecialchars($row['cs_email']) ?></a></div>
  263. <div class="whatsapp"><?= htmlspecialchars($row['cs_whatsapp']) ?></div>
  264. <div class="wechat"><?= htmlspecialchars($row['cs_wechat']) ?></div>
  265. <div class="linkedin"><?= htmlspecialchars($row['cs_linkedin']) ?></div>
  266. <div class="facebook"><?= htmlspecialchars($row['cs_facebook']) ?></div>
  267. <div class="alibaba"><?= htmlspecialchars($row['cs_alibaba']) ?></div>
  268. </div>
  269. <div class="noteItem2">备注</div>
  270. <div class="notecontent">
  271. <div class="chain">
  272. 流转记录:
  273. <?php
  274. if (!empty($row['cs_chain'])) {
  275. $myArray = explode(',', $row['cs_chain']);
  276. $sqlStr = "SELECT em_user FROM employee WHERE id=" . (int)$myArray[0];
  277. for ($j = 1; $j < count($myArray); $j++) {
  278. $sqlStr .= " UNION ALL SELECT em_user FROM employee WHERE id=" . (int)$myArray[$j];
  279. }
  280. $chainResult = $conn->query($sqlStr);
  281. while ($chainRow = $chainResult->fetch_assoc()) {
  282. echo htmlspecialchars($chainRow['em_user']) . " > ";
  283. }
  284. }
  285. ?>
  286. </div>
  287. <?= htmlUnCode($row['cs_note']) ?>
  288. </div>
  289. </div>
  290. <?php
  291. }
  292. } else {
  293. if (empty($keys)) {
  294. ?>
  295. <tr>
  296. <div align="center">当前暂无沉默客户</div>
  297. </tr>
  298. <?php
  299. } else {
  300. ?>
  301. <tr>
  302. <div align="center"><a href="?">Sorry,没有找到"<?= htmlspecialchars($keyscode) ?>"相关的信息,点击返回</a></div>
  303. </tr>
  304. <?php
  305. }
  306. }
  307. ?>
  308. <div colspan="9">
  309. <div class="showpagebox">
  310. <?php
  311. if (isset($totalPages) && $totalPages > 1) {
  312. $pageName = "?Keys=" . $keys . $urlStr . "&";
  313. $pagelen = 3;
  314. if ($page > 1) {
  315. echo "<a href=\"{$pageName}Page=1\">首页</a>";
  316. echo "<a href=\"{$pageName}Page=" . ($page - 1) . "\">上一页</a>";
  317. }
  318. if ($pagelen * 2 + 1 >= $totalPages) {
  319. $startPage = 1;
  320. $endPage = $totalPages;
  321. } else {
  322. if ($page <= $pagelen + 1) {
  323. $startPage = 1;
  324. $endPage = $pagelen * 2 + 1;
  325. } else {
  326. $startPage = $page - $pagelen;
  327. $endPage = $page + $pagelen;
  328. }
  329. if ($page + $pagelen > $totalPages) {
  330. $startPage = $totalPages - $pagelen * 2;
  331. $endPage = $totalPages;
  332. }
  333. }
  334. for ($i = $startPage; $i <= $endPage; $i++) {
  335. if ($i == $page) {
  336. echo "<a class=\"current\">{$i}</a>";
  337. } else {
  338. echo "<a href=\"{$pageName}Page={$i}\">{$i}</a>";
  339. }
  340. }
  341. if ($page < $totalPages) {
  342. if ($totalPages - $page > $pagelen) {
  343. echo "<a href=\"{$pageName}Page={$totalPages}\">...{$totalPages}</a>";
  344. }
  345. echo "<a href=\"{$pageName}Page=" . ($page + 1) . "\">下一页</a>";
  346. echo "<a href=\"{$pageName}Page={$totalPages}\">尾页</a>";
  347. }
  348. echo "<input type=\"text\" id=\"Pagego\" value=\"{$page}\"
  349. onFocus=\"if(this.value == '{$page}'){this.value='';}\"
  350. onBlur=\"if(this.value == ''){this.value='{$page}';}\"
  351. onKeyUp=\"this.value=this.value.replace(/\D/g,'')\"
  352. onKeyDown=\"if(event.keyCode==13){location.href='{$pageName}Page='+document.getElementById('Pagego').value}\" />";
  353. }
  354. ?>
  355. </div>
  356. </div>
  357. </div>
  358. </form>
  359. </div>
  360. </body>
  361. </html>