customersFollow.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <?php
  2. require_once 'conn.php';
  3. checkLogin();
  4. ?>
  5. <!DOCTYPE html>
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  9. <title>管理区域</title>
  10. <link rel="stylesheet" href="css/common.css" type="text/css" />
  11. <link rel="stylesheet" href="css/alert.css" type="text/css" />
  12. <script src="system/js/jquery-1.7.2.min.js"></script>
  13. <script src="js/js.js"></script>
  14. </head>
  15. <body class="clear">
  16. <?php require_once 'panel.php'; ?>
  17. <div id="man_zone">
  18. <?php
  19. $act = $_GET['act'] ?? '';
  20. if ($act == "postchk") {
  21. $keys = urlencode($_GET['Keys'] ?? '');
  22. $page = $_GET['Page'] ?? '';
  23. $chkact = $_POST['chkact'] ?? '';
  24. if (!empty($_POST['chkbox'])) {
  25. $sqlStr = "";
  26. foreach ($_POST['chkbox'] as $id) {
  27. $sqlStr .= ($sqlStr ? " OR id=" : " WHERE id=") . (int)$id;
  28. }
  29. switch ($chkact) {
  30. case "0":
  31. case "1":
  32. case "2":
  33. case "3":
  34. $sqlStr = "UPDATE customer SET cs_deal=" . $chkact . $sqlStr;
  35. break;
  36. default:
  37. $sqlStr = "UPDATE customer SET cs_belong=" . str_replace("t", "", $chkact) . $sqlStr;
  38. }
  39. $conn->query($sqlStr);
  40. header("Location: ?Keys=" . $keys . "&Page=" . $page);
  41. exit;
  42. }
  43. }
  44. $keys = $_GET['Keys'] ?? '';
  45. $keyscode = textEncode($keys);
  46. $page = $_GET['Page'] ?? '';
  47. $filterCountry = $_GET['fliterCountry'] ?? '';
  48. $filterQudao = $_GET['fliterQudao'] ?? '';
  49. $filterDeal = $_GET['fliterDeal'] ?? '';
  50. $filterBusiness = $_GET['fliterBusiness'] ?? '';
  51. $filterContact = $_GET['fliterContact'] ?? '';
  52. $filterStr = "";
  53. $urlStr = "";
  54. if (!empty($filterCountry)) {
  55. $filterStr .= " AND cs_country=" . (int)$filterCountry;
  56. $urlStr .= "&fliterCountry=" . $filterCountry;
  57. }
  58. if (!empty($filterQudao)) {
  59. $filterStr .= " AND cs_from=" . (int)$filterQudao;
  60. $urlStr .= "&fliterQudao=" . $filterQudao;
  61. }
  62. if (!empty($filterDeal)) {
  63. $filterStr .= " AND cs_deal=" . (int)$filterDeal;
  64. $urlStr .= "&fliterDeal=" . $filterDeal;
  65. }
  66. if (!empty($filterBusiness)) {
  67. $filterStr .= " AND cs_type=" . (int)$filterBusiness;
  68. $urlStr .= "&fliterBusiness=" . $filterBusiness;
  69. }
  70. if (!empty($filterContact)) {
  71. switch ($filterContact) {
  72. case "1": $filterStr .= " AND cs_tel<>''"; break;
  73. case "2": $filterStr .= " AND cs_wechat<>''"; break;
  74. case "3": $filterStr .= " AND cs_whatsapp<>''"; break;
  75. case "4": $filterStr .= " AND cs_email<>''"; break;
  76. case "5": $filterStr .= " AND cs_linkedin<>''"; break;
  77. case "6": $filterStr .= " AND cs_facebook<>''"; break;
  78. default: $filterStr .= " AND cs_alibaba<>''";
  79. }
  80. $urlStr .= "&fliterContact=" . $filterContact;
  81. }
  82. $keys = urlencode($keys);
  83. $hrefstr = "?keys=" . $keys;
  84. ?>
  85. <form id="form1" method="post" action="?act=postchk&Keys=<?= $keys ?>&Page=<?= $page ?>" onSubmit="return false">
  86. <div class="fastSelect clear">
  87. <H1>搜索条件</H1>
  88. <div class="selectItem">
  89. <label>区域</label>
  90. <select name="fliterCountry" class="filterSearch">
  91. <option value="">请选择国家地区</option>
  92. <?php
  93. $result = $conn->query("SELECT id, countryName FROM country");
  94. while ($row = $result->fetch_assoc()) {
  95. $selected = ($filterCountry == $row['id']) ? ' selected="selected"' : '';
  96. echo "<option value=\"{$row['id']}\"{$selected}>{$row['countryName']}</option>";
  97. }
  98. ?>
  99. </select>
  100. </div>
  101. <div class="selectItem">
  102. <label>来源渠道</label>
  103. <select name="fliterQudao" class="filterSearch">
  104. <option value="">请选择渠道</option>
  105. <?php
  106. $result = $conn->query("SELECT id, ch_name FROM qudao");
  107. while ($row = $result->fetch_assoc()) {
  108. $selected = ($filterQudao == $row['id']) ? ' selected="selected"' : '';
  109. echo "<option value=\"{$row['id']}\"{$selected}>{$row['ch_name']}</option>";
  110. }
  111. ?>
  112. </select>
  113. </div>
  114. <div class="selectItem">
  115. <label>是否成交</label>
  116. <select name="fliterDeal" class="filterSearch">
  117. <option value="">请选择</option>
  118. <option value="0"<?= ($filterDeal == "0") ? ' selected="selected"' : '' ?>>无响应</option>
  119. <option value="1"<?= ($filterDeal == "1") ? ' selected="selected"' : '' ?>>背景调查</option>
  120. <option value="2"<?= ($filterDeal == "2") ? ' 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) ? '请输入搜索关键词' : $keyscode ?>"
  152. onFocus="if(this.value == '<?= empty($keyscode) ? '请输入搜索关键词' : $keyscode ?>'){this.value='';}"
  153. onBlur="if(this.value == ''){this.value='<?= empty($keyscode) ? '请输入搜索关键词' : $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">
  160. <div class="theader">
  161. <div class="col1"><input type="checkbox" name="chkall" id="chkall" onClick="chkboxall(this,'chkbox')" /></div>
  162. <div class="col2">序号</div>
  163. <div class="col3">客户编号</div>
  164. <div class="col4">渠道来源</div>
  165. <div class="col5">区域</div>
  166. <div class="col6">客户类型</div>
  167. <div class="col6">是否成交</div>
  168. <div class="colmark">颜色标记</div>
  169. <div class="col6">录入时间</div>
  170. <div class="col9">操作</div>
  171. </div>
  172. <?php
  173. $sql = "SELECT id, cs_code, cs_from, cs_country, cs_type, cs_deal, cs_addtime, cs_tel, cs_email,
  174. cs_whatsapp, cs_wechat, cs_linkedin, cs_facebook, cs_alibaba, colortag, cs_note
  175. FROM customer
  176. WHERE cs_deal<>3 AND DATEDIFF(NOW(), cs_updatetime) > 55 AND cs_belong=" . $_SESSION['employee_id'] . "
  177. AND (cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  178. OR cs_name LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  179. OR cs_email LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  180. OR cs_wechat LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  181. OR cs_tel LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  182. OR cs_whatsapp LIKE '%" . $conn->real_escape_string($keyscode) . "%')" .
  183. $filterStr . " ORDER BY cs_state DESC, id DESC";
  184. $result = $conn->query($sql);
  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. // Store results in array for pagination
  194. $rows = [];
  195. while ($row = $result->fetch_assoc()) {
  196. $rows[] = $row;
  197. }
  198. // Get paginated results
  199. $paginatedRows = array_slice($rows, $offset, $pageSize);
  200. $tempNum = $offset;
  201. foreach ($paginatedRows as $row) {
  202. $tempNum++;
  203. ?>
  204. <div class="tline color<?= $row['colortag'] ?>">
  205. <div class="col1" align="center"><input type="checkbox" name="chkbox[]" value="<?= $row['id'] ?>" /></div>
  206. <div class="col2"><?= $tempNum ?></div>
  207. <div class="col3 slidepanel"><?= htmlspecialchars($row['cs_code']) ?></div>
  208. <div class="col4">
  209. <?php
  210. $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
  211. echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialchars($qudaoRow['ch_name']) : '未填写';
  212. ?>
  213. </div>
  214. <div class="col5">
  215. <?php
  216. $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
  217. echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialchars($countryRow['countryName']) : '未填写';
  218. ?>
  219. </div>
  220. <div class="col6">
  221. <?php
  222. $typeResult = $conn->query("SELECT businessType FROM clientType WHERE id=" . (int)$row['cs_type']);
  223. echo ($typeRow = $typeResult->fetch_assoc()) ? htmlspecialchars($typeRow['businessType']) : '未填写';
  224. ?>
  225. </div>
  226. <div class="col6">
  227. <?php
  228. if ($row['cs_deal'] == 2) {
  229. echo "明确需求";
  230. } elseif ($row['cs_deal'] == 1) {
  231. echo "背景调查";
  232. } else {
  233. echo "未成交";
  234. }
  235. ?>
  236. </div>
  237. <div class="colmark colormark">
  238. <ul class="colorlist" data-id="<?= $row['id'] ?>">
  239. <li value="1" class="color1"></li>
  240. <li value="2" class="color2"></li>
  241. <li value="3" class="color3"></li>
  242. <li value="4" class="color4"></li>
  243. <li value="0" class="color0"></li>
  244. </ul>
  245. </div>
  246. <div class="col6"><?= $row['cs_addtime'] ?></div>
  247. <div class="col9">
  248. <a href="customerEdit.php?Keys=<?= $keys ?>&Page=<?= $page ?>&act=edit&id=<?= $row['id'] ?>"
  249. class="ico_edit ico">修改</a>
  250. </div>
  251. </div>
  252. <div class="notepanel clear">
  253. <div class="noteItem">联系方式</div>
  254. <div class="lx">
  255. <div class="tel"><?= htmlspecialchars($row['cs_tel']) ?></div>
  256. <div class="mail">
  257. <a href="mailto:<?= htmlspecialchars($row['cs_email']) ?>">
  258. <?= htmlspecialchars($row['cs_email']) ?>
  259. </a>
  260. </div>
  261. <div class="whatapp"><?= htmlspecialchars($row['cs_whatsapp']) ?></div>
  262. <div class="wechat"><?= htmlspecialchars($row['cs_wechat']) ?></div>
  263. <div class="linkedin"><?= htmlspecialchars($row['cs_linkedin']) ?></div>
  264. <div class="facebook"><?= htmlspecialchars($row['cs_facebook']) ?></div>
  265. <div class="alibaba"><?= htmlspecialchars($row['cs_alibaba']) ?></div>
  266. </div>
  267. <div class="noteItem2">备注</div>
  268. <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>
  269. </div>
  270. <?php
  271. }
  272. } else {
  273. if (empty($keys)) {
  274. ?>
  275. <tr>
  276. <div align="center" colspan="9">Sorry,当前暂无信息</div>
  277. </tr>
  278. <?php
  279. } else {
  280. ?>
  281. <tr>
  282. <div align="center" colspan="9">
  283. <a href="?">Sorry,没有找到"<?= htmlspecialchars($keyscode) ?>"相关的信息,点击返回</a>
  284. </div>
  285. </tr>
  286. <?php
  287. }
  288. }
  289. ?>
  290. <div colspan="9">
  291. <div class="showpagebox">
  292. <?php
  293. if (isset($totalPages) && $totalPages > 1) {
  294. $pageName = "?Keys=" . $keys . $urlStr . "&";
  295. $pagelen = 3;
  296. if ($page > 1) {
  297. echo "<a href=\"{$pageName}Page=1\">首页</a>";
  298. echo "<a href=\"{$pageName}Page=" . ($page - 1) . "\">上一页</a>";
  299. }
  300. if ($pagelen * 2 + 1 >= $totalPages) {
  301. $startPage = 1;
  302. $endPage = $totalPages;
  303. } else {
  304. if ($page <= $pagelen + 1) {
  305. $startPage = 1;
  306. $endPage = $pagelen * 2 + 1;
  307. } else {
  308. $startPage = $page - $pagelen;
  309. $endPage = $page + $pagelen;
  310. }
  311. if ($page + $pagelen > $totalPages) {
  312. $startPage = $totalPages - $pagelen * 2;
  313. $endPage = $totalPages;
  314. }
  315. }
  316. for ($i = $startPage; $i <= $endPage; $i++) {
  317. if ($i == $page) {
  318. echo "<a class=\"current\">{$i}</a>";
  319. } else {
  320. echo "<a href=\"{$pageName}Page={$i}\">{$i}</a>";
  321. }
  322. }
  323. if ($page < $totalPages) {
  324. if ($totalPages - $page > $pagelen) {
  325. echo "<a href=\"{$pageName}Page={$totalPages}\">...{$totalPages}</a>";
  326. }
  327. echo "<a href=\"{$pageName}Page=" . ($page + 1) . "\">下一页</a>";
  328. echo "<a href=\"{$pageName}Page={$totalPages}\">尾页</a>";
  329. }
  330. echo "<input type=\"text\" id=\"Pagego\" value=\"{$page}\"
  331. onFocus=\"if(this.value == '{$page}'){this.value='';}\"
  332. onBlur=\"if(this.value == ''){this.value='{$page}';}\"
  333. onKeyUp=\"this.value=this.value.replace(/\D/g,'')\"
  334. onKeyDown=\"if(event.keyCode==13){location.href='{$pageName}Page='+document.getElementById('Pagego').value}\" />";
  335. }
  336. ?>
  337. </div>
  338. <?php require_once 'postchkbox.php'; ?>
  339. </div>
  340. </div>
  341. </form>
  342. </div>
  343. </body>
  344. </html>