customers.php 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
  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. $sql = "UPDATE customer SET
  423. cs_updatetime = NOW(),
  424. cs_code = REPLACE(cs_code, '-', '/{$employeeCode}-'),
  425. cs_belong = {$employeeId},
  426. cs_chain = CONCAT(cs_chain, ',{$employeeId}')
  427. WHERE id IN ({$ids})";
  428. mysqli_query($conn, $sql);
  429. // 记录操作日志
  430. $action = "{$_SESSION['employee_name']} 批量转移{$count}个客户({$ids})给业务员【{$employeeName}】";
  431. logAction($action);
  432. } else {
  433. switch($chkact) {
  434. case "0":
  435. case "1":
  436. case "2":
  437. $sql = "UPDATE customer SET cs_deal = $chkact WHERE id IN ($ids)";
  438. break;
  439. case "-1":
  440. // 删除客户记录和联系人记录(依靠外键级联删除)
  441. $sql = "DELETE FROM customer WHERE id IN ($ids)";
  442. break;
  443. }
  444. if (isset($sql)) {
  445. mysqli_query($conn, $sql);
  446. }
  447. }
  448. $keys = urlencode($_GET['Keys'] ?? '');
  449. $page = $_GET['Page'] ?? '';
  450. header("Location: ?keys=$keys&Page=$page$urlStr");
  451. exit;
  452. }
  453. }
  454. /*
  455. // 处理筛选条件
  456. $fliterQudao = $_GET['fliterQudao'] ?? '';
  457. $fliterDeal = $_GET['fliterDeal'] ?? '';
  458. $fliterTeam = $_GET['fliterTeam'] ?? '';
  459. $fliterContact = $_GET['fliterContact'] ?? '';
  460. $fliterEmployee = $_GET['fliterEmployee'] ?? '';
  461. $fliterStr = "";
  462. if (!empty($fliterQudao)) {
  463. $fliterStr .= " AND c.cs_from = " . intval($fliterQudao);
  464. $urlStr .= "&fliterQudao=" . $fliterQudao;
  465. }
  466. if (!empty($fliterDeal)) {
  467. $fliterStr .= " AND c.cs_deal = " . intval($fliterDeal);
  468. $urlStr .= "&fliterDeal=" . $fliterDeal;
  469. }
  470. if (!empty($fliterTeam)) {
  471. $fliterStr .= " AND (c.cs_belong = " . intval($fliterTeam) .
  472. " OR c.cs_belong IN (SELECT id FROM employee WHERE em_role = " . intval($fliterTeam) . "))";
  473. $urlStr .= "&fliterTeam=" . $fliterTeam;
  474. }
  475. if (!empty($fliterEmployee)) {
  476. $fliterStr .= " AND c.cs_belong = " . intval($fliterEmployee);
  477. $urlStr .= "&fliterEmployee=" . $fliterEmployee;
  478. }
  479. if (!empty($fliterContact)) {
  480. switch ($fliterContact) {
  481. case "1": $fliterStr .= " AND (cc.tel_1 != '' OR cc.tel_2 != '' OR cc.tel_3 != '')"; break;
  482. case "2": $fliterStr .= " AND (cc.wechat_1 != '' OR cc.wechat_2 != '' OR cc.wechat_3 != '')"; break;
  483. case "3": $fliterStr .= " AND (cc.whatsapp_1 != '' OR cc.whatsapp_2 != '' OR cc.whatsapp_3 != '')"; break;
  484. case "4": $fliterStr .= " AND (cc.email_1 != '' OR cc.email_2 != '' OR cc.email_3 != '')"; break;
  485. case "5": $fliterStr .= " AND (cc.linkedin_1 != '' OR cc.linkedin_2 != '' OR cc.linkedin_3 != '')"; break;
  486. case "6": $fliterStr .= " AND (cc.facebook_1 != '' OR cc.facebook_2 != '' OR cc.facebook_3 != '')"; break;
  487. case "7": $fliterStr .= " AND (cc.alibaba_1 != '' OR cc.alibaba_2 != '' OR cc.alibaba_3 != '')"; break;
  488. }
  489. $urlStr .= "&fliterContact=" . $fliterContact;
  490. }
  491. // 搜索和排序
  492. $keys = $_GET['Keys'] ?? '';
  493. $keyscode = textEncode($keys);
  494. $page = $_GET['Page'] ?? 1;
  495. $ord = $_GET['Ord'] ?? '';
  496. $ordStr = !empty($ord) ? "$ord," : "";
  497. // 构建查询SQL - 修改为联合查询
  498. $sqlStr = "SELECT c.id, c.cs_code, c.cs_company, c.cs_country, c.cs_address, c.cs_from,
  499. c.cs_deal, c.cs_addtime, c.cs_updatetime, c.cs_belong, c.cs_note, c.cs_claimFrom,
  500. c.cs_chain, c.cs_dealdate, c.cs_type, c.cs_belongclient, c.allowedit,c.colortag,
  501. cc.id as contact_id, cc.contact_name,
  502. cc.tel_1, cc.tel_1_format, cc.tel_1_bu,
  503. cc.tel_2, cc.tel_2_format, cc.tel_2_bu,
  504. cc.tel_3, cc.tel_3_format, cc.tel_3_bu,
  505. cc.email_1, cc.email_1_bu,
  506. cc.email_2, cc.email_2_bu,
  507. cc.email_3, cc.email_3_bu,
  508. cc.whatsapp_1, cc.whatsapp_1_format, cc.whatsapp_1_bu,
  509. cc.whatsapp_2, cc.whatsapp_2_format, cc.whatsapp_2_bu,
  510. cc.whatsapp_3, cc.whatsapp_3_format, cc.whatsapp_3_bu,
  511. cc.wechat_1, cc.wechat_1_bu,
  512. cc.wechat_2, cc.wechat_2_bu,
  513. cc.wechat_3, cc.wechat_3_bu,
  514. cc.linkedin_1, cc.linkedin_1_bu,
  515. cc.linkedin_2, cc.linkedin_2_bu,
  516. cc.linkedin_3, cc.linkedin_3_bu,
  517. cc.facebook_1, cc.facebook_1_bu,
  518. cc.facebook_2, cc.facebook_2_bu,
  519. cc.facebook_3, cc.facebook_3_bu,
  520. cc.alibaba_1, cc.alibaba_1_bu,
  521. cc.alibaba_2, cc.alibaba_2_bu,
  522. cc.alibaba_3, cc.alibaba_3_bu
  523. FROM customer c
  524. LEFT JOIN customer_contact cc ON c.id = cc.customer_id
  525. WHERE 1=1";
  526. if (!empty($keyscode)) {
  527. $sqlStr .= " AND (c.cs_code LIKE '%$keyscode%'
  528. OR cc.contact_name LIKE '%$keyscode%'
  529. OR cc.tel_1 LIKE '%$keyscode%'
  530. OR cc.tel_2 LIKE '%$keyscode%'
  531. OR cc.tel_3 LIKE '%$keyscode%'
  532. OR cc.email_1 LIKE '%$keyscode%'
  533. OR cc.email_2 LIKE '%$keyscode%'
  534. OR cc.email_3 LIKE '%$keyscode%'
  535. OR cc.wechat_1 LIKE '%$keyscode%'
  536. OR cc.wechat_2 LIKE '%$keyscode%'
  537. OR cc.wechat_3 LIKE '%$keyscode%'
  538. OR cc.whatsapp_1_format LIKE '%$keyscode%'
  539. OR cc.whatsapp_2_format LIKE '%$keyscode%'
  540. OR cc.whatsapp_3_format LIKE '%$keyscode%'
  541. OR cc.linkedin_1 LIKE '%$keyscode%'
  542. OR cc.linkedin_2 LIKE '%$keyscode%'
  543. OR cc.linkedin_3 LIKE '%$keyscode%'
  544. OR cc.facebook_1 LIKE '%$keyscode%'
  545. OR cc.facebook_2 LIKE '%$keyscode%'
  546. OR cc.facebook_3 LIKE '%$keyscode%'
  547. OR cc.alibaba_1 LIKE '%$keyscode%'
  548. OR cc.alibaba_2 LIKE '%$keyscode%'
  549. OR cc.alibaba_3 LIKE '%$keyscode%'
  550. OR c.id IN (SELECT customerId FROM tagtable WHERE tagName LIKE '%$keyscode%'))";
  551. }
  552. $sqlStr .= " $fliterStr ORDER BY {$ordStr}c.cs_updatetime DESC";
  553. */
  554. ?>
  555. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  556. <html xmlns="http://www.w3.org/1999/xhtml">
  557. <head>
  558. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  559. <title>客户列表</title>
  560. <link rel="stylesheet" href="css/common.css" type="text/css" />
  561. <link rel="stylesheet" href="css/alert.css" type="text/css" />
  562. <script src="js/jquery-1.7.2.min.js"></script>
  563. <script src="js/js.js"></script>
  564. <style>
  565. body {
  566. margin: 0;
  567. padding: 20px;
  568. background: #fff;
  569. }
  570. #man_zone {
  571. margin-left: 0;
  572. }
  573. </style>
  574. </head>
  575. <body>
  576. <div id="man_zone">
  577. <?php
  578. $keys = $_GET['Keys'] ?? '';
  579. $keys = str_replace([" ", "+"], "", $keys);
  580. $keyscode = textEncode($keys);
  581. $page = $_GET['Page'] ?? 1;
  582. $filters = [
  583. 'Country' => $_GET['fliterCountry'] ?? '',
  584. 'Qudao' => $_GET['fliterQudao'] ?? '',
  585. 'Deal' => $_GET['fliterDeal'] ?? '',
  586. 'Business' => $_GET['fliterBusiness'] ?? '',
  587. 'Contact' => $_GET['fliterContact'] ?? ''
  588. ];
  589. $filterStr = "";
  590. $urlStr = "";
  591. // Build filter conditions
  592. if (!empty($filters['Country'])) {
  593. $filterStr .= " AND c.cs_country=" . (int)$filters['Country'];
  594. $urlStr .= "&fliterCountry=" . $filters['Country'];
  595. }
  596. if (!empty($filters['Qudao'])) {
  597. $filterStr .= " AND c.cs_from=" . (int)$filters['Qudao'];
  598. $urlStr .= "&fliterQudao=" . $filters['Qudao'];
  599. }
  600. if (!empty($filters['Deal'])) {
  601. $filterStr .= " AND c.cs_deal=" . (int)$filters['Deal'];
  602. $urlStr .= "&fliterDeal=" . $filters['Deal'];
  603. }
  604. if (!empty($filters['Business'])) {
  605. $filterStr .= " AND c.cs_type=" . (int)$filters['Business'];
  606. $urlStr .= "&fliterBusiness=" . $filters['Business'];
  607. }
  608. if (!empty($filters['Contact'])) {
  609. switch ($filters['Contact']) {
  610. case "1": $filterStr .= " AND c.id IN (SELECT customer_id FROM customer_contact WHERE tel_1 != '' OR tel_2 != '' OR tel_3 != '')"; break;
  611. case "2": $filterStr .= " AND c.id IN (SELECT customer_id FROM customer_contact WHERE wechat_1 != '' OR wechat_2 != '' OR wechat_3 != '')"; break;
  612. case "3": $filterStr .= " AND c.id IN (SELECT customer_id FROM customer_contact WHERE whatsapp_1 != '' OR whatsapp_2 != '' OR whatsapp_3 != '')"; break;
  613. case "4": $filterStr .= " AND c.id IN (SELECT customer_id FROM customer_contact WHERE email_1 != '' OR email_2 != '' OR email_3 != '')"; break;
  614. case "5": $filterStr .= " AND c.id IN (SELECT customer_id FROM customer_contact WHERE linkedin_1 != '' OR linkedin_2 != '' OR linkedin_3 != '')"; break;
  615. case "6": $filterStr .= " AND c.id IN (SELECT customer_id FROM customer_contact WHERE facebook_1 != '' OR facebook_2 != '' OR facebook_3 != '')"; break;
  616. case "7": $filterStr .= " AND c.id IN (SELECT customer_id FROM customer_contact WHERE alibaba_1 != '' OR alibaba_2 != '' OR alibaba_3 != '')"; break;
  617. }
  618. $urlStr .= "&fliterContact=" . $filters['Contact'];
  619. }
  620. $keys = urlencode($keys);
  621. $hrefstr = "?keys=" . $keys;
  622. ?>
  623. <form id="form1" method="post" action="?act=postchk&Keys=<?= $keys ?>&Page=<?= $page ?>" onSubmit="return false">
  624. <div class="fastSelect clear">
  625. <H1>搜索条件</H1>
  626. <div class="selectItem">
  627. <label>区域</label>
  628. <select name="fliterCountry" class="filterSearch">
  629. <option value="">请选择国家地区</option>
  630. <?php
  631. $result = $conn->query("SELECT id, countryName FROM country ORDER BY CONVERT(countryName USING gbk) COLLATE gbk_chinese_ci ASC");
  632. while ($row = $result->fetch_assoc()) {
  633. $selected = ($filters['Country'] == $row['id']) ? ' selected' : '';
  634. echo "<option value=\"{$row['id']}\"$selected>{$row['countryName']}</option>";
  635. }
  636. ?>
  637. </select>
  638. </div>
  639. <div class="selectItem">
  640. <label>来源渠道</label>
  641. <select name="fliterQudao" class="filterSearch">
  642. <option value="">请选择渠道</option>
  643. <?php
  644. $result = $conn->query("SELECT id, ch_name FROM qudao");
  645. while ($row = $result->fetch_assoc()) {
  646. $selected = ($filters['Qudao'] == $row['id']) ? ' selected' : '';
  647. echo "<option value=\"{$row['id']}\"$selected>{$row['ch_name']}</option>";
  648. }
  649. ?>
  650. </select>
  651. </div>
  652. <div class="selectItem">
  653. <label>跟进阶段</label>
  654. <select name="fliterDeal" class="filterSearch">
  655. <option value="">请选择</option>
  656. <option value="1"<?= ($filters['Deal'] == "1") ? ' selected' : '' ?>>背景调查</option>
  657. <option value="2"<?= ($filters['Deal'] == "2") ? ' selected' : '' ?>>明确需求</option>
  658. <option value="3"<?= ($filters['Deal'] == "3") ? ' selected' : '' ?>>已成交</option>
  659. </select>
  660. </div>
  661. <div class="selectItem">
  662. <label>客户类型</label>
  663. <select name="fliterBusiness" class="filterSearch">
  664. <option value="">请选择</option>
  665. <?php
  666. $result = $conn->query("SELECT id, businessType FROM clienttype");
  667. while ($row = $result->fetch_assoc()) {
  668. $selected = ($filters['Business'] == $row['id']) ? ' selected' : '';
  669. echo "<option value=\"{$row['id']}\"$selected>{$row['businessType']}</option>";
  670. }
  671. ?>
  672. </select>
  673. </div>
  674. <div class="selectItem">
  675. <label>联系方式</label>
  676. <select name="fliterContact" class="filterSearch">
  677. <option value="">请选择</option>
  678. <option value="1"<?= ($filters['Contact'] == "1") ? ' selected' : '' ?>>电话</option>
  679. <option value="2"<?= ($filters['Contact'] == "2") ? ' selected' : '' ?>>微信</option>
  680. <option value="3"<?= ($filters['Contact'] == "3") ? ' selected' : '' ?>>WhatsApp</option>
  681. <option value="4"<?= ($filters['Contact'] == "4") ? ' selected' : '' ?>>邮箱</option>
  682. <option value="5"<?= ($filters['Contact'] == "5") ? ' selected' : '' ?>>领英</option>
  683. <option value="6"<?= ($filters['Contact'] == "6") ? ' selected' : '' ?>>Facebook</option>
  684. <option value="7"<?= ($filters['Contact'] == "7") ? ' selected' : '' ?>>阿里巴巴</option>
  685. </select>
  686. </div>
  687. <div class="inputSearch">
  688. <input type="text" id="keys" class="inputTxt" placeholder="请输入搜索关键词"
  689. value="<?= empty($keyscode) ? '' : $keyscode ?>"
  690. onKeyDown="if(event.keyCode==13){location.href='?Keys='+encodeURIComponent(document.getElementById('keys').value)}" />
  691. <input type="button" id="searchgo" class="searchgo" value="go"
  692. onClick="location.href='?Keys='+encodeURIComponent(document.getElementById('keys').value)" />
  693. </div>
  694. </div>
  695. <div class="table2 em<?= $_SESSION['employee_id'] ?>">
  696. <div class="theader">
  697. <div class="col1"><input type="checkbox" name="chkall" id="chkall" onClick="chkboxall(this,'chkbox')" /></div>
  698. <div class="col2">序号</div>
  699. <div class="col3">客户编号</div>
  700. <div class="col4">渠道来源</div>
  701. <div class="col5">区域</div>
  702. <div class="col6">客户类型</div>
  703. <div class="col6">跟进阶段</div>
  704. <div class="colmark">颜色标记</div>
  705. <div class="col6">录入时间</div>
  706. <div class="col9">操作</div>
  707. </div>
  708. <?php
  709. $sql = "SELECT c.id, c.cs_code, c.cs_company, c.cs_country, c.cs_address, c.cs_from,
  710. c.cs_deal, c.cs_addtime, c.cs_updatetime, c.cs_belong, c.cs_note, c.cs_claimFrom,
  711. c.cs_chain, c.cs_dealdate, c.cs_type, c.cs_belongclient, c.allowedit,c.colortag
  712. FROM customer c
  713. WHERE c.is_silent=0 AND c.cs_deal>0 AND c.cs_belong=" . (int)$_SESSION['employee_id'];
  714. $searchPattern = mysqli_real_escape_string($conn, $keyscode);
  715. if(!empty($searchPattern)) {
  716. $sql .= " AND (c.cs_code LIKE '%$searchPattern%'
  717. OR c.id IN (SELECT customer_id FROM customer_contact WHERE
  718. contact_name LIKE '%$searchPattern%' OR
  719. tel_1 LIKE '%$searchPattern%' OR
  720. tel_2 LIKE '%$searchPattern%' OR
  721. tel_3 LIKE '%$searchPattern%' OR
  722. email_1 LIKE '%$searchPattern%' OR
  723. email_2 LIKE '%$searchPattern%' OR
  724. email_3 LIKE '%$searchPattern%' OR
  725. wechat_1 LIKE '%$searchPattern%' OR
  726. wechat_2 LIKE '%$searchPattern%' OR
  727. wechat_3 LIKE '%$searchPattern%' OR
  728. whatsapp_1_format LIKE '%$searchPattern%' OR
  729. whatsapp_2_format LIKE '%$searchPattern%' OR
  730. whatsapp_3_format LIKE '%$searchPattern%' OR
  731. linkedin_1 LIKE '%$searchPattern%' OR
  732. linkedin_2 LIKE '%$searchPattern%' OR
  733. linkedin_3 LIKE '%$searchPattern%' OR
  734. facebook_1 LIKE '%$searchPattern%' OR
  735. facebook_2 LIKE '%$searchPattern%' OR
  736. facebook_3 LIKE '%$searchPattern%' OR
  737. alibaba_1 LIKE '%$searchPattern%' OR
  738. alibaba_2 LIKE '%$searchPattern%' OR
  739. alibaba_3 LIKE '%$searchPattern%')
  740. OR c.id IN (SELECT customerId FROM tagtable WHERE tagName LIKE '%$searchPattern%'))";
  741. }
  742. $sql .= " $filterStr ORDER BY c.colortag DESC, c.id DESC";
  743. $result = mysqli_query($conn, $sql);
  744. // Pagination logic
  745. $perPage = 20;
  746. $totalRecords = mysqli_num_rows($result);
  747. $totalPages = max(1, ceil($totalRecords / $perPage));
  748. $page = max(1, min((int)$page, $totalPages));
  749. $offset = max(0, ($page - 1) * $perPage);
  750. // Add pagination to query
  751. $sql .= " LIMIT $offset, $perPage";
  752. $result = mysqli_query($conn, $sql);
  753. if (mysqli_num_rows($result) > 0) {
  754. $tempNum = $offset;
  755. while ($row = mysqli_fetch_assoc($result)) {
  756. $tempNum++;
  757. ?>
  758. <div class="tline color<?= $row['colortag'] ?>">
  759. <div class="col1" align="center"><input type="checkbox" name="chkbox[]" value="<?= $row['id'] ?>" /></div>
  760. <div class="col2"><?= $tempNum ?></div>
  761. <div class="col3 slidepanel"><?= $row['cs_code'] ?>
  762. <?php if ($row['cs_claimFrom'] > 0): ?>
  763. <img src="../images/yijiao.png" class="handover" title="来自认领">
  764. <?php endif; ?>
  765. </div>
  766. <div class="col4">
  767. <?php
  768. $qudao = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
  769. echo $qudao->num_rows > 0 ? $qudao->fetch_assoc()['ch_name'] : '未填写';
  770. ?>
  771. </div>
  772. <div class="col5">
  773. <?php
  774. $country = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
  775. echo $country->num_rows > 0 ? $country->fetch_assoc()['countryName'] : '未填写';
  776. ?>
  777. </div>
  778. <div class="col6">
  779. <?php
  780. $clientType = $conn->query("SELECT businessType FROM clienttype WHERE id=" . (int)$row['cs_type']);
  781. echo $clientType->num_rows > 0 ? $clientType->fetch_assoc()['businessType'] : '未填写';
  782. ?>
  783. </div>
  784. <div class="col6">
  785. <?php
  786. switch ($row['cs_deal']) {
  787. case 3: echo '<span style="color:red;">成交</span>'; break;
  788. case 2: echo '明确需求'; break;
  789. case 1: echo '背景调查'; break;
  790. default: echo '无响应';
  791. }
  792. ?>
  793. </div>
  794. <div class="colmark colormark">
  795. <ul class="colorlist" data-id="<?= $row['id'] ?>">
  796. <li value="1" class="color1"></li>
  797. <li value="2" class="color2"></li>
  798. <li value="3" class="color3"></li>
  799. <li value="4" class="color4"></li>
  800. <li value="0" class="color0"></li>
  801. </ul>
  802. </div>
  803. <div class="col6"><?= $row['cs_addtime'] ?></div>
  804. <div class="col9">
  805. <a href="customerEdit.php?Keys=<?= $keys ?>&fliterDeal=<?= $filters['Deal'] ?>&fliterBusiness=<?= $filters['Business'] ?>&Page=<?= $page ?>&act=edit&id=<?= $row['id'] ?>" class="ico_edit ico">修改</a>
  806. <a href="order_add.php?customer_id=<?= $row['id'] ?>" class="ico_add ico">添加订单</a>
  807. </div>
  808. </div>
  809. <div class="notepanel clear">
  810. <div class="noteItem">联系方式</div>
  811. <div class="lx">
  812. <?php
  813. // Fetch all contacts for this customer
  814. $contact_sql = "SELECT * FROM customer_contact WHERE customer_id = " . $row['id'];
  815. $contact_result = mysqli_query($conn, $contact_sql);
  816. while ($contact = mysqli_fetch_assoc($contact_result)) {
  817. ?>
  818. <div class="contact-block">
  819. <?php if(!empty($contact['contact_name'])): ?>
  820. <div class="contact-name"><?= $contact['contact_name'] ?></div>
  821. <?php endif; ?>
  822. <div class="tel">
  823. <?php if(!empty($contact['tel_1'])): ?>
  824. <div><?= $contact['tel_1'] ?></div>
  825. <?php endif; ?>
  826. <?php if(!empty($contact['tel_2'])): ?>
  827. <div><?= $contact['tel_2'] ?></div>
  828. <?php endif; ?>
  829. <?php if(!empty($contact['tel_3'])): ?>
  830. <div><?= $contact['tel_3'] ?></div>
  831. <?php endif; ?>
  832. </div>
  833. <div class="mail">
  834. <?php if(!empty($contact['email_1'])): ?>
  835. <div><a href="mailto:<?= $contact['email_1'] ?>"><?= $contact['email_1'] ?></a></div>
  836. <?php endif; ?>
  837. <?php if(!empty($contact['email_2'])): ?>
  838. <div><a href="mailto:<?= $contact['email_2'] ?>"><?= $contact['email_2'] ?></a></div>
  839. <?php endif; ?>
  840. <?php if(!empty($contact['email_3'])): ?>
  841. <div><a href="mailto:<?= $contact['email_3'] ?>"><?= $contact['email_3'] ?></a></div>
  842. <?php endif; ?>
  843. </div>
  844. <div class="whatsapp">
  845. <?php if(!empty($contact['whatsapp_1'])): ?>
  846. <div><?= $contact['whatsapp_1'] ?></div>
  847. <?php endif; ?>
  848. <?php if(!empty($contact['whatsapp_2'])): ?>
  849. <div><?= $contact['whatsapp_2'] ?></div>
  850. <?php endif; ?>
  851. <?php if(!empty($contact['whatsapp_3'])): ?>
  852. <div><?= $contact['whatsapp_3'] ?></div>
  853. <?php endif; ?>
  854. </div>
  855. <div class="wechat">
  856. <?php if(!empty($contact['wechat_1'])): ?>
  857. <div><?= $contact['wechat_1'] ?></div>
  858. <?php endif; ?>
  859. <?php if(!empty($contact['wechat_2'])): ?>
  860. <div><?= $contact['wechat_2'] ?></div>
  861. <?php endif; ?>
  862. <?php if(!empty($contact['wechat_3'])): ?>
  863. <div><?= $contact['wechat_3'] ?></div>
  864. <?php endif; ?>
  865. </div>
  866. <div class="linkedin">
  867. <?php if(!empty($contact['linkedin_1'])): ?>
  868. <div><?= $contact['linkedin_1'] ?></div>
  869. <?php endif; ?>
  870. <?php if(!empty($contact['linkedin_2'])): ?>
  871. <div><?= $contact['linkedin_2'] ?></div>
  872. <?php endif; ?>
  873. <?php if(!empty($contact['linkedin_3'])): ?>
  874. <div><?= $contact['linkedin_3'] ?></div>
  875. <?php endif; ?>
  876. </div>
  877. <div class="facebook">
  878. <?php if(!empty($contact['facebook_1'])): ?>
  879. <div><?= $contact['facebook_1'] ?></div>
  880. <?php endif; ?>
  881. <?php if(!empty($contact['facebook_2'])): ?>
  882. <div><?= $contact['facebook_2'] ?></div>
  883. <?php endif; ?>
  884. <?php if(!empty($contact['facebook_3'])): ?>
  885. <div><?= $contact['facebook_3'] ?></div>
  886. <?php endif; ?>
  887. </div>
  888. <div class="alibaba">
  889. <?php if(!empty($contact['alibaba_1'])): ?>
  890. <div><?= $contact['alibaba_1'] ?></div>
  891. <?php endif; ?>
  892. <?php if(!empty($contact['alibaba_2'])): ?>
  893. <div><?= $contact['alibaba_2'] ?></div>
  894. <?php endif; ?>
  895. <?php if(!empty($contact['alibaba_3'])): ?>
  896. <div><?= $contact['alibaba_3'] ?></div>
  897. <?php endif; ?>
  898. </div>
  899. </div>
  900. <?php } ?>
  901. </div>
  902. <div class="noteItem2">备注</div>
  903. <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>
  904. </div>
  905. <?php
  906. }
  907. } else {
  908. if (empty($keys)) {
  909. echo '<tr><div align="center" colspan="9">Sorry,当前暂无信息</div></tr>';
  910. } else {
  911. echo '<tr><div align="center" colspan="9"><a href="?">Sorry,没有找到"' .
  912. htmlspecialcharsFix($keyscode) . '"相关的信息,点击返回</a></div></tr>';
  913. }
  914. }
  915. ?>
  916. <div colspan="9">
  917. <div class="showpagebox">
  918. <?php
  919. if ($totalPages > 1) {
  920. $pageName = "?Keys=$keys$urlStr&";
  921. $pageLen = 3;
  922. if ($page > 1) {
  923. echo "<a href=\"{$pageName}Page=1\">首页</a>";
  924. echo "<a href=\"{$pageName}Page=" . ($page - 1) . "\">上一页</a>";
  925. }
  926. if ($pageLen * 2 + 1 >= $totalPages) {
  927. $startPage = 1;
  928. $endPage = $totalPages;
  929. } else {
  930. if ($page <= $pageLen + 1) {
  931. $startPage = 1;
  932. $endPage = $pageLen * 2 + 1;
  933. } else {
  934. $startPage = $page - $pageLen;
  935. $endPage = $page + $pageLen;
  936. }
  937. if ($page + $pageLen > $totalPages) {
  938. $startPage = $totalPages - $pageLen * 2;
  939. $endPage = $totalPages;
  940. }
  941. }
  942. for ($i = $startPage; $i <= $endPage; $i++) {
  943. if ($i == $page) {
  944. echo "<a class=\"current\">$i</a>";
  945. } else {
  946. echo "<a href=\"{$pageName}Page=$i\">$i</a>";
  947. }
  948. }
  949. if ($page < $totalPages) {
  950. if ($totalPages - $page > $pageLen) {
  951. echo "<a href=\"{$pageName}Page=$totalPages\">...$totalPages</a>";
  952. }
  953. echo "<a href=\"{$pageName}Page=" . ($page + 1) . "\">下一页</a>";
  954. echo "<a href=\"{$pageName}Page=$totalPages\">尾页</a>";
  955. }
  956. }
  957. ?>
  958. </div>
  959. <?php require_once 'postchkbox.php'; ?>
  960. </div>
  961. </div>
  962. </form>
  963. </div>
  964. </body>
  965. </html>