customers.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. <?php
  2. require_once 'conn.php';
  3. checkLogin();
  4. // 辅助函数
  5. function textDecode($str) {
  6. return htmlspecialchars_decode($str, ENT_QUOTES);
  7. }
  8. function htmlDecode($str) {
  9. return htmlspecialchars_decode($str, ENT_QUOTES);
  10. }
  11. $act = $_GET['act'] ?? '';
  12. $urlStr = '';
  13. // 处理保存操作
  14. if ($act == "save") {
  15. $isedit = false;
  16. $id = $_POST['id'] ?? '';
  17. if (!empty($id) && is_numeric($id)) {
  18. $isedit = true;
  19. }
  20. // 获取表单数据
  21. $cs_code = textEncode($_POST['cs_code']);
  22. $cs_company = textEncode($_POST['cs_company']);
  23. $cs_name = textEncode($_POST['cs_name']);
  24. $cs_belong = $_POST['cs_belong'];
  25. $cs_country = $_POST['cs_country'];
  26. $cs_from = $_POST['cs_from'];
  27. $cs_tel = textEncode($_POST['cs_tel']);
  28. $cs_email = textEncode($_POST['cs_email']);
  29. $cs_whatsapp = textEncode($_POST['cs_whatsapp']);
  30. $cs_wechat = textEncode($_POST['cs_wechat']);
  31. $cs_linkedin = textEncode($_POST['cs_linkedin']);
  32. $cs_facebook = textEncode($_POST['cs_facebook']);
  33. $cs_alibaba = textEncode($_POST['cs_alibaba']);
  34. $cs_state = $_POST['cs_state'];
  35. $cs_deal = $_POST['cs_deal'];
  36. $no_content = htmlEncode($_POST['no_content']);
  37. $allowedit = isset($_POST['allowedit']) ? 1 : 0;
  38. if ($isedit) {
  39. // 更新现有记录
  40. $sql = "SELECT cs_chain FROM customer WHERE id = $id";
  41. $result = mysqli_query($conn, $sql);
  42. if ($row = mysqli_fetch_assoc($result)) {
  43. $cs_chain = $row['cs_chain'];
  44. $chain_array = explode(',', $cs_chain);
  45. $last_item = end($chain_array);
  46. if ($last_item != $cs_belong) {
  47. $cs_chain .= ",$cs_belong";
  48. }
  49. $sql = "UPDATE customer SET
  50. cs_code = '$cs_code',
  51. cs_company = '$cs_company',
  52. cs_name = '$cs_name',
  53. cs_belong = '$cs_belong',
  54. cs_country = '$cs_country',
  55. cs_from = '$cs_from',
  56. cs_tel = '$cs_tel',
  57. cs_email = '$cs_email',
  58. cs_whatsapp = '$cs_whatsapp',
  59. cs_wechat = '$cs_wechat',
  60. cs_linkedin = '$cs_linkedin',
  61. cs_facebook = '$cs_facebook',
  62. cs_alibaba = '$cs_alibaba',
  63. cs_state = '$cs_state',
  64. cs_deal = '$cs_deal',
  65. cs_note = '$no_content',
  66. allowedit = $allowedit,
  67. cs_chain = '$cs_chain',
  68. cs_updatetime = NOW()
  69. WHERE id = $id";
  70. mysqli_query($conn, $sql);
  71. $page = $_GET['Page'] ?? '';
  72. $keys = urlencode($_GET['Keys'] ?? '');
  73. header("Location: ?keys=$keys&Page=$page$urlStr");
  74. exit;
  75. }
  76. }
  77. }
  78. // 处理编辑操作
  79. if ($act == "edit") {
  80. $id = $_GET['id'] ?? '';
  81. $isedit = false;
  82. if (!empty($id) && is_numeric($id)) {
  83. $isedit = true;
  84. }
  85. if ($isedit) {
  86. $sql = "SELECT c.*, n.c_code FROM customer c
  87. LEFT JOIN mynote n ON c.cs_code = n.c_code
  88. WHERE c.id = $id";
  89. $result = mysqli_query($conn, $sql);
  90. if ($row = mysqli_fetch_assoc($result)) {
  91. $cs_code = textDecode($row['cs_code']);
  92. $cs_company = textDecode($row['cs_company']);
  93. $cs_name = textDecode($row['cs_name']);
  94. $cs_country = $row['cs_country'];
  95. $cs_from = $row['cs_from'];
  96. $cs_tel = textDecode($row['cs_tel']);
  97. $cs_telBu = textDecode($row['cs_telBu']);
  98. $cs_email = textDecode($row['cs_email']);
  99. $cs_emailBu = textDecode($row['cs_emailBu']);
  100. $cs_whatsapp = textDecode($row['cs_whatsapp']);
  101. $cs_whatsappBu = textDecode($row['cs_whatsappBu']);
  102. $cs_wechat = textDecode($row['cs_wechat']);
  103. $cs_wechatBu = textDecode($row['cs_wechatBu']);
  104. $cs_linkedin = textDecode($row['cs_linkedin']);
  105. $cs_linkedinBu = textDecode($row['cs_linkedinBu']);
  106. $cs_facebook = textDecode($row['cs_facebook']);
  107. $cs_facebookBu = textDecode($row['cs_facebookBu']);
  108. $cs_alibaba = textDecode($row['cs_alibaba']);
  109. $cs_alibabaBu = textDecode($row['cs_alibabaBu']);
  110. $cs_address = textDecode($row['cs_address']);
  111. $cs_addtime = $row['cs_addtime'];
  112. $cs_updatetime = $row['cs_updatetime'];
  113. $cs_belong = $row['cs_belong'];
  114. $cs_state = $row['cs_state'];
  115. $cs_deal = $row['cs_deal'];
  116. $cs_note = htmlDecode($row['cs_note']);
  117. $allowedit = $row['allowedit'];
  118. }
  119. }
  120. }
  121. // 处理批量操作
  122. if ($act == "postchk") {
  123. if (isset($_POST['chkbox']) && isset($_POST['chkact'])) {
  124. $chkact = $_POST['chkact'];
  125. $ids = implode(',', array_map('intval', $_POST['chkbox']));
  126. switch($chkact) {
  127. case "0":
  128. case "1":
  129. $sql = "UPDATE customer SET cs_state = $chkact WHERE id IN ($ids)";
  130. break;
  131. case "-1":
  132. $sql = "DELETE FROM customer WHERE id IN ($ids)";
  133. break;
  134. }
  135. if (isset($sql)) {
  136. mysqli_query($conn, $sql);
  137. }
  138. $keys = urlencode($_GET['Keys'] ?? '');
  139. $page = $_GET['Page'] ?? '';
  140. header("Location: ?keys=$keys&Page=$page$urlStr");
  141. exit;
  142. }
  143. }
  144. // 处理筛选条件
  145. $fliterQudao = $_GET['fliterQudao'] ?? '';
  146. $fliterDeal = $_GET['fliterDeal'] ?? '';
  147. $fliterTeam = $_GET['fliterTeam'] ?? '';
  148. $fliterContact = $_GET['fliterContact'] ?? '';
  149. $fliterEmployee = $_GET['fliterEmployee'] ?? '';
  150. $fliterStr = "";
  151. if (!empty($fliterQudao)) {
  152. $fliterStr .= " AND cs_from = " . intval($fliterQudao);
  153. $urlStr .= "&fliterQudao=" . $fliterQudao;
  154. }
  155. if (!empty($fliterDeal)) {
  156. $fliterStr .= " AND cs_deal = " . intval($fliterDeal);
  157. $urlStr .= "&fliterDeal=" . $fliterDeal;
  158. }
  159. if (!empty($fliterTeam)) {
  160. $fliterStr .= " AND (cs_belong = " . intval($fliterTeam) .
  161. " OR cs_belong IN (SELECT id FROM employee WHERE em_role = " . intval($fliterTeam) . "))";
  162. $urlStr .= "&fliterTeam=" . $fliterTeam;
  163. }
  164. if (!empty($fliterEmployee)) {
  165. $fliterStr .= " AND cs_belong = " . intval($fliterEmployee);
  166. $urlStr .= "&fliterEmployee=" . $fliterEmployee;
  167. }
  168. if (!empty($fliterContact)) {
  169. switch($fliterContact) {
  170. case "1": $fliterStr .= " AND cs_tel != ''"; break;
  171. case "2": $fliterStr .= " AND cs_wechat != ''"; break;
  172. case "3": $fliterStr .= " AND cs_whatsapp != ''"; break;
  173. case "4": $fliterStr .= " AND cs_email != ''"; break;
  174. case "5": $fliterStr .= " AND cs_linkedin != ''"; break;
  175. case "6": $fliterStr .= " AND cs_facebook != ''"; break;
  176. case "7": $fliterStr .= " AND cs_alibaba != ''"; break;
  177. }
  178. $urlStr .= "&fliterContact=" . $fliterContact;
  179. }
  180. // 搜索和排序
  181. $keys = $_GET['Keys'] ?? '';
  182. $keyscode = textEncode($keys);
  183. $page = $_GET['Page'] ?? 1;
  184. $ord = $_GET['Ord'] ?? '';
  185. $ordStr = !empty($ord) ? "$ord," : "";
  186. // 构建查询SQL
  187. $sqlStr = "SELECT id, cs_code, cs_name, cs_country, cs_address, cs_tel, cs_email,
  188. cs_whatsapp, cs_wechat, cs_linkedin, cs_facebook, cs_addtime, cs_alibaba,
  189. cs_from, cs_deal, cs_updatetime, cs_belong, cs_note, cs_claimFrom, cs_chain,
  190. cs_dealdate
  191. FROM customer
  192. WHERE (cs_code LIKE '%$keyscode%'
  193. OR cs_name LIKE '%$keyscode%'
  194. OR cs_wechat LIKE '%$keyscode%'
  195. OR cs_alibaba LIKE '%$keyscode%'
  196. OR cs_telformat LIKE '%$keyscode%'
  197. OR cs_whatsappformat LIKE '%$keyscode%'
  198. OR cs_email LIKE '%$keyscode%')
  199. $fliterStr
  200. ORDER BY {$ordStr}cs_updatetime DESC";
  201. ?>
  202. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  203. <html xmlns="http://www.w3.org/1999/xhtml">
  204. <head>
  205. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  206. <title>客户列表</title>
  207. <link rel="stylesheet" href="css/common.css" type="text/css" />
  208. <link rel="stylesheet" href="css/alert.css" type="text/css" />
  209. <script src="js/jquery-1.7.2.min.js"></script>
  210. <script src="js/js.js"></script>
  211. <style>
  212. body {
  213. margin: 0;
  214. padding: 20px;
  215. background: #fff;
  216. }
  217. #man_zone {
  218. margin-left: 0;
  219. }
  220. </style>
  221. </head>
  222. <body>
  223. <div id="man_zone">
  224. <?php
  225. $keys = $_GET['Keys'] ?? '';
  226. $keys = str_replace([" ", "+"], "", $keys);
  227. $keyscode = textEncode($keys);
  228. $page = $_GET['Page'] ?? 1;
  229. $filters = [
  230. 'Country' => $_GET['fliterCountry'] ?? '',
  231. 'Qudao' => $_GET['fliterQudao'] ?? '',
  232. 'Deal' => $_GET['fliterDeal'] ?? '',
  233. 'Business' => $_GET['fliterBusiness'] ?? '',
  234. 'Contact' => $_GET['fliterContact'] ?? ''
  235. ];
  236. $filterStr = "";
  237. $urlStr = "";
  238. // Build filter conditions
  239. if (!empty($filters['Country'])) {
  240. $filterStr .= " AND cs_country=" . (int)$filters['Country'];
  241. $urlStr .= "&fliterCountry=" . $filters['Country'];
  242. }
  243. if (!empty($filters['Qudao'])) {
  244. $filterStr .= " AND cs_from=" . (int)$filters['Qudao'];
  245. $urlStr .= "&fliterQudao=" . $filters['Qudao'];
  246. }
  247. if (!empty($filters['Deal'])) {
  248. $filterStr .= " AND cs_deal=" . (int)$filters['Deal'];
  249. $urlStr .= "&fliterDeal=" . $filters['Deal'];
  250. }
  251. if (!empty($filters['Business'])) {
  252. $filterStr .= " AND cs_type=" . (int)$filters['Business'];
  253. $urlStr .= "&fliterBusiness=" . $filters['Business'];
  254. }
  255. if (!empty($filters['Contact'])) {
  256. switch ($filters['Contact']) {
  257. case "1": $filterStr .= " AND cs_tel<>''"; break;
  258. case "2": $filterStr .= " AND cs_wechat<>''"; break;
  259. case "3": $filterStr .= " AND cs_whatsapp<>''"; break;
  260. case "4": $filterStr .= " AND cs_email<>''"; break;
  261. case "5": $filterStr .= " AND cs_linkedin<>''"; break;
  262. case "6": $filterStr .= " AND cs_facebook<>''"; break;
  263. default: $filterStr .= " AND cs_alibaba<>''";
  264. }
  265. $urlStr .= "&fliterContact=" . $filters['Contact'];
  266. }
  267. $keys = urlencode($keys);
  268. $hrefstr = "?keys=" . $keys;
  269. ?>
  270. <form id="form1" method="post" action="?act=postchk&Keys=<?= $keys ?>&Page=<?= $page ?>" onSubmit="return false">
  271. <div class="fastSelect clear">
  272. <H1>搜索条件</H1>
  273. <div class="selectItem">
  274. <label>区域</label>
  275. <select name="fliterCountry" class="filterSearch">
  276. <option value="">请选择国家地区</option>
  277. <?php
  278. $result = $conn->query("SELECT id, countryName FROM country");
  279. while ($row = $result->fetch_assoc()) {
  280. $selected = ($filters['Country'] == $row['id']) ? ' selected' : '';
  281. echo "<option value=\"{$row['id']}\"$selected>{$row['countryName']}</option>";
  282. }
  283. ?>
  284. </select>
  285. </div>
  286. <div class="selectItem">
  287. <label>来源渠道</label>
  288. <select name="fliterQudao" class="filterSearch">
  289. <option value="">请选择渠道</option>
  290. <?php
  291. $result = $conn->query("SELECT id, ch_name FROM qudao");
  292. while ($row = $result->fetch_assoc()) {
  293. $selected = ($filters['Qudao'] == $row['id']) ? ' selected' : '';
  294. echo "<option value=\"{$row['id']}\"$selected>{$row['ch_name']}</option>";
  295. }
  296. ?>
  297. </select>
  298. </div>
  299. <div class="selectItem">
  300. <label>跟进阶段</label>
  301. <select name="fliterDeal" class="filterSearch">
  302. <option value="">请选择</option>
  303. <option value="1"<?= ($filters['Deal'] == "1") ? ' selected' : '' ?>>背景调查</option>
  304. <option value="2"<?= ($filters['Deal'] == "2") ? ' selected' : '' ?>>明确需求</option>
  305. <option value="3"<?= ($filters['Deal'] == "3") ? ' selected' : '' ?>>已成交</option>
  306. </select>
  307. </div>
  308. <div class="selectItem">
  309. <label>客户类型</label>
  310. <select name="fliterBusiness" class="filterSearch">
  311. <option value="">请选择</option>
  312. <?php
  313. $result = $conn->query("SELECT id, businessType FROM clienttype");
  314. while ($row = $result->fetch_assoc()) {
  315. $selected = ($filters['Business'] == $row['id']) ? ' selected' : '';
  316. echo "<option value=\"{$row['id']}\"$selected>{$row['businessType']}</option>";
  317. }
  318. ?>
  319. </select>
  320. </div>
  321. <div class="selectItem">
  322. <label>联系方式</label>
  323. <select name="fliterContact" class="filterSearch">
  324. <option value="">请选择</option>
  325. <option value="1"<?= ($filters['Contact'] == "1") ? ' selected' : '' ?>>电话</option>
  326. <option value="2"<?= ($filters['Contact'] == "2") ? ' selected' : '' ?>>微信</option>
  327. <option value="3"<?= ($filters['Contact'] == "3") ? ' selected' : '' ?>>WhatsApp</option>
  328. <option value="4"<?= ($filters['Contact'] == "4") ? ' selected' : '' ?>>邮箱</option>
  329. <option value="5"<?= ($filters['Contact'] == "5") ? ' selected' : '' ?>>领英</option>
  330. <option value="6"<?= ($filters['Contact'] == "6") ? ' selected' : '' ?>>Facebook</option>
  331. <option value="7"<?= ($filters['Contact'] == "7") ? ' selected' : '' ?>>阿里巴巴</option>
  332. </select>
  333. </div>
  334. <div class="inputSearch">
  335. <input type="text" id="keys" class="inputTxt"
  336. value="<?= empty($keyscode) ? '请输入搜索关键词' : $keyscode ?>"
  337. onFocus="if(this.value == '<?= empty($keyscode) ? '请输入搜索关键词' : $keyscode ?>'){this.value='';}"
  338. onBlur="if(this.value == ''){this.value='<?= empty($keyscode) ? '请输入搜索关键词' : $keyscode ?>';}"
  339. onKeyDown="if(event.keyCode==13){location.href='?Keys='+escape(document.getElementById('keys').value)}" />
  340. <input type="button" id="searchgo" class="searchgo" value="go"
  341. onClick="location.href='?Keys='+escape(document.getElementById('keys').value)" />
  342. </div>
  343. </div>
  344. <div class="table2 em<?= $_SESSION['employee_id'] ?>">
  345. <div class="theader">
  346. <div class="col1"><input type="checkbox" name="chkall" id="chkall" onClick="chkboxall(this,'chkbox')" /></div>
  347. <div class="col2">序号</div>
  348. <div class="col3">客户编号</div>
  349. <div class="col4">渠道来源</div>
  350. <div class="col5">区域</div>
  351. <div class="col6">客户类型</div>
  352. <div class="col6">跟进阶段</div>
  353. <div class="colmark">颜色标记</div>
  354. <div class="col6">录入时间</div>
  355. <div class="col9">操作</div>
  356. </div>
  357. <?php
  358. $sql = "SELECT id, cs_code, cs_from, cs_country, cs_type, cs_deal, cs_addtime,
  359. cs_tel, cs_email, cs_whatsapp, cs_wechat, cs_linkedin, cs_facebook,
  360. cs_alibaba, colortag, cs_note, cs_claimFrom
  361. FROM customer
  362. WHERE is_silent=0 AND cs_deal>0 AND cs_belong=" . (int)$_SESSION['employee_id'];
  363. $searchPattern = mysqli_real_escape_string($conn, $keyscode);
  364. if(!empty($searchPattern)) {
  365. $sql .= " AND (cs_code LIKE '%$searchPattern%'
  366. OR cs_name LIKE '%$searchPattern%'
  367. OR cs_email LIKE '%$searchPattern%'
  368. OR cs_wechat LIKE '%$searchPattern%'
  369. OR cs_telformat LIKE '%$searchPattern%'
  370. OR cs_whatsappformat LIKE '%$searchPattern%'
  371. OR cs_code LIKE '%$searchPattern%')";
  372. }
  373. $sql .= " $filterStr ORDER BY colortag DESC, id DESC";
  374. $result = mysqli_query($conn, $sql);
  375. // Pagination logic
  376. $perPage = 20;
  377. $totalRecords = mysqli_num_rows($result);
  378. $totalPages = max(1, ceil($totalRecords / $perPage));
  379. $page = max(1, min((int)$page, $totalPages));
  380. $offset = max(0, ($page - 1) * $perPage);
  381. // Add pagination to query
  382. $sql .= " LIMIT $offset, $perPage";
  383. $result = mysqli_query($conn, $sql);
  384. if (mysqli_num_rows($result) > 0) {
  385. $tempNum = $offset;
  386. while ($row = mysqli_fetch_assoc($result)) {
  387. $tempNum++;
  388. ?>
  389. <div class="tline color<?= $row['colortag'] ?>">
  390. <div class="col1" align="center"><input type="checkbox" name="chkbox" value="<?= $row['id'] ?>" /></div>
  391. <div class="col2"><?= $tempNum ?></div>
  392. <div class="col3 slidepanel"><?= $row['cs_code'] ?>
  393. <?php if ($row['cs_claimFrom'] > 0): ?>
  394. <img src="../images/yijiao.png" class="handover" title="来自认领">
  395. <?php endif; ?>
  396. </div>
  397. <div class="col4">
  398. <?php
  399. $qudao = $conn->query("SELECT ch_name FROM qudao WHERE id=" . (int)$row['cs_from']);
  400. echo $qudao->num_rows > 0 ? $qudao->fetch_assoc()['ch_name'] : '未填写';
  401. ?>
  402. </div>
  403. <div class="col5">
  404. <?php
  405. $country = $conn->query("SELECT countryName FROM country WHERE id=" . (int)$row['cs_country']);
  406. echo $country->num_rows > 0 ? $country->fetch_assoc()['countryName'] : '未填写';
  407. ?>
  408. </div>
  409. <div class="col6">
  410. <?php
  411. $clientType = $conn->query("SELECT businessType FROM clienttype WHERE id=" . (int)$row['cs_type']);
  412. echo $clientType->num_rows > 0 ? $clientType->fetch_assoc()['businessType'] : '未填写';
  413. ?>
  414. </div>
  415. <div class="col6">
  416. <?php
  417. switch ($row['cs_deal']) {
  418. case 3: echo '<span style="color:red;">成交</span>'; break;
  419. case 2: echo '明确需求'; break;
  420. case 1: echo '背景调查'; break;
  421. default: echo '无响应';
  422. }
  423. ?>
  424. </div>
  425. <div class="colmark colormark">
  426. <ul class="colorlist" data-id="<?= $row['id'] ?>">
  427. <li value="1" class="color1"></li>
  428. <li value="2" class="color2"></li>
  429. <li value="3" class="color3"></li>
  430. <li value="4" class="color4"></li>
  431. <li value="0" class="color0"></li>
  432. </ul>
  433. </div>
  434. <div class="col6"><?= $row['cs_addtime'] ?></div>
  435. <div class="col9">
  436. <a href="customerEdit.php?Keys=<?= $keys ?>&fliterDeal=<?= $filters['Deal'] ?>&fliterBusiness=<?= $filters['Business'] ?>&Page=<?= $page ?>&act=edit&id=<?= $row['id'] ?>" class="ico_edit ico">修改</a>
  437. </div>
  438. </div>
  439. <div class="notepanel clear">
  440. <div class="noteItem">联系方式</div>
  441. <div class="lx">
  442. <div class="tel"><?= $row['cs_tel'] ?></div>
  443. <div class="mail"><a href="mailto:<?= $row['cs_email'] ?>"><?= $row['cs_email'] ?></a></div>
  444. <div class="whatsapp"><?= $row['cs_whatsapp'] ?></div>
  445. <div class="wechat"><?= $row['cs_wechat'] ?></div>
  446. <div class="linkedin"><?= $row['cs_linkedin'] ?></div>
  447. <div class="facebook"><?= $row['cs_facebook'] ?></div>
  448. <div class="alibaba"><?= $row['cs_alibaba'] ?></div>
  449. </div>
  450. <div class="noteItem2">备注</div>
  451. <div class="notecontent"><?= htmlUnCode($row['cs_note']) ?></div>
  452. </div>
  453. <?php
  454. }
  455. } else {
  456. if (empty($keys)) {
  457. echo '<tr><div align="center" colspan="9">Sorry,当前暂无信息</div></tr>';
  458. } else {
  459. echo '<tr><div align="center" colspan="9"><a href="?">Sorry,没有找到"' .
  460. htmlspecialcharsFix($keyscode) . '"相关的信息,点击返回</a></div></tr>';
  461. }
  462. }
  463. ?>
  464. <div colspan="9">
  465. <div class="showpagebox">
  466. <?php
  467. if ($totalPages > 1) {
  468. $pageName = "?Keys=$keys$urlStr&";
  469. $pageLen = 3;
  470. if ($page > 1) {
  471. echo "<a href=\"{$pageName}Page=1\">首页</a>";
  472. echo "<a href=\"{$pageName}Page=" . ($page - 1) . "\">上一页</a>";
  473. }
  474. if ($pageLen * 2 + 1 >= $totalPages) {
  475. $startPage = 1;
  476. $endPage = $totalPages;
  477. } else {
  478. if ($page <= $pageLen + 1) {
  479. $startPage = 1;
  480. $endPage = $pageLen * 2 + 1;
  481. } else {
  482. $startPage = $page - $pageLen;
  483. $endPage = $page + $pageLen;
  484. }
  485. if ($page + $pageLen > $totalPages) {
  486. $startPage = $totalPages - $pageLen * 2;
  487. $endPage = $totalPages;
  488. }
  489. }
  490. for ($i = $startPage; $i <= $endPage; $i++) {
  491. if ($i == $page) {
  492. echo "<a class=\"current\">$i</a>";
  493. } else {
  494. echo "<a href=\"{$pageName}Page=$i\">$i</a>";
  495. }
  496. }
  497. if ($page < $totalPages) {
  498. if ($totalPages - $page > $pageLen) {
  499. echo "<a href=\"{$pageName}Page=$totalPages\">...$totalPages</a>";
  500. }
  501. echo "<a href=\"{$pageName}Page=" . ($page + 1) . "\">下一页</a>";
  502. echo "<a href=\"{$pageName}Page=$totalPages\">尾页</a>";
  503. }
  504. }
  505. ?>
  506. </div>
  507. <?php require_once 'postchkbox.php'; ?>
  508. </div>
  509. </div>
  510. </form>
  511. </div>
  512. </body>
  513. </html>