customersFollow.php 15 KB

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