teamSeas.php 21 KB

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