92 lines
3.1 KiB
PHP
92 lines
3.1 KiB
PHP
<?php
|
|
/**
|
|
* 班级操行分管理系统 - 管理端首页
|
|
*
|
|
* 开发者: Canglan
|
|
* 联系方式: admin@sea-studio.top
|
|
* 版权归属: Sea Network Technology Studio
|
|
* 许可证: MIT License
|
|
*
|
|
* 版权所有 © Sea Network Technology Studio
|
|
*/
|
|
|
|
require_once __DIR__ . '/../config.php';
|
|
|
|
if (!isset($_SESSION['user_id']) || $_SESSION['user_type'] !== 'admin') {
|
|
header('Location: /index.php');
|
|
exit();
|
|
}
|
|
|
|
$page_title = '首页';
|
|
$role = $_SESSION['role'] ?? '';
|
|
include __DIR__ . '/../includes/header.php';
|
|
?>
|
|
|
|
<?php include __DIR__ . '/../includes/nav.php'; ?>
|
|
|
|
<div class="container">
|
|
<div class="stats-grid" id="dashboardStats"></div>
|
|
|
|
<div class="card">
|
|
<div class="card-title">快捷操作</div>
|
|
<div class="action-buttons" id="quickActions"></div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-title">操行分排行榜</div>
|
|
<div class="table-wrapper">
|
|
<table class="table">
|
|
<thead>
|
|
<tr><th>排名</th><th>学号</th><th>姓名</th><th>操行分</th></tr>
|
|
</thead>
|
|
<tbody id="rankingList"></tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
async function loadDashboard() {
|
|
const studentsRes = await apiGet('/api/admin/students');
|
|
if (studentsRes && studentsRes.success) {
|
|
document.getElementById('dashboardStats').innerHTML = `
|
|
<div class="stat-card">
|
|
<div class="stat-label">学生总数</div>
|
|
<div class="stat-value">${studentsRes.data.total || 0}</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
let quickActions = '';
|
|
if ('<?php echo $role; ?>' === '班主任' || '<?php echo $role; ?>' === '班长' || '<?php echo $role; ?>' === '劳动委员' || '<?php echo $role; ?>' === '志愿委员') {
|
|
quickActions += '<button class="btn btn-primary" onclick="location.href=\'/admin/conduct.php\'">操行分管理</button>';
|
|
}
|
|
if ('<?php echo $role; ?>' === '班主任') {
|
|
quickActions += '<button class="btn btn-success" onclick="location.href=\'/admin/students.php\'">导入学生</button>';
|
|
quickActions += '<button class="btn btn-secondary" onclick="location.href=\'/admin/conduct.php\'">导出德育分记录</button>';
|
|
}
|
|
document.getElementById('quickActions').innerHTML = quickActions || '<p>暂无快捷操作</p>';
|
|
|
|
const rankingRes = await apiGet('/api/student/ranking', { limit: 100 });
|
|
if (rankingRes && rankingRes.success) {
|
|
let html = '';
|
|
rankingRes.data.ranking.forEach((student, index) => {
|
|
html += `<tr>
|
|
<td>${index + 1}</td>
|
|
<td>${escapeHtml(student.student_no)}</td>
|
|
<td>${escapeHtml(student.name)}</td>
|
|
<td>${student.total_points}</td>
|
|
</tr>`;
|
|
});
|
|
if (rankingRes.data.ranking.length === 0) {
|
|
html = '<tr><td colspan="4" style="text-align:center;">暂无数据</td></tr>';
|
|
}
|
|
document.getElementById('rankingList').innerHTML = html;
|
|
}
|
|
}
|
|
|
|
loadDashboard();
|
|
</script>
|
|
<script src="/assets/js/admin.js"></script>
|
|
|
|
<?php include __DIR__ . '/../includes/footer.php'; ?>
|