Files
transfer.tapee.ac.th/reports/transfer_report.php
T
pongpon pitisuk 72701ad58c Initial import
2026-06-25 16:49:13 +07:00

217 lines
11 KiB
PHP

<?php
$page_title = 'รายงานการประเมินเทียบโอนรายวิชา';
require_once __DIR__ . '/../includes/functions.php';
requireLogin();
$student_id = intval($_GET['student_id'] ?? 0);
requireStudentAccess($student_id);
$student = getStudent($student_id);
if (!$student) {
die('ไม่พบข้อมูลนักศึกษา');
}
$pdf_path = getStudentTransferPdfPath($student_id);
$report = null;
$error_msg = null;
if ($pdf_path && file_exists($pdf_path)) {
try {
$report = parseTransferReportFromPdf($pdf_path);
} catch (Exception $e) {
$error_msg = 'เกิดข้อผิดพลาดในการประมวลผลไฟล์ PDF: ' . $e->getMessage();
}
} else {
$error_msg = 'ยังไม่ได้นำเข้าไฟล์ PDF สำหรับการเทียบโอนวิชานี้ หรือไม่พบไฟล์ PDF ในระบบ';
}
$is_dbc = ($student['curriculum_code'] == 'DBC');
?>
<!DOCTYPE html>
<html lang="th">
<head>
<meta charset="UTF-8">
<title>รายงานผลการประเมินเทียบโอนรายวิชา - <?= htmlspecialchars($student['student_code']) ?></title>
<style>
@media print {
.no-print { display: none; }
body { font-family: 'TH Sarabun New', 'Leelawadee', 'Tahoma', sans-serif; }
}
body {
font-family: 'TH Sarabun New', 'Leelawadee', 'Tahoma', sans-serif;
font-size: 14px; padding: 20px; color: #333;
background-color: #f8f9fa;
}
.container {
max-width: 1000px;
margin: 0 auto;
background: white;
padding: 30px;
box-shadow: 0 0 10px rgba(0,0,0,0.05);
border-radius: 8px;
}
.header { text-align: center; border-bottom: 2px solid #333; padding-bottom: 10px; margin-bottom: 20px; }
.header h1 { font-size: 22px; margin: 0; font-weight: bold; }
.header h2 { font-size: 18px; margin: 5px 0; font-weight: normal; }
.student-info { margin-bottom: 25px; }
.student-info table { width: 100%; border: none; }
.student-info td { padding: 4px 10px; border: none; font-size: 14px; }
.section-title {
background: #0d6efd;
color: white;
padding: 6px 12px;
font-size: 15px;
font-weight: bold;
margin-top: 25px;
margin-bottom: 10px;
border-radius: 4px;
}
.section-title.dbc { background: #198754; }
.section-title.secondary { background: #6c757d; }
table { width: 100%; border-collapse: collapse; margin: 10px 0; }
th, td { border: 1px solid #ccc; padding: 6px 10px; text-align: left; font-size: 13px; }
th { background: #f1f3f5; font-weight: bold; }
.center { text-align: center; }
.right { text-align: right; }
.bold { font-weight: bold; }
.text-muted { color: #6c757d; }
.btn-print {
display: inline-block;
padding: 8px 16px;
background: #0d6efd;
color: white;
text-decoration: none;
border-radius: 4px;
margin-bottom: 15px;
font-size: 13px;
font-weight: bold;
}
.btn-print:hover { background: #0b5ed7; }
.alert {
padding: 15px;
margin-bottom: 20px;
border: 1px solid transparent;
border-radius: 4px;
font-size: 14px;
}
.alert-danger {
color: #842029;
background-color: #f8d7da;
border-color: #f5c2c7;
}
.footer { text-align: center; margin-top: 40px; padding-top: 15px; border-top: 1px solid #eee; font-size: 12px; color: #888; }
</style>
</head>
<body>
<div class="container">
<div class="no-print" style="margin-bottom:20px;">
<a href="#" onclick="window.print();return false;" class="btn-print">🖨️ พิมพ์รายงานนี้</a>
<a href="../students/view.php?id=<?= $student_id ?>" class="btn-print" style="background:#6c757d;">⬅ กลับไปข้อมูลนักศึกษา</a>
</div>
<div class="header">
<h1>ผลการประเมินเทียบโอนรายวิชา</h1>
<h2>มหาวิทยาลัยตาปี (Tapee University)</h2>
</div>
<div class="student-info">
<table>
<tr>
<td style="width:15%;"><strong>รหัสนักศึกษา:</strong></td>
<td style="width:35%;"><?= htmlspecialchars($student['student_code']) ?></td>
<td style="width:15%;"><strong>ปีที่เข้าศึกษา:</strong></td>
<td style="width:35%;"><?= $student['enrollment_year'] ?></td>
</tr>
<tr>
<td><strong>ชื่อ-นามสกุล:</strong></td>
<td><?= htmlspecialchars($student['name_th']) ?> (<?= htmlspecialchars($student['name_en']) ?>)</td>
<td><strong>คณะ:</strong></td>
<td><?= htmlspecialchars($student['faculty'] ?: '-') ?></td>
</tr>
<tr>
<td><strong>สาขาวิชา:</strong></td>
<td>
<?= htmlspecialchars($student['curriculum_code']) ?> - <?= htmlspecialchars($student['curriculum_name']) ?>
<div style="margin-top: 4px; font-size: 13px; color: #555;">
<strong>หน่วยกิตที่เทียบโอนได้:</strong> <span style="font-weight: bold; color: #198754; font-size: 14px;"><?= getTransferCreditsTotal($student_id) ?></span> หน่วยกิต
</div>
</td>
<td><strong>สถาบันที่จบเดิม:</strong></td>
<td><?= htmlspecialchars($student['graduated_institution'] ?: '-') ?></td>
</tr>
</table>
</div>
<?php if ($error_msg): ?>
<div class="alert alert-danger">
⚠️ <?= htmlspecialchars($error_msg) ?>
</div>
<?php else: ?>
<div class="section-title <?= $is_dbc ? 'dbc' : '' ?>">รายละเอียดวิชาที่เทียบโอนได้</div>
<table>
<thead>
<tr>
<th rowspan="2" class="center" style="vertical-align: middle; width: 5%;">ลำดับ</th>
<th colspan="3" class="center">วิชาปลายทาง (ตามหลักสูตร)</th>
<th colspan="5" class="center">วิชาต้นทางที่ใช้เทียบ (สถาบันเดิม)</th>
</tr>
<tr>
<th class="center" style="width: 10%;">รหัส</th>
<th>ชื่อวิชา</th>
<th class="center" style="width: 8%;">หน่วยกิต</th>
<th class="center" style="width: 12%;">รหัส</th>
<th>ชื่อวิชา</th>
<th class="center" style="width: 8%;">หน่วยกิต</th>
<th class="center" style="width: 6%;">เกรด</th>
<th class="center" style="width: 10%;">ความสอดคล้อง</th>
</tr>
</thead>
<tbody>
<?php if (empty($report['transfers'])): ?>
<tr>
<td colspan="9" class="center text-muted">ไม่พบข้อมูลรายวิชาที่เทียบโอนได้</td>
</tr>
<?php else: ?>
<?php foreach ($report['transfers'] as $transfer): ?>
<?php
$num_sources = count($transfer['sources']);
$first_source = $transfer['sources'][0];
?>
<tr>
<td class="center" rowspan="<?= $num_sources ?>"><?= htmlspecialchars($transfer['seq']) ?></td>
<td class="center bold" rowspan="<?= $num_sources ?>"><?= htmlspecialchars($transfer['target_code']) ?></td>
<td class="bold" rowspan="<?= $num_sources ?>"><?= htmlspecialchars($transfer['target_name']) ?></td>
<td class="center bold" rowspan="<?= $num_sources ?>"><?= number_format($transfer['target_credits'], 1) ?></td>
<td class="center"><?= htmlspecialchars($first_source['code']) ?></td>
<td><?= htmlspecialchars($first_source['name']) ?></td>
<td class="center"><?= htmlspecialchars($first_source['credits']) ?></td>
<td class="center bold"><?= htmlspecialchars($first_source['grade']) ?></td>
<td class="center"><?= htmlspecialchars($first_source['similarity']) ?></td>
</tr>
<?php for ($i = 1; $i < $num_sources; $i++): $src = $transfer['sources'][$i]; ?>
<tr>
<td class="center"><?= htmlspecialchars($src['code']) ?></td>
<td><?= htmlspecialchars($src['name']) ?></td>
<td class="center"><?= htmlspecialchars($src['credits']) ?></td>
<td class="center bold"><?= htmlspecialchars($src['grade']) ?></td>
<td class="center"><?= htmlspecialchars($src['similarity']) ?></td>
</tr>
<?php endfor; ?>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
<?php endif; ?>
<div class="footer">
ระบบเทียบโอนรายวิชา มหาวิทยาลัยตาปี<br>
เอกสารฉบับนี้วิเคราะห์และแสดงผลข้อมูลเทียบเคียงโดยตรงจากเอกสารผลประเมิน (PDF) ณ วันที่ <?= date('d/m/Y H:i') ?> น.
</div>
</div>
</body>
</html>