silentCustomer.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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 c.cs_country=" . (int)$filterCountry;
  42. $urlStr .= "&fliterCountry=" . $filterCountry;
  43. }
  44. if (!empty($filterQudao)) {
  45. $filterStr .= " AND c.cs_from=" . (int)$filterQudao;
  46. $urlStr .= "&fliterQudao=" . $filterQudao;
  47. }
  48. if (!empty($filterDeal)) {
  49. $filterStr .= " AND c.cs_deal=" . (int)$filterDeal;
  50. $urlStr .= "&fliterDeal=" . $filterDeal;
  51. }
  52. if (!empty($filterBusiness)) {
  53. $filterStr .= " AND c.cs_type=" . (int)$filterBusiness;
  54. $urlStr .= "&fliterBusiness=" . $filterBusiness;
  55. }
  56. if (!empty($filterContact)) {
  57. switch ($filterContact) {
  58. case "1": $filterStr .= " AND cc.tel<>''"; break;
  59. case "2": $filterStr .= " AND cc.wechat<>''"; break;
  60. case "3": $filterStr .= " AND cc.whatsapp<>''"; break;
  61. case "4": $filterStr .= " AND cc.email<>''"; break;
  62. case "5": $filterStr .= " AND cc.linkedin<>''"; break;
  63. case "6": $filterStr .= " AND cc.facebook<>''"; break;
  64. default: $filterStr .= " AND cc.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) ? '请输入搜索关键词' : htmlspecialcharsFix($keyscode) ?>"
  162. onFocus="if(this.value == '<?= empty($keyscode) ? '请输入搜索关键词' : htmlspecialcharsFix($keyscode) ?>'){this.value='';}"
  163. onBlur="if(this.value == ''){this.value='<?= empty($keyscode) ? '请输入搜索关键词' : htmlspecialcharsFix($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 c.id, c.cs_code, c.cs_from, c.cs_country, c.cs_type, c.cs_deal, c.cs_addtime,
  182. cc.tel as cs_tel, cc.email as cs_email, cc.whatsapp as cs_whatsapp, cc.wechat as cs_wechat,
  183. cc.linkedin as cs_linkedin, cc.facebook as cs_facebook, cc.alibaba as cs_alibaba,
  184. c.colortag, c.cs_note, c.cs_claimFrom, c.cs_belong, c.cs_chain
  185. FROM customer c
  186. LEFT JOIN customer_contact cc ON c.id = cc.customer_id
  187. WHERE (c.is_silent=1 OR (c.cs_deal=0 AND c.cs_belong=" . $_SESSION['employee_id'] . "))
  188. AND (c.cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  189. OR cc.contact_name LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  190. OR cc.email LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  191. OR cc.wechat LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  192. OR cc.tel_format LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  193. OR cc.whatsapp_format LIKE '%" . $conn->real_escape_string($keyscode) . "%'
  194. OR c.cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%')" .
  195. $filterStr . " ORDER BY c.colortag DESC, c.id DESC";
  196. $result = $conn->query($sqlStr);
  197. if ($result && $result->num_rows > 0) {
  198. $pageSize = 20;
  199. $page = empty($page) ? 1 : $page;
  200. $page = ($page === 'end') ? ceil($result->num_rows / $pageSize) : $page;
  201. $page = (!is_numeric($page) || $page < 1) ? 1 : (int)$page;
  202. $totalPages = ceil($result->num_rows / $pageSize);
  203. $page = ($page > $totalPages) ? $totalPages : $page;
  204. $offset = $pageSize * ($page - 1);
  205. $rows = [];
  206. while ($row = $result->fetch_assoc()) {
  207. $rows[] = $row;
  208. }
  209. $paginatedRows = array_slice($rows, $offset, $pageSize);
  210. $tempNum = $offset;
  211. foreach ($paginatedRows as $row) {
  212. $tempNum++;
  213. ?>
  214. <div class="tline color<?= $row['colortag'] ?>">
  215. <div class="col2"><?= $tempNum ?></div>
  216. <div class="col3 slidepanel">
  217. <?= htmlspecialcharsFix($row['cs_code']) ?>
  218. <?php if ($row['cs_claimFrom'] > 0): ?>
  219. <img src="../images/yijiao.png" class="handover" title="来自认领">
  220. <?php endif; ?>
  221. </div>
  222. <div class="col10">
  223. <?php
  224. $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
  225. echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialcharsFix($qudaoRow['ch_name']) : '未填写';
  226. ?>
  227. </div>
  228. <div class="col10">
  229. <?php
  230. $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
  231. echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialcharsFix($countryRow['countryName']) : '未填写';
  232. ?>
  233. </div>
  234. <div class="col10">
  235. <?php
  236. $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id=" . (int)$row['cs_type']);
  237. echo ($typeRow = $typeResult->fetch_assoc()) ? htmlspecialcharsFix($typeRow['businessType']) : '未填写';
  238. ?>
  239. </div>
  240. <div class="col10">
  241. <?php
  242. if ($row['cs_deal'] == 3) {
  243. echo "<span style='color:red;'>成交</span>";
  244. } elseif ($row['cs_deal'] == 2) {
  245. echo "明确需求";
  246. } elseif ($row['cs_deal'] == 1) {
  247. echo "背景调查";
  248. } else {
  249. echo "无响应";
  250. }
  251. ?>
  252. </div>
  253. <div class="col6"><?= $row['cs_addtime'] ?></div>
  254. <div class="col6">
  255. <?php if ($row['cs_belong'] == $_SESSION['employee_id']): ?>
  256. <a href="customerEdit.php?id=<?= $row['id'] ?>" class="ico_edit ico">修改</a>
  257. <?php endif; ?>
  258. </div>
  259. </div>
  260. <div class="notepanel clear">
  261. <div class="noteItem">联系方式</div>
  262. <div class="lx">
  263. <div class="tel"><?= htmlspecialcharsFix($row['cs_tel']) ?></div>
  264. <div class="mail"><a href="mailto:<?= htmlspecialcharsFix($row['cs_email']) ?>"><?= htmlspecialcharsFix($row['cs_email']) ?></a></div>
  265. <div class="whatsapp"><?= htmlspecialcharsFix($row['cs_whatsapp']) ?></div>
  266. <div class="wechat"><?= htmlspecialcharsFix($row['cs_wechat']) ?></div>
  267. <div class="linkedin"><?= htmlspecialcharsFix($row['cs_linkedin']) ?></div>
  268. <div class="facebook"><?= htmlspecialcharsFix($row['cs_facebook']) ?></div>
  269. <div class="alibaba"><?= htmlspecialcharsFix($row['cs_alibaba']) ?></div>
  270. </div>
  271. <div class="noteItem2">备注</div>
  272. <div class="notecontent">
  273. <div class="chain">
  274. 流转记录:
  275. <?php
  276. if (!empty($row['cs_chain'])) {
  277. $myArray = explode(',', $row['cs_chain']);
  278. $sqlStr = "SELECT em_user FROM employee WHERE id=" . (int)$myArray[0];
  279. for ($j = 1; $j < count($myArray); $j++) {
  280. $sqlStr .= " UNION ALL SELECT em_user FROM employee WHERE id=" . (int)$myArray[$j];
  281. }
  282. $chainResult = $conn->query($sqlStr);
  283. while ($chainRow = $chainResult->fetch_assoc()) {
  284. echo htmlspecialcharsFix($chainRow['em_user']) . " > ";
  285. }
  286. }
  287. ?>
  288. </div>
  289. <?= htmlUnCode($row['cs_note']) ?>
  290. </div>
  291. </div>
  292. <?php
  293. }
  294. } else {
  295. if (empty($keys)) {
  296. ?>
  297. <tr>
  298. <div align="center">当前暂无沉默客户</div>
  299. </tr>
  300. <?php
  301. } else {
  302. ?>
  303. <tr>
  304. <div align="center"><a href="?">Sorry,没有找到"<?= htmlspecialcharsFix($keyscode) ?>"相关的信息,点击返回</a></div>
  305. </tr>
  306. <?php
  307. }
  308. }
  309. ?>
  310. <div colspan="9">
  311. <div class="showpagebox">
  312. <?php
  313. if (isset($totalPages) && $totalPages > 1) {
  314. $pageName = "?Keys=" . $keys . $urlStr . "&";
  315. $pagelen = 3;
  316. if ($page > 1) {
  317. echo "<a href=\"{$pageName}Page=1\">首页</a>";
  318. echo "<a href=\"{$pageName}Page=" . ($page - 1) . "\">上一页</a>";
  319. }
  320. if ($pagelen * 2 + 1 >= $totalPages) {
  321. $startPage = 1;
  322. $endPage = $totalPages;
  323. } else {
  324. if ($page <= $pagelen + 1) {
  325. $startPage = 1;
  326. $endPage = $pagelen * 2 + 1;
  327. } else {
  328. $startPage = $page - $pagelen;
  329. $endPage = $page + $pagelen;
  330. }
  331. if ($page + $pagelen > $totalPages) {
  332. $startPage = $totalPages - $pagelen * 2;
  333. $endPage = $totalPages;
  334. }
  335. }
  336. for ($i = $startPage; $i <= $endPage; $i++) {
  337. if ($i == $page) {
  338. echo "<a class=\"current\">{$i}</a>";
  339. } else {
  340. echo "<a href=\"{$pageName}Page={$i}\">{$i}</a>";
  341. }
  342. }
  343. if ($page < $totalPages) {
  344. if ($totalPages - $page > $pagelen) {
  345. echo "<a href=\"{$pageName}Page={$totalPages}\">...{$totalPages}</a>";
  346. }
  347. echo "<a href=\"{$pageName}Page=" . ($page + 1) . "\">下一页</a>";
  348. echo "<a href=\"{$pageName}Page={$totalPages}\">尾页</a>";
  349. }
  350. echo "<input type=\"text\" id=\"Pagego\" value=\"{$page}\"
  351. onFocus=\"if(this.value == '{$page}'){this.value='';}\"
  352. onBlur=\"if(this.value == ''){this.value='{$page}';}\"
  353. onKeyUp=\"this.value=this.value.replace(/\D/g,'')\"
  354. onKeyDown=\"if(event.keyCode==13){location.href='{$pageName}Page='+document.getElementById('Pagego').value}\" />";
  355. }
  356. ?>
  357. </div>
  358. </div>
  359. </div>
  360. </form>
  361. </div>
  362. </body>
  363. </html>