Ejemplo n.º 1
0
 protected function savetimetable()
 {
     $required = array("exam_id" => "Examination Name", "check" => "Exam Timetable");
     global $user;
     if ($user->checkAdmin() == true) {
         if (isset($_POST)) {
             foreach ($required as $key => $value) {
                 if (!isset($_POST[$key]) || $_POST[$key] == '' || $_POST[$key] == 'select') {
                     echo $value . ' is Required<br/>';
                     return;
                 }
             }
             global $objPDO;
             require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/exam_timetable_class.php';
             require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/examination_section_subject_class.php';
             require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/section_class.php';
             $exam_id = $_POST['exam_id'];
             $sec = new Section($objPDO);
             $fn_an = array("0" => "FN", "1" => "AN");
             $sec_name = $sec->getSectionArray();
             foreach ($_POST as $k => $v) {
                 if ($k != 'exam_id' && $k != 'check' && $k != 'save_timetable') {
                     $parts_1 = explode('_', $k);
                     $section_id_1 = $parts_1[2];
                     foreach ($_POST as $r => $s) {
                         if ($r != 'exam_id' && $r != 'check' && $r != 'save_timetable') {
                             $parts_2 = explode('_', $r);
                             $section_id_2 = $parts_2[2];
                             if ($s == $v && $k != $r && $v != 0 && $section_id_1 == $section_id_2) {
                                 echo 'Exam Clash.. Please Check Section [[' . $sec_name[$section_id_1] . ']] on ' . $parts_1[0] . '-' . $fn_an[$parts_1[1]] . ' and ' . $parts_2[0] . '-' . $fn_an[$parts_2[1]];
                                 return;
                             }
                         }
                     }
                 }
             }
             echo 'Saving...';
             foreach ($_POST as $key => $value) {
                 if ($key != 'exam_id' && $key != 'check' && $key != 'save_timetable') {
                     $parts = explode('_', $key);
                     $date = date('Y-m-d H:i:s T', strtotime($parts[0]));
                     $slot = $parts[1];
                     $section_id = $parts[2];
                     $subject_id = $value;
                     if ($subject_id == 0) {
                         continue;
                     } else {
                         $rel = new ExaminationSectionSubject($objPDO);
                         $rel->setSectionId($section_id);
                         $rel->setSubjectId($subject_id);
                         $rel->setExaminationId($exam_id);
                         $sub_rel_id = $rel->getIDByElems();
                         $tt = new ExamTimetable($objPDO);
                         if ($tt->checkExamSubjectId($sub_rel_id)) {
                             $tt->deleteByExamSubjectId($sub_rel_id);
                         }
                         $tt->setSlot($slot);
                         $tt->setDate($date);
                         $tt->setExamSubjectId($sub_rel_id);
                         $tt->save();
                     }
                 }
             }
             echo '<meta http-equiv="Refresh" content="0;url=http://localhost/cloud/examination/"/>';
         }
     } else {
         header('Location:http://localhost/cloud');
     }
 }
Ejemplo n.º 2
0
 public static function dropDownListEditable($val, $id, $name, $type, $class = NULL, $input = NULL, $textVal = NULL, $class_select = NULL)
 {
     Utility::editableSelectScript($id);
     global $objPDO;
     include_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/subject_class.php';
     include_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/section_class.php';
     include_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/teacher_class.php';
     $sec = new Section($objPDO);
     $section = $sec->getSectionArray();
     $tea = new Teacher($objPDO);
     $teacher = $tea->getTeacherArray($input);
     $sub = new Subject($objPDO);
     $subject = $sub->getSubjectArray();
     $numeric_level = array("select" => "--Select--", "0" => "0", "1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10", "11" => "11", "12" => "12");
     $blood_group = array("select" => "--Select--", "A+" => "A+", "B+" => "B+", "O+" => "O+", "AB+" => "AB+", "A-" => "A-", "B-" => "B-", "O-" => "O-", "AB-" => "AB-");
     $category = array("select" => "--Select--", "OC" => "General(OC)", "SC" => "SC", "ST" => "ST", "OBC" => "OBC", "NRI" => "NRI", "Defence" => "Defence");
     if ($class == NULL) {
         $class = "text_editable";
     }
     $list = array();
     if ($type == "numeric_level") {
         $list = $numeric_level;
     } else {
         if ($type == "blood_group") {
             $list = $blood_group;
         } else {
             if ($type == "category") {
                 $list = $category;
             } else {
                 if ($type == "subject") {
                     $list = $subject;
                 } else {
                     if ($type == "section") {
                         $list = $section;
                     } else {
                         if ($type == "teacher") {
                             $list = $teacher;
                         }
                     }
                 }
             }
         }
     }
     $textVal = "";
     if (array_key_exists($val, $list)) {
         $textVal = $list[$val];
     }
     $html = '<input type="text" readonly="readonly" id="' . $id . '" class="' . $class . '" value="' . $textVal . '"/>';
     $html .= '<select class="' . $class_select . '" style="display:none" id="' . $id . '"  name="' . $name . '" >';
     foreach ($list as $key => $value) {
         if ($key == $val) {
             $html .= '<option class="' . $class_select . '" selected="selected" value="' . $key . '">' . $value . '</option>';
         } else {
             $html .= '<option value="' . $key . '">' . $value . '</option>';
         }
     }
     $html .= '</select>';
     echo $html;
 }
Ejemplo n.º 3
0
 protected function teacherview()
 {
     global $user;
     global $objPDO;
     $student = new student($objPDO, $user->getuserId());
     $headMenu = array("username" => $student->getName());
     if ($user->checkAdmin() == true || $student->checkTeacher()) {
         if ($user->checkAdmin()) {
             $teacher = $_GET['uid'];
         } else {
             require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/teacher_class.php';
             $teacherProfile = new Teacher($objPDO);
             $teacherProfile->loadByUserId($student->getID());
             $teacher = $teacherProfile->getID();
         }
         include $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/timetable_settings_class.php';
         $sett = new TimetableSettings($objPDO);
         $slots = $sett->getAllSlots();
         if (!isset($slots)) {
             $num_slots = 0;
         } else {
             $num_slots = count($slots);
         }
         include_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/subject_class.php';
         include_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/timetable_class.php';
         include_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/section_class.php';
         $tt = new Timetable($objPDO);
         $sec = new Section($objPDO);
         $timetable = $tt->getByTeacherId($teacher);
         $subject = $tt->getTeacherSubject($teacher);
         $section = $sec->getSectionArray();
         $total = 0;
         $count = array();
         foreach ($timetable as $key => $value) {
             $total++;
             if (array_key_exists($value, $count)) {
                 $count[$value]++;
             } else {
                 $count[$value] = 1;
             }
         }
         include $_SERVER['DOCUMENT_ROOT'] . '/cloud/view/teacher_timetable_view_template.php';
     } else {
         header('Location:http://localhost/cloud');
     }
 }