public function getteasubrel($class, $subject)
 {
     global $objPDO;
     $teacher = array();
     include_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/section_teacher_subject_class.php';
     $rel = new SectionTeacherSubjectRelations($objPDO);
     $teacher = $rel->getByClassSubject($class, $subject);
     if ($teacher) {
         return $teacher;
     } else {
         return false;
     }
 }
Пример #2
0
 protected function validate()
 {
     $required = array("section" => "Section");
     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;
             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);
             }
             require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/timetable_class.php';
             require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/section_teacher_subject_class.php';
             require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/controller/utility_class.php';
             for ($i = 0; $i < count($_POST['time_table']); $i++) {
                 $spl = array();
                 $spl = explode("-", $_POST['time_table'][$i]);
                 if (isset($spl[1])) {
                     $ttab = new Timetable($objPDO);
                     $ttab->setSectionId($_POST['section']);
                     $ttab->setSlot($spl[1]);
                     $ttab->getBySecSlot();
                     if ($spl[0] != '0') {
                         $rel = new SectionTeacherSubjectRelations($objPDO);
                         $tid = $rel->getByClassSubject($_POST['section'], $spl[0]);
                         if ($ttab->checkTeacherSlot($spl[1], $tid, $_POST['section'])) {
                             $ttab->setSubjectId($spl[0]);
                             $ttab->setTeacherId($tid);
                         } else {
                             $ttab->markForDeletion();
                             include_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/subject_class.php';
                             $sub = new Subject($objPDO, $spl[0]);
                             $day = floor($spl[1] / $num_slots);
                             $slot = $spl[1] % $num_slots;
                             echo "Teacher Slot Unavailable for " . $sub->getName() . " at " . Utility::getDay($day + 1) . " " . $slots[$slot] . "<br/>";
                             return;
                             $label = false;
                         }
                     } else {
                         if ($spl[0] == '0') {
                             $ttab->markForDeletion();
                         }
                     }
                     if (!isset($label) || $label != false) {
                     }
                     $ttab->save();
                 }
             }
             echo 'Saving...';
             if (!isset($label) || $label != false) {
                 echo '<meta http-equiv="Refresh" content="0;url=http://localhost/cloud/timetable"/>';
             }
         }
     } else {
         header('Location:http://localhost/cloud');
     }
 }