Initial import

This commit is contained in:
pongpon pitisuk
2026-06-25 16:49:13 +07:00
commit 72701ad58c
120 changed files with 17590 additions and 0 deletions
+100
View File
@@ -0,0 +1,100 @@
<?php
$page_title = 'รายชื่อนักศึกษา';
require_once __DIR__ . '/../includes/functions.php';
if (isStudent()) {
header('Location: ' . BASE_URL . '/index.php');
exit;
}
require_once __DIR__ . '/../includes/header.php';
$students = getStudents();
$db = getDB();
$credits_map = [];
if (!empty($students)) {
$ids = array_column($students, 'id');
$placeholders = implode(',', array_fill(0, count($ids), '?'));
$stmt = $db->prepare("
SELECT
student_id,
COALESCE(SUM(CASE WHEN source_type = 'transfer' THEN credits ELSE 0 END), 0) AS transfer_total,
COALESCE(SUM(CASE WHEN source_type = 'manual' THEN credits ELSE 0 END), 0) AS manual_total,
COALESCE(SUM(credits), 0) AS total
FROM student_courses
WHERE student_id IN ($placeholders)
GROUP BY student_id
");
$stmt->execute($ids);
foreach ($stmt->fetchAll() as $row) {
$credits_map[$row['student_id']] = [
'transfer' => floatval($row['transfer_total']),
'manual' => floatval($row['manual_total']),
'total' => floatval($row['total'])
];
}
}
?>
<div class="page-heading">
<div>
<h4><i class="bi bi-people"></i> รายชื่อนักศึกษา</h4>
<div class="text-muted small">ทั้งหมด <?= count($students) ?> รายการ</div>
</div>
<a href="add.php" class="btn btn-primary"><i class="bi bi-person-plus"></i> เพิ่มนักศึกษา</a>
</div>
<div class="card">
<div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
<h4 class="mb-0"><i class="bi bi-table"></i> ตารางข้อมูลนักศึกษา</h4>
<span class="badge bg-primary"><?= count($students) ?> รายการ</span>
</div>
<div class="card-body">
<?php if (empty($students)): ?>
<div class="alert alert-info">ยังไม่มีข้อมูลนักศึกษา <a href="add.php">คลิกเพิ่มนักศึกษา</a></div>
<?php else: ?>
<div class="table-responsive">
<table class="table table-hover table-bordered">
<thead class="table-light">
<tr>
<th>รหัสนักศึกษา</th>
<th>ชื่อ-นามสกุล</th>
<th>สาขาวิชา</th>
<th>คณะ</th>
<th>สถาบันที่จบ</th>
<th>วุฒิเดิม</th>
<th>ปีการศึกษา</th>
<th class="text-center">หน่วยกิตที่เทียบโอน</th>
<th class="text-center">หน่วยกิตที่เรียนแล้ว</th>
<th class="text-center">หน่วยกิตทั้งหมดที่เทียบโอนและเรียนแล้ว</th>
<th>การจัดการ</th>
</tr>
</thead>
<tbody>
<?php foreach ($students as $s): ?>
<tr>
<td><strong><?= htmlspecialchars($s['student_code']) ?></strong></td>
<td><?= htmlspecialchars($s['name_th']) ?></td>
<td><span class="badge bg-<?= $s['curriculum_code'] == 'DT' ? 'primary' : 'success' ?>"><?= htmlspecialchars($s['curriculum_code']) ?></span></td>
<td><small><?= htmlspecialchars($s['faculty'] ?: '-') ?></small></td>
<td><small><?= htmlspecialchars($s['graduated_institution'] ?: '-') ?></small></td>
<td><small><?= htmlspecialchars($s['previous_qualification'] ?: '-') ?></small></td>
<td><?= $s['enrollment_year'] ?></td>
<td class="text-center"><?= $credits_map[$s['id']]['transfer'] ?? 0 ?></td>
<td class="text-center"><?= $credits_map[$s['id']]['manual'] ?? 0 ?></td>
<td class="text-center fw-bold"><?= $credits_map[$s['id']]['total'] ?? 0 ?></td>
<td>
<div class="action-buttons">
<a href="view.php?id=<?= $s['id'] ?>" class="btn btn-info btn-sm"><i class="bi bi-eye"></i> ดูข้อมูล</a>
<a href="edit.php?id=<?= $s['id'] ?>" class="btn btn-warning btn-sm"><i class="bi bi-pencil"></i> แก้ไข</a>
<a href="delete.php?id=<?= $s['id'] ?>" class="btn btn-danger btn-sm" onclick="return confirm('ยืนยันการลบข้อมูลนักศึกษา?')"><i class="bi bi-trash"></i> ลบ</a>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
<?php require_once __DIR__ . '/../includes/footer.php'; ?>