claimRecord.php 7.1 KB

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