Files
ClassManager/frontend/admin/semesters.php
2026-05-29 20:16:25 +08:00

205 lines
8.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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();
}
$role = $_SESSION['role'] ?? '';
if ($role !== '班主任') {
header('Location: /admin/dashboard.php');
exit();
}
$page_title = '学期管理';
include __DIR__ . '/../includes/header.php';
?>
<?php include __DIR__ . '/../includes/nav.php'; ?>
<div class="container">
<div class="card">
<div class="action-bar">
<button class="btn btn-primary" onclick="showCreateSemesterModal()">创建新学期</button>
</div>
<div class="table-wrapper">
<table class="table">
<thead>
<tr>
<th>学期名称</th>
<th>开始日期</th>
<th>结束日期</th>
<th>当前周数</th>
<th>状态</th>
<th>记录数</th>
<th>创建时间</th>
<th>操作</th>
</tr>
</thead>
<tbody id="semesterList"></tbody>
</table>
</div>
</div>
</div>
<!-- 创建学期模态框 -->
<div id="createSemesterModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>创建新学期</h3>
<button class="modal-close" onclick="closeModal('createSemesterModal')">&times;</button>
</div>
<form onsubmit="event.preventDefault(); submitCreateSemester()">
<div class="form-group">
<label>学期名称 <span style="color:red;">*</span></label>
<input type="text" id="semesterName" required placeholder="如2025春季学期" maxlength="100">
</div>
<div style="margin-bottom: 8px;">
<button type="button" class="btn btn-sm btn-outline" style="margin-right: 6px;" onclick="fillSemesterDates('upper')">上学期9月-次年2月</button>
<button type="button" class="btn btn-sm btn-outline" onclick="fillSemesterDates('lower')">下学期3月-7月</button>
</div>
<div class="form-group">
<label>开始日期</label>
<input type="date" id="semesterStartDate">
</div>
<div class="form-group">
<label>结束日期 <small style="color: #999;">(可选)</small></label>
<input type="date" id="semesterEndDate" placeholder="可选,不确定可不填">
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">创建学期</button>
<button type="button" class="btn" onclick="closeModal('createSemesterModal')">取消</button>
</div>
</form>
</div>
</div>
<!-- 编辑学期模态框 -->
<div id="editSemesterModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>编辑学期</h3>
<button class="modal-close" onclick="closeModal('editSemesterModal')">&times;</button>
</div>
<form onsubmit="event.preventDefault(); submitEditSemester()">
<input type="hidden" id="editSemesterId">
<div class="form-group">
<label>学期名称 <span style="color:red;">*</span></label>
<input type="text" id="editSemesterName" required placeholder="如2025春季学期" maxlength="100">
</div>
<div class="form-group">
<label>开始日期</label>
<input type="date" id="editSemesterStartDate">
</div>
<div class="form-group">
<label>结束日期 <small style="color: #999;">(可选)</small></label>
<input type="date" id="editSemesterEndDate">
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">保存修改</button>
<button type="button" class="btn btn-danger" onclick="deleteSemester()">删除学期</button>
<button type="button" class="btn" onclick="closeModal('editSemesterModal')">取消</button>
</div>
</form>
</div>
</div>
<!-- 关联数据确认模态框 -->
<div id="associateConfirmModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>关联数据到学期</h3>
<button class="modal-close" onclick="closeModal('associateConfirmModal')">&times;</button>
</div>
<div class="form-group">
<p id="associateConfirmText" style="margin: 10px 0;"></p>
<p style="color: #666; font-size: 14px;">将把该日期范围内所有未分配学期的操行分记录和考勤记录关联到此学期。</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="confirmAssociate()">确认关联</button>
<button type="button" class="btn" onclick="closeModal('associateConfirmModal')">取消</button>
</div>
</div>
</div>
<!-- 归档确认模态框 -->
<div id="archiveConfirmModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>确认归档学期</h3>
<button class="modal-close" onclick="closeModal('archiveConfirmModal')">&times;</button>
</div>
<div class="form-group">
<p id="archiveConfirmText" style="margin: 10px 0;"></p>
<p style="color: #666; font-size: 14px;">归档会创建所有学生当前操行分的数据快照,原始数据不受影响。</p>
<div style="margin-top: 10px;">
<label style="display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px;">
<input type="checkbox" id="archiveResetScores">
归档后重置所有学生操行分为初始值60分
</label>
</div>
<p style="color: #e74c3c; font-size: 13px; margin-top: 6px;">注意:归档前需确保学期已设置开始日期,否则无法归档。归档后该学期数据将变为只读,不可撤销。</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="confirmArchive()">确认归档</button>
<button type="button" class="btn" onclick="closeModal('archiveConfirmModal')">取消</button>
</div>
</div>
</div>
<!-- 归档数据查看模态框 -->
<div id="archiveDataModal" class="modal">
<div class="modal-content" style="max-width: 700px;">
<div class="modal-header">
<h3 id="archiveDataTitle">归档数据</h3>
<button class="modal-close" onclick="closeModal('archiveDataModal')">&times;</button>
</div>
<div class="table-wrapper">
<table class="table">
<thead>
<tr>
<th colspan="2" style="text-align:center; border-bottom: none;">基本信息</th>
<th rowspan="2" style="vertical-align: middle;">姓名</th>
<th rowspan="2" style="vertical-align: middle;">操行分</th>
<th colspan="4" style="text-align:center; border-bottom: none;">考勤统计</th>
<th colspan="3" style="text-align:center; border-bottom: none;">作业统计</th>
</tr>
<tr>
<th>排名</th>
<th>学号</th>
<th>出勤</th>
<th>缺勤</th>
<th>迟到</th>
<th>请假</th>
<th>已交</th>
<th>未交</th>
<th>迟交</th>
</tr>
</thead>
<tbody id="archiveDataList"></tbody>
</table>
</div>
<div class="pagination" id="archivePagination"></div>
<div class="modal-footer">
<button type="button" class="btn" onclick="closeModal('archiveDataModal')">关闭</button>
</div>
</div>
</div>
<script src="/assets/js/modules/modal-utils.js"></script>
<script src="/assets/js/semesters.js"></script>
<?php include __DIR__ . '/../includes/footer.php'; ?>