} if ($id != 'new') { // print_r($_REQUEST); unset($scheduleAssociation); unset($gradeAssociation); $tot_seat = $_REQUEST['tables']['course_periods'][$_REQUEST['course_period_id']]['TOTAL_SEATS']; $does_attn = $_REQUEST['tables']['course_period_var'][$_REQUEST['course_period_id']]['DOES_ATTENDANCE']; if ($tot_seat != '') { $seat_num = DBGet(DBQuery('SELECT FILLED_SEATS FROM course_periods WHERE COURSE_PERIOD_ID=\'' . $_REQUEST['course_period_id'] . '\' LIMIT 0,1 ')); if ($seat_num[1]['FILLED_SEATS'] > $tot_seat) { $tot_seat = 'error'; } } $update = true; if ($tot_seat != '' && $does_attn != '') { if (scheduleAssociation($id)) { $scheduleAssociation = true; } if (gradeAssociation($id)) { $gradeAssociation = true; } } if ($tot_seat != 'error') { if (!$scheduleAssociation && !$gradeAssociation) { if ($table_name == 'courses' && $columns['SUBJECT_ID'] && $columns['SUBJECT_ID'] != $_REQUEST['subject_id']) { $_REQUEST['subject_id'] = $columns['SUBJECT_ID']; } $sql = "UPDATE {$table_name} SET "; if ($table_name == 'course_periods') { $current = DBGet(DBQuery("SELECT TEACHER_ID,MARKING_PERIOD_ID,SHORT_NAME,TOTAL_SEATS,CALENDAR_ID FROM course_periods WHERE " . $where[$table_name] . "='{$id}'")); if ($scheduleAssociation) {
if (scheduleAssociation($id) && ($column == 'ROOM_ID' || $column == 'DAYS' || $column == 'PERIOD_ID' || $column == 'MARKING_PERIOD_ID')) { $flag_err = 'Y'; } if ($table_name == 'courses' || $table_name == 'course_subjects') { $sql .= $column . "='" . str_replace("'", "''", $value) . "',"; $go = true; } if (!scheduleAssociation($id) && ($column == 'MARKING_PERIOD_ID' || $column == 'MP' || $column == 'GENDER_RESTRICTION' || $column == 'PARENT_ID')) { $sql .= $column . "='" . str_replace("'", "''", $value) . "',"; $go = true; } if (!scheduleAssociation($id) && ($column == 'BEGIN_DATE' || $column == 'END_DATE')) { $sql .= $column . "='" . str_replace("'", "''", date('Y-m-d', strtotime($value))) . "',"; $go = true; } if (!scheduleAssociation($id) && $table_name == 'course_period_var' && $_REQUEST['tables']['course_periods'][$id]['SCHEDULE_TYPE'] == 'FIXED') { if ($column == 'PERIOD_ID') { $period_time_edt = DBGet(DBQuery("SELECT START_TIME, END_TIME FROM school_periods WHERE period_id={$value}")); $period_time_edt = $period_time_edt[1]; $start_time_edt = $period_time_edt['START_TIME']; $end_time_edt = $period_time_edt['END_TIME']; $check_attn = DBGet(DBQuery('SELECT * FROM school_periods WHERE PERIOD_ID=' . $value)); $check_attn = $check_attn[1]; if ($check_attn['ATTENDANCE'] == 'Y') { $sql .= " PERIOD_ID=" . $value . " , START_TIME='" . $start_time_edt . "' , END_TIME='" . $end_time_edt . "',"; } else { $sql .= " PERIOD_ID=" . $value . " , START_TIME='" . $start_time_edt . "' , END_TIME='" . $end_time_edt . "',DOES_ATTENDANCE=NULL,"; } $go = true; } if ($column == 'ROOM_ID' || $column == 'DAYS' || $column == 'DOES_ATTENDANCE') {