claimRecord.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. // 使用SQL拼接方式获取新的客户编码
  118. $customerQuery = "SELECT cs_code FROM customer WHERE id = " . intval($row['cs_id']);
  119. $customerResult = $conn->query($customerQuery);
  120. $customerCode = ($customerRow = $customerResult->fetch_assoc()) ? $customerRow['cs_code'] : '';
  121. ?>
  122. <tr>
  123. <td><?= $tempNum ?></td>
  124. <td><?= $row['claimTime'] ?></td>
  125. <td><span style="color:#0099CC;"><?= htmlspecialcharsFix($row['newEmp']) ?></span> 认领了
  126. <span style="color:#0099CC;"><?= htmlspecialcharsFix($row['originalEmp']) ?></span> 的客户(<?= htmlspecialcharsFix($row['oldCode']) ?>)</td>
  127. <td><?= htmlspecialcharsFix($customerCode) ?></td>
  128. </tr>
  129. <?php
  130. }
  131. } else {
  132. ?>
  133. <tr>
  134. <td colspan="4">当前暂无认领记录</td>
  135. </tr>
  136. <?php
  137. }
  138. ?>
  139. </tbody>
  140. <tfoot>
  141. <tr>
  142. <td colspan="4">
  143. <div class="showpagebox">
  144. <?php
  145. if (isset($totalPages) && $totalPages > 1) {
  146. $pageName = "?Keys=" . $keys . ($urlStr ?? '') . "&searcheType=" . $searcheType . "&";
  147. $pagelen = 3;
  148. // First page and Previous page
  149. if ($page > 1) {
  150. echo "<a href=\"{$pageName}Page=1\">首页</a>";
  151. echo "<a href=\"{$pageName}Page=" . ($page - 1) . "\">上一页</a>";
  152. }
  153. // Calculate page range
  154. if ($pagelen * 2 + 1 >= $totalPages) {
  155. $startPage = 1;
  156. $endPage = $totalPages;
  157. } else {
  158. if ($page <= $pagelen + 1) {
  159. $startPage = 1;
  160. $endPage = $pagelen * 2 + 1;
  161. } else {
  162. $startPage = $page - $pagelen;
  163. $endPage = $page + $pagelen;
  164. }
  165. if ($page + $pagelen > $totalPages) {
  166. $startPage = $totalPages - $pagelen * 2;
  167. $endPage = $totalPages;
  168. }
  169. }
  170. // Page numbers
  171. for ($i = $startPage; $i <= $endPage; $i++) {
  172. if ($i == $page) {
  173. echo "<a class=\"current\">{$i}</a>";
  174. } else {
  175. echo "<a href=\"{$pageName}Page={$i}\">{$i}</a>";
  176. }
  177. }
  178. // Next page and Last page
  179. if ($page < $totalPages) {
  180. if ($totalPages - $page > $pagelen) {
  181. echo "<a href=\"{$pageName}Page={$totalPages}\">...{$totalPages}</a>";
  182. }
  183. echo "<a href=\"{$pageName}Page=" . ($page + 1) . "\">下一页</a>";
  184. echo "<a href=\"{$pageName}Page={$totalPages}\">尾页</a>";
  185. }
  186. }
  187. ?>
  188. </div>
  189. </td>
  190. </tr>
  191. </tfoot>
  192. </table>
  193. </form>
  194. </div>
  195. </body>
  196. </html>