highSeas.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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?ver=0620"></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. $keys = $_GET['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. $filterBelong = $_GET['fliterBelong'] ?? '';
  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($filterBelong)) {
  57. $filterStr .= " AND c.cs_belong=" . (int)$filterBelong;
  58. $urlStr .= "&fliterBelong=" . $filterBelong;
  59. }
  60. $keys = urlencode($keys);
  61. $hrefstr = "?keys=" . $keys;
  62. // 使用SQL拼接方式
  63. $employee_id = intval($_SESSION['employee_id']);
  64. ?>
  65. <form id="form1" method="post" action="?act=postchk&Keys=<?= $keys ?>&Page=<?= $page ?>" onSubmit="return false">
  66. <div class="fastSelect clear">
  67. <H1>搜索条件</H1>
  68. <div class="selectItem">
  69. <label>区域</label>
  70. <select name="fliterCountry" class="filterSearch">
  71. <option value="">请选择国家地区</option>
  72. <?php
  73. $result = $conn->query("SELECT id, countryName FROM country");
  74. while ($row = $result->fetch_assoc()) {
  75. $selected = ($filterCountry == $row['id']) ? ' selected="selected"' : '';
  76. echo "<option value=\"{$row['id']}\"{$selected}>{$row['countryName']}</option>";
  77. }
  78. ?>
  79. </select>
  80. </div>
  81. <div class="selectItem">
  82. <label>来源渠道</label>
  83. <select name="fliterQudao" class="filterSearch">
  84. <option value="">请选择渠道</option>
  85. <?php
  86. $result = $conn->query("SELECT id, ch_name FROM qudao");
  87. while ($row = $result->fetch_assoc()) {
  88. $selected = ($filterQudao == $row['id']) ? ' selected="selected"' : '';
  89. echo "<option value=\"{$row['id']}\"{$selected}>{$row['ch_name']}</option>";
  90. }
  91. ?>
  92. </select>
  93. </div>
  94. <div class="selectItem">
  95. <label>跟进阶段</label>
  96. <select name="fliterDeal" class="filterSearch">
  97. <option value="">请选择</option>
  98. <option value="0"<?= ($filterDeal == "0") ? ' selected="selected"' : '' ?>>无响应</option>
  99. <option value="1"<?= ($filterDeal == "1") ? ' selected="selected"' : '' ?>>背景调查</option>
  100. <option value="2"<?= ($filterDeal == "2") ? ' selected="selected"' : '' ?>>明确需求</option>
  101. </select>
  102. </div>
  103. <div class="selectItem">
  104. <label>客户类型</label>
  105. <select name="fliterBusiness" class="filterSearch">
  106. <option value="">请选择</option>
  107. <?php
  108. $result = $conn->query("SELECT id, businessType FROM clienttype");
  109. while ($row = $result->fetch_assoc()) {
  110. $selected = ($filterBusiness == $row['id']) ? ' selected="selected"' : '';
  111. echo "<option value=\"{$row['id']}\"{$selected}>{$row['businessType']}</option>";
  112. }
  113. ?>
  114. </select>
  115. </div>
  116. <div class="selectItem">
  117. <label>业务员</label>
  118. <select name="fliterBelong" class="filterSearch">
  119. <option value="">请选择</option>
  120. <?php
  121. $result = $conn->query("SELECT id, em_user FROM employee");
  122. while ($row = $result->fetch_assoc()) {
  123. $selected = ($filterBelong == $row['id']) ? ' selected="selected"' : '';
  124. echo "<option value=\"{$row['id']}\"{$selected}>{$row['em_user']}</option>";
  125. }
  126. ?>
  127. </select>
  128. </div>
  129. </div>
  130. <div width="100%" border="0" cellpadding="3" cellspacing="1" class="table2">
  131. <div class="theader">
  132. <div class="col9">序号</div>
  133. <div class="col3">客户编号</div>
  134. <div class="col4">渠道来源</div>
  135. <div class="col5">区域</div>
  136. <div class="col6">客户类型</div>
  137. <div class="col6">是否成交</div>
  138. <div class="col20">更新日期</div>
  139. <div class="col4">操作</div>
  140. </div>
  141. <?php
  142. // 使用SQL拼接方式,同时适配新的customer_contact表结构
  143. $escapedKeyscode = $conn->real_escape_string($keyscode);
  144. $sql = "SELECT c.id,
  145. MAX(c.cs_code) as cs_code,
  146. MAX(c.cs_from) as cs_from,
  147. MAX(c.cs_country) as cs_country,
  148. MAX(c.cs_type) as cs_type,
  149. MAX(c.cs_deal) as cs_deal,
  150. MAX(c.cs_addtime) as cs_addtime,
  151. MAX(c.cs_updatetime) as cs_updatetime,
  152. MAX(c.cs_note) as cs_note,
  153. MAX(c.cs_claimFrom) as cs_claimFrom,
  154. MAX(c.cs_state) as cs_state,
  155. GROUP_CONCAT(DISTINCT cc.id) as contact_ids,
  156. GROUP_CONCAT(DISTINCT cc.contact_name) as contact_names,
  157. GROUP_CONCAT(DISTINCT cc.tel_1) as tel_1_list,
  158. GROUP_CONCAT(DISTINCT cc.tel_2) as tel_2_list,
  159. GROUP_CONCAT(DISTINCT cc.tel_3) as tel_3_list,
  160. GROUP_CONCAT(DISTINCT cc.email_1) as email_1_list,
  161. GROUP_CONCAT(DISTINCT cc.email_2) as email_2_list,
  162. GROUP_CONCAT(DISTINCT cc.email_3) as email_3_list,
  163. GROUP_CONCAT(DISTINCT cc.whatsapp_1) as whatsapp_1_list,
  164. GROUP_CONCAT(DISTINCT cc.whatsapp_2) as whatsapp_2_list,
  165. GROUP_CONCAT(DISTINCT cc.whatsapp_3) as whatsapp_3_list,
  166. GROUP_CONCAT(DISTINCT cc.wechat_1) as wechat_1_list,
  167. GROUP_CONCAT(DISTINCT cc.wechat_2) as wechat_2_list,
  168. GROUP_CONCAT(DISTINCT cc.wechat_3) as wechat_3_list,
  169. GROUP_CONCAT(DISTINCT cc.linkedin_1) as linkedin_1_list,
  170. GROUP_CONCAT(DISTINCT cc.linkedin_2) as linkedin_2_list,
  171. GROUP_CONCAT(DISTINCT cc.linkedin_3) as linkedin_3_list,
  172. GROUP_CONCAT(DISTINCT cc.facebook_1) as facebook_1_list,
  173. GROUP_CONCAT(DISTINCT cc.facebook_2) as facebook_2_list,
  174. GROUP_CONCAT(DISTINCT cc.facebook_3) as facebook_3_list,
  175. GROUP_CONCAT(DISTINCT cc.alibaba_1) as alibaba_1_list,
  176. GROUP_CONCAT(DISTINCT cc.alibaba_2) as alibaba_2_list,
  177. GROUP_CONCAT(DISTINCT cc.alibaba_3) as alibaba_3_list
  178. FROM customer c
  179. LEFT JOIN customer_contact cc ON c.id = cc.customer_id
  180. WHERE c.cs_deal<>3 AND c.cs_deal<>0 AND c.cs_type<>2 AND c.cs_belong<>13
  181. AND c.cs_belong<>" . $employee_id . "
  182. AND DATEDIFF(NOW(), c.cs_updatetime) > 60
  183. AND c.cs_country NOT IN (2, 229, 13, 153)
  184. AND c.cs_belongclient=0
  185. AND NOT EXISTS (
  186. SELECT 1 FROM customer_contact
  187. WHERE customer_id = c.id
  188. AND wechat_1 LIKE 'wxid%'
  189. )
  190. AND (c.cs_code LIKE '%" . $escapedKeyscode . "%'
  191. OR cc.contact_name LIKE '%" . $escapedKeyscode . "%'
  192. OR cc.email_1 LIKE '%" . $escapedKeyscode . "%'
  193. OR cc.email_2 LIKE '%" . $escapedKeyscode . "%'
  194. OR cc.email_3 LIKE '%" . $escapedKeyscode . "%'
  195. OR cc.wechat_1 LIKE '%" . $escapedKeyscode . "%'
  196. OR cc.wechat_2 LIKE '%" . $escapedKeyscode . "%'
  197. OR cc.wechat_3 LIKE '%" . $escapedKeyscode . "%'
  198. OR cc.tel_1 LIKE '%" . $escapedKeyscode . "%'
  199. OR cc.tel_2 LIKE '%" . $escapedKeyscode . "%'
  200. OR cc.tel_3 LIKE '%" . $escapedKeyscode . "%'
  201. OR cc.whatsapp_1 LIKE '%" . $escapedKeyscode . "%'
  202. OR cc.whatsapp_2 LIKE '%" . $escapedKeyscode . "%'
  203. OR cc.whatsapp_3 LIKE '%" . $escapedKeyscode . "%')" .
  204. $filterStr . " GROUP BY c.id ORDER BY cs_state DESC, c.id DESC";
  205. $result = $conn->query($sql);
  206. if ($result && $result->num_rows > 0) {
  207. $pageSize = 20;
  208. $page = empty($page) ? 1 : $page;
  209. $page = ($page === 'end') ? ceil($result->num_rows / $pageSize) : $page;
  210. $page = (!is_numeric($page) || $page < 1) ? 1 : (int)$page;
  211. $totalPages = ceil($result->num_rows / $pageSize);
  212. $page = ($page > $totalPages) ? $totalPages : $page;
  213. $offset = $pageSize * ($page - 1);
  214. // Store results in array for pagination
  215. $rows = [];
  216. while ($row = $result->fetch_assoc()) {
  217. $rows[] = $row;
  218. }
  219. // Get paginated results
  220. $paginatedRows = array_slice($rows, $offset, $pageSize);
  221. $tempNum = $offset;
  222. foreach ($paginatedRows as $row) {
  223. $tempNum++;
  224. ?>
  225. <div class="tline">
  226. <div class="col9"><?= $tempNum ?></div>
  227. <div class="col3 slidepanel"><?= htmlspecialcharsFix($row['cs_code']) ?></div>
  228. <div class="col4">
  229. <?php
  230. // 使用SQL拼接方式
  231. $cs_from = intval($row['cs_from']);
  232. $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id=" . $cs_from);
  233. echo ($qudaoRow = $qudaoResult->fetch_assoc()) ? htmlspecialcharsFix($qudaoRow['ch_name']) : '未填写';
  234. ?>
  235. </div>
  236. <div class="col5">
  237. <?php
  238. // 使用SQL拼接方式
  239. $cs_country = intval($row['cs_country']);
  240. $countryResult = $conn->query("SELECT countryName FROM country WHERE id=" . $cs_country);
  241. echo ($countryRow = $countryResult->fetch_assoc()) ? htmlspecialcharsFix($countryRow['countryName']) : '未填写';
  242. ?>
  243. </div>
  244. <div class="col6">
  245. <?php
  246. // 使用SQL拼接方式
  247. $cs_type = intval($row['cs_type']);
  248. $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id=" . $cs_type);
  249. echo ($typeRow = $typeResult->fetch_assoc()) ? htmlspecialcharsFix($typeRow['businessType']) : '未填写';
  250. ?>
  251. </div>
  252. <div class="col6">
  253. <?php
  254. if ($row['cs_deal'] == 2) {
  255. echo "明确需求";
  256. } elseif ($row['cs_deal'] == 1) {
  257. echo "背景调查";
  258. }
  259. ?>
  260. </div>
  261. <div class="col20"><?= $row['cs_updatetime'] ?></div>
  262. <div class="col4"><span id="claim1" class="claim" data-id="<?= $row['id'] ?>">认领</span></div>
  263. </div>
  264. <div class="notepanel clear">
  265. <div class="noteItem">联系方式</div>
  266. <div class="lx">
  267. <?php
  268. // 显示联系人和联系方式
  269. $contacts = explode(',', $row['contact_names']);
  270. $contactIds = explode(',', $row['contact_ids']);
  271. // 处理电话
  272. echo '<div class="tel">';
  273. if (!empty($row['tel_1_list'])) echo htmlspecialcharsFix($row['tel_1_list']) . '<br>';
  274. if (!empty($row['tel_2_list'])) echo htmlspecialcharsFix($row['tel_2_list']) . '<br>';
  275. if (!empty($row['tel_3_list'])) echo htmlspecialcharsFix($row['tel_3_list']);
  276. echo '</div>';
  277. // 处理邮箱
  278. echo '<div class="mail">';
  279. if (!empty($row['email_1_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_1_list']) . '">' . htmlspecialcharsFix($row['email_1_list']) . '</a><br>';
  280. if (!empty($row['email_2_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_2_list']) . '">' . htmlspecialcharsFix($row['email_2_list']) . '</a><br>';
  281. if (!empty($row['email_3_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_3_list']) . '">' . htmlspecialcharsFix($row['email_3_list']) . '</a>';
  282. echo '</div>';
  283. // 处理WhatsApp
  284. echo '<div class="whatsapp">';
  285. if (!empty($row['whatsapp_1_list'])) echo htmlspecialcharsFix($row['whatsapp_1_list']) . '<br>';
  286. if (!empty($row['whatsapp_2_list'])) echo htmlspecialcharsFix($row['whatsapp_2_list']) . '<br>';
  287. if (!empty($row['whatsapp_3_list'])) echo htmlspecialcharsFix($row['whatsapp_3_list']);
  288. echo '</div>';
  289. // 处理微信
  290. echo '<div class="wechat">';
  291. if (!empty($row['wechat_1_list'])) echo htmlspecialcharsFix($row['wechat_1_list']) . '<br>';
  292. if (!empty($row['wechat_2_list'])) echo htmlspecialcharsFix($row['wechat_2_list']) . '<br>';
  293. if (!empty($row['wechat_3_list'])) echo htmlspecialcharsFix($row['wechat_3_list']);
  294. echo '</div>';
  295. // 处理LinkedIn
  296. echo '<div class="linkedin">';
  297. if (!empty($row['linkedin_1_list'])) echo htmlspecialcharsFix($row['linkedin_1_list']) . '<br>';
  298. if (!empty($row['linkedin_2_list'])) echo htmlspecialcharsFix($row['linkedin_2_list']) . '<br>';
  299. if (!empty($row['linkedin_3_list'])) echo htmlspecialcharsFix($row['linkedin_3_list']);
  300. echo '</div>';
  301. // 处理Facebook
  302. echo '<div class="facebook">';
  303. if (!empty($row['facebook_1_list'])) echo htmlspecialcharsFix($row['facebook_1_list']) . '<br>';
  304. if (!empty($row['facebook_2_list'])) echo htmlspecialcharsFix($row['facebook_2_list']) . '<br>';
  305. if (!empty($row['facebook_3_list'])) echo htmlspecialcharsFix($row['facebook_3_list']);
  306. echo '</div>';
  307. // 处理阿里巴巴
  308. echo '<div class="alibaba">';
  309. if (!empty($row['alibaba_1_list'])) echo htmlspecialcharsFix($row['alibaba_1_list']) . '<br>';
  310. if (!empty($row['alibaba_2_list'])) echo htmlspecialcharsFix($row['alibaba_2_list']) . '<br>';
  311. if (!empty($row['alibaba_3_list'])) echo htmlspecialcharsFix($row['alibaba_3_list']);
  312. echo '</div>';
  313. ?>
  314. </div>
  315. <div class="noteItem2">备注</div>
  316. <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>
  317. </div>
  318. <?php
  319. }
  320. } else {
  321. if (empty($keys)) {
  322. ?>
  323. <tr>
  324. <div align="center" colspan="8">Sorry,当前暂无信息</div>
  325. </tr>
  326. <?php
  327. } else {
  328. ?>
  329. <tr>
  330. <div align="center" colspan="8">
  331. <a href="?">Sorry,没有找到"<?= htmlspecialcharsFix($keyscode) ?>"相关的信息,点击返回</a>
  332. </div>
  333. </tr>
  334. <?php
  335. }
  336. }
  337. ?>
  338. <div colspan="8">
  339. <div class="showpagebox">
  340. <?php
  341. if (isset($totalPages) && $totalPages > 1) {
  342. $pageName = "?Keys=" . $keys . $urlStr . "&";
  343. $pagelen = 3;
  344. if ($page > 1) {
  345. echo "<a href=\"{$pageName}Page=1\">首页</a>";
  346. echo "<a href=\"{$pageName}Page=" . ($page - 1) . "\">上一页</a>";
  347. }
  348. if ($pagelen * 2 + 1 >= $totalPages) {
  349. $startPage = 1;
  350. $endPage = $totalPages;
  351. } else {
  352. if ($page <= $pagelen + 1) {
  353. $startPage = 1;
  354. $endPage = $pagelen * 2 + 1;
  355. } else {
  356. $startPage = $page - $pagelen;
  357. $endPage = $page + $pagelen;
  358. }
  359. if ($page + $pagelen > $totalPages) {
  360. $startPage = $totalPages - $pagelen * 2;
  361. $endPage = $totalPages;
  362. }
  363. }
  364. for ($i = $startPage; $i <= $endPage; $i++) {
  365. if ($i == $page) {
  366. echo "<a class=\"current\">{$i}</a>";
  367. } else {
  368. echo "<a href=\"{$pageName}Page={$i}\">{$i}</a>";
  369. }
  370. }
  371. if ($page < $totalPages) {
  372. if ($totalPages - $page > $pagelen) {
  373. echo "<a href=\"{$pageName}Page={$totalPages}\">...{$totalPages}</a>";
  374. }
  375. echo "<a href=\"{$pageName}Page=" . ($page + 1) . "\">下一页</a>";
  376. echo "<a href=\"{$pageName}Page={$totalPages}\">尾页</a>";
  377. }
  378. echo "<input type=\"text\" id=\"Pagego\" value=\"{$page}\"
  379. onFocus=\"if(this.value == '{$page}'){this.value='';}\"
  380. onBlur=\"if(this.value == ''){this.value='{$page}';}\"
  381. onKeyUp=\"this.value=this.value.replace(/\D/g,'')\"
  382. onKeyDown=\"if(event.keyCode==13){location.href='{$pageName}Page='+document.getElementById('Pagego').value}\" />";
  383. }
  384. ?>
  385. </div>
  386. </div>
  387. </div>
  388. </form>
  389. </div>
  390. </body>
  391. </html>