abnormal.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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. $page = $_GET['Page'] ?? '';
  31. $keys = urlencode($_GET['Keys'] ?? '');
  32. $hrefstr = "?keys=" . $keys;
  33. // 使用SQL拼接方式
  34. $employee_id = intval($_SESSION['employee_id']);
  35. ?>
  36. <form id="form1" method="post" action="?act=postchk&Keys=<?= $keys ?>&Page=<?= $page ?>" onSubmit="return false">
  37. <div class="fastSelect clear">
  38. <H1>异常客户</H1>
  39. </div>
  40. <div width="100%" border="0" cellpadding="3" cellspacing="1" class="table2 em<?= $employee_id ?>">
  41. <div class="theader">
  42. <div class="col1"><input type="checkbox" name="chkall" id="chkall" onClick="chkboxall(this,'chkbox')" /></div>
  43. <div class="col2">序号</div>
  44. <div class="col3">客户编号</div>
  45. <div class="col4">渠道来源</div>
  46. <div class="col5">区域</div>
  47. <div class="col6">客户类型</div>
  48. <div class="col6">跟进阶段</div>
  49. <div class="colmark">颜色标记</div>
  50. <div class="col6">录入时间</div>
  51. <div class="col9">操作</div>
  52. </div>
  53. <?php
  54. // 适配新的customer_contact表结构并使用SQL拼接方式
  55. $sqlStr = "SELECT c.id,
  56. MAX(c.cs_code) as cs_code,
  57. MAX(c.cs_from) as cs_from,
  58. MAX(c.cs_country) as cs_country,
  59. MAX(c.cs_type) as cs_type,
  60. MAX(c.cs_deal) as cs_deal,
  61. MAX(c.cs_addtime) as cs_addtime,
  62. MAX(c.colortag) as colortag,
  63. MAX(c.cs_note) as cs_note,
  64. MAX(c.cs_claimFrom) as cs_claimFrom,
  65. GROUP_CONCAT(DISTINCT cc.id) as contact_ids,
  66. GROUP_CONCAT(DISTINCT cc.contact_name) as contact_names,
  67. GROUP_CONCAT(DISTINCT cc.tel_1) as tel_1_list,
  68. GROUP_CONCAT(DISTINCT cc.tel_2) as tel_2_list,
  69. GROUP_CONCAT(DISTINCT cc.tel_3) as tel_3_list,
  70. GROUP_CONCAT(DISTINCT cc.email_1) as email_1_list,
  71. GROUP_CONCAT(DISTINCT cc.email_2) as email_2_list,
  72. GROUP_CONCAT(DISTINCT cc.email_3) as email_3_list,
  73. GROUP_CONCAT(DISTINCT cc.whatsapp_1) as whatsapp_1_list,
  74. GROUP_CONCAT(DISTINCT cc.whatsapp_2) as whatsapp_2_list,
  75. GROUP_CONCAT(DISTINCT cc.whatsapp_3) as whatsapp_3_list,
  76. GROUP_CONCAT(DISTINCT cc.wechat_1) as wechat_1_list,
  77. GROUP_CONCAT(DISTINCT cc.wechat_2) as wechat_2_list,
  78. GROUP_CONCAT(DISTINCT cc.wechat_3) as wechat_3_list,
  79. GROUP_CONCAT(DISTINCT cc.linkedin_1) as linkedin_1_list,
  80. GROUP_CONCAT(DISTINCT cc.linkedin_2) as linkedin_2_list,
  81. GROUP_CONCAT(DISTINCT cc.linkedin_3) as linkedin_3_list,
  82. GROUP_CONCAT(DISTINCT cc.facebook_1) as facebook_1_list,
  83. GROUP_CONCAT(DISTINCT cc.facebook_2) as facebook_2_list,
  84. GROUP_CONCAT(DISTINCT cc.facebook_3) as facebook_3_list,
  85. GROUP_CONCAT(DISTINCT cc.alibaba_1) as alibaba_1_list,
  86. GROUP_CONCAT(DISTINCT cc.alibaba_2) as alibaba_2_list,
  87. GROUP_CONCAT(DISTINCT cc.alibaba_3) as alibaba_3_list
  88. FROM customer c
  89. LEFT JOIN customer_contact cc ON c.id = cc.customer_id
  90. WHERE (
  91. (NOT EXISTS (SELECT 1 FROM customer_contact WHERE customer_id = c.id AND alibaba_1 <> '')
  92. AND (c.cs_code LIKE '%阿里%' OR c.cs_code LIKE '%1688%')
  93. AND c.cs_belong = " . $employee_id . ")
  94. OR
  95. (c.cs_from = 8
  96. AND NOT EXISTS (SELECT 1 FROM customer_contact WHERE customer_id = c.id AND wechat_1 <> '')
  97. AND c.cs_belong = " . $employee_id . ")
  98. )
  99. GROUP BY c.id
  100. ORDER BY MAX(c.colortag) DESC, c.id DESC";
  101. $result = $conn->query($sqlStr);
  102. if ($result && $result->num_rows > 0) {
  103. $pageSize = 20;
  104. $page = empty($page) ? 1 : $page;
  105. $page = $page === 'end' ? ceil($result->num_rows / $pageSize) : $page;
  106. $page = !is_numeric($page) || $page < 1 ? 1 : (int)$page;
  107. $totalPages = ceil($result->num_rows / $pageSize);
  108. $page = $page > $totalPages ? $totalPages : $page;
  109. $offset = $pageSize * ($page - 1);
  110. // Store all results in array
  111. $rows = [];
  112. while ($row = $result->fetch_assoc()) {
  113. $rows[] = $row;
  114. }
  115. // Get paginated results
  116. $paginatedRows = array_slice($rows, $offset, $pageSize);
  117. $tempNum = $offset;
  118. foreach ($paginatedRows as $row) {
  119. $tempNum++;
  120. ?>
  121. <div class="tline color<?= $row['colortag'] ?>">
  122. <div class="col1" align="center"><input type="checkbox" name="chkbox[]" value="<?= $row['id'] ?>" /></div>
  123. <div class="col2"><?= $tempNum ?></div>
  124. <div class="col3 slidepanel"><?= htmlspecialcharsFix($row['cs_code']) ?><?php if ($row['cs_claimFrom'] > 0): ?><img src="../images/yijiao.png" class="handover" title="来自认领"><?php endif; ?></div>
  125. <div class="col4">
  126. <?php
  127. // 使用SQL拼接方式
  128. $cs_from = intval($row['cs_from']);
  129. $qudaoResult = $conn->query("SELECT ch_name FROM qudao WHERE id = " . $cs_from);
  130. if ($qudaoRow = $qudaoResult->fetch_assoc()) {
  131. echo htmlspecialcharsFix($qudaoRow['ch_name']);
  132. } else {
  133. echo "未填写";
  134. }
  135. ?>
  136. </div>
  137. <div class="col5">
  138. <?php
  139. // 使用SQL拼接方式
  140. $cs_country = intval($row['cs_country']);
  141. $countryResult = $conn->query("SELECT countryName FROM country WHERE id = " . $cs_country);
  142. if ($countryRow = $countryResult->fetch_assoc()) {
  143. echo htmlspecialcharsFix($countryRow['countryName']);
  144. } else {
  145. echo "未填写";
  146. }
  147. ?>
  148. </div>
  149. <div class="col6">
  150. <?php
  151. // 使用SQL拼接方式
  152. $cs_type = intval($row['cs_type']);
  153. $typeResult = $conn->query("SELECT businessType FROM clienttype WHERE id = " . $cs_type);
  154. if ($typeRow = $typeResult->fetch_assoc()) {
  155. echo htmlspecialcharsFix($typeRow['businessType']);
  156. } else {
  157. echo "未填写";
  158. }
  159. ?>
  160. </div>
  161. <div class="col6">
  162. <?php
  163. switch ($row['cs_deal']) {
  164. case 3:
  165. echo '<span style="color:red;">成交</span>';
  166. break;
  167. case 2:
  168. echo '明确需求';
  169. break;
  170. case 1:
  171. echo '背景调查';
  172. break;
  173. default:
  174. echo '无响应';
  175. }
  176. ?>
  177. </div>
  178. <div class="colmark colormark">
  179. <ul class="colorlist" data-id="<?= $row['id'] ?>">
  180. <li value="1" class="color1"></li>
  181. <li value="2" class="color2"></li>
  182. <li value="3" class="color3"></li>
  183. <li value="4" class="color4"></li>
  184. <li value="0" class="color0"></li>
  185. </ul>
  186. </div>
  187. <div class="col6"><?= $row['cs_addtime'] ?></div>
  188. <div class="col9"><a href="customerEdit.php?Keys=<?= $keys ?>&fliterDeal=<?= $_GET['fliterDeal'] ?? '' ?>&fliterBusiness=<?= $_GET['fliterBusiness'] ?? '' ?>&Page=<?= $page ?>&act=edit&id=<?= $row['id'] ?>" class="ico_edit ico">修改</a></div>
  189. </div>
  190. <div class="notepanel clear">
  191. <div class="noteItem">联系方式</div>
  192. <div class="lx">
  193. <?php
  194. // 显示联系人和联系方式
  195. $contacts = explode(',', $row['contact_names']);
  196. $contactIds = explode(',', $row['contact_ids']);
  197. // 处理电话
  198. echo '<div class="tel">';
  199. if (!empty($row['tel_1_list'])) echo htmlspecialcharsFix($row['tel_1_list']) . '<br>';
  200. if (!empty($row['tel_2_list'])) echo htmlspecialcharsFix($row['tel_2_list']) . '<br>';
  201. if (!empty($row['tel_3_list'])) echo htmlspecialcharsFix($row['tel_3_list']);
  202. echo '</div>';
  203. // 处理邮箱
  204. echo '<div class="mail">';
  205. if (!empty($row['email_1_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_1_list']) . '">' . htmlspecialcharsFix($row['email_1_list']) . '</a><br>';
  206. if (!empty($row['email_2_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_2_list']) . '">' . htmlspecialcharsFix($row['email_2_list']) . '</a><br>';
  207. if (!empty($row['email_3_list'])) echo '<a href="mailto:' . htmlspecialcharsFix($row['email_3_list']) . '">' . htmlspecialcharsFix($row['email_3_list']) . '</a>';
  208. echo '</div>';
  209. // 处理WhatsApp
  210. echo '<div class="whatsapp">';
  211. if (!empty($row['whatsapp_1_list'])) echo htmlspecialcharsFix($row['whatsapp_1_list']) . '<br>';
  212. if (!empty($row['whatsapp_2_list'])) echo htmlspecialcharsFix($row['whatsapp_2_list']) . '<br>';
  213. if (!empty($row['whatsapp_3_list'])) echo htmlspecialcharsFix($row['whatsapp_3_list']);
  214. echo '</div>';
  215. // 处理微信
  216. echo '<div class="wechat">';
  217. if (!empty($row['wechat_1_list'])) echo htmlspecialcharsFix($row['wechat_1_list']) . '<br>';
  218. if (!empty($row['wechat_2_list'])) echo htmlspecialcharsFix($row['wechat_2_list']) . '<br>';
  219. if (!empty($row['wechat_3_list'])) echo htmlspecialcharsFix($row['wechat_3_list']);
  220. echo '</div>';
  221. // 处理LinkedIn
  222. echo '<div class="linkedin">';
  223. if (!empty($row['linkedin_1_list'])) echo htmlspecialcharsFix($row['linkedin_1_list']) . '<br>';
  224. if (!empty($row['linkedin_2_list'])) echo htmlspecialcharsFix($row['linkedin_2_list']) . '<br>';
  225. if (!empty($row['linkedin_3_list'])) echo htmlspecialcharsFix($row['linkedin_3_list']);
  226. echo '</div>';
  227. // 处理Facebook
  228. echo '<div class="facebook">';
  229. if (!empty($row['facebook_1_list'])) echo htmlspecialcharsFix($row['facebook_1_list']) . '<br>';
  230. if (!empty($row['facebook_2_list'])) echo htmlspecialcharsFix($row['facebook_2_list']) . '<br>';
  231. if (!empty($row['facebook_3_list'])) echo htmlspecialcharsFix($row['facebook_3_list']);
  232. echo '</div>';
  233. // 处理阿里巴巴
  234. echo '<div class="alibaba">';
  235. if (!empty($row['alibaba_1_list'])) echo htmlspecialcharsFix($row['alibaba_1_list']) . '<br>';
  236. if (!empty($row['alibaba_2_list'])) echo htmlspecialcharsFix($row['alibaba_2_list']) . '<br>';
  237. if (!empty($row['alibaba_3_list'])) echo htmlspecialcharsFix($row['alibaba_3_list']);
  238. echo '</div>';
  239. ?>
  240. </div>
  241. <div class="noteItem2">备注</div>
  242. <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>
  243. </div>
  244. <?php
  245. }
  246. } else {
  247. if (empty($keys)) {
  248. ?>
  249. <tr>
  250. <div align="center" colspan="9">Sorry,当前暂无信息</div>
  251. </tr>
  252. <?php
  253. } else {
  254. ?>
  255. <tr>
  256. <div align="center" colspan="9"><a href="?">Sorry,没有找到"<?= $keyscode ?? '' ?>"相关的信息,点击返回</a></div>
  257. </tr>
  258. <?php
  259. }
  260. }
  261. ?>
  262. <div colspan="9">
  263. <div class="showpagebox">
  264. <?php
  265. if (isset($totalPages) && $totalPages > 1) {
  266. $pageName = "?Keys=" . $keys . ($urlStr ?? '') . "&";
  267. $pagelen = 3;
  268. // First page and Previous page
  269. if ($page > 1) {
  270. echo "<a href=\"{$pageName}Page=1\">首页</a>";
  271. echo "<a href=\"{$pageName}Page=" . ($page - 1) . "\">上一页</a>";
  272. }
  273. // Calculate page range
  274. if ($pagelen * 2 + 1 >= $totalPages) {
  275. $startPage = 1;
  276. $endPage = $totalPages;
  277. } else {
  278. if ($page <= $pagelen + 1) {
  279. $startPage = 1;
  280. $endPage = $pagelen * 2 + 1;
  281. } else {
  282. $startPage = $page - $pagelen;
  283. $endPage = $page + $pagelen;
  284. }
  285. if ($page + $pagelen > $totalPages) {
  286. $startPage = $totalPages - $pagelen * 2;
  287. $endPage = $totalPages;
  288. }
  289. }
  290. // Page numbers
  291. for ($i = $startPage; $i <= $endPage; $i++) {
  292. if ($i == $page) {
  293. echo "<a class=\"current\">{$i}</a>";
  294. } else {
  295. echo "<a href=\"{$pageName}Page={$i}\">{$i}</a>";
  296. }
  297. }
  298. // Next page and Last page
  299. if ($page < $totalPages) {
  300. if ($totalPages - $page > $pagelen) {
  301. echo "<a href=\"{$pageName}Page={$totalPages}\">...{$totalPages}</a>";
  302. }
  303. echo "<a href=\"{$pageName}Page=" . ($page + 1) . "\">下一页</a>";
  304. echo "<a href=\"{$pageName}Page={$totalPages}\">尾页</a>";
  305. }
  306. }
  307. ?>
  308. </div>
  309. </div>
  310. </div>
  311. </form>
  312. </div>
  313. </body>
  314. </html>