v0.1测试
This commit is contained in:
83
frontend/parent/attendance.php
Normal file
83
frontend/parent/attendance.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?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'] !== 'parent') {
|
||||
header('Location: /index.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
$page_title = '考勤记录';
|
||||
include __DIR__ . '/../includes/header.php';
|
||||
?>
|
||||
|
||||
<div class="nav">
|
||||
<a href="/parent/dashboard.php" class="nav-item">首页</a>
|
||||
<a href="/parent/homework.php" class="nav-item">作业情况</a>
|
||||
<a href="/parent/attendance.php" class="nav-item active">考勤记录</a>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card"><div class="stat-label">出勤</div><div class="stat-value" id="attPresent">0</div></div>
|
||||
<div class="stat-card"><div class="stat-label">缺勤</div><div class="stat-value" id="attAbsent">0</div></div>
|
||||
<div class="stat-card"><div class="stat-label">迟到</div><div class="stat-value" id="attLate">0</div></div>
|
||||
<div class="stat-card"><div class="stat-label">请假</div><div class="stat-value" id="attLeave">0</div></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></tr></thead>
|
||||
<tbody id="attendanceList"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
async function loadAttendance() {
|
||||
const res = await apiGet('/api/parent/child/attendance');
|
||||
if (res && res.success) {
|
||||
let present = 0, absent = 0, late = 0, leave = 0;
|
||||
let html = '';
|
||||
res.data.records.forEach(record => {
|
||||
html += `<tr>
|
||||
<td>${record.date}</td>
|
||||
<td>${getStatusBadge(record.status, 'attendance')}</td>
|
||||
<td>${escapeHtml(record.reason || '-')}</td>
|
||||
</tr>`;
|
||||
switch(record.status) {
|
||||
case 'present': present++; break;
|
||||
case 'absent': absent++; break;
|
||||
case 'late': late++; break;
|
||||
case 'leave': leave++; break;
|
||||
}
|
||||
});
|
||||
document.getElementById('attPresent').textContent = present;
|
||||
document.getElementById('attAbsent').textContent = absent;
|
||||
document.getElementById('attLate').textContent = late;
|
||||
document.getElementById('attLeave').textContent = leave;
|
||||
|
||||
if (res.data.records.length === 0) {
|
||||
html = '<tr><td colspan="3" style="text-align:center;">暂无记录</td></tr>';
|
||||
}
|
||||
document.getElementById('attendanceList').innerHTML = html;
|
||||
}
|
||||
}
|
||||
loadAttendance();
|
||||
</script>
|
||||
<script src="/assets/js/parent.js"></script>
|
||||
|
||||
<?php include __DIR__ . '/../includes/footer.php'; ?>
|
||||
272
frontend/parent/dashboard.php
Normal file
272
frontend/parent/dashboard.php
Normal file
@@ -0,0 +1,272 @@
|
||||
<?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'] !== 'parent') {
|
||||
header('Location: /index.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
$student_id = $_SESSION['student_id'];
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?php echo SITE_NAME; ?> - 家长端</title>
|
||||
<link rel="stylesheet" href="/assets/css/style.css">
|
||||
<style>
|
||||
.child-info {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border-radius: 12px;
|
||||
color: white;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.child-name {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.child-no {
|
||||
font-size: 14px;
|
||||
opacity: 0.9;
|
||||
}
|
||||
.conduct-score {
|
||||
text-align: center;
|
||||
padding: 30px;
|
||||
}
|
||||
.score-number {
|
||||
font-size: 72px;
|
||||
font-weight: bold;
|
||||
color: #667eea;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h1><?php echo SITE_NAME; ?> - 家长端</h1>
|
||||
<div class="header-info">
|
||||
<span class="user-name" id="userName"></span>
|
||||
<button class="btn-logout" id="logoutBtn">退出登录</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="nav">
|
||||
<button class="nav-item active" data-page="dashboard">首页</button>
|
||||
<button class="nav-item" data-page="homework">作业情况</button>
|
||||
<button class="nav-item" data-page="attendance">考勤记录</button>
|
||||
</div>
|
||||
|
||||
<div class="container" id="pageContainer">
|
||||
<!-- 首页内容 -->
|
||||
<div id="page-dashboard" class="page-content">
|
||||
<div class="child-info" id="childInfo">
|
||||
<div class="child-name" id="childName">--</div>
|
||||
<div class="child-no" id="childNo">--</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="conduct-score">
|
||||
<div class="score-number" id="totalPoints">--</div>
|
||||
<div class="score-label">当前操行分</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 作业情况页 -->
|
||||
<div id="page-homework" class="page-content" style="display: none;">
|
||||
<div class="card">
|
||||
<div class="card-title">作业列表</div>
|
||||
<div class="table-wrapper">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>科目</th>
|
||||
<th>作业标题</th>
|
||||
<th>截止日期</th>
|
||||
<th>状态</th>
|
||||
<th>备注</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="homeworkList"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 考勤记录页 -->
|
||||
<div id="page-attendance" class="page-content" style="display: none;">
|
||||
<div class="stats-grid">
|
||||
<div class="stat-card">
|
||||
<div class="stat-label">出勤</div>
|
||||
<div class="stat-value" id="attPresent">0</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-label">缺勤</div>
|
||||
<div class="stat-value" id="attAbsent">0</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-label">迟到</div>
|
||||
<div class="stat-value" id="attLate">0</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-label">请假</div>
|
||||
<div class="stat-value" id="attLeave">0</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-title">考勤记录明细</div>
|
||||
<div class="table-wrapper">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日期</th>
|
||||
<th>状态</th>
|
||||
<th>原因</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="attendanceList"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const API_BASE_URL = '<?php echo API_BASE_URL; ?>';
|
||||
const STUDENT_ID = <?php echo $student_id ?: 0; ?>;
|
||||
|
||||
// 页面切换
|
||||
function showPage(pageName) {
|
||||
document.querySelectorAll('.page-content').forEach(page => {
|
||||
page.style.display = 'none';
|
||||
});
|
||||
document.getElementById(`page-${pageName}`).style.display = 'block';
|
||||
|
||||
document.querySelectorAll('.nav-item').forEach(item => {
|
||||
item.classList.remove('active');
|
||||
if (item.dataset.page === pageName) {
|
||||
item.classList.add('active');
|
||||
}
|
||||
});
|
||||
|
||||
switch(pageName) {
|
||||
case 'dashboard':
|
||||
loadDashboard();
|
||||
break;
|
||||
case 'homework':
|
||||
loadHomework();
|
||||
break;
|
||||
case 'attendance':
|
||||
loadAttendance();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 加载首页
|
||||
async function loadDashboard() {
|
||||
try {
|
||||
// 获取子女信息
|
||||
const childRes = await apiGet(`/api/parent/child/conduct`);
|
||||
if (childRes && childRes.success) {
|
||||
document.getElementById('childName').textContent = childRes.data.student_name;
|
||||
document.getElementById('childNo').textContent = childRes.data.student_no;
|
||||
document.getElementById('totalPoints').textContent = childRes.data.total_points;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载首页失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 加载作业
|
||||
async function loadHomework() {
|
||||
try {
|
||||
const res = await apiGet(`/api/parent/child/homework`);
|
||||
if (res && res.success) {
|
||||
let html = '';
|
||||
res.data.homework.forEach(hw => {
|
||||
html += `
|
||||
<tr>
|
||||
<td>${hw.subject}</td>
|
||||
<td>${hw.title}</td>
|
||||
<td>${hw.deadline}</td>
|
||||
<td>${getStatusBadge(hw.status, 'homework')}</td>
|
||||
<td>${hw.comments || '-'}</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
if (res.data.homework.length === 0) {
|
||||
html = '<tr><td colspan="5" style="text-align:center;">暂无作业</td></tr>';
|
||||
}
|
||||
document.getElementById('homeworkList').innerHTML = html;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载作业失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 加载考勤
|
||||
async function loadAttendance() {
|
||||
try {
|
||||
const res = await apiGet(`/api/parent/child/attendance`);
|
||||
if (res && res.success) {
|
||||
const records = res.data.records;
|
||||
let present = 0, absent = 0, late = 0, leave = 0;
|
||||
|
||||
let html = '';
|
||||
records.forEach(record => {
|
||||
html += `
|
||||
<tr>
|
||||
<td>${record.date}</td>
|
||||
<td>${getStatusBadge(record.status, 'attendance')}</td>
|
||||
<td>${record.reason || '-'}</td>
|
||||
</tr>
|
||||
`;
|
||||
switch(record.status) {
|
||||
case 'present': present++; break;
|
||||
case 'absent': absent++; break;
|
||||
case 'late': late++; break;
|
||||
case 'leave': leave++; break;
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('attPresent').textContent = present;
|
||||
document.getElementById('attAbsent').textContent = absent;
|
||||
document.getElementById('attLate').textContent = late;
|
||||
document.getElementById('attLeave').textContent = leave;
|
||||
|
||||
if (records.length === 0) {
|
||||
html = '<tr><td colspan="3" style="text-align:center;">暂无考勤记录</td></tr>';
|
||||
}
|
||||
document.getElementById('attendanceList').innerHTML = html;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载考勤失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化
|
||||
document.querySelectorAll('.nav-item').forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
showPage(btn.dataset.page);
|
||||
});
|
||||
});
|
||||
|
||||
loadDashboard();
|
||||
</script>
|
||||
<script src="/assets/js/common.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
66
frontend/parent/homework.php
Normal file
66
frontend/parent/homework.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?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'] !== 'parent') {
|
||||
header('Location: /index.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
$page_title = '作业情况';
|
||||
include __DIR__ . '/../includes/header.php';
|
||||
?>
|
||||
|
||||
<div class="nav">
|
||||
<a href="/parent/dashboard.php" class="nav-item">首页</a>
|
||||
<a href="/parent/homework.php" class="nav-item active">作业情况</a>
|
||||
<a href="/parent/attendance.php" class="nav-item">考勤记录</a>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<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><th>备注</th></tr></thead>
|
||||
<tbody id="homeworkList"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
async function loadHomework() {
|
||||
const res = await apiGet('/api/parent/child/homework');
|
||||
if (res && res.success) {
|
||||
let html = '';
|
||||
res.data.homework.forEach(hw => {
|
||||
html += `<tr>
|
||||
<td>${escapeHtml(hw.subject)}</td>
|
||||
<td>${escapeHtml(hw.title)}</td>
|
||||
<td>${hw.deadline}</td>
|
||||
<td>${getStatusBadge(hw.status, 'homework')}</td>
|
||||
<td>${escapeHtml(hw.comments || '-')}</td>
|
||||
</tr>`;
|
||||
});
|
||||
if (res.data.homework.length === 0) {
|
||||
html = '<tr><td colspan="5" style="text-align:center;">暂无作业</td></tr>';
|
||||
}
|
||||
document.getElementById('homeworkList').innerHTML = html;
|
||||
}
|
||||
}
|
||||
loadHomework();
|
||||
</script>
|
||||
<script src="/assets/js/parent.js"></script>
|
||||
|
||||
<?php include __DIR__ . '/../includes/footer.php'; ?>
|
||||
Reference in New Issue
Block a user