<?php session_start();include 'common.php';if(!isset($_SESSION['user'])){header("Location:login.php");exit;}$u=$_SESSION['user'];$f='user/'.APPID1.'_'.$u.suffix;if(isset($_GET['del'])&&is_numeric($_GET['del'])){$i=intval($_GET['del']);if(file_exists($f)){$r=json_decode(file_get_contents($f),true);if(isset($r[$i])){array_splice($r,$i,1);file_put_contents($f,json_encode($r,JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT));}}header("Location:record.php");exit;}$r=[];if(file_exists($f)){$r=json_decode(file_get_contents($f),true);if(!is_array($r))$r=[];}$k=$_GET['q']??'';if($k!==''){$r=array_filter($r,function($x)use($k){$s=($x['name']??'').($x['sex']??'').($x['inputdate']??'');return mb_strpos($s,$k)!==false;});}$p=max(1,intval($_GET['page']??1));$s=10;$t=count($r);$tp=max(1,ceil($t/$s));$sl=array_slice(array_values($r),($p-1)*$s,$s);function g($x){return $x=='0'?'男':'女';}?><!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><title>排盘记录</title><link rel="stylesheet" href="date/date/bootstrap.min5.3.1.css"><style>body{background:#f8f9fa;font-family:"PingFang SC","Microsoft YaHei",Arial,sans-serif}.container{max-width:600px;margin:24px auto 70px auto;padding:0 8px}@media (max-width:700px){.container{max-width:100%;margin:8px auto 70px auto;padding:0 3px}}.form-inline{flex-wrap:wrap;gap:6px}.form-inline .form-control,.form-inline .btn{font-size:1.05rem;padding:0.5em 0.9em}.table-responsive{margin-bottom:12px;border-radius:8px;overflow-x:auto}.table{background:#fff;margin-bottom:0;font-size:1rem;min-width:340px;border-radius:8px;overflow:hidden}.table td,.table th{vertical-align:middle;padding:0.55em 0.5em;border-color:#eee}.icon-btn{border:none;background:transparent;cursor:pointer;padding:2px 6px}.icon-pencil{font-size:20px;color:#333}.icon-del{font-size:20px;color:#cc0000}.table tr td:last-child{white-space:nowrap}.text-muted{font-size:1rem}.record-link{color:#222;text-decoration:none;display:block;width:100%;transition:background 0.12s;border-radius:4px;padding:2px 0}.page-pagination-wrap{display:flex;justify-content:center;align-items:center;margin:16px 0 0 0;gap:18px}@media (max-width:600px){.form-inline .form-control,.form-inline .btn{font-size:0.98rem;padding:0.45em 0.7em}.table{font-size:0.98rem;min-width:220px}.table-responsive{margin-bottom:4px}.text-muted{font-size:0.95rem}.table td,.table th{padding:0.45em 0.25em}.page-pagination-wrap{gap:10px;margin-top:10px}}@media (max-width:400px){.table{font-size:0.93rem}}</style></head><body><div class="container"><form class="d-flex align-items-center mb-2" method="get"><input type="text" class="form-control me-2" name="q" value="<?=htmlspecialchars($k)?>" placeholder="搜索姓名/时间" style="flex:1;min-width:100px;"><button class="btn btn-outline-secondary me-1" style="min-width:64px;">搜索</button><button type="button" class="btn btn-outline-info me-1" style="min-width:90px;" onclick="location.href='changepwd.php'">修改密码</button><button type="button" class="btn btn-outline-danger" style="min-width:60px;" onclick="location.href='logout.php'">退出</button></form>
<?php $recordsList = $sl ?? [];$currentPage = max(1, intval($p ?? 1));$totalPages = max(1, intval($tp ?? 1));$searchQuery = htmlspecialchars($k ?? '');function renderPagination($currentPage, $totalPages, $queryParams) {$prevPage = max(1, $currentPage - 1);$nextPage = min($totalPages, $currentPage + 1);$prevDisabled = $currentPage <= 1 ? 'disabled' : '';$nextDisabled = $currentPage >= $totalPages ? 'disabled' : '';$baseUrl = '?' . http_build_query($queryParams);echo "<div class='page-pagination-wrap'><button class='btn btn-secondary btn-sm' $prevDisabled onclick=\"location.href='{$baseUrl}&page=$prevPage'\">上一页</button><span style='font-size:0.98rem;'>$currentPage / $totalPages</span><button class='btn btn-secondary btn-sm' $nextDisabled onclick=\"location.href='{$baseUrl}&page=$nextPage'\">下一页</button></div>";}?><div class='table-responsive'><table class='table table-bordered mb-1'><tbody><?php if (empty($recordsList)) {echo '<tr><td colspan="2" class="text-center text-muted">暂无记录</td></tr>';} else {foreach ($recordsList as $i => $x) {$recordId = $i + ($currentPage - 1) * $s;$name = htmlspecialchars($x['name'] ?? '');$sex = g($x['sex'] ?? '');$delUrl = "?del={$recordId}";$showUrl = "show.php?ID=1&id={$recordId}";echo "<tr><td><a class='record-link' href='{$showUrl}'>";if($x['DateType']==4){echo "{$name} {$sex} 反推 {$x['ng']} {$x['yg']} {$x['rg']} {$x['sg']}";}if($x['DateType']==5){echo "{$name} {$sex} {$x['inputdate']}";}if($x['DateType']==7){echo "{$name} {$sex} 速排 {$x['supai']}";}echo "</a></td><td class='action-column'><a class='icon-btn' title='删除' href='{$delUrl}' onclick='return confirm(\"确定要删除此条记录吗？\");'><svg class='icon-del' viewBox='0 0 1024 1024' width='20' height='20'><circle cx='512' cy='512' r='512' fill='#f5f5f5'/><path d='M320 320l384 384M704 320L320 704' stroke='#cc0000' stroke-width='60' stroke-linecap='round'/></svg></a></td></tr>";}}?></tbody></table></div><?php renderPagination($currentPage, $totalPages, ['q' => $searchQuery]);include'footer.php';?></body></html>