customers.php 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054
  1. <?php
  2. require_once 'conn.php';
  3. checkLogin();
  4. // 辅助函数
  5. $act = $_GET['act'] ?? '';
  6. $urlStr = '';
  7. //
  8. //// 处理保存操作
  9. //if ($act == "save") {
  10. // $isedit = false;
  11. // $id = $_POST['id'] ?? '';
  12. // if (!empty($id) && is_numeric($id)) {
  13. // $isedit = true;
  14. // }
  15. //
  16. // // 获取表单数据 - 客户基本信息
  17. // $cs_code = textEncode($_POST['cs_code']);
  18. // $cs_company = textEncode($_POST['cs_company']);
  19. // $cs_belong = $_POST['cs_belong'];
  20. // $cs_country = $_POST['cs_country'];
  21. // $cs_from = $_POST['cs_from'];
  22. // $cs_state = $_POST['cs_state'];
  23. // $cs_deal = $_POST['cs_deal'];
  24. // $cs_type = $_POST['cs_type'] ?? 5;
  25. // $cs_belongclient = $_POST['cs_belongclient'] ?? 0;
  26. // $no_content = htmlEncode($_POST['no_content']);
  27. // $allowedit = isset($_POST['allowedit']) ? 1 : 0;
  28. // $cs_address = textEncode($_POST['cs_address'] ?? '');
  29. // $mytag = textEncode($_POST['mytag'] ?? '');
  30. // $mytag = str_replace(['&#60;&#47;span&#62;&#60;span&#62;', '&#60;&#47;span&#62;', '&#60;span&#62;'], [',', '', ''], $mytag);
  31. // $mytag = explode(',', $mytag);
  32. //
  33. // // 获取联系人信息
  34. // $contacts = $_POST['contact'] ?? [];
  35. //
  36. // // 验证必填字段
  37. // if (empty($cs_code)) {
  38. // echo "<script>alert('客户编码不能为空');history.back();</script>";
  39. // exit;
  40. // }
  41. //
  42. // if ($cs_country == 0) {
  43. // echo "<script>alert('这是哪个国家的客户?');history.back();</script>";
  44. // exit;
  45. // }
  46. //
  47. // if ($cs_from == "0") {
  48. // echo "<script>alert('请填写客户来源!');history.back();</script>";
  49. // exit;
  50. // }
  51. //
  52. // // 自动检测来源
  53. // if (strpos($cs_code, ';1688') !== false) {
  54. // $cs_from = 1; // 1688
  55. // }
  56. // if (strpos($cs_code, ';阿里') !== false) {
  57. // $cs_from = 2; // International station
  58. // }
  59. // if (strpos($cs_code, '官网') !== false) {
  60. // $cs_from = 3; // Website
  61. // }
  62. //
  63. // // 验证联系方式
  64. // $primary_contact = !empty($contacts) ? current($contacts) : [];
  65. //
  66. // if ($allowedit != 1) {
  67. // // 阿里巴巴验证
  68. // if (($cs_from == 1 || $cs_from == 2) && empty($primary_contact['alibaba_1'])) {
  69. // echo "<script>alert('阿里旺旺为必填项');history.back();</script>";
  70. // exit;
  71. // }
  72. //
  73. // // 官网来源验证
  74. // if ($cs_from == 3) {
  75. // $has_required = false;
  76. // for ($i = 1; $i <= 3; $i++) {
  77. // if (!empty($primary_contact['tel_' . $i]) ||
  78. // !empty($primary_contact['whatsapp_' . $i]) ||
  79. // !empty($primary_contact['wechat_' . $i])) {
  80. // $has_required = true;
  81. // break;
  82. // }
  83. // }
  84. // if (!$has_required) {
  85. // echo "<script>alert('电话和WhatsApp为必填项');history.back();</script>";
  86. // exit;
  87. // }
  88. // }
  89. //
  90. // // 市场客户验证
  91. // if ($cs_from == 8) {
  92. // $has_wechat = false;
  93. // for ($i = 1; $i <= 3; $i++) {
  94. // if (!empty($primary_contact['wechat_' . $i])) {
  95. // $has_wechat = true;
  96. // break;
  97. // }
  98. // }
  99. // if (!$has_wechat) {
  100. // echo "<script>alert('微信为必填项');history.back();</script>";
  101. // exit;
  102. // }
  103. // }
  104. //
  105. // // Facebook验证
  106. // if ($cs_from == 12) {
  107. // $has_facebook = false;
  108. // for ($i = 1; $i <= 3; $i++) {
  109. // if (!empty($primary_contact['facebook_' . $i])) {
  110. // $has_facebook = true;
  111. // break;
  112. // }
  113. // }
  114. // if (!$has_facebook) {
  115. // echo "<script>alert('Facebook为必填项');history.back();</script>";
  116. // exit;
  117. // }
  118. // }
  119. // }
  120. //
  121. // if ($isedit) {
  122. // // 验证客户所有权
  123. // $sql = "SELECT cs_chain FROM customer WHERE id = $id";
  124. // $result = mysqli_query($conn, $sql);
  125. // if ($row = mysqli_fetch_assoc($result)) {
  126. // $cs_chain = $row['cs_chain'];
  127. // $chain_array = explode(',', $cs_chain);
  128. // $last_item = end($chain_array);
  129. //
  130. // if ($last_item != $cs_belong) {
  131. // $cs_chain .= ",$cs_belong";
  132. // }
  133. //
  134. // // 更新客户基本信息
  135. // $sql = "UPDATE customer SET
  136. // cs_code = '$cs_code',
  137. // cs_company = '$cs_company',
  138. // cs_belong = '$cs_belong',
  139. // cs_country = '$cs_country',
  140. // cs_address = '$cs_address',
  141. // cs_from = '$cs_from',
  142. // cs_state = '$cs_state',
  143. // cs_deal = '$cs_deal',
  144. // cs_type = '$cs_type',
  145. // cs_belongclient = '$cs_belongclient',
  146. // cs_note = '$no_content',
  147. // allowedit = $allowedit,
  148. // cs_chain = '$cs_chain',
  149. // cs_updatetime = NOW()";
  150. //
  151. // // 处理cs_dealdate
  152. // if ($cs_deal == 3) {
  153. // $sql .= ", cs_dealdate = CASE WHEN cs_dealdate IS NULL THEN NOW() ELSE cs_dealdate END";
  154. // }
  155. //
  156. // $sql .= " WHERE id = $id";
  157. // mysqli_query($conn, $sql);
  158. //
  159. // // 处理联系人信息
  160. // $existingContactIds = [];
  161. // foreach ($contacts as $contact) {
  162. // if (!empty($contact['id'])) {
  163. // $existingContactIds[] = (int)$contact['id'];
  164. // }
  165. // }
  166. //
  167. // // 删除不再使用的联系人记录
  168. // if (!empty($existingContactIds)) {
  169. // $idsToKeep = implode(',', $existingContactIds);
  170. // $deleteContactsSql = "DELETE FROM customer_contact WHERE customer_id = $id AND id NOT IN ($idsToKeep)";
  171. // } else {
  172. // $deleteContactsSql = "DELETE FROM customer_contact WHERE customer_id = $id";
  173. // }
  174. // mysqli_query($conn, $deleteContactsSql);
  175. //
  176. // // 更新或添加联系人信息
  177. // foreach ($contacts as $contact) {
  178. // $contact_id = !empty($contact['id']) ? (int)$contact['id'] : 0;
  179. // $contact_name = textEncode($contact['contact_name'] ?? '');
  180. //
  181. // // 准备SQL字段和值
  182. // $fields = ['contact_name'];
  183. // $values = ["'" . mysqli_real_escape_string($conn, $contact_name) . "'"];
  184. // $updates = ["contact_name = '" . mysqli_real_escape_string($conn, $contact_name) . "'"];
  185. //
  186. // // 处理所有联系方式类型
  187. // $methodTypes = ['tel', 'email', 'whatsapp', 'wechat', 'linkedin', 'facebook', 'alibaba'];
  188. // foreach ($methodTypes as $type) {
  189. // for ($i = 1; $i <= 3; $i++) {
  190. // $field = $type . '_' . $i;
  191. // $format_field = $field . '_format';
  192. // $bu_field = $field . '_bu';
  193. //
  194. // $value = textEncode($contact[$field] ?? '');
  195. // $format_value = ($type == 'tel' || $type == 'whatsapp') ? numFormat($value) : '';
  196. // $bu_value = textEncode($contact[$bu_field] ?? $value);
  197. //
  198. // // 添加字段名
  199. // $fields[] = $field;
  200. // $fields[] = $bu_field;
  201. // if ($type == 'tel' || $type == 'whatsapp') {
  202. // $fields[] = $format_field;
  203. // }
  204. //
  205. // // 添加值
  206. // $values[] = "'" . mysqli_real_escape_string($conn, $value) . "'";
  207. // $values[] = "'" . mysqli_real_escape_string($conn, $bu_value) . "'";
  208. // if ($type == 'tel' || $type == 'whatsapp') {
  209. // $values[] = "'" . mysqli_real_escape_string($conn, $format_value) . "'";
  210. // }
  211. //
  212. // // 添加更新语句
  213. // $updates[] = $field . " = '" . mysqli_real_escape_string($conn, $value) . "'";
  214. // $updates[] = $bu_field . " = '" . mysqli_real_escape_string($conn, $bu_value) . "'";
  215. // if ($type == 'tel' || $type == 'whatsapp') {
  216. // $updates[] = $format_field . " = '" . mysqli_real_escape_string($conn, $format_value) . "'";
  217. // }
  218. // }
  219. // }
  220. //
  221. // if ($contact_id > 0) {
  222. // // 更新已有联系人
  223. // $updateContactSql = "UPDATE customer_contact SET " .
  224. // implode(", ", $updates) . ", updated_at = NOW() " .
  225. // "WHERE id = $contact_id AND customer_id = $id";
  226. // mysqli_query($conn, $updateContactSql);
  227. // } else {
  228. // // 添加新联系人
  229. // $insertContactSql = "INSERT INTO customer_contact (" .
  230. // implode(", ", $fields) . ", customer_id, created_at, updated_at) VALUES (" .
  231. // implode(", ", $values) . ", $id, NOW(), NOW())";
  232. // mysqli_query($conn, $insertContactSql);
  233. // }
  234. // }
  235. //
  236. // // 更新标签
  237. // mysqli_query($conn, "DELETE FROM tagtable WHERE customerId = $id");
  238. // foreach ($mytag as $tag) {
  239. // if (!empty(trim($tag))) {
  240. // $tagSql = "INSERT INTO tagtable (tagName, employeeId, customerId) VALUES ('" .
  241. // mysqli_real_escape_string($conn, $tag) . "', " .
  242. // $_SESSION['employee_id'] . ", $id)";
  243. // mysqli_query($conn, $tagSql);
  244. // }
  245. // }
  246. //
  247. // $page = $_GET['Page'] ?? '';
  248. // $keys = urlencode($_GET['Keys'] ?? '');
  249. // header("Location: ?keys=$keys&Page=$page$urlStr");
  250. // exit;
  251. // }
  252. // } else {
  253. // // 创建新记录
  254. // // 插入客户基本信息
  255. // $sql = "INSERT INTO customer (
  256. // cs_code, cs_company, cs_country, cs_address, cs_from,
  257. // cs_belong, cs_state, cs_deal, cs_type, cs_belongclient,
  258. // cs_note, allowedit, cs_chain, cs_addtime, cs_updatetime,
  259. // is_silent, cs_dealdate
  260. // ) VALUES (
  261. // '$cs_code', '$cs_company', '$cs_country', '$cs_address', '$cs_from',
  262. // '$cs_belong', '$cs_state', '$cs_deal', '$cs_type', '$cs_belongclient',
  263. // '$no_content', $allowedit, '$cs_belong', NOW(), NOW(),
  264. // 0, " . ($cs_deal == 3 ? "NOW()" : "NULL") . "
  265. // )";
  266. // mysqli_query($conn, $sql);
  267. // $new_customer_id = mysqli_insert_id($conn);
  268. //
  269. // // 插入联系人信息
  270. // if ($new_customer_id > 0) {
  271. // foreach ($contacts as $contact) {
  272. // $contact_name = textEncode($contact['contact_name'] ?? '');
  273. //
  274. // // 准备SQL字段和值
  275. // $fields = ['contact_name'];
  276. // $values = ["'" . mysqli_real_escape_string($conn, $contact_name) . "'"];
  277. //
  278. // // 处理所有联系方式类型
  279. // $methodTypes = ['tel', 'email', 'whatsapp', 'wechat', 'linkedin', 'facebook', 'alibaba'];
  280. // foreach ($methodTypes as $type) {
  281. // for ($i = 1; $i <= 3; $i++) {
  282. // $field = $type . '_' . $i;
  283. // $format_field = $field . '_format';
  284. // $bu_field = $field . '_bu';
  285. //
  286. // $value = textEncode($contact[$field] ?? '');
  287. // $format_value = ($type == 'tel' || $type == 'whatsapp') ? numFormat($value) : '';
  288. // $bu_value = textEncode($contact[$bu_field] ?? $value);
  289. //
  290. // // 添加字段名
  291. // $fields[] = $field;
  292. // $fields[] = $bu_field;
  293. // if ($type == 'tel' || $type == 'whatsapp') {
  294. // $fields[] = $format_field;
  295. // }
  296. //
  297. // // 添加值
  298. // $values[] = "'" . mysqli_real_escape_string($conn, $value) . "'";
  299. // $values[] = "'" . mysqli_real_escape_string($conn, $bu_value) . "'";
  300. // if ($type == 'tel' || $type == 'whatsapp') {
  301. // $values[] = "'" . mysqli_real_escape_string($conn, $format_value) . "'";
  302. // }
  303. // }
  304. // }
  305. //
  306. // // 添加新联系人
  307. // $insertContactSql = "INSERT INTO customer_contact (" .
  308. // implode(", ", $fields) . ", customer_id, created_at, updated_at) VALUES (" .
  309. // implode(", ", $values) . ", $new_customer_id, NOW(), NOW())";
  310. // mysqli_query($conn, $insertContactSql);
  311. // }
  312. //
  313. // // 保存标签
  314. // foreach ($mytag as $tag) {
  315. // if (!empty(trim($tag))) {
  316. // $tagSql = "INSERT INTO tagtable (tagName, employeeId, customerId) VALUES ('" .
  317. // mysqli_real_escape_string($conn, $tag) . "', " .
  318. // $_SESSION['employee_id'] . ", $new_customer_id)";
  319. // mysqli_query($conn, $tagSql);
  320. // }
  321. // }
  322. //
  323. // $page = $_GET['Page'] ?? '';
  324. // $keys = urlencode($_GET['Keys'] ?? '');
  325. // header("Location: ?keys=$keys&Page=$page$urlStr");
  326. // exit;
  327. // }
  328. // }
  329. //}
  330. //
  331. //// 处理编辑操作
  332. //if ($act == "edit") {
  333. // $id = $_GET['id'] ?? '';
  334. // $isedit = false;
  335. // if (!empty($id) && is_numeric($id)) {
  336. // $isedit = true;
  337. // }
  338. //
  339. // if ($isedit) {
  340. // // 联合查询客户基本信息和联系人信息
  341. // $sql = "SELECT c.*,
  342. // cc.id as contact_id, cc.contact_name,
  343. // cc.tel_1, cc.tel_1_format, cc.tel_1_bu,
  344. // cc.tel_2, cc.tel_2_format, cc.tel_2_bu,
  345. // cc.tel_3, cc.tel_3_format, cc.tel_3_bu,
  346. // cc.email_1, cc.email_1_bu,
  347. // cc.email_2, cc.email_2_bu,
  348. // cc.email_3, cc.email_3_bu,
  349. // cc.whatsapp_1, cc.whatsapp_1_format, cc.whatsapp_1_bu,
  350. // cc.whatsapp_2, cc.whatsapp_2_format, cc.whatsapp_2_bu,
  351. // cc.whatsapp_3, cc.whatsapp_3_format, cc.whatsapp_3_bu,
  352. // cc.wechat_1, cc.wechat_1_bu,
  353. // cc.wechat_2, cc.wechat_2_bu,
  354. // cc.wechat_3, cc.wechat_3_bu,
  355. // cc.linkedin_1, cc.linkedin_1_bu,
  356. // cc.linkedin_2, cc.linkedin_2_bu,
  357. // cc.linkedin_3, cc.linkedin_3_bu,
  358. // cc.facebook_1, cc.facebook_1_bu,
  359. // cc.facebook_2, cc.facebook_2_bu,
  360. // cc.facebook_3, cc.facebook_3_bu,
  361. // cc.alibaba_1, cc.alibaba_1_bu,
  362. // cc.alibaba_2, cc.alibaba_2_bu,
  363. // cc.alibaba_3, cc.alibaba_3_bu
  364. // FROM customer c
  365. // LEFT JOIN customer_contact cc ON c.id = cc.customer_id
  366. // WHERE c.id = $id";
  367. // $result = mysqli_query($conn, $sql);
  368. // if ($row = mysqli_fetch_assoc($result)) {
  369. // $cs_code = textDecode($row['cs_code']);
  370. // $cs_company = textDecode($row['cs_company']);
  371. // $cs_name = textDecode($row['contact_name']);
  372. // $cs_country = $row['cs_country'];
  373. // $cs_from = $row['cs_from'];
  374. // $cs_tel = textDecode($row['tel_1']);
  375. // $cs_telBu = textDecode($row['tel_1_bu']);
  376. // $cs_email = textDecode($row['email_1']);
  377. // $cs_emailBu = textDecode($row['email_1_bu']);
  378. // $cs_whatsapp = textDecode($row['whatsapp_1']);
  379. // $cs_whatsappBu = textDecode($row['whatsapp_1_bu']);
  380. // $cs_wechat = textDecode($row['wechat_1']);
  381. // $cs_wechatBu = textDecode($row['wechat_1_bu']);
  382. // $cs_linkedin = textDecode($row['linkedin_1']);
  383. // $cs_linkedinBu = textDecode($row['linkedin_1_bu']);
  384. // $cs_facebook = textDecode($row['facebook_1']);
  385. // $cs_facebookBu = textDecode($row['facebook_1_bu']);
  386. // $cs_alibaba = textDecode($row['alibaba_1']);
  387. // $cs_alibabaBu = textDecode($row['alibaba_1_bu']);
  388. // $cs_address = textDecode($row['cs_address']);
  389. // $cs_addtime = $row['cs_addtime'];
  390. // $cs_updatetime = $row['cs_updatetime'];
  391. // $cs_belong = $row['cs_belong'];
  392. // $cs_state = $row['cs_state'];
  393. // $cs_deal = $row['cs_deal'];
  394. // $cs_note = htmlDecode($row['cs_note']);
  395. // $allowedit = $row['allowedit'];
  396. // }
  397. // }
  398. //}
  399. // 处理批量操作
  400. if ($act == "postchk") {
  401. if (isset($_POST['chkbox']) && isset($_POST['chkact'])) {
  402. $chkact = $_POST['chkact'];
  403. $ids = implode(',', array_map('intval', $_POST['chkbox']));
  404. $count = count($_POST['chkbox']);
  405. // 检查是否为员工转让操作
  406. if (substr($chkact, 0, 1) === 't') {
  407. // 从chkact值中提取员工ID
  408. $employeeId = (int)substr($chkact, 1);
  409. // 获取员工代码和名称
  410. $stmt = $conn->prepare("SELECT em_code, em_user FROM employee WHERE id = ?");
  411. $stmt->bind_param("i", $employeeId);
  412. $stmt->execute();
  413. $result = $stmt->get_result();
  414. $employeeCode = '';
  415. $employeeName = '未知业务员';
  416. if ($row = $result->fetch_assoc()) {
  417. $employeeCode = $row['em_code'];
  418. $employeeName = $row['em_user'];
  419. }
  420. $stmt->close();
  421. // 检查是否有客户已经属于目标业务员
  422. $checkSql = "SELECT GROUP_CONCAT(id) as existing_ids FROM customer
  423. WHERE cs_belong = $employeeId AND id IN ({$ids})";
  424. $checkResult = $conn->query($checkSql);
  425. $existingIds = "";
  426. if ($checkResult && $checkRow = $checkResult->fetch_assoc()) {
  427. $existingIds = $checkRow['existing_ids'];
  428. }
  429. if (!empty($existingIds)) {
  430. // 有客户已经属于该业务员,显示错误信息
  431. echo "<script>alert('无法转移,客户ID:{$existingIds} 已经属于业务员【{$employeeName}】!');history.back();</script>";
  432. exit;
  433. }
  434. // 更新客户记录
  435. $sql = "UPDATE customer SET
  436. cs_updatetime = NOW(),
  437. cs_code = REPLACE(cs_code, '-', '/{$employeeCode}-'),
  438. cs_belong = {$employeeId},
  439. cs_chain = CONCAT(cs_chain, ',{$employeeId}')
  440. WHERE id IN ({$ids})";
  441. mysqli_query($conn, $sql);
  442. // 记录操作日志
  443. $action = "{$_SESSION['employee_name']} 批量转移{$count}个客户({$ids})给业务员【{$employeeName}】";
  444. logAction($action);
  445. } else {
  446. switch($chkact) {
  447. case "0":
  448. case "1":
  449. case "2":
  450. $sql = "UPDATE customer SET cs_deal = $chkact WHERE id IN ($ids)";
  451. break;
  452. case "-1":
  453. // 删除客户记录和联系人记录(依靠外键级联删除)
  454. $sql = "DELETE FROM customer WHERE id IN ($ids)";
  455. break;
  456. }
  457. if (isset($sql)) {
  458. mysqli_query($conn, $sql);
  459. }
  460. }
  461. $keys = urlencode($_GET['Keys'] ?? '');
  462. $page = $_GET['Page'] ?? '';
  463. header("Location: ?keys=$keys&Page=$page$urlStr");
  464. exit;
  465. }
  466. }
  467. /*
  468. // 处理筛选条件
  469. $fliterQudao = $_GET['fliterQudao'] ?? '';
  470. $fliterDeal = $_GET['fliterDeal'] ?? '';
  471. $fliterTeam = $_GET['fliterTeam'] ?? '';
  472. $fliterContact = $_GET['fliterContact'] ?? '';
  473. $fliterEmployee = $_GET['fliterEmployee'] ?? '';
  474. $fliterStr = "";
  475. if (!empty($fliterQudao)) {
  476. $fliterStr .= " AND c.cs_from = " . intval($fliterQudao);
  477. $urlStr .= "&fliterQudao=" . $fliterQudao;
  478. }
  479. if (!empty($fliterDeal)) {
  480. $fliterStr .= " AND c.cs_deal = " . intval($fliterDeal);
  481. $urlStr .= "&fliterDeal=" . $fliterDeal;
  482. }
  483. if (!empty($fliterTeam)) {
  484. $fliterStr .= " AND (c.cs_belong = " . intval($fliterTeam) .
  485. " OR c.cs_belong IN (SELECT id FROM employee WHERE em_role = " . intval($fliterTeam) . "))";
  486. $urlStr .= "&fliterTeam=" . $fliterTeam;
  487. }
  488. if (!empty($fliterEmployee)) {
  489. $fliterStr .= " AND c.cs_belong = " . intval($fliterEmployee);
  490. $urlStr .= "&fliterEmployee=" . $fliterEmployee;
  491. }
  492. if (!empty($fliterContact)) {
  493. switch ($fliterContact) {
  494. case "1": $fliterStr .= " AND (cc.tel_1 != '' OR cc.tel_2 != '' OR cc.tel_3 != '')"; break;
  495. case "2": $fliterStr .= " AND (cc.wechat_1 != '' OR cc.wechat_2 != '' OR cc.wechat_3 != '')"; break;
  496. case "3": $fliterStr .= " AND (cc.whatsapp_1 != '' OR cc.whatsapp_2 != '' OR cc.whatsapp_3 != '')"; break;
  497. case "4": $fliterStr .= " AND (cc.email_1 != '' OR cc.email_2 != '' OR cc.email_3 != '')"; break;
  498. case "5": $fliterStr .= " AND (cc.linkedin_1 != '' OR cc.linkedin_2 != '' OR cc.linkedin_3 != '')"; break;
  499. case "6": $fliterStr .= " AND (cc.facebook_1 != '' OR cc.facebook_2 != '' OR cc.facebook_3 != '')"; break;
  500. case "7": $fliterStr .= " AND (cc.alibaba_1 != '' OR cc.alibaba_2 != '' OR cc.alibaba_3 != '')"; break;
  501. }
  502. $urlStr .= "&fliterContact=" . $fliterContact;
  503. }
  504. // 搜索和排序
  505. $keys = $_GET['Keys'] ?? '';
  506. $keyscode = textEncode($keys);
  507. $page = $_GET['Page'] ?? 1;
  508. $ord = $_GET['Ord'] ?? '';
  509. $ordStr = !empty($ord) ? "$ord," : "";
  510. // 构建查询SQL - 修改为联合查询
  511. $sqlStr = "SELECT c.id, c.cs_code, c.cs_company, c.cs_country, c.cs_address, c.cs_from,
  512. c.cs_deal, c.cs_addtime, c.cs_updatetime, c.cs_belong, c.cs_note, c.cs_claimFrom,
  513. c.cs_chain, c.cs_dealdate, c.cs_type, c.cs_belongclient, c.allowedit,c.colortag,
  514. cc.id as contact_id, cc.contact_name,
  515. cc.tel_1, cc.tel_1_format, cc.tel_1_bu,
  516. cc.tel_2, cc.tel_2_format, cc.tel_2_bu,
  517. cc.tel_3, cc.tel_3_format, cc.tel_3_bu,
  518. cc.email_1, cc.email_1_bu,
  519. cc.email_2, cc.email_2_bu,
  520. cc.email_3, cc.email_3_bu,
  521. cc.whatsapp_1, cc.whatsapp_1_format, cc.whatsapp_1_bu,
  522. cc.whatsapp_2, cc.whatsapp_2_format, cc.whatsapp_2_bu,
  523. cc.whatsapp_3, cc.whatsapp_3_format, cc.whatsapp_3_bu,
  524. cc.wechat_1, cc.wechat_1_bu,
  525. cc.wechat_2, cc.wechat_2_bu,
  526. cc.wechat_3, cc.wechat_3_bu,
  527. cc.linkedin_1, cc.linkedin_1_bu,
  528. cc.linkedin_2, cc.linkedin_2_bu,
  529. cc.linkedin_3, cc.linkedin_3_bu,
  530. cc.facebook_1, cc.facebook_1_bu,
  531. cc.facebook_2, cc.facebook_2_bu,
  532. cc.facebook_3, cc.facebook_3_bu,
  533. cc.alibaba_1, cc.alibaba_1_bu,
  534. cc.alibaba_2, cc.alibaba_2_bu,
  535. cc.alibaba_3, cc.alibaba_3_bu
  536. FROM customer c
  537. LEFT JOIN customer_contact cc ON c.id = cc.customer_id
  538. WHERE 1=1";
  539. if (!empty($keyscode)) {
  540. $sqlStr .= " AND (c.cs_code LIKE '%$keyscode%'
  541. OR cc.contact_name LIKE '%$keyscode%'
  542. OR cc.tel_1 LIKE '%$keyscode%'
  543. OR cc.tel_2 LIKE '%$keyscode%'
  544. OR cc.tel_3 LIKE '%$keyscode%'
  545. OR cc.email_1 LIKE '%$keyscode%'
  546. OR cc.email_2 LIKE '%$keyscode%'
  547. OR cc.email_3 LIKE '%$keyscode%'
  548. OR cc.wechat_1 LIKE '%$keyscode%'
  549. OR cc.wechat_2 LIKE '%$keyscode%'
  550. OR cc.wechat_3 LIKE '%$keyscode%'
  551. OR cc.whatsapp_1_format LIKE '%$keyscode%'
  552. OR cc.whatsapp_2_format LIKE '%$keyscode%'
  553. OR cc.whatsapp_3_format LIKE '%$keyscode%'
  554. OR cc.linkedin_1 LIKE '%$keyscode%'
  555. OR cc.linkedin_2 LIKE '%$keyscode%'
  556. OR cc.linkedin_3 LIKE '%$keyscode%'
  557. OR cc.facebook_1 LIKE '%$keyscode%'
  558. OR cc.facebook_2 LIKE '%$keyscode%'
  559. OR cc.facebook_3 LIKE '%$keyscode%'
  560. OR cc.alibaba_1 LIKE '%$keyscode%'
  561. OR cc.alibaba_2 LIKE '%$keyscode%'
  562. OR cc.alibaba_3 LIKE '%$keyscode%'
  563. OR c.id IN (SELECT customerId FROM tagtable WHERE tagName LIKE '%$keyscode%'))";
  564. }
  565. $sqlStr .= " $fliterStr ORDER BY {$ordStr}c.cs_updatetime DESC";
  566. */
  567. ?>
  568. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  569. <html xmlns="http://www.w3.org/1999/xhtml">
  570. <head>
  571. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  572. <title>客户列表</title>
  573. <link rel="stylesheet" href="css/common.css" type="text/css" />
  574. <link rel="stylesheet" href="css/alert.css" type="text/css" />
  575. <script src="js/jquery-1.7.2.min.js"></script>
  576. <script src="js/js.js"></script>
  577. <style>
  578. body {
  579. margin: 0;
  580. background: #fff;
  581. }
  582. #man_zone {
  583. margin-left: 0;
  584. }
  585. /*解决操作换行变形问题*/
  586. .table2 .col9 {
  587. white-space: nowrap;
  588. overflow: hidden;
  589. }
  590. </style>
  591. </head>
  592. <body>
  593. <div id="man_zone">
  594. <?php
  595. $keys = $_GET['Keys'] ?? '';
  596. $keys = str_replace([" ", "+"], "", $keys);
  597. $keyscode = textEncode($keys);
  598. $page = $_GET['Page'] ?? 1;
  599. $filters = [
  600. 'Country' => $_GET['fliterCountry'] ?? '',
  601. 'Qudao' => $_GET['fliterQudao'] ?? '',
  602. 'Deal' => $_GET['fliterDeal'] ?? '',
  603. 'Business' => $_GET['fliterBusiness'] ?? '',
  604. 'Contact' => $_GET['fliterContact'] ?? ''
  605. ];
  606. $filterStr = "";
  607. $urlStr = "";
  608. // Build filter conditions
  609. if (!empty($filters['Country'])) {
  610. $filterStr .= " AND c.cs_country=" . (int)$filters['Country'];
  611. $urlStr .= "&fliterCountry=" . $filters['Country'];
  612. }
  613. if (!empty($filters['Qudao'])) {
  614. $filterStr .= " AND c.cs_from=" . (int)$filters['Qudao'];
  615. $urlStr .= "&fliterQudao=" . $filters['Qudao'];
  616. }
  617. if (!empty($filters['Deal'])) {
  618. $filterStr .= " AND c.cs_deal=" . (int)$filters['Deal'];
  619. $urlStr .= "&fliterDeal=" . $filters['Deal'];
  620. }
  621. if (!empty($filters['Business'])) {
  622. $filterStr .= " AND c.cs_type=" . (int)$filters['Business'];
  623. $urlStr .= "&fliterBusiness=" . $filters['Business'];
  624. }
  625. if (!empty($filters['Contact'])) {
  626. switch ($filters['Contact']) {
  627. case "1": $filterStr .= " AND c.id IN (SELECT customer_id FROM customer_contact WHERE tel_1 != '' OR tel_2 != '' OR tel_3 != '')"; break;
  628. case "2": $filterStr .= " AND c.id IN (SELECT customer_id FROM customer_contact WHERE wechat_1 != '' OR wechat_2 != '' OR wechat_3 != '')"; break;
  629. case "3": $filterStr .= " AND c.id IN (SELECT customer_id FROM customer_contact WHERE whatsapp_1 != '' OR whatsapp_2 != '' OR whatsapp_3 != '')"; break;
  630. case "4": $filterStr .= " AND c.id IN (SELECT customer_id FROM customer_contact WHERE email_1 != '' OR email_2 != '' OR email_3 != '')"; break;
  631. case "5": $filterStr .= " AND c.id IN (SELECT customer_id FROM customer_contact WHERE linkedin_1 != '' OR linkedin_2 != '' OR linkedin_3 != '')"; break;
  632. case "6": $filterStr .= " AND c.id IN (SELECT customer_id FROM customer_contact WHERE facebook_1 != '' OR facebook_2 != '' OR facebook_3 != '')"; break;
  633. case "7": $filterStr .= " AND c.id IN (SELECT customer_id FROM customer_contact WHERE alibaba_1 != '' OR alibaba_2 != '' OR alibaba_3 != '')"; break;
  634. }
  635. $urlStr .= "&fliterContact=" . $filters['Contact'];
  636. }
  637. $keys = urlencode($keys);
  638. $hrefstr = "?keys=" . $keys;
  639. ?>
  640. <form id="form1" method="post" action="?act=postchk&Keys=<?= $keys ?>&Page=<?= $page ?>" onSubmit="return false">
  641. <div class="fastSelect clear">
  642. <H1>搜索条件</H1>
  643. <div class="selectItem">
  644. <label>区域</label>
  645. <select name="fliterCountry" class="filterSearch">
  646. <option value="">请选择国家地区</option>
  647. <?php
  648. $result = $conn->query("SELECT id, countryName FROM country ORDER BY CONVERT(countryName USING gbk) COLLATE gbk_chinese_ci ASC");
  649. while ($row = $result->fetch_assoc()) {
  650. $selected = ($filters['Country'] == $row['id']) ? ' selected' : '';
  651. echo "<option value=\"{$row['id']}\"$selected>{$row['countryName']}</option>";
  652. }
  653. ?>
  654. </select>
  655. </div>
  656. <div class="selectItem">
  657. <label>来源渠道</label>
  658. <select name="fliterQudao" class="filterSearch">
  659. <option value="">请选择渠道</option>
  660. <?php
  661. $result = $conn->query("SELECT id, ch_name FROM qudao");
  662. while ($row = $result->fetch_assoc()) {
  663. $selected = ($filters['Qudao'] == $row['id']) ? ' selected' : '';
  664. echo "<option value=\"{$row['id']}\"$selected>{$row['ch_name']}</option>";
  665. }
  666. ?>
  667. </select>
  668. </div>
  669. <div class="selectItem">
  670. <label>跟进阶段</label>
  671. <select name="fliterDeal" class="filterSearch">
  672. <option value="">请选择</option>
  673. <option value="1"<?= ($filters['Deal'] == "1") ? ' selected' : '' ?>>背景调查</option>
  674. <option value="2"<?= ($filters['Deal'] == "2") ? ' selected' : '' ?>>明确需求</option>
  675. <option value="3"<?= ($filters['Deal'] == "3") ? ' selected' : '' ?>>已成交</option>
  676. </select>
  677. </div>
  678. <div class="selectItem">
  679. <label>客户类型</label>
  680. <select name="fliterBusiness" class="filterSearch">
  681. <option value="">请选择</option>
  682. <?php
  683. $result = $conn->query("SELECT id, businessType FROM clienttype");
  684. while ($row = $result->fetch_assoc()) {
  685. $selected = ($filters['Business'] == $row['id']) ? ' selected' : '';
  686. echo "<option value=\"{$row['id']}\"$selected>{$row['businessType']}</option>";
  687. }
  688. ?>
  689. </select>
  690. </div>
  691. <div class="selectItem">
  692. <label>联系方式</label>
  693. <select name="fliterContact" class="filterSearch">
  694. <option value="">请选择</option>
  695. <option value="1"<?= ($filters['Contact'] == "1") ? ' selected' : '' ?>>电话</option>
  696. <option value="2"<?= ($filters['Contact'] == "2") ? ' selected' : '' ?>>微信</option>
  697. <option value="3"<?= ($filters['Contact'] == "3") ? ' selected' : '' ?>>WhatsApp</option>
  698. <option value="4"<?= ($filters['Contact'] == "4") ? ' selected' : '' ?>>邮箱</option>
  699. <option value="5"<?= ($filters['Contact'] == "5") ? ' selected' : '' ?>>领英</option>
  700. <option value="6"<?= ($filters['Contact'] == "6") ? ' selected' : '' ?>>Facebook</option>
  701. <option value="7"<?= ($filters['Contact'] == "7") ? ' selected' : '' ?>>阿里巴巴</option>
  702. </select>
  703. </div>
  704. <div class="inputSearch">
  705. <input type="text" id="keys" class="inputTxt" placeholder="请输入搜索关键词"
  706. value="<?= empty($keyscode) ? '' : $keyscode ?>"
  707. onKeyDown="if(event.keyCode==13){location.href='?Keys='+encodeURIComponent(document.getElementById('keys').value)}" />
  708. <input type="button" id="searchgo" class="searchgo" value="go"
  709. onClick="location.href='?Keys='+encodeURIComponent(document.getElementById('keys').value)" />
  710. </div>
  711. </div>
  712. <div class="table2 em<?= $_SESSION['employee_id'] ?>">
  713. <div class="theader">
  714. <div class="col1"><input type="checkbox" name="chkall" id="chkall" onClick="chkboxall(this,'chkbox')" /></div>
  715. <div class="col2">序号</div>
  716. <div class="col3">客户编号</div>
  717. <div class="col4">渠道来源</div>
  718. <div class="col5">区域</div>
  719. <div class="col6">客户类型</div>
  720. <div class="col6">跟进阶段</div>
  721. <div class="colmark">颜色标记</div>
  722. <div class="col6">录入时间</div>
  723. <div class="col9">操作</div>
  724. </div>
  725. <?php
  726. $sql = "SELECT c.id, c.cs_code, c.cs_company, c.cs_country, c.cs_address, c.cs_from,
  727. c.cs_deal, c.cs_addtime, c.cs_updatetime, c.cs_belong, c.cs_note, c.cs_claimFrom,
  728. c.cs_chain, c.cs_dealdate, c.cs_type, c.cs_belongclient, c.allowedit,c.colortag
  729. FROM customer c
  730. WHERE c.is_silent=0 AND c.cs_deal>0 AND c.cs_belong=" . (int)$_SESSION['employee_id'];
  731. $searchPattern = mysqli_real_escape_string($conn, $keyscode);
  732. if(!empty($searchPattern)) {
  733. $sql .= " AND (c.cs_code LIKE '%$searchPattern%'
  734. OR c.id IN (SELECT customer_id FROM customer_contact WHERE
  735. contact_name LIKE '%$searchPattern%' OR
  736. tel_1 LIKE '%$searchPattern%' OR
  737. tel_2 LIKE '%$searchPattern%' OR
  738. tel_3 LIKE '%$searchPattern%' OR
  739. email_1 LIKE '%$searchPattern%' OR
  740. email_2 LIKE '%$searchPattern%' OR
  741. email_3 LIKE '%$searchPattern%' OR
  742. wechat_1 LIKE '%$searchPattern%' OR
  743. wechat_2 LIKE '%$searchPattern%' OR
  744. wechat_3 LIKE '%$searchPattern%' OR
  745. whatsapp_1_format LIKE '%$searchPattern%' OR
  746. whatsapp_2_format LIKE '%$searchPattern%' OR
  747. whatsapp_3_format LIKE '%$searchPattern%' OR
  748. linkedin_1 LIKE '%$searchPattern%' OR
  749. linkedin_2 LIKE '%$searchPattern%' OR
  750. linkedin_3 LIKE '%$searchPattern%' OR
  751. facebook_1 LIKE '%$searchPattern%' OR
  752. facebook_2 LIKE '%$searchPattern%' OR
  753. facebook_3 LIKE '%$searchPattern%' OR
  754. alibaba_1 LIKE '%$searchPattern%' OR
  755. alibaba_2 LIKE '%$searchPattern%' OR
  756. alibaba_3 LIKE '%$searchPattern%')
  757. OR c.id IN (SELECT customerId FROM tagtable WHERE tagName LIKE '%$searchPattern%'))";
  758. }
  759. $sql .= " $filterStr ORDER BY c.colortag DESC, c.id DESC";
  760. $result = mysqli_query($conn, $sql);
  761. // Pagination logic
  762. $perPage = 20;
  763. $totalRecords = mysqli_num_rows($result);
  764. $totalPages = max(1, ceil($totalRecords / $perPage));
  765. $page = max(1, min((int)$page, $totalPages));
  766. $offset = max(0, ($page - 1) * $perPage);
  767. // Add pagination to query
  768. $sql .= " LIMIT $offset, $perPage";
  769. $result = mysqli_query($conn, $sql);
  770. if (mysqli_num_rows($result) > 0) {
  771. $tempNum = $offset;
  772. while ($row = mysqli_fetch_assoc($result)) {
  773. $tempNum++;
  774. ?>
  775. <div class="tline color<?= $row['colortag'] ?>">
  776. <div class="col1" align="center"><input type="checkbox" name="chkbox[]" value="<?= $row['id'] ?>" /></div>
  777. <div class="col2"><?= $tempNum ?></div>
  778. <div class="col3 slidepanel"><?= $row['cs_code'] ?>
  779. <?php if ($row['cs_claimFrom'] > 0): ?>
  780. <img src="../images/yijiao.png" class="handover" title="来自认领">
  781. <?php endif; ?>
  782. </div>
  783. <div class="col4">
  784. <?php
  785. $qudao = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
  786. echo $qudao->num_rows > 0 ? $qudao->fetch_assoc()['ch_name'] : '未填写';
  787. ?>
  788. </div>
  789. <div class="col5">
  790. <?php
  791. $country = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
  792. echo $country->num_rows > 0 ? $country->fetch_assoc()['countryName'] : '未填写';
  793. ?>
  794. </div>
  795. <div class="col6">
  796. <?php
  797. // 使用JOIN查询一次性获取所有业务类型
  798. $businessTypes = $conn->query("
  799. SELECT ct.businessType
  800. FROM customer_business_type cbt
  801. JOIN clienttype ct ON cbt.business_type_id = ct.id
  802. WHERE cbt.customer_id = " . (int)$row['id']);
  803. if ($businessTypes->num_rows > 0) {
  804. $types = [];
  805. while ($type = $businessTypes->fetch_assoc()) {
  806. $types[] = $type['businessType'];
  807. }
  808. // 显示所有业务类型,用顿号分隔
  809. echo implode('、', $types);
  810. } else {
  811. echo '未填写';
  812. }
  813. ?>
  814. </div>
  815. <div class="col6">
  816. <?php
  817. switch ($row['cs_deal']) {
  818. case 3: echo '<span style="color:red;">成交</span>'; break;
  819. case 2: echo '明确需求'; break;
  820. case 1: echo '背景调查'; break;
  821. default: echo '无响应';
  822. }
  823. ?>
  824. </div>
  825. <div class="colmark colormark">
  826. <ul class="colorlist" data-id="<?= $row['id'] ?>">
  827. <li value="1" class="color1"></li>
  828. <li value="2" class="color2"></li>
  829. <li value="3" class="color3"></li>
  830. <li value="4" class="color4"></li>
  831. <li value="0" class="color0"></li>
  832. </ul>
  833. </div>
  834. <div class="col6"><?= $row['cs_addtime'] ?></div>
  835. <div class="col9">
  836. <a href="customerEdit.php?Keys=<?= $keys ?>&fliterDeal=<?= $filters['Deal'] ?>&fliterBusiness=<?= $filters['Business'] ?>&Page=<?= $page ?>&act=edit&id=<?= $row['id'] ?>" class="ico_edit ico">修改</a>
  837. <a href="order_add.php?customer_id=<?= $row['id'] ?>" class="ico_add ico">添加订单</a>
  838. </div>
  839. </div>
  840. <div class="notepanel clear">
  841. <div class="noteItem">联系方式</div>
  842. <div class="lx">
  843. <?php
  844. // Fetch all contacts for this customer
  845. $contact_sql = "SELECT * FROM customer_contact WHERE customer_id = " . $row['id'];
  846. $contact_result = mysqli_query($conn, $contact_sql);
  847. while ($contact = mysqli_fetch_assoc($contact_result)) {
  848. ?>
  849. <div class="contact-block">
  850. <?php if(!empty($contact['contact_name'])): ?>
  851. <div class="contact-name"><?= $contact['contact_name'] ?></div>
  852. <?php endif; ?>
  853. <div class="tel">
  854. <?php if(!empty($contact['tel_1'])): ?>
  855. <div><?= $contact['tel_1'] ?></div>
  856. <?php endif; ?>
  857. <?php if(!empty($contact['tel_2'])): ?>
  858. <div><?= $contact['tel_2'] ?></div>
  859. <?php endif; ?>
  860. <?php if(!empty($contact['tel_3'])): ?>
  861. <div><?= $contact['tel_3'] ?></div>
  862. <?php endif; ?>
  863. </div>
  864. <div class="mail">
  865. <?php if(!empty($contact['email_1'])): ?>
  866. <div><a href="mailto:<?= $contact['email_1'] ?>"><?= $contact['email_1'] ?></a></div>
  867. <?php endif; ?>
  868. <?php if(!empty($contact['email_2'])): ?>
  869. <div><a href="mailto:<?= $contact['email_2'] ?>"><?= $contact['email_2'] ?></a></div>
  870. <?php endif; ?>
  871. <?php if(!empty($contact['email_3'])): ?>
  872. <div><a href="mailto:<?= $contact['email_3'] ?>"><?= $contact['email_3'] ?></a></div>
  873. <?php endif; ?>
  874. </div>
  875. <div class="whatsapp">
  876. <?php if(!empty($contact['whatsapp_1'])): ?>
  877. <div><?= $contact['whatsapp_1'] ?></div>
  878. <?php endif; ?>
  879. <?php if(!empty($contact['whatsapp_2'])): ?>
  880. <div><?= $contact['whatsapp_2'] ?></div>
  881. <?php endif; ?>
  882. <?php if(!empty($contact['whatsapp_3'])): ?>
  883. <div><?= $contact['whatsapp_3'] ?></div>
  884. <?php endif; ?>
  885. </div>
  886. <div class="wechat">
  887. <?php if(!empty($contact['wechat_1'])): ?>
  888. <div><?= $contact['wechat_1'] ?></div>
  889. <?php endif; ?>
  890. <?php if(!empty($contact['wechat_2'])): ?>
  891. <div><?= $contact['wechat_2'] ?></div>
  892. <?php endif; ?>
  893. <?php if(!empty($contact['wechat_3'])): ?>
  894. <div><?= $contact['wechat_3'] ?></div>
  895. <?php endif; ?>
  896. </div>
  897. <div class="linkedin">
  898. <?php if(!empty($contact['linkedin_1'])): ?>
  899. <div><?= $contact['linkedin_1'] ?></div>
  900. <?php endif; ?>
  901. <?php if(!empty($contact['linkedin_2'])): ?>
  902. <div><?= $contact['linkedin_2'] ?></div>
  903. <?php endif; ?>
  904. <?php if(!empty($contact['linkedin_3'])): ?>
  905. <div><?= $contact['linkedin_3'] ?></div>
  906. <?php endif; ?>
  907. </div>
  908. <div class="facebook">
  909. <?php if(!empty($contact['facebook_1'])): ?>
  910. <div><?= $contact['facebook_1'] ?></div>
  911. <?php endif; ?>
  912. <?php if(!empty($contact['facebook_2'])): ?>
  913. <div><?= $contact['facebook_2'] ?></div>
  914. <?php endif; ?>
  915. <?php if(!empty($contact['facebook_3'])): ?>
  916. <div><?= $contact['facebook_3'] ?></div>
  917. <?php endif; ?>
  918. </div>
  919. <div class="alibaba">
  920. <?php if(!empty($contact['alibaba_1'])): ?>
  921. <div><?= $contact['alibaba_1'] ?></div>
  922. <?php endif; ?>
  923. <?php if(!empty($contact['alibaba_2'])): ?>
  924. <div><?= $contact['alibaba_2'] ?></div>
  925. <?php endif; ?>
  926. <?php if(!empty($contact['alibaba_3'])): ?>
  927. <div><?= $contact['alibaba_3'] ?></div>
  928. <?php endif; ?>
  929. </div>
  930. </div>
  931. <?php } ?>
  932. </div>
  933. <div class="noteItem2">备注</div>
  934. <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>
  935. </div>
  936. <?php
  937. }
  938. } else {
  939. if (empty($keys)) {
  940. echo '<tr><div align="center" colspan="9">Sorry,当前暂无信息</div></tr>';
  941. } else {
  942. echo '<tr><div align="center" colspan="9"><a href="?">Sorry,没有找到"' .
  943. htmlspecialcharsFix($keyscode) . '"相关的信息,点击返回</a></div></tr>';
  944. }
  945. }
  946. ?>
  947. <div colspan="9">
  948. <div class="showpagebox">
  949. <?php
  950. if ($totalPages > 1) {
  951. $pageName = "?Keys=$keys$urlStr&";
  952. $pageLen = 3;
  953. if ($page > 1) {
  954. echo "<a href=\"{$pageName}Page=1\">首页</a>";
  955. echo "<a href=\"{$pageName}Page=" . ($page - 1) . "\">上一页</a>";
  956. }
  957. if ($pageLen * 2 + 1 >= $totalPages) {
  958. $startPage = 1;
  959. $endPage = $totalPages;
  960. } else {
  961. if ($page <= $pageLen + 1) {
  962. $startPage = 1;
  963. $endPage = $pageLen * 2 + 1;
  964. } else {
  965. $startPage = $page - $pageLen;
  966. $endPage = $page + $pageLen;
  967. }
  968. if ($page + $pageLen > $totalPages) {
  969. $startPage = $totalPages - $pageLen * 2;
  970. $endPage = $totalPages;
  971. }
  972. }
  973. for ($i = $startPage; $i <= $endPage; $i++) {
  974. if ($i == $page) {
  975. echo "<a class=\"current\">$i</a>";
  976. } else {
  977. echo "<a href=\"{$pageName}Page=$i\">$i</a>";
  978. }
  979. }
  980. if ($page < $totalPages) {
  981. if ($totalPages - $page > $pageLen) {
  982. echo "<a href=\"{$pageName}Page=$totalPages\">...$totalPages</a>";
  983. }
  984. echo "<a href=\"{$pageName}Page=" . ($page + 1) . "\">下一页</a>";
  985. echo "<a href=\"{$pageName}Page=$totalPages\">尾页</a>";
  986. }
  987. }
  988. ?>
  989. </div>
  990. <?php require_once 'postchkbox.php'; ?>
  991. </div>
  992. </div>
  993. </form>
  994. </div>
  995. </body>
  996. </html>