customers.php 45 KB

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