forked from afzafri/UiTM-Timetable-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
executable file
·66 lines (52 loc) · 1.8 KB
/
api.php
File metadata and controls
executable file
·66 lines (52 loc) · 1.8 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
<?php
require_once('./modules/istudent_module.php');
require_once('./modules/icress_module.php');
require_once('./modules/excel_module.php');
CACHE_TYPE == 'file' ? require_once('./modules/file_module.php') : require_once('./modules/sqlite_module.php');
if(isset($_GET['getlist'])) {
die(CACHE_TYPE == 'file' ? file_getJadual()
: db_getJadual());
}
if(isset($_GET['getsubject'])) {
if(!empty($_POST['faculty'])) {
die(CACHE_TYPE == 'file' ? file_getFaculty($_POST['faculty'])
: db_getFaculty($_POST['faculty']));
}
}
if(isset($_GET['getgroup'])) {
if(!empty($_POST['subject']) && !empty($_POST['faculty'])) {
die(CACHE_TYPE == 'file' ? file_getSubject($_POST['faculty'], $_POST['subject'])
: db_getSubject($_POST['faculty'], $_POST['subject']));
}
}
if(isset($_GET['fetchDataMatrix'])) {
if(!empty($_POST['studentId'])) {
try {
$obj = new IStudent($_POST['studentId']);
$courses = $obj->getCourses();
$uitmcode = $obj->getUiTMCode();
if($courses === null || $uitmcode === false) {
throw new Exception("Can't fetch resources for this student Id (" . $_POST['studentId'] . ") !");
}
die(json_encode(array(
'Courses' => $courses,
'UiTMCode' => $uitmcode)));
} catch (Exception $e) {
die('Alert_Error:' . htmlentities($e->getMessage()));
}
}
}
if(isset($_GET['exportexcel'])) {
if(!empty($_POST['timetableInfo'])) {
$obj = new Excel();
$result = $obj->exportExcel($_POST['timetableInfo']);
die($result);
}
}
if(isset($_GET['importexcel'])) {
if(!empty($_FILES['excelFile'])) {
$obj = new Excel();
$result = $obj->importExcel($_FILES['excelFile']);
die($result);
}
}