-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport.php
More file actions
101 lines (92 loc) · 5.45 KB
/
Copy pathexport.php
File metadata and controls
101 lines (92 loc) · 5.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
require_once("includes/auth.php");
require_role(['admin', 'staff']);
include("config.php");
$years_result = mysqli_query($conn, "SELECT DISTINCT academic_year FROM students ORDER BY academic_year DESC");
$total_students = mysqli_fetch_assoc(mysqli_query($conn, "SELECT COUNT(*) as c FROM students"))['c'];
$page_title = "Export ข้อมูล";
$form_width = true;
include("includes/header.php");
?>
<div class="breadcrumb">
<a href="index.php"><?php echo icon('home', ['class'=>'icon-sm']); ?> หน้าหลัก</a>
<span class="sep">/</span><span class="current">Export ข้อมูล</span>
</div>
<div class="page-header"><div><h1>Export ข้อมูลนักศึกษาและการฝึกงาน</h1></div></div>
<p class="page-subtitle mb-4">เลือกตัวกรอง (หรือปล่อยว่างเพื่อ Export ข้อมูลทั้งหมด) แล้วเลือกรูปแบบไฟล์ที่ต้องการ</p>
<div class="alert alert-info">
<?php echo icon('info'); ?>
<span>มีข้อมูลนักศึกษาทั้งหมด <strong><?php echo number_format($total_students); ?></strong> รายการก่อนกรอง — ไฟล์ที่ได้จะไม่รวมรหัสผ่านหรือข้อมูลลับใดๆ และเข้าถึงได้เฉพาะอาจารย์/เจ้าหน้าที่ที่เข้าสู่ระบบเท่านั้น</span>
</div>
<div class="card">
<form method="GET" action="export_excel.php" id="exportForm" target="_blank">
<div class="form-grid">
<div class="gc-6">
<label class="form-label" for="internship_status">สถานะการฝึกงาน</label>
<select id="internship_status" name="internship_status" class="input">
<option value="">ทั้งหมด</option>
<option value="กำลังฝึกงาน">กำลังฝึกงาน</option>
<option value="ฝึกงานเสร็จสิ้น">ฝึกงานเสร็จสิ้น</option>
<option value="ยกเลิกการฝึกงาน">ยกเลิกการฝึกงาน</option>
</select>
</div>
<div class="gc-6">
<label class="form-label" for="year_level">ชั้นปี</label>
<select id="year_level" name="year_level" class="input">
<option value="">ทั้งหมด</option>
<?php for($y=1;$y<=6;$y++): ?>
<option value="<?php echo $y; ?>">ปี <?php echo $y; ?></option>
<?php endfor; ?>
</select>
</div>
<div class="gc-6">
<label class="form-label" for="semester">ภาคการศึกษา</label>
<select id="semester" name="semester" class="input">
<option value="">ทั้งหมด</option>
<option value="1">ภาคเรียนที่ 1</option>
<option value="2">ภาคเรียนที่ 2</option>
<option value="3">ภาคฤดูร้อน</option>
</select>
</div>
<div class="gc-6">
<label class="form-label" for="academic_year">ปีการศึกษา</label>
<select id="academic_year" name="academic_year" class="input">
<option value="">ทั้งหมด</option>
<?php mysqli_data_seek($years_result, 0); while($y = mysqli_fetch_assoc($years_result)): ?>
<option value="<?php echo $y['academic_year']; ?>"><?php echo $y['academic_year']; ?></option>
<?php endwhile; ?>
</select>
</div>
</div>
<div class="btn-group mt-4">
<button type="submit" formaction="export_excel.php" class="btn btn-primary" id="exportExcelBtn"><?php echo icon('download', ['class'=>'icon-sm']); ?> Export เป็น Excel</button>
<button type="submit" formaction="export_pdf.php" class="btn btn-secondary" id="exportPdfBtn"><?php echo icon('download', ['class'=>'icon-sm']); ?> Export เป็น PDF</button>
</div>
</form>
</div>
<script>
(function() {
var form = document.getElementById('exportForm');
var excelBtn = document.getElementById('exportExcelBtn');
var pdfBtn = document.getElementById('exportPdfBtn');
function guard(btn, label) {
btn.addEventListener('click', function() {
window.setTimeout(function() {
excelBtn.disabled = true;
pdfBtn.disabled = true;
btn.setAttribute('aria-busy', 'true');
btn.textContent = 'กำลังสร้างไฟล์...';
window.setTimeout(function() {
excelBtn.disabled = false;
pdfBtn.disabled = false;
excelBtn.textContent = 'Export เป็น Excel';
pdfBtn.textContent = 'Export เป็น PDF';
}, 3000);
}, 0);
});
}
guard(excelBtn, 'Excel');
guard(pdfBtn, 'PDF');
})();
</script>
<?php include("includes/footer.php"); ?>