customersNew.php 21 KB

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