$SEMESTER_TABLE_KEY_NAMES_ARRAY = $TABLE_KEY_NAMES_ARRAY[$SEMESTER_PAGE_SWITCH]; $semesterListArray = table_data_query($SEMESTER_TABLE_NAME, $SEMESTER_TABLE_KEY_NAMES_ARRAY); $semesterTargetArray = $_POST['semesterList']; //Load target teacher $teacherTargetArray = $_POST['teacherList']; //QUERY the $teacherListArray $TEACHER_TABLE_NAME = table_name_form($PAGE_INFO_ARRAY, $TEACHER_PAGE_SWITCH, $semesterListArray, $semesterTargetArray); $TEACHER_TABLE_KEY_NAMES_ARRAY = $TABLE_KEY_NAMES_ARRAY[$TEACHER_PAGE_SWITCH]; $TEACHER_TABLE_KEY_TYPES_ARRAY = $TABLE_KEY_TYPES_ARRAY[$TEACHER_PAGE_SWITCH]; $teacherListArray = table_data_query($TEACHER_TABLE_NAME, $TEACHER_TABLE_KEY_NAMES_ARRAY); //Load the target array ID number $targetId = $teacherListArray[$teacherTargetArray][$TEACHER_TABLE_KEY_NAMES_ARRAY['ID']]; //TODO : rewrite the database_table_create "if" phrase //CREATE the TABLE if not avaliable if ($semesterTargetArray != "") { database_table_create($TEACHER_TABLE_NAME, $TEACHER_TABLE_KEY_NAMES_ARRAY, $TEACHER_TABLE_KEY_TYPES_ARRAY); } //ADD the information to database if POST print $_POST['TEACHER_NAME']; if ($_POST["teacherInfoAdd"]) { //Load the POST info array foreach ($TEACHER_TABLE_KEY_NAMES_ARRAY as $value) { $teacherInfoArray[$value] = $_POST[$value]; } var_dump($teacherInfoArray); unset($value); table_data_add($TEACHER_TABLE_NAME, $TEACHER_TABLE_KEY_NAMES_ARRAY, $teacherInfoArray); } //DELETE the information from database if POST if ($_POST["teacherListDelete"]) { table_data_delete_by_id($TEACHER_TABLE_NAME, $targetId);
$SEMESTER_TABLE_KEY_NAMES_ARRAY = $TABLE_KEY_NAMES_ARRAY[$SEMESTER_PAGE_SWITCH]; $semesterListArray = table_data_query($SEMESTER_TABLE_NAME, $SEMESTER_TABLE_KEY_NAMES_ARRAY); //Load the target array number $semesterTargetArray = $_POST['semesterList']; $courseTypeTargetArray = $_POST['courseTypeList']; //QUERY the $courseTypeListArray $TABLE_NAME = table_name_form($PAGE_INFO_ARRAY, $PAGE_SWITCH, $semesterListArray, $semesterTargetArray); $THIS_TABLE_KEY_NAMES_ARRAY = $TABLE_KEY_NAMES_ARRAY[$PAGE_SWITCH]; $THIS_TABLE_KEY_TYPES_ARRAY = $TABLE_KEY_TYPES_ARRAY[$PAGE_SWITCH]; $courseTypeListArray = table_data_query($TABLE_NAME, $THIS_TABLE_KEY_NAMES_ARRAY); //Load the target array ID number $targetId = $courseTypeListArray[$courseTypeTargetArray][$THIS_TABLE_KEY_NAMES_ARRAY['ID']]; //TODO : rewrite the database_table_create "if" phrase //CREATE the TABLE if not avaliable if ($semesterTargetArray != "") { database_table_create($TABLE_NAME, $THIS_TABLE_KEY_NAMES_ARRAY, $THIS_TABLE_KEY_TYPES_ARRAY); } //QUERY the $courseTypeInfoArray from database.COURSE and ADD it into database. if (!is_array($courseTypeListArray)) { //Get all course type and load in $courseTypeArray. $COURSE_TABLE_NAME = table_name_form($PAGE_INFO_ARRAY, $COURSE_PAGE_SWITCH, $semesterListArray, $semesterTargetArray); $COURSE_TABLE_KEY_NAMES_ARRAY = table_key_names_array_get($COURSE_TABLE_NAME); $courseTypeArray = $COURSE_TABLE_KEY_NAMES_ARRAY; unset($courseTypeArray['COURSE_NAME'], $courseTypeArray['COURSE_CAPABILITY'], $courseTypeArray['COURSE_STYLE'], $courseTypeArray['ID']); //Get all course course type total period and load in $courseTypeTotalPeriodArray and ADD into database.COURSE_TYPE. $courseListArray = table_data_query($COURSE_TABLE_NAME, $COURSE_TABLE_KEY_NAMES_ARRAY); $courseListArrayCount0 = count($courseListArray); foreach ($courseTypeArray as $type) { //LOAD into an array for ($i = 0; $i < $courseListArrayCount0; $i++) { $courseTypeTotalPeriodArray[$type] += $courseListArray[$i][$type];
$SEMESTER_TABLE_KEY_NAMES_ARRAY = $TABLE_KEY_NAMES_ARRAY[$SEMESTER_PAGE_SWITCH]; $semesterListArray = table_data_query($SEMESTER_TABLE_NAME, $SEMESTER_TABLE_KEY_NAMES_ARRAY); $semesterTargetArray = $_POST['semesterList']; //Load target classroom $classroomTargetArray = $_POST['classroomList']; //QUERY the $classroomListArray $CLASSROOM_TABLE_NAME = table_name_form($PAGE_INFO_ARRAY, $CLASSROOM_PAGE_SWITCH, $semesterListArray, $semesterTargetArray); $CLASSROOM_TABLE_KEY_NAMES_ARRAY = $TABLE_KEY_NAMES_ARRAY[$CLASSROOM_PAGE_SWITCH]; $CLASSROOM_TABLE_KEY_TYPES_ARRAY = $TABLE_KEY_TYPES_ARRAY[$CLASSROOM_PAGE_SWITCH]; $classroomListArray = table_data_query($CLASSROOM_TABLE_NAME, $CLASSROOM_TABLE_KEY_NAMES_ARRAY); //Load the target array ID number $targetId = $classroomListArray[$classroomTargetArray][$CLASSROOM_TABLE_KEY_NAMES_ARRAY['ID']]; //TODO : rewrite the database_table_create "if" phrase //CREATE the TABLE if not avaliable if ($semesterTargetArray != "") { database_table_create($CLASSROOM_TABLE_NAME, $CLASSROOM_TABLE_KEY_NAMES_ARRAY, $CLASSROOM_TABLE_KEY_TYPES_ARRAY); } //ADD the information to database if POST print $_POST['CLASSROOM_NAME']; if ($_POST["classroomInfoAdd"]) { //Load the POST info array foreach ($CLASSROOM_TABLE_KEY_NAMES_ARRAY as $value) { $classroomInfoArray[$value] = $_POST[$value]; } unset($value); table_data_add($CLASSROOM_TABLE_NAME, $CLASSROOM_TABLE_KEY_NAMES_ARRAY, $classroomInfoArray); } //DELETE the information from database if POST if ($_POST["classroomListDelete"]) { table_data_delete_by_id($CLASSROOM_TABLE_NAME, $targetId); }
$courseInsertInfoArrayCount0 = count($courseInsertInfoArray); for ($i = 0; $i < $courseInsertInfoArrayCount0 - 1; $i++) { //[BUG][120501_1] Import file have a title line, so that "-1". $courseInsertInfoArray[$i]['COURSE_KEY_NAME'] = "COURSE_" . $i; } //ADD the COURSE data $COURSE_TABLE_KEY_NAMES_ARRAY = array_picker($courseImportInfoArray, 0); //Pick the table key names from import array. $COURSE_TABLE_KEY_NAMES_ARRAY = array_key_insert($COURSE_TABLE_KEY_NAMES_ARRAY, "id", "id"); //The import data not include ID key, so add it. $COURSE_TABLE_KEY_NAMES_ARRAY = array_key_insert($COURSE_TABLE_KEY_NAMES_ARRAY, "COURSE_KEY_NAME", "COURSE_KEY_NAME"); //The import data not include COURSE_KEY_NAME key, so add it. $COURSE_TABLE_KEY_TYPES_ARRAY = table_key_types_auto_fill($COURSE_TABLE_KEY_TYPES_ARRAY, $COURSE_TABLE_KEY_NAMES_ARRAY, 0, "varchar(15)", 1); $COURSE_TABLE_KEY_TYPES_ARRAY = array_key_insert($COURSE_TABLE_KEY_TYPES_ARRAY, "id", "int NOT NULL AUTO_INCREMENT, PRIMARY KEY(id)"); $COURSE_TABLE_KEY_TYPES_ARRAY = array_key_insert($COURSE_TABLE_KEY_TYPES_ARRAY, "COURSE_KEY_NAME", "varchar(15)"); database_table_create($COURSE_TABLE_NAME, $COURSE_TABLE_KEY_NAMES_ARRAY, $COURSE_TABLE_KEY_TYPES_ARRAY); unset($COURSE_TABLE_KEY_NAMES_ARRAY['id']); //Drop the table key id for data insert by key names array. for ($i = 0; $i < $courseInsertInfoArrayCount0 - 1; $i++) { //Import file have a title line, so that "-1". table_data_add($COURSE_TABLE_NAME, $COURSE_TABLE_KEY_NAMES_ARRAY, $courseInsertInfoArray[$i]); } } //Reload $COURSE_TABLE_KEY_NAMES_ARRAY. $COURSE_TABLE_KEY_NAMES_ARRAY = table_key_names_array_get($COURSE_TABLE_NAME); //QUERY the $courseListArray $courseListArray = table_data_query($COURSE_TABLE_NAME, $COURSE_TABLE_KEY_NAMES_ARRAY); //------ -[ Views Functions ]- ------ div_head_output_with_class_option("mainMiddle"); //Print Main Title main_title_output($PAGE_INFO_ARRAY, $PAGE_SWITCH);
//Database Query menthod if ($_POST['classListQuery']) { $studentsScheduleArray = table_data_query($STUDENTS_TABLE_NAME, $STUDENTS_SCHEDULE_TABLE_KEY_NAMES_ARRAY); } //Database Delete method //TODO: Test this method. if ($_POST['classListDelete']) { $studentsScheduleArray = table_data_query($STUDENTS_TABLE_NAME, $STUDENTS_SCHEDULE_TABLE_KEY_NAMES_ARRAY); $studentsScheduleArrayCount0 = count($studentsScheduleArray); for ($i = 0; $i < $studentsScheduleArrayCount0; $i++) { $targetDeleteId = $studentsScheduleArray[$i]['id']; table_data_delete_by_id($STUDENTS_SCHEDULE_TABLE_NAME, $targetDeleteId); } } //Create the dataabse table. database_table_create($STUDENTS_SCHEDULE_TABLE_NAME, $STUDENTS_SCHEDULE_TABLE_KEY_NAMES_ARRAY, $STUDENTS_SCHEDULE_TABLE_KEY_TYPES_ARRAY); //Load target class name. $classTargetArray = $_POST['classList']; //Reschedule determinative syntax if ($_POST['RESCHEDULE']) { $targetClassName = $classListArray[$classTargetArray]['CLASS_NAME']; //Load $courseWeekArray //$courseWeekArray structure describe //$courseWeekArray[0] = 0; // [1] = 2; //... $targetClassListArrayTemp = table_data_query($CLASS_TABLE_NAME, $CLASS_TABLE_KEY_NAMES_ARRAY, "CLASS_NAME = '{$targetClassName}'"); $targetClassListArrayTempCount0 = count($targetClassListArrayTemp); for ($i = 0; $i < $targetClassListArrayTempCount0; $i++) { if ($targetClassListArrayTemp[$i]['CLASS_TYPE']) { $targetClassListArray = $targetClassListArrayTemp[$i];
$CLASS_TABLE_KEY_NAMES_ARRAY = table_key_names_array_get($CLASS_TABLE_NAME); $classListArray = table_data_query($CLASS_TABLE_NAME, $CLASS_TABLE_KEY_NAMES_ARRAY); //Load course key name union array $courseKeyNameUnionArray = course_key_name_union_array_get($courseListArray); //CREATE the TOTAL_SCHEDULE_TABLE //TODO: add "if" phrase. $TOTAL_SCHEDULE_TABLE_NAME = table_name_form($PAGE_INFO_ARRAY, $TOTAL_SCHEDULE_PAGE_SWITCH, $semesterListArray, $semesterTargetArray); //Form the $TOTAL_SCHEDULE_TABLE_KEY_NAMES_ARRAY and $TOTAL_SCHEDULE_TABLE_KEY_TYPES_ARRAY $TOTAL_SCHEDULE_TABLE_KEY_NAMES_ARRAY = $TABLE_KEY_NAMES_ARRAY[$TOTAL_SCHEDULE_PAGE_SWITCH]; $TOTAL_SCHEDULE_TABLE_KEY_TYPES_ARRAY = $TABLE_KEY_TYPES_ARRAY[$TOTAL_SCHEDULE_PAGE_SWITCH]; $courseListArrayCount0 = count($courseListArray); for ($i = 0; $i < $courseListArrayCount0; $i++) { $TOTAL_SCHEDULE_TABLE_KEY_NAMES_ARRAY = table_key_names_auto_fill($TOTAL_SCHEDULE_TABLE_KEY_NAMES_ARRAY, $courseListArray[$i]['COURSE_KEY_NAME'], $COURSE_IN_A_DAY, 1); $TOTAL_SCHEDULE_TABLE_KEY_TYPES_ARRAY = table_key_types_auto_fill($TOTAL_SCHEDULE_TABLE_KEY_TYPES_ARRAY, $courseListArray[$i]['COURSE_KEY_NAME'], $COURSE_IN_A_DAY, "varchar(15)", 1); } database_table_create($TOTAL_SCHEDULE_TABLE_NAME, $TOTAL_SCHEDULE_TABLE_KEY_NAMES_ARRAY, $TOTAL_SCHEDULE_TABLE_KEY_TYPES_ARRAY); //// Arrange data preload //Load semester week $SEMESTER_WEEK_SET = $_POST[$TOTAL_SCHEDULE_TABLE_KEY_NAMES_ARRAY['SEMESTER_WEEK']] - 1; //Load semester week //QUERY the $totalScheduleArray $totalScheduleArray = table_data_query($TOTAL_SCHEDULE_TABLE_NAME, $TOTAL_SCHEDULE_TABLE_KEY_NAMES_ARRAY, "SEMESTER_WEEK = {$SEMESTER_WEEK_SET}"); //Reschedule determinative syntax if ($_POST['RESCHEDULE']) { //Load $appointedClassArray which has been appointed the week of semester // //Example: //$appointedClassArray[0]['CLASS_NAME'] = "机设09-1"; //$appointedClassArray[0]['CLASS_TYPE'] = "A"; //$appointedClassArray[0]['ID'] = "0"; //$appointedClassArray[0]['COURSE_0'] = "2";