123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?php
- require_once 'conn.php';
- checkLogin();
- ?>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>管理区域</title>
- <link rel="stylesheet" href="css/common.css" type="text/css" />
- <link rel="stylesheet" href="css/alert.css" type="text/css" />
- <script src="system/js/jquery-1.7.2.min.js"></script>
- <script src="js/js.js"></script>
- <script>
- function goSearch() {
- var keys = document.getElementById("keys").value;
- var myselect = document.getElementById("searcheType");
- var index = myselect.selectedIndex;
- var searcheType = myselect.options[index].value;
- location.href = '?Keys=' + escape(keys) + '&searcheType=' + searcheType;
- }
- function keyDownSearch() {
- var e = window.event || event;
- if (e.keyCode == 13) {
- var keys = document.getElementById("keys").value;
- var myselect = document.getElementById("searcheType");
- var index = myselect.selectedIndex;
- var searcheType = myselect.options[index].value;
- location.href = '?Keys=' + escape(keys) + '&searcheType=' + searcheType;
- }
- }
- </script>
- <style>
- body {
- margin: 0;
- padding: 20px;
- background: #fff;
- }
- #man_zone {
- margin-left: 0;
- }
- </style>
- </head>
- <body class="clear">
- <?php // require_once 'panel.php'; ?>
- <?php
- $page = $_GET['Page'] ?? '';
- $keys = $_GET['Keys'] ?? '';
- $keyscode = textEncode($keys);
- $searcheType = $_GET['searcheType'] ?? '';
- switch ($searcheType) {
- case "1":
- $filterStr = "WHERE originalEmp LIKE '%" . $conn->real_escape_string($keyscode) . "%'";
- break;
- case "2":
- $filterStr = "WHERE newEmp LIKE '%" . $conn->real_escape_string($keyscode) . "%'";
- break;
- case "3":
- $filterStr = "WHERE oldCode LIKE '%" . $conn->real_escape_string($keyscode) . "%'";
- break;
- case "4":
- $filterStr = "WHERE cs_id IN (SELECT id FROM customer WHERE cs_code LIKE '%" . $conn->real_escape_string($keyscode) . "%')";
- break;
- default:
- $filterStr = "";
- }
- ?>
- <div id="man_zone">
- <form id="form1" method="post" action="?Keys=<?= $keyscode ?>&Page=<?= $page ?>&searcheType=<?= $searcheType ?>" onSubmit="return false">
- <div class="fastSelect clear">
- <H1>搜索条件</H1>
- <div class="inputSearch">
- <select name="searcheType" id="searcheType">
- <option value="">未筛选</option>
- <option value="1" <?= ($searcheType == "1") ? 'selected="selected"' : '' ?>>原属业务员</option>
- <option value="2" <?= ($searcheType == "2") ? 'selected="selected"' : '' ?>>新跟进业务员</option>
- <option value="3" <?= ($searcheType == "3") ? 'selected="selected"' : '' ?>>原编号</option>
- <option value="4" <?= ($searcheType == "4") ? 'selected="selected"' : '' ?>>新编号</option>
- </select>
- <input type="text" id="keys" class="inputTxt"
- value="<?= empty($keyscode) ? '请输入搜索关键词' : $keyscode ?>"
- onFocus="if(this.value == '<?= empty($keyscode) ? '请输入搜索关键词' : $keyscode ?>'){this.value='';}"
- onBlur="if(this.value == ''){this.value='<?= empty($keyscode) ? '请输入搜索关键词' : $keyscode ?>';}"
- onKeyDown="keyDownSearch();" />
- <input type="button" id="searchgo" class="searchgo" value="go" onClick="goSearch();" />
- </div>
- </div>
- <table class="teamStatistics table1" border="1px" bordercollapse="collapse" cellspacing="0" cellpadding="5" bordercolor="#DDD">
- <tr class="theader">
- <th>序号</th>
- <th>时间</th>
- <th>记录</th>
- <th>新编号</th>
- </tr>
- <tbody>
- <?php
- $sql = "SELECT * FROM claimrecord " . $filterStr . " ORDER BY claimTime DESC";
- $result = $conn->query($sql);
- if ($result && $result->num_rows > 0) {
- $pageSize = 20;
- $page = empty($page) ? 1 : $page;
- $page = $page === 'end' ? ceil($result->num_rows / $pageSize) : $page;
- $page = !is_numeric($page) || $page < 1 ? 1 : (int)$page;
- $totalPages = ceil($result->num_rows / $pageSize);
- $page = $page > $totalPages ? $totalPages : $page;
- $offset = $pageSize * ($page - 1);
-
- // Store all results in array
- $rows = [];
- while ($row = $result->fetch_assoc()) {
- $rows[] = $row;
- }
-
- // Get paginated results
- $paginatedRows = array_slice($rows, $offset, $pageSize);
- $tempNum = $offset;
-
- foreach ($paginatedRows as $row) {
- $tempNum++;
-
- // 使用SQL拼接方式获取新的客户编码
- $customerQuery = "SELECT cs_code FROM customer WHERE id = " . intval($row['cs_id']);
- $customerResult = $conn->query($customerQuery);
- $customerCode = ($customerRow = $customerResult->fetch_assoc()) ? $customerRow['cs_code'] : '';
- ?>
- <tr>
- <td><?= $tempNum ?></td>
- <td><?= $row['claimTime'] ?></td>
- <td><span style="color:#0099CC;"><?= htmlspecialcharsFix($row['newEmp']) ?></span> 认领了
- <span style="color:#0099CC;"><?= htmlspecialcharsFix($row['originalEmp']) ?></span> 的客户(<?= htmlspecialcharsFix($row['oldCode']) ?>)</td>
- <td><?= htmlspecialcharsFix($customerCode) ?></td>
- </tr>
- <?php
- }
- } else {
- ?>
- <tr>
- <td colspan="4">当前暂无认领记录</td>
- </tr>
- <?php
- }
- ?>
- </tbody>
- <tfoot>
- <tr>
- <td colspan="4">
- <div class="showpagebox">
- <?php
- if (isset($totalPages) && $totalPages > 1) {
- $pageName = "?Keys=" . $keys . ($urlStr ?? '') . "&searcheType=" . $searcheType . "&";
- $pagelen = 3;
- // First page and Previous page
- if ($page > 1) {
- echo "<a href=\"{$pageName}Page=1\">首页</a>";
- echo "<a href=\"{$pageName}Page=" . ($page - 1) . "\">上一页</a>";
- }
- // Calculate page range
- if ($pagelen * 2 + 1 >= $totalPages) {
- $startPage = 1;
- $endPage = $totalPages;
- } else {
- if ($page <= $pagelen + 1) {
- $startPage = 1;
- $endPage = $pagelen * 2 + 1;
- } else {
- $startPage = $page - $pagelen;
- $endPage = $page + $pagelen;
- }
- if ($page + $pagelen > $totalPages) {
- $startPage = $totalPages - $pagelen * 2;
- $endPage = $totalPages;
- }
- }
- // Page numbers
- for ($i = $startPage; $i <= $endPage; $i++) {
- if ($i == $page) {
- echo "<a class=\"current\">{$i}</a>";
- } else {
- echo "<a href=\"{$pageName}Page={$i}\">{$i}</a>";
- }
- }
- // Next page and Last page
- if ($page < $totalPages) {
- if ($totalPages - $page > $pagelen) {
- echo "<a href=\"{$pageName}Page={$totalPages}\">...{$totalPages}</a>";
- }
- echo "<a href=\"{$pageName}Page=" . ($page + 1) . "\">下一页</a>";
- echo "<a href=\"{$pageName}Page={$totalPages}\">尾页</a>";
- }
- }
- ?>
- </div>
- </td>
- </tr>
- </tfoot>
- </table>
- </form>
- </div>
- </body>
- </html>
|