public function index() { $content = "<div class='link_button'>\n <a href='?controller=curricula&action=export'>Export to EXCEL</a>\n <a href='?controller=timetable&action=show'>Timetable</a>\n <a href='?controller=teachers&action=index'>Teachers</a>\n </div>"; /* CONFIGURES DROP DOWN Menus (2 in this case: programs and genre) */ $connection = new database(); $table = new simple_table_ops(); // 3 drop down menus: // 1. level_id // 2. teacher_id // 3. subject_id $sql = "SELECT courses.course_id, levels.level AS course\n FROM courses\n JOIN levels ON courses.level_id = levels.level_id\n WHERE courses.school_year_id = {$_SESSION['current_school_year_id']}\n ORDER BY levels.level_id ASC"; $courses_result = $connection->query($sql); $sql = "SELECT teachers.teacher_id, CONCAT (teachers.nom, ' ', teachers.prenom, ' | ', teachers.nom_khmer, ' ', teachers.prenom_khmer, ' | ', sexes.sex) as teacher\n FROM teachers\n JOIN sexes ON teachers.sex_id = sexes.sex_id\n WHERE teachers.active_id=1\n ORDER BY teachers.nom ASC, teachers.prenom ASC"; $teachers_result = $connection->query($sql); $sql = "SELECT subject_id, subject FROM subjects ORDER BY subject"; $subjects_result = $connection->query($sql); $drop_down = array('course_id' => array('course' => $courses_result), 'teacher_id' => array('teacher' => $teachers_result), 'subject_id' => array('subject' => $subjects_result)); $table->set_drop_down($drop_down); /********************************************************************/ /* CONFIGURES Form structure */ $top_form = array('action' => '?controller=curricula&action=add', 'div' => "class='solitary_input'", 'div_button' => "class='submit_button1'", 'method' => 'post', 'id' => 'top_form', 'elements' => array(1 => array('drop_down' => 'teacher_id'), 2 => array('drop_down' => 'subject_id'), 3 => array('drop_down' => 'course_id'), 4 => array('submit' => 'add'))); $table->set_top_form($top_form); /********************************************************************/ /* CONFIGURES Main table contents (from MySQL) */ $columns = array('Teacher', 'Subject', 'Course', 'Action'); $table->set_html_table_column_names($columns); $sql = "SELECT curricula.curriculum_id, CONCAT (teachers.nom, ' ', teachers.prenom, ' | ', teachers.nom_khmer, ' ', teachers.prenom_khmer, ' | ', sexes.sex) as teacher, subjects.subject, levels.level\n FROM curricula\n JOIN courses ON curricula.course_id = courses.course_id\n JOIN subjects ON curricula.subject_id = subjects.subject_id\n JOIN teachers ON teachers.teacher_id = curricula.teacher_id\n JOIN sexes ON teachers.sex_id = sexes.sex_id\n JOIN levels ON courses.level_id = levels.level_id\n WHERE teachers.active_id=1 AND courses.school_year_id = {$_SESSION['current_school_year_id']}\n ORDER BY subjects.subject ASC, levels.level_id ASC, teachers.nom ASC, teachers.prenom ASC\n "; $details_link = array(1 => array('edit', '?controller=curricula&action=details&id=')); $table->set_details_link($details_link); $table->set_main_table($connection->query($sql)); /********************************************************************/ $content .= '<table>' . $table->get_table() . '</table>'; $output['content'] = $content; return $output; }
public function index() { $content = "<div class='link_button'>\n <a href='?controller=teachers&action=export'>Export to EXCEL</a>\n <a href='?controller=timetable&action=show'>Timetable</a>\n <a href='?controller=curricula&action=index'>Curricula</a>\n </div>"; /* CONFIGURES DROP DOWN Menus (2 in this case: programs and genre) */ $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); $drop_down = array('sex_id' => array('sex' => $sex_result), 'active_id' => array('active' => $active_result)); $table->set_drop_down($drop_down); /********************************************************************/ /* CONFIGURES Form structure */ $top_form = array('action' => '?controller=teachers&action=add', 'div' => "class='solitary_input'", 'div_button' => "class='submit_button1'", '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('drop_down' => 'sex_id'), 6 => array('drop_down' => 'active_id'), 7 => array('submit' => 'add'))); $table->set_top_form($top_form); /********************************************************************/ /* CONFIGURES Main table contents (from MySQL) */ $columns = array('Last Name', 'First Name', 'Last Name Khmer', 'First Name Khmer', 'Genre', 'Active', 'Action'); $table->set_html_table_column_names($columns); $sql = 'SELECT teachers.teacher_id, teachers.nom, teachers.prenom, teachers.nom_khmer, teachers.prenom_khmer, sexes.sex, actives.active FROM sexes LEFT JOIN teachers ON teachers.sex_id = sexes.sex_id LEFT JOIN actives ON teachers.active_id = actives.active_id ORDER BY teachers.nom ASC, teachers.prenom ASC '; $details_link = array(1 => array('edit', '?controller=teachers&action=details&id=')); $table->set_details_link($details_link); $table->set_main_table($connection->query($sql)); /********************************************************************/ $content .= '<table>' . $table->get_table() . '</table>'; $output['content'] = $content; return $output; }
public function index() { // ______________________________ // | School Year | Level | Action | // |---------------------|--------| // | | | [add] | // |------------------------------| // | 2015/2016 | | details| // ------------------------------ // /* CONFIGURES DROP DOWN Menus (2 in this case: programs and genre) */ $connection = new database(); $table = new simple_table_ops(); $content = "<div class='third_left'><p>Here are the class hours. If you change when a class starts/ends, change it here, but<p>DO NOT change the ORDER!"; $sql = 'SELECT time_id, time_class FROM time ORDER BY time_id ASC'; $levels_result = $connection->query($sql); $drop_down = array('time_id' => array('time_class' => $levels_result)); $table->set_drop_down($drop_down); /********************************************************************/ /* CONFIGURES Form structure */ $top_form = array('action' => '?controller=time&action=add', 'div' => "class='solitary_input'", 'method' => 'post', 'id' => 'top_form', 'elements' => array(1 => array('drop_down' => 'time_id'), 2 => array('submit' => 'add'))); $table->set_top_form($top_form); /********************************************************************/ /* CONFIGURES Main table contents (from MySQL) */ $columns = array('Time', 'Action'); $table->set_html_table_column_names($columns); $sql = "SELECT time.time_id, time_class\n FROM time\n ORDER BY time_id ASC\n "; $result = $connection->query($sql); if ($connection->get_row_num() == 0) { $content .= "<p>Currently, you have no time configured. Choose one and click [ADD]."; } else { $content .= "<p>Currently, you have " . $connection->get_row_num() . " time configured."; } $content .= "</div>"; $details_link = array(1 => array('details', '?controller=time&action=details&id=')); $table->set_details_link($details_link); $table->set_main_table($result); /********************************************************************/ $content .= "<div class='third_middle'><table>{$table->get_table()}</table></div>"; $output['content'] = $content; return $output; }
public function index() { // ______________________________ // | School Year | Level | Action | // |---------------------|--------| // | | | [add] | // |------------------------------| // | 2015/2016 | | details| // ------------------------------ // /* CONFIGURES DROP DOWN Menus (2 in this case: programs and genre) */ $connection = new database(); $table = new simple_table_ops(); $content = '<p>Here you can add courses to the school year ' . $_SESSION['current_school_year'] . '.<p>Each course is a level of school grade.'; $sql = 'SELECT level_id, level FROM levels ORDER BY level_id ASC'; $levels_result = $connection->query($sql); $drop_down = array('level_id' => array('level' => $levels_result)); $table->set_drop_down($drop_down); /********************************************************************/ /* CONFIGURES Form structure */ $top_form = array('action' => '?controller=courses&action=add', 'div' => "class='solitary_input'", 'method' => 'post', 'id' => 'top_form', 'elements' => array(1 => array('drop_down' => 'level_id'), 2 => array('submit' => 'add'))); $table->set_top_form($top_form); /********************************************************************/ /* CONFIGURES Main table contents (from MySQL) */ $columns = array('Level', 'Action'); $table->set_html_table_column_names($columns); $sql = "SELECT courses.course_id, levels.level\n FROM courses\n JOIN levels ON courses.level_id = levels.level_id\n WHERE courses.school_year_id={$_SESSION['current_school_year_id']}\n "; $result = $connection->query($sql); if ($connection->get_row_num() == 0) { $content .= "<p>Currently, you have no courses configured. Choose one and click [ADD]."; } else { $content .= "<p>Currently, you have " . $connection->get_row_num() . " courses configured."; } $details_link = array(1 => array('details', '?controller=courses&action=details&id=')); $table->set_details_link($details_link); $table->set_main_table($result); /********************************************************************/ $content .= "<div class='submit_top_left'><table>{$table->get_table()}</table></div>"; $output['content'] = $content; return $output; }
public function index() { $connection = new database(); $table = new simple_table_ops(); $content = '<p>Add or Delete a Timetable Identifier.'; /* CONFIGURES Form structure */ $top_form = array('action' => '?controller=timetable2&action=add', 'div' => "class='solitary_input'", 'div_button' => "class='submit_button1'", 'method' => 'post', 'id' => 'top_form', 'elements' => array(1 => array('text' => 'nom'), 2 => array('date' => 'date_from'), 3 => array('date' => 'date_to'), 4 => array('submit' => 'add'))); $table->set_top_form($top_form); /********************************************************************/ /* CONFIGURES Main table contents (from MySQL) */ $columns = array('Timetable Name', 'Start Date', 'End Date', 'Action'); $table->set_html_table_column_names($columns); $sql = "SELECT timetable_period_id, nom, date_from, date_to\n FROM timetable_periods\n WHERE school_year_id={$_SESSION['current_school_year_id']}\n ORDER BY date_from DESC, date_to DESC\n "; $details_link = array(1 => array('edit', '?controller=timetable2&action=details&id=')); $table->set_details_link($details_link); $table->set_main_table($connection->query($sql)); /********************************************************************/ $content .= '<table>' . $table->get_table() . '</table>'; $output['content'] = $content; return $output; }
public function index() { // show current year students // plus a selector with all school years // connect to db // queries all students from current year // display them with links on names, and a checking box beside each student // offer on top an action selector to process selected students: // 1. Details // 2. Inactivate (delete is not allowed) // 3. Other ? $content = "<div class='link_button'>\n <a href='?controller=students&action=export'>Export to EXCEL</a>\n <a href='?controller=classes&action=index'>Classes</a>\n <a href='?controller=attendances&action=index'>Attendance</a>\n <a href='?controller=results&action=index'>Results</a>\n </div>"; /* CONFIGURES DROP DOWN Menus (2 in this case: programs and genre) */ $connection = new database(); $table = new simple_table_ops(); $sql = 'SELECT sex_id, sex FROM sexes'; $sex_result = $connection->query($sql); $sql = 'SELECT active_id, active FROM actives'; $active_result = $connection->query($sql); $sql = 'SELECT program_id, program FROM programs ORDER BY program ASC'; $programs_result = $connection->query($sql); $drop_down = array('sex_id' => array('sex' => $sex_result), 'active_id' => array('active' => $active_result), 'program_id' => array('program' => $programs_result)); $table->set_drop_down($drop_down); /********************************************************************/ /* CONFIGURES Form structure */ $top_form = array('action' => '?controller=students&action=add', 'div' => "class='solitary_input'", 'div_button' => "class='submit_button1'", '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('date' => 'dob'), 7 => array('empty' => ''), 8 => array('drop_down' => 'sex_id'), 9 => array('drop_down' => 'program_id'), 10 => array('drop_down' => 'active_id'), 11 => array('submit' => 'add'))); $table->set_top_form($top_form); /********************************************************************/ /* CONFIGURES Main table contents (from MySQL) */ $columns = array('Last Name', 'First Name', 'Last Name Khmer', 'First Name Khmer', 'Matricule', 'Date of Birth', 'Age', 'Genre', 'Program', 'Active', 'Action'); $table->set_html_table_column_names($columns); $sql = "SELECT students.student_id, students.nom, students.prenom, students.nom_khmer, students.prenom_khmer, students.matricule, students.dob, TIMESTAMPDIFF(YEAR,students.dob,NOW()) AS age, sexes.sex, programs.program, actives.active\n FROM sexes\n JOIN students ON sexes.sex_id = students.sex_id\n JOIN programs ON students.program_id = programs.program_id\n JOIN actives ON actives.active_id = students.active_id\n ORDER BY students.nom ASC\n "; $details_link = array(1 => array('edit', '?controller=students&action=details2&id=')); $table->set_details_link($details_link); $table->set_main_table($connection->query($sql)); /********************************************************************/ $content .= "<table>" . $table->get_table() . '</table>'; $output['content'] = $content; return $output; }
public function index() { $connection = new database(); $table = new simple_table_ops(); $content = '<p>Edit the names of the WEEK, which starts always on Mondays.'; $content .= '<p>BE CAREFUL not to mistake the days, they are used in the [TIMETABLE] table.'; $content .= '<p>The order they appear here are of utmost importance: change this and you will mess all timetables!'; $content .= '<p>You obviously cannot add or delete a day, simply because in a week you will always have 7 days :)'; /* CONFIGURES Main table contents (from MySQL) */ $columns = array('Week Day', 'Action'); $table->set_html_table_column_names($columns); $sql = 'SELECT weekday_id, weekday FROM weekdays ORDER BY weekday_id ASC '; $details_link = array(1 => array('edit', '?controller=weekdays&action=details&id=')); $table->set_details_link($details_link); $table->set_main_table($connection->query($sql)); /********************************************************************/ $content .= '<table width="250px">' . $table->get_table() . '</table>'; $output['content'] = $content; return $output; }
public function index() { $connection = new database(); $table = new simple_table_ops(); $content = '<p>Add or Delete a LEVEL. It corresponds to a CLASS in French. <p>BE CAREFUL! When deleting, be sure you have just created the level, and has not used it in [COURSES] table!'; /* CONFIGURES Form structure */ $top_form = array('action' => '?controller=levels&action=add', 'div' => "class='solitary_input'", 'method' => 'post', 'id' => 'top_form', 'elements' => array(1 => array('text' => 'level'), 2 => array('submit' => 'add'))); $table->set_top_form($top_form); /********************************************************************/ /* CONFIGURES Main table contents (from MySQL) */ $columns = array('Level', 'Action'); $table->set_html_table_column_names($columns); $sql = 'SELECT level_id, level FROM levels ORDER BY LENGTH (level), level '; $details_link = array(1 => array('delete', '?controller=levels&action=delete&id=')); $table->set_details_link($details_link); $table->set_main_table($connection->query($sql)); /********************************************************************/ $content .= '<table>' . $table->get_table() . '</table>'; $output['content'] = $content; return $output; }
public function index() { $connection = new database(); $table = new simple_table_ops(); $content = '<p>Add or Delete a School Year. <p>BE CAREFUL! When deleting, be sure you have just created the school year, and has not used it in [COURSES] table!'; /* CONFIGURES Form structure */ $top_form = array('action' => '?controller=school_years&action=add', 'div' => "class='solitary_input'", 'method' => 'post', 'id' => 'top_form', 'elements' => array(1 => array('text' => 'school_year'), 2 => array('submit' => 'add'))); $table->set_top_form($top_form); /********************************************************************/ /* CONFIGURES Main table contents (from MySQL) */ $columns = array('School Year', 'Action'); $table->set_html_table_column_names($columns); $sql = 'SELECT school_year_id, school_year FROM school_years ORDER BY school_year DESC '; $details_link = array(1 => array('delete', '?controller=school_years&action=delete&id=')); $table->set_details_link($details_link); $table->set_main_table($connection->query($sql)); /********************************************************************/ $content .= '<table>' . $table->get_table() . '</table>'; $output['content'] = $content; return $output; }
public function index() { $content = ""; /* CONFIGURES DROP DOWN Menus (2 in this case: programs and genre) */ $connection = new database(); $table = new simple_table_ops(); $sql = "SELECT courses.course_id, levels.level\n FROM courses\n JOIN levels ON courses.level_id = levels.level_id\n WHERE courses.school_year_id = {$_SESSION['current_school_year_id']}\n ORDER BY levels.level_id ASC\n\n "; $courses_result = $connection->query($sql); if ($connection->get_row_num() == 0) { // no courses were setup - redirect $content .= "<p> No courses were found for the year {$_SESSION['current_school_year']}.<p>Go to [COURSES] to add a new one."; $output['content'] = $content; return $output; } $drop_down = array('course_id' => array('course' => $courses_result)); $table->set_drop_down($drop_down); /* CONFIGURES top column in neat names and html formatted */ $neat_column_names = array('Select', 'Surname', 'Name', 'Surname Kh', 'Name Kh', 'Genre', 'Program', 'Age'); $table->set_html_table_column_names($neat_column_names); /********************************************************************/ /* CONFIGURES main left table */ // selects ALL students from students where student_id is not inside [COURSES] table // need: select students that are not found in [COURSES] of the current_year_id. /* $sql = "SELECT students.student_id, students.nom, students.prenom, students.nom_khmer, students.prenom_khmer, sexes.sex, programs.program, TIMESTAMPDIFF(YEAR,students.dob,NOW()) AS age FROM students LEFT JOIN courses ON courses.student_id=students.student_id JOIN sexes ON students.sex_id=sexes.sex_id JOIN programs ON students.program_id=programs.program_id WHERE courses.school_year_id Is Null AND students.active_id=1 ORDER BY age ASC, nom ASC, prenom ASC"; */ $sql = "SELECT students.student_id, students.nom, students.prenom, students.nom_khmer, students.prenom_khmer, sexes.sex, programs.program, TIMESTAMPDIFF(YEAR,students.dob,NOW()) AS age\n FROM students\n JOIN sexes ON students.sex_id=sexes.sex_id\n JOIN programs ON students.program_id=programs.program_id\n WHERE students.active_id=1 AND NOT students.student_id IN (\n SELECT students.student_id\n FROM students\n JOIN classes ON classes.student_id = students.student_id\n JOIN courses ON courses.course_id = classes.course_id\n JOIN school_years ON school_years.school_year_id = courses.school_year_id\n WHERE courses.school_year_id = {$_SESSION['current_school_year_id']})\n ORDER BY age ASC, students.prenom, students.nom"; // CHECK: if no result, warn that you need to add students to students table before making courses! // $content .= 'Before building courses, you need to add STUDENTS to the [STUDENTS] table!'; $result = $connection->query($sql); if ($connection->get_row_num() == 0) { // no records found - $output['menu2'] = "No free students were found. To add a new STUDENT, click <a href='?controller=students&action=index'>HERE</a>."; } $table->set_id_column('student_id'); $table->set_html_check_box($result); $content .= "<div class='submit_top_left'><table width='100%'><tr><td>" . $table->get_html_drop_down('course_id') . "</td></tr></table></div>"; $content .= "<div class='half_left'><br><br><table width='100%'>"; $content .= $table->get_html_table_column_names(); $content .= "<form action = '?controller=classes&action=move' method = 'post' id='top_form'>"; $content .= $table->get_html_check_box(); $content .= "<div class='submit_top_left2'><input type ='submit' value='Move selected STUDENTS to Course ->'></div>"; $content .= "</form></table></div>"; //TODO (secondary): // foreach (total of courses.levels_id) // select student from classes // assemble table with new tables from select and add row containing levels.level on top // alternate div class table_row1/table_row2 for each group of class // end foreach // $courses_sql = "SELECT classes.classe_id,\n levels.level,\n students.nom, students.prenom, students.nom_khmer, students.prenom_khmer,\n sexes.sex,\n programs.program\n\n FROM courses\n JOIN classes ON classes.course_id = courses.course_id\n JOIN students ON classes.student_id = students.student_id\n JOIN programs ON programs.program_id = students.program_id\n JOIN sexes ON sexes.sex_id = students.sex_id\n JOIN school_years ON school_years.school_year_id = courses.school_year_id\n JOIN levels ON levels.level_id = courses.level_id\n WHERE courses.school_year_id = " . $_SESSION['current_school_year_id'] . "\n ORDER BY school_years.school_year DESC, levels.level_id ASC, students.nom ASC, students.prenom ASC\n "; // TODO: priority high - generate tables per level_id $courses_table = new simple_table_ops(); $columns = array('Surname', 'Name', 'Surname Kh', 'Name Kh', 'Genre', 'Program', 'Action'); $courses_table->set_html_table_column_names($columns); $details_link = array(1 => array('details', '?controller=classes&action=details&id=')); $courses_table->set_details_link($details_link); $content .= "<div class='half_right'>"; $sql = "SELECT level_id FROM courses GROUP BY level_id ORDER BY level_id"; $levels_result = $connection->query($sql); foreach ($levels_result as $row) { $content .= "<table width='100%'>"; foreach ($row as $field => $value) { $courses_sql = "SELECT classes.classe_id,\n\n students.nom, students.prenom, students.nom_khmer, students.prenom_khmer,\n sexes.sex,\n programs.program\n\n FROM courses\n JOIN classes ON classes.course_id = courses.course_id\n JOIN students ON classes.student_id = students.student_id\n JOIN programs ON programs.program_id = students.program_id\n JOIN sexes ON sexes.sex_id = students.sex_id\n JOIN school_years ON school_years.school_year_id = courses.school_year_id\n JOIN levels ON levels.level_id = courses.level_id\n WHERE courses.school_year_id = " . $_SESSION['current_school_year_id'] . " AND courses.level_id={$value}\n ORDER BY school_years.school_year DESC, levels.level_id ASC, students.nom ASC, students.prenom ASC\n "; $courses_table->set_main_table($connection->query($courses_sql)); $content .= "<tr><td colspan='7'>Grade: " . $value . "</td></tr>"; $content .= $courses_table->get_html_table_column_names(); $content .= $courses_table->get_html_main_table(); $content .= '</td></tr>'; } $content .= "</table>"; } $content .= "</div>"; /********************************************************************/ $output['content'] = $content; return $output; }
public function profiles_index() { $connection = new database(); $table = new simple_table_ops(); $content = "<div class='link_button'>\n <a href='?controller=admin&action=users_index'>Users</a>\n <a href='?controller=admin&action=acl_index'>Access Control List</a>\n <a href='?controller=admin&action=controllers_index'>Controllers</a>\n </div>"; $content .= "<p>Add/Edit or Delete a Profile"; $content .= "<p>Profiles are like badges: if you are the ADMIN, you can do whatever you want, delete any record etc."; $content .= "<p>After adding a new profile, you should configure the Access Control List."; $content .= "<p>Note that ADMIN profile is not listed; however, it is present in Profiles table. ADMIN is non-editable/non-deletable/non-appraisable."; $content .= "<p>You should avoid deleting a profile. Instead, if needed, create another profile and negate access in Access Control List page."; /* CONFIGURES Form structure */ $top_form = array('action' => '?controller=admin&action=profiles_add', 'div' => "class='solitary_input'", 'method' => 'post', 'id' => 'top_form', 'elements' => array(1 => array('text' => 'profile'), 2 => array('submit' => 'add'))); $table->set_top_form($top_form); /********************************************************************/ /* CONFIGURES Main table contents (from MySQL) */ $columns = array('Profile', 'Action'); $table->set_html_table_column_names($columns); $sql = 'SELECT profile_id, profile FROM profiles WHERE NOT profile_id = 1 ORDER BY profile ASC '; $details_link = array(1 => array('edit', '?controller=admin&action=profiles_details&id=')); $table->set_details_link($details_link); $table->set_main_table($connection->query($sql)); /********************************************************************/ $content .= '<table>' . $table->get_table() . '</table>'; $output['content'] = $content; return $output; }