subCustomers.php 16 KB

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