public function delete() { $table = new simple_table_ops(); $table->set_id_column('timetable_period_id'); $table->set_table_name('timetable_periods'); $table->delete(); header("Location: http://" . WEBSITE_URL . "/index.php?controller={$_GET['controller']}&action=index"); }
public function update() { // id value has already been sent into <form action string> // just call simple_table_ops class, which will process $_POST['variables'] $update = new simple_table_ops(); $columns = array('weekday'); $update->set_id_column('weekday_id'); $update->set_table_name('weekdays'); $update->set_table_column_names($columns); $update->update(); header("Location: http://" . WEBSITE_URL . "/index.php?controller={$_GET['controller']}&action=index"); }
public function update() { // id value has already been sent into <form action string> // just call simple_table_ops class, which will process $_POST['variables'] $update = new simple_table_ops(); $columns = array('level_id'); $update->set_id_column('course_id'); $update->set_table_name('courses'); $update->set_table_column_names($columns); return $update->update(); }
public function update() { if (!isset($_GET['id'])) { // id = timetable_period_id, NOT timetable_id ! $content = "<p>Error in timetable controller, update action - id index is not set!"; $output['content'] = $content; return $output; } $update = new simple_table_ops(); $columns = array('curriculum_id', 'start_time_id', 'end_time_id', 'weekday_id', 'classroom_id', 'timetable_period_id'); $update->set_id_column('timetable_id'); $update->set_table_name('timetables'); $update->set_table_column_names($columns); $update->update(); header("Location: http://" . WEBSITE_URL . "/index.php?controller=timetable&action=show&submit=yes&timetable_period_id={$_POST['timetable_period_id']}"); }
public function details2() { // details combines seeing with editing $id = $_GET['id']; $columns = array('nom, prenom, nom_khmer, prenom_khmer, matricule, dob, program_id, sex_id, active_id'); $neat_columns = array('Last Name', 'First Name', 'Last Name Khmer', 'First Name Khmer', 'Matricule', 'Date of Birth', 'Program', 'Genre', 'Active', 'Update', 'Delete'); $form = array('action' => '?controller=students&action=update&id=' . $id, 'div' => "class='solitary_input'", 'div_button' => "class='submit_button1'", 'action_links' => array(1 => array('delete', '?controller=students&action=delete&id=')), 'method' => 'post', 'id' => 'top_form', 'elements' => array(1 => array('text' => 'nom'), 2 => array('text' => 'prenom'), 3 => array('text' => 'nom_khmer'), 4 => array('text' => 'prenom_khmer'), 5 => array('text' => 'matricule'), 6 => array('text' => 'dob'), 7 => array('drop_down' => 'program_id'), 8 => array('drop_down' => 'sex_id'), 9 => array('drop_down' => 'active_id'), 10 => array('submit' => 'update'))); $connection = new database(); $table = new simple_table_ops(); $sql = 'SELECT sex_id, sex FROM sexes'; $sex_result = $connection->query($sql); $sql2 = 'SELECT active_id, active FROM actives'; $active_result = $connection->query($sql2); $sql3 = 'SELECT program_id, program FROM programs'; $programs_result = $connection->query($sql3); $drop_down = array('sex_id' => array('sex' => $sex_result), 'active_id' => array('active' => $active_result), 'program_id' => array('program' => $programs_result)); $table->set_table_name('students'); $table->set_id_column('student_id'); $table->set_table_column_names($columns); $table->set_html_table_column_names($neat_columns); $table->set_values_form(); // set values found in database into form elements when building top_form $table->set_drop_down($drop_down); $table->set_form_array($form); $content = '<table>'; $content .= $table->details(); $content .= '</table>'; //require_once 'models/studentsModel.php'; // needless to add require $studentsModel_handler = new studentsModel(); $studentsModel_handler->set_student_id($id); $content .= $studentsModel_handler->get_timetable_html(); $content .= $studentsModel_handler->get_attendance() . "<br>"; $content .= $studentsModel_handler->get_results() . "<br>"; $output['content'] = $content; return $output; }
public function update() { $update = new simple_table_ops(); $columns = array('course_id'); $update->set_id_column('classe_id'); $update->set_table_name('classes'); $update->set_table_column_names($columns); $update->update(); header("Location: http://" . WEBSITE_URL . "/index.php?controller={$_GET['controller']}&action=index"); }
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"); }