subCustomers.php 16 KB

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