Пример #1
0
 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;
 }
Пример #2
0
 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;
 }
Пример #3
0
 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;
 }
Пример #4
0
 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;
 }
Пример #5
0
 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;
 }
Пример #6
0
 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;
 }
Пример #7
0
 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;
 }
Пример #8
0
 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;
 }
Пример #9
0
 public function show()
 {
     // TODO: when coming back from update, show previous timetable
     $connection = new database();
     $table = new simple_table_ops();
     if (isset($_POST['timetable_period_id'])) {
         //if (isset($_GET['timetable_period_id'])) {
         //$timetable_period_id = $_GET['timetable_period_id'];
         $timetable_period_id = $_POST['timetable_period_id'];
         $post_values = array('timetable_period_id' => $timetable_period_id);
         $table->set_values_form_manually($post_values);
     }
     if (isset($_GET['timetable_period_id'])) {
         $timetable_period_id = $_GET['timetable_period_id'];
         //$timetable_period_id = $_POST['timetable_period_id'];
         $post_values = array('timetable_period_id' => $timetable_period_id);
         $table->set_values_form_manually($post_values);
     }
     $this->timetable_period_id = $timetable_period_id;
     $content = "<div class='link_button'>\n                        <a href='?controller=teachers&action=index'>Teacher</a>\n                        <a href='?controller=curricula&action=index'>Curricula</a>\n                    </div>";
     /* CONFIGURES DROP DOWN Menu */
     $sql = "SELECT timetable_period_id, CONCAT (nom, ' - ', date_from, ' to ', date_to) as period\n                FROM timetable_periods\n                WHERE school_year_id = {$_SESSION['current_school_year_id']}\n                ";
     $timetable_periods_result = $connection->query($sql);
     $drop_down = array('timetable_period_id' => array('period' => $timetable_periods_result));
     $table->set_drop_down($drop_down);
     /********************************************************************/
     /* CONFIGURES Form structure */
     $top_form = array('action' => '?controller=timetable&action=show&submit=yes', 'div' => "class='solitary_input'", 'div_button' => "class='submit_button1'", 'method' => 'post', 'id' => 'top_form', 'elements' => array(1 => array('drop_down' => 'timetable_period_id'), 3 => array('submit' => 'Show Timetable')));
     $table->set_top_form($top_form);
     /********************************************************************/
     $columns = array('Timetable', 'Action');
     $table->set_html_table_column_names($columns);
     $content .= "<table width='auto'>" . $table->get_html_table_column_names() . $table->get_form() . '</table>';
     if (isset($_GET['submit'])) {
         if ($_GET['submit'] == 'yes') {
             $this->set_timetable_html();
             $content .= $this->get_timetable_html();
         }
     }
     $output['content'] = $content;
     return $output;
 }
Пример #10
0
 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;
 }
Пример #11
0
 public function index()
 {
     $content = '<div class="third_left">';
     $content .= file_get_contents('views/help/help1.php');
     $content .= file_get_contents('views/messages/messages.php');
     $content .= '</div>';
     /************  left/middle ************/
     $content .= "<div class='third_middle'>";
     // drop down with school_years and submit button => set $_SESSION['current_year_id'] and $_SESSION['current_year'] variables here
     $connection = new database();
     $table = new simple_table_ops();
     $sql = 'SELECT school_year_id, school_year FROM school_years ORDER BY school_year DESC';
     $school_year_result = $connection->query($sql);
     if ($connection->get_row_num() == 0) {
         // no school year were found, please add one
         $content .= "<p> No school year was found! <p>Please, add a school year in [CONFIGURATION] if you are the administrator.";
     }
     $drop_down = array('school_year_id' => array('school_year' => $school_year_result));
     $form_values = array('school_year_id' => $_SESSION['current_school_year_id']);
     $table->set_values_form_manually($form_values);
     //  set drop_down menu with current_school_year_id
     $table->set_drop_down($drop_down);
     /* CONFIGURES top column in neat names and html formatted */
     $neat_column_names = array('School Year', 'Action');
     $table->set_html_table_column_names($neat_column_names);
     /* CONFIGURES Form structure */
     $top_form = array('action' => '?controller=home&action=setschoolyear', 'div' => "class='solitary_input'", 'div_button' => "class='form_button'", 'method' => 'post', 'id' => 'top_form', 'elements' => array(1 => array('drop_down' => 'school_year_id'), 11 => array('submit' => 'Set School Year')));
     $table->set_top_form($top_form);
     /********************************************************************/
     $content .= "<table id=pan>";
     $content .= "<tr><td>";
     $content .= "<table width='226px'>";
     $content .= $table->get_html_table_column_names();
     $content .= $table->get_form() . "</table>";
     $content .= "<p>Select the School Year to use throughout the application. <p>You can see it in the upper right (in orange). Any operation (class, curriculum, timetable etc creation) are automatically attached to this School Year.";
     $content .= "</td></tr></table>";
     /* CONFIGURES Main table contents */
     $columns = array('Available School Years');
     $table->set_html_table_column_names($columns);
     $sql = 'SELECT school_year_id, school_year
             FROM school_years
             ORDER BY school_year DESC
     ';
     $table->set_main_table($connection->query($sql));
     /********************************************************************/
     $content .= "<table id=pan>";
     $content .= "<tr><td>";
     $content .= "<table width='113px'>";
     $content .= $table->get_html_table_column_names();
     $content .= $table->get_html_main_table();
     $content .= '</table>';
     $content .= "</td><td>List of School Years already in the database.<p>To add a new school year, go to <a href='?controller=school_years&action=index'>Configuration->School Years</a></td></tr></table>";
     $content .= "</div>";
     /************  middle/right ************/
     $content .= "<div class='third_right'>";
     /* CONFIGURES Main table contents (from MySQL) */
     /* LIST OF ALL PROGRAMS */
     $columns = array('Programs');
     $table->set_html_table_column_names($columns);
     $sql = 'SELECT program_id, program
             FROM programs
             ORDER BY program ASC
     ';
     $table->set_main_table($connection->query($sql));
     $content .= "<table id=pan><tr><td>";
     $content .= "<table width='113px'>";
     $content .= $table->get_html_table_column_names();
     $content .= $table->get_html_main_table();
     $content .= '</table>';
     $content .= "</td><td>List of programs in the database.<p>If a program is changed or created, go to <a href='?controller=program&action=index'>Configuration->Programs</a></td></tr></table>";
     /********************************************************************/
     $columns = array('Program', 'Students');
     $table->set_html_table_column_names($columns);
     $sql = "SELECT students.program_id, programs.program, COUNT(students.student_id)\n               FROM students\n               JOIN programs ON programs.program_id = students.program_id\n               GROUP BY program_id\n               ORDER BY programs.program";
     $table->set_main_table($connection->query($sql));
     $content .= "<table id=pan><tr><td>";
     $content .= "<table width='226px'>" . $table->get_html_table_column_names() . $table->get_html_main_table() . '</table>';
     $sql = "SELECT COUNT(DISTINCT program_id), COUNT(student_id)\n               FROM students\n               ";
     $total_students = $connection->query($sql);
     $content .= "<p>Total programs: " . $total_students[0]['COUNT(DISTINCT program_id)'];
     $content .= "<br>Total students: " . $total_students[0]['COUNT(student_id)'];
     $content .= "</td></tr></table>";
     $content .= "</div>";
     $output['content'] = $content;
     $output['footer'] = 'Welcome to CSS AEC-Foyer Lataste System';
     return $output;
 }
Пример #12
0
 public function index()
 {
     $content = "<div class='link_button'>\n                        <a href='?controller=attendances&action=export'>Export to EXCEL</a>\n\n                    </div>";
     // attendances index:
     //   Receives curriculum_id -
     /* CONFIGURES DROP DOWN Menus (2 in this case: programs and genre) */
     $connection = new database();
     $table = new simple_table_ops();
     $sql = "SELECT month_id, month FROM months ORDER BY month_id";
     $months_result = $connection->query($sql);
     $sql = "SELECT curricula.curriculum_id,\n                    CONCAT (teachers.nom, ' ', teachers.prenom, ' ', teachers.nom_khmer, ' ', teachers.prenom_khmer, ' ',\n                    subjects.subject, ' ', levels.level) as curricula\n                FROM curricula\n                JOIN teachers ON teachers.teacher_id = curricula.teacher_id\n                JOIN subjects ON subjects.subject_id = curricula.subject_id\n                JOIN courses  ON courses.course_id   = curricula.course_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 levels.level_id ASC, teachers.nom ASC";
     $curricula_result = $connection->query($sql);
     $drop_down = array('curriculum_id' => array('curricula' => $curricula_result), 'month_id' => array('month' => $months_result));
     // TODO: set values from $_POST if $_POST isset in order to preset drop down values
     if (isset($_POST['curriculum_id']) and isset($_POST['month_id'])) {
         $curriculum_id = $_POST['curriculum_id'];
         $month_id = $_POST['month_id'];
         $post_values = array('curriculum_id' => $curriculum_id, 'month_id' => $month_id);
         $table->set_values_form_manually($post_values);
     }
     $table->set_drop_down($drop_down);
     /********************************************************************/
     /* CONFIGURES Form structure */
     $top_form = array('action' => '?controller=attendances&action=index&submit=yes', 'div' => "class='solitary_input'", 'div_button' => "class='submit_button1'", 'method' => 'post', 'id' => 'top_form', 'elements' => array(1 => array('drop_down' => 'curriculum_id'), 2 => array('drop_down' => 'month_id'), 3 => array('submit' => 'Show Attendance Table')));
     $table->set_top_form($top_form);
     /********************************************************************/
     $columns = array('Curricula', 'Month', 'Action');
     $table->set_html_table_column_names($columns);
     $content .= "<table width='auto'>" . $table->get_html_table_column_names() . $table->get_form() . '</table>';
     if (isset($_GET['submit'])) {
         if ($_GET['submit'] == 'yes') {
             //$second_table = new simple_table_ops();
             // TODO:REFACTOR
             // show table
             // 1. Get records from [attendance] table corresponding to
             // $_POST['course_id'] groups the records in classes->attendances.
             // From classes we get the students list and creates the attendance list with a 'text' input in array
             // COUNT DAYS IN MONTH - separate in first/second school year
             $year_first_semester = substr($_SESSION['current_school_year'], 0, 4);
             $year_second_semester = substr($_SESSION['current_school_year'], -4, 4);
             if ($month_id < 9) {
                 // user wants attendance list of first semester
                 $total_days = cal_days_in_month(CAL_GREGORIAN, $month_id, $year_first_semester);
             } else {
                 // user wants attendance list of second semester
                 $total_days = cal_days_in_month(CAL_GREGORIAN, $month_id, $year_second_semester);
             }
             $input_form = '';
             // retrieves info (if any) from [attendances] table
             //      using:
             //          1. curriculum_id
             //          2. month_id
             //
             $days_month = '';
             for ($i = 1; $i <= 31; $i++) {
                 $days_month .= "attendances.day" . $i . ",";
             }
             $days_month = substr($days_month, 0, -1);
             $sql = "SELECT classes.student_id, {$days_month}\n                        FROM attendances\n                        JOIN classes ON classes.classe_id = attendances.classe_id\n                        JOIN curricula ON curricula.curriculum_id = attendances.curriculum_id\n                        WHERE curricula.curriculum_id = {$curriculum_id} AND attendances.month_id = {$month_id}";
             $sda = $connection->query($sql);
             // Now, should extract students (in the form of classes.classe_id) found in classes absent in [attendances]
             // This is necessary if a student starts studying in the middle of the school year
             $missing_students_sql = "SELECT classes.classe_id\n                        FROM classes\n                        JOIN courses  ON courses.course_id   = classes.course_id\n                        JOIN curricula ON curricula.course_id = courses.course_id\n                        WHERE curricula.curriculum_id = {$curriculum_id} AND NOT classes.student_id IN\n                            (SELECT classes.student_id\n                            FROM attendances\n                            JOIN classes ON classes.classe_id = attendances.classe_id\n                            JOIN curricula ON curricula.curriculum_id = attendances.curriculum_id\n                            WHERE curricula.curriculum_id = {$curriculum_id} AND attendances.month_id = {$month_id})";
             $missing_classes_id = $connection->query($missing_students_sql);
             // then, insert missing students into [attendances] table, and present it to user
             $sql = "INSERT INTO attendances (classe_id, curriculum_id, month_id) VALUES (?, ?, ?)";
             foreach ($missing_classes_id as $row) {
                 $classe_id = $row['classe_id'];
                 echo $classe_id . ", ";
                 $data[] = array($classe_id, $curriculum_id, $month_id);
                 // $connection->insert($sql, $data);
             }
             $connection->insert($sql, $data);
             // this selects all students found in [attendances], which should be now up-to-date
             $sql = "SELECT attendances.attendance_id, CONCAT(students.nom, ' ', students.prenom) as nom_prenom, programs.program, sexes.sex, {$days_month}\n                        FROM curricula\n                        JOIN courses  ON curricula.course_id = courses.course_id\n                        JOIN classes  ON courses.course_id   = classes.course_id\n                        JOIN students ON classes.student_id  = students.student_id\n                        JOIN attendances ON attendances.classe_id = classes.classe_id\n                        JOIN sexes ON sexes.sex_id = students.sex_id\n                        JOIN programs ON programs.program_id = students.program_id\n                        WHERE curricula.curriculum_id = {$curriculum_id} AND attendances.month_id = {$month_id}\n                        ORDER BY students.nom ASC, students.prenom ASC";
             $sql = "SELECT attendances.attendance_id, CONCAT(students.nom, ' ', students.prenom) as nom_prenom, programs.program, sexes.sex, {$days_month}\n                        FROM curricula\n                        JOIN courses  ON curricula.course_id = courses.course_id\n                        JOIN classes  ON courses.course_id   = classes.course_id\n                        JOIN students ON classes.student_id  = students.student_id\n                        JOIN attendances ON attendances.classe_id = classes.classe_id\n                        JOIN sexes ON sexes.sex_id = students.sex_id\n                        JOIN programs ON programs.program_id = students.program_id\n                        WHERE curricula.curriculum_id = {$curriculum_id} AND attendances.month_id = {$month_id}\n                        ORDER BY students.nom ASC, students.prenom ASC";
             $sql = "SELECT attendances.attendance_id, CONCAT(students.nom, ' ', students.prenom) as nom_prenom, programs.program, sexes.sex, attendances.day1,attendances.day2,attendances.day3,attendances.day4,attendances.day5,attendances.day6,attendances.day7,attendances.day8,attendances.day9,attendances.day10,attendances.day11,attendances.day12,attendances.day13,attendances.day14,attendances.day15,attendances.day16,attendances.day17,attendances.day18,attendances.day19,attendances.day20,attendances.day21,attendances.day22,attendances.day23,attendances.day24,attendances.day25,attendances.day26,attendances.day27,attendances.day28,attendances.day29,attendances.day30,attendances.day31\n                        FROM attendances\n                        JOIN curricula ON curricula.curriculum_id = attendances.curriculum_id\n                        JOIN classes   ON classes.classe_id  = attendances.classe_id\n                        JOIN students  ON classes.student_id = students.student_id\n                        JOIN sexes     ON sexes.sex_id = students.sex_id\n                        JOIN programs  ON programs.program_id = students.program_id\n                        WHERE curricula.curriculum_id = {$curriculum_id} AND attendances.month_id = {$month_id}\n                        ORDER BY students.nom ASC, students.prenom ASC";
             $students_id = $connection->query($sql);
             /* CONFIGURES DROP DOWN Menu ****************************************/
             // Bug: drop down menu on ALL input elements is PLAIN UGLY. TODO: better insert info on large form
             $sql = 'SELECT attendance_check_id, attendance_abb FROM attendance_checks';
             $attendances_result = $connection->query($sql);
             /********************************************************************/
             $input_form .= "<tr><td><center>Student</center></td><td>Program</td><td>Genre</td>";
             for ($i = 1; $i <= $total_days; $i++) {
                 $input_form .= "<td><center>{$i}</center></td>";
             }
             $input_form .= "</tr>";
             foreach ($students_id as $student_id) {
                 $input_form .= "<tr><td>" . $student_id['nom_prenom'] . "</td><td><center>" . $student_id['program'] . "</center></td><td>" . $student_id['sex'] . "</td>";
                 for ($i = 1; $i <= $total_days; $i++) {
                     $name_day = "attendance[" . $student_id['attendance_id'] . "][" . $i . "]";
                     $current_day = 'day' . $i;
                     $value = $student_id[$current_day];
                     // drop down menu on EACH cell is just too ugly - leave as text, and do a validation later in 'save' method
                     $input_form .= "<td><input type = 'text' name = '{$name_day}' value = '{$value}' size='1'></td>";
                 }
                 $input_form .= "</tr>";
             }
             $input_form .= "<input type='submit' value='save'>";
             $content .= "<table><form method='post' action='?controller=attendances&action=save&id={$curriculum_id}&total_days={$total_days}' id='top_form'>";
             $content .= $input_form;
             $content .= "</form></table>";
         }
     }
     $output['content'] = $content;
     return $output;
 }