public function add() { $columns = array('level'); $table = new simple_table_ops(); $table->set_table_name('levels'); $table->set_table_column_names($columns); $table->add(); 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('nom', 'date_from', 'date_to'); $update->set_id_column('timetable_period_id'); $update->set_table_name('timetable_periods'); $update->set_table_column_names($columns); $update->update(); header("Location: http://" . WEBSITE_URL . "/index.php?controller={$_GET['controller']}&action=index"); }
public function add() { // First, add the new school_year to [school_years] table: $columns = array('school_year'); $table = new simple_table_ops(); $table->set_table_name('school_years'); $table->set_table_column_names($columns); $table->add(); // then, gets the last inserted id (not through lastInsertedId function, because it may be buggy: /* SELECT article, dealer, price FROM shop WHERE price=(SELECT MAX(price) FROM shop); */ $sql = "SELECT school_year_id, school_year\n FROM school_years\n WHERE school_year_id=(SELECT MAX(school_year_id) FROM school_years)\n "; $school_years_handle = new database(); $new_school_year_result = $school_years_handle->query($sql); $new_school_year_id = $new_school_year_result[0]['school_year_id']; $new_school_year = $new_school_year_result[0]['school_year']; /* Populate automatically [courses] table with values from level_id and $_SESSION['current_school_year_id'] */ $levels_handler = new database(); $sql = "SELECT level_id FROM levels"; $result = $levels_handler->query($sql); $insert_sql = "INSERT INTO courses (school_year_id, level_id) VALUES (?, ?)"; foreach ($result as $row) { foreach ($row as $value) { // insert $value into courses and $_SESSION['current_school_year_id'] $data = array($new_school_year_id, $value); $levels_handler->insert($insert_sql, $data); } } // Update current_school_year_id to the newly added 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 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() { // 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('course_id', 'teacher_id', 'subject_id'); $update->set_id_column('curriculum_id'); $update->set_table_name('curricula'); $update->set_table_column_names($columns); $update->update(); header("Location: http://" . WEBSITE_URL . "/index.php?controller={$_GET['controller']}&action=index"); }
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"); }