-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsemester_manage.php
103 lines (89 loc) · 3.24 KB
/
semester_manage.php
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
/**
* Semester Manage page
*
* Serial: 120405
* by: M.Karminski
*
*/
//Page number
$PAGE_SWITCH = 1;
//Include files
include('settings.php');
include('html_head.php');
include('etc/global_vars.php');
include('functions/database_functions.php');
include('functions/global_functions.php');
include('functions/views_output_functions.php');
//TODO: set the default POST value to disable the php notice.
//Load the file name for post
$FILE_NAME = $_SERVER['PHP_SELF'];
//Load the database table name
$TABLE_NAME = $PAGE_INFO_ARRAY[$PAGE_SWITCH]['TABLE_NAME'];
//Load this page database table key names array
$THIS_TABLE_KEY_NAMES_ARRAY = $TABLE_KEY_NAMES_ARRAY[$PAGE_SWITCH];
//Load this page database table key types array
$THIS_TABLE_KEY_TYPES_ARRAY = $TABLE_KEY_TYPES_ARRAY[$PAGE_SWITCH];
//QUERY the $semesterListArray
$semesterListArray = table_data_query($TABLE_NAME, $THIS_TABLE_KEY_NAMES_ARRAY);
//Load the target array number
$targetArray = $_POST['semesterList'];
//Load the target array ID number
$targetId = $semesterListArray[$targetArray][$THIS_TABLE_KEY_NAMES_ARRAY['id']];
//Reunion the semester name
$_POST[$THIS_TABLE_KEY_NAMES_ARRAY['SEMESTER']] = $_POST["semesterPartA"]."_".$_POST["semesterPartB"];
//CREATE the TABLE if query result not avaliable
if(!$semesterListArray){
database_table_create($TABLE_NAME, $THIS_TABLE_KEY_NAMES_ARRAY, $THIS_TABLE_KEY_TYPES_ARRAY);
}
//ADD the semester information to database if POST
if($_POST["semesterInfoAdd"]){
//Load the POST info array
foreach($THIS_TABLE_KEY_NAMES_ARRAY as $value){
$semesterInfoArray[$value] = $_POST[$THIS_TABLE_KEY_NAMES_ARRAY[$value]];
}
unset($value);
table_data_add($TABLE_NAME, $THIS_TABLE_KEY_NAMES_ARRAY, $semesterInfoArray);
}
//DELETE the semester information to database if POST
if($_POST["semesterListDelete"]){
table_data_delete_by_id($TABLE_NAME, $targetId);
}
//CHANGE the semester information to database if POST
if($_POST["semesterInfoChange"]){
foreach($THIS_TABLE_KEY_NAMES_ARRAY as $value){
$semesterInfoChangeArray[$value] = $_POST[$THIS_TABLE_KEY_NAMES_ARRAY[$value]];
}
unset($value);
table_data_change($TABLE_NAME, $THIS_TABLE_KEY_NAMES_ARRAY, $targetId, $semesterInfoChangeArray);
}
//REQUERY the $semesterListArray for display
$semesterListArray = table_data_query($TABLE_NAME, $THIS_TABLE_KEY_NAMES_ARRAY);
//------ -[ Views Output ]- ------
div_head_output_with_class_option("mainMiddle");
//Print Main Title
main_title_output($PAGE_INFO_ARRAY, $PAGE_SWITCH);
//Print main form
div_head_output_with_class_option("form");
//Print form Block
form_head_output($FILE_NAME, "post");
//Print semesterList Block
div_head_output_with_class_option("mainMiddleBlockLeft");
semester_list_output($PAGE_SWITCH, $semesterListArray, $THIS_TABLE_KEY_NAMES_ARRAY, $targetArray);
div_end_output();
//Print semesterInfo Block
div_head_output_with_class_option("mainMiddleBlockRight");
if(!$_POST["semesterListChange"]){
semester_info_output($THIS_TABLE_KEY_NAMES_ARRAY);
}elseif($_POST["semesterListChange"]){
semester_info_change_output($semesterListArray, $THIS_TABLE_KEY_NAMES_ARRAY, $targetArray);
}
div_end_output();
form_end_output();
div_end_output();
div_end_output();
//Print HTML end
body_end_output();
html_end_output();
//Fin.
?>