public function delete() { $table = new simple_table_ops(); $table->set_id_column('course_id'); $table->set_table_name('courses'); $table->delete(); header("Location: http://" . WEBSITE_URL . "/index.php?controller={$_GET['controller']}&action=index"); }
public function delete() { // receives ONLY the timetable_id $table = new simple_table_ops(); $table->set_id_column('timetable_id'); $table->set_table_name('timetables'); $table->delete(); header("Location: http://" . WEBSITE_URL . "/index.php?controller=timetable&action=show&submit=yes&timetable_period_id={$_GET['timetable_period_id']}"); }
public function delete() { // When deleting check if the selected school_year_id is present in courses table // if yes, do not delete, and issue a warning $content = ''; $delete_handler = new database(); $sql = "SELECT school_year_id FROM school_years"; $result = $delete_handler->query($sql); if ($delete_handler->get_row_num() == 1) { $content .= '<p>You cannot delete the last school year!'; $output['content'] = $content; return $output; } $sql = "SELECT school_year_id FROM courses WHERE school_year_id={$_GET['id']}"; echo $sql . '<br>'; $result = $delete_handler->query($sql); if ($delete_handler->get_row_num() !== 0) { $content .= '<p>You cannot delete this school year!<p>You need first to delete ALL the courses attached to this year.'; $content .= "<p>There are currently {$delete_handler->get_row_num()} courses."; $output['content'] = $content; return $output; } $table = new simple_table_ops(); $table->set_id_column('school_year_id'); $table->set_table_name('school_years'); $table->delete(); // Check that when deleting, $_SESSION['current_school_year_id'] should be updated // Forbid last school_year deletion if last in school_years $sql = "SELECT MAX(school_year_id), school_year FROM school_years"; $school_years_handle = new database(); $new_school_year_result = $school_years_handle->query($sql); $new_school_year_id = $new_school_year_result[0]['MAX(school_year_id)']; $new_school_year = $new_school_year_result[0]['school_year']; $_SESSION['current_school_year_id'] = $new_school_year_id; $_SESSION['current_school_year'] = $new_school_year; header("Location: http://" . WEBSITE_URL . "/index.php?controller={$_GET['controller']}&action=index"); }
public function remove() { // removes student from [classes] table $table = new simple_table_ops(); $table->set_id_column('classe_id'); $table->set_table_name('classes'); $table->delete(); header("Location: http://" . WEBSITE_URL . "/index.php?controller={$_GET['controller']}&action=index"); }
public function profiles_delete() { // When deleting check if the selected school_year_id is present in courses table // if yes, do not delete, and issue a warning $table = new simple_table_ops(); $table->set_id_column('profile_id'); $table->set_table_name('profiles'); $table->delete(); header("Location: http://" . WEBSITE_URL . "/index.php?controller={$_GET['controller']}&action=profiles_index"); }