silentCustomer.php 16 KB

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