claimRecord.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. <script>
  15. function goSearch() {
  16. var keys = document.getElementById("keys").value;
  17. var myselect = document.getElementById("searcheType");
  18. var index = myselect.selectedIndex;
  19. var searcheType = myselect.options[index].value;
  20. location.href = '?Keys=' + escape(keys) + '&searcheType=' + searcheType;
  21. }
  22. function keyDownSearch() {
  23. var e = window.event || event;
  24. if (e.keyCode == 13) {
  25. var keys = document.getElementById("keys").value;
  26. var myselect = document.getElementById("searcheType");
  27. var index = myselect.selectedIndex;
  28. var searcheType = myselect.options[index].value;
  29. location.href = '?Keys=' + escape(keys) + '&searcheType=' + searcheType;
  30. }
  31. }
  32. </script>
  33. </head>
  34. <body class="clear">
  35. <?php require_once 'panel.php'; ?>
  36. <?php
  37. $page = $_GET['Page'] ?? '';
  38. $keys = $_GET['Keys'] ?? '';
  39. $keyscode = textEncode($keys);
  40. $searcheType = $_GET['searcheType'] ?? '';
  41. switch ($searcheType) {
  42. case "1":
  43. $filterStr = "WHERE originalEmp LIKE '%" . $conn->real_escape_string($keyscode) . "%'";
  44. break;
  45. case "2":
  46. $filterStr = "WHERE newEmp LIKE '%" . $conn->real_escape_string($keyscode) . "%'";
  47. break;
  48. case "3":
  49. $filterStr = "WHERE oldCode LIKE '%" . $conn->real_escape_string($keyscode) . "%'";
  50. break;
  51. case "4":
  52. $filterStr = "WHERE cs_id IN (SELECT id FROM customer WHERE cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%')";
  53. break;
  54. default:
  55. $filterStr = "";
  56. }
  57. ?>
  58. <div id="man_zone">
  59. <form id="form1" method="post" action="?Keys=<?= $keyscode ?>&Page=<?= $page ?>&searcheType=<?= $searcheType ?>" onSubmit="return false">
  60. <div class="fastSelect clear">
  61. <H1>搜索条件</H1>
  62. <div class="inputSearch">
  63. <select name="searcheType" id="searcheType">
  64. <option value="">未筛选</option>
  65. <option value="1" <?= ($searcheType == "1") ? 'selected="selected"' : '' ?>>原属业务员</option>
  66. <option value="2" <?= ($searcheType == "2") ? 'selected="selected"' : '' ?>>新跟进业务员</option>
  67. <option value="3" <?= ($searcheType == "3") ? 'selected="selected"' : '' ?>>原编号</option>
  68. <option value="4" <?= ($searcheType == "4") ? 'selected="selected"' : '' ?>>新编号</option>
  69. </select>
  70. <input type="text" id="keys" class="inputTxt"
  71. value="<?= empty($keyscode) ? '请输入搜索关键词' : $keyscode ?>"
  72. onFocus="if(this.value == '<?= empty($keyscode) ? '请输入搜索关键词' : $keyscode ?>'){this.value='';}"
  73. onBlur="if(this.value == ''){this.value='<?= empty($keyscode) ? '请输入搜索关键词' : $keyscode ?>';}"
  74. onKeyDown="keyDownSearch();" />
  75. <input type="button" id="searchgo" class="searchgo" value="go" onClick="goSearch();" />
  76. </div>
  77. </div>
  78. <table class="teamStatistics table1" border="1px" bordercollapse="collapse" cellspacing="0" cellpadding="5" bordercolor="#DDD">
  79. <tr class="theader">
  80. <th>序号</th>
  81. <th>时间</th>
  82. <th>记录</th>
  83. <th>新编号</th>
  84. </tr>
  85. <tbody>
  86. <?php
  87. $sql = "SELECT * FROM claimRecord " . $filterStr . " ORDER BY claimTime DESC";
  88. $result = $conn->query($sql);
  89. if ($result && $result->num_rows > 0) {
  90. $pageSize = 20;
  91. $page = empty($page) ? 1 : $page;
  92. $page = $page === 'end' ? ceil($result->num_rows / $pageSize) : $page;
  93. $page = !is_numeric($page) || $page < 1 ? 1 : (int)$page;
  94. $totalPages = ceil($result->num_rows / $pageSize);
  95. $page = $page > $totalPages ? $totalPages : $page;
  96. $offset = $pageSize * ($page - 1);
  97. // Store all results in array
  98. $rows = [];
  99. while ($row = $result->fetch_assoc()) {
  100. $rows[] = $row;
  101. }
  102. // Get paginated results
  103. $paginatedRows = array_slice($rows, $offset, $pageSize);
  104. $tempNum = $offset;
  105. foreach ($paginatedRows as $row) {
  106. $tempNum++;
  107. // Get new customer code
  108. $customerResult = $conn->query("SELECT cs_code FROM customer WHERE id = " . $row['cs_id']);
  109. $customerCode = ($customerRow = $customerResult->fetch_assoc()) ? $customerRow['cs_code'] : '';
  110. ?>
  111. <tr>
  112. <td><?= $tempNum ?></td>
  113. <td><?= $row['claimTime'] ?></td>
  114. <td><span style="color:#0099CC;"><?= $row['newEmp'] ?></span> 认领了
  115. <span style="color:#0099CC;"><?= $row['originalEmp'] ?></span> 的客户(<?= $row['oldCode'] ?>)</td>
  116. <td><?= $customerCode ?></td>
  117. </tr>
  118. <?php
  119. }
  120. } else {
  121. ?>
  122. <tr>
  123. <td colspan="4">当前暂无认领记录</td>
  124. </tr>
  125. <?php
  126. }
  127. ?>
  128. </tbody>
  129. <tfoot>
  130. <tr>
  131. <td colspan="4">
  132. <div class="showpagebox">
  133. <?php
  134. if (isset($totalPages) && $totalPages > 1) {
  135. $pageName = "?Keys=" . $keys . ($urlStr ?? '') . "&searcheType=" . $searcheType . "&";
  136. $pagelen = 3;
  137. // First page and Previous page
  138. if ($page > 1) {
  139. echo "<a href=\"{$pageName}Page=1\">首页</a>";
  140. echo "<a href=\"{$pageName}Page=" . ($page - 1) . "\">上一页</a>";
  141. }
  142. // Calculate page range
  143. if ($pagelen * 2 + 1 >= $totalPages) {
  144. $startPage = 1;
  145. $endPage = $totalPages;
  146. } else {
  147. if ($page <= $pagelen + 1) {
  148. $startPage = 1;
  149. $endPage = $pagelen * 2 + 1;
  150. } else {
  151. $startPage = $page - $pagelen;
  152. $endPage = $page + $pagelen;
  153. }
  154. if ($page + $pagelen > $totalPages) {
  155. $startPage = $totalPages - $pagelen * 2;
  156. $endPage = $totalPages;
  157. }
  158. }
  159. // Page numbers
  160. for ($i = $startPage; $i <= $endPage; $i++) {
  161. if ($i == $page) {
  162. echo "<a class=\"current\">{$i}</a>";
  163. } else {
  164. echo "<a href=\"{$pageName}Page={$i}\">{$i}</a>";
  165. }
  166. }
  167. // Next page and Last page
  168. if ($page < $totalPages) {
  169. if ($totalPages - $page > $pagelen) {
  170. echo "<a href=\"{$pageName}Page={$totalPages}\">...{$totalPages}</a>";
  171. }
  172. echo "<a href=\"{$pageName}Page=" . ($page + 1) . "\">下一页</a>";
  173. echo "<a href=\"{$pageName}Page={$totalPages}\">尾页</a>";
  174. }
  175. }
  176. ?>
  177. </div>
  178. </td>
  179. </tr>
  180. </tfoot>
  181. </table>
  182. </form>
  183. </div>
  184. </body>
  185. </html>