public static function doSelectByAccalFromPrereq() { $accal_id = sfContext::getInstance()->getRequest()->getParameter('accal_id'); if (!$accal_id) { return array(); } $c = new Criteria(); $c->add(SubjectAccalPeer::ACADEMIC_CALENDAR_ID, $accal_id); $c->addJoin(SubjectPeer::ID, SubjectAccalPeer::SUBJECT_ID); $c->addAscendingOrderByColumn(SubjectPeer::NAME); return SubjectAccalPeer::doSelect($c); }
public function getSubjectAccals($criteria = null, $con = null) { include_once 'lib/model/om/BaseSubjectAccalPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collSubjectAccals === null) { if ($this->isNew()) { $this->collSubjectAccals = array(); } else { $criteria->add(SubjectAccalPeer::EMPLOYEE_ID, $this->getId()); SubjectAccalPeer::addSelectColumns($criteria); $this->collSubjectAccals = SubjectAccalPeer::doSelect($criteria, $con); } } else { if (!$this->isNew()) { $criteria->add(SubjectAccalPeer::EMPLOYEE_ID, $this->getId()); SubjectAccalPeer::addSelectColumns($criteria); if (!isset($this->lastSubjectAccalCriteria) || !$this->lastSubjectAccalCriteria->equals($criteria)) { $this->collSubjectAccals = SubjectAccalPeer::doSelect($criteria, $con); } } } $this->lastSubjectAccalCriteria = $criteria; return $this->collSubjectAccals; }
public function executeEdit() { $student_id = $this->getRequestParameter('student_id'); $student = StudentPeer::retrieveByPK($student_id); $this->forward404Unless($student); $this->student = $student; $group_id = $this->getContext()->getUser()->getAttribute('group_id', null, 'bo'); $c = new Criteria(); $c->add(JobPeer::CODE, $this->getModuleName()); $job = JobPeer::doSelectOne($c); $acl = AclPeer::retrieveByPK($group_id, $job->getId()); if (!$acl) { $this->forward('default', 'error404'); } $this->can_add = $acl->getAddPriv() == 1; $this->can_edit = $acl->getEditPriv() == 1; $this->can_remove = $acl->getRemovePriv() == 1; $student_course = StudentCoursePeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($student_course); $accal_options = array(); $accals = $student_course->getSubjectAccal()->getAcademicCalendar()->getCurriculum()->getAcademicCalendars(); foreach ($accals as $accal) { $accal_options[$accal->getId()] = $accal->toString(); } $c = new Criteria(); $c->add(AcademicCalendarPeer::ID, $student_course->getSubjectAccal()->getAcademicCalendarId()); $c->addJoin(SubjectAccalPeer::ACADEMIC_CALENDAR_ID, AcademicCalendarPeer::ID); $c->addJoin(SubjectAccalPeer::SUBJECT_ID, SubjectPeer::ID); $c->addAscendingOrderByColumn(AcademicCalendarPeer::CODE); $c->addAscendingOrderByColumn(SubjectPeer::CODE); $c->addAscendingOrderByColumn(SubjectPeer::NAME); $c->setDistinct(); $subject_accals = SubjectAccalPeer::doSelect($c); $subject_accal_options = array(); foreach ($subject_accals as $subject_accal) { if ($subject_accal->getSubject()) { $subject_accal_options[$subject_accal->getId()] = $subject_accal->toString(); } } $disabled_sa = array(); $saved_student_courses = $student->getStudentCourses(); foreach ($saved_student_courses as $ssc) { if ($student_course->getId() != $ssc->getId()) { $disabled_sa[] = $ssc->getSubjectAccalId(); } } $objs = SubjectAccalPeer::doSelectByAccal(); foreach ($objs as $o) { $content[$o->getId()] = $o->toStringWithLector(); $c = new Criteria(); $c->add(SubjectAccalPeer::ID, $o->getId()); $c->add(SubjectCurrPeer::SUBJECT_ID, $o->getSubjectId()); $c->addJoin(AcademicCalendarPeer::ID, SubjectAccalPeer::ACADEMIC_CALENDAR_ID); $c->addJoin(AcademicCalendarPeer::CURRICULUM_ID, SubjectCurrPeer::CURRICULUM_ID); $c->addJoin(SubjectCurrPeer::ID, SubjectPrereqPeer::SUBCURR); $sps = SubjectPrereqPeer::doSelect($c); foreach ($sps as $sp) { $s = $sp->getSubjectCurrRelatedBySubcurrPrereq()->getSubject(); // prereq subject must be in closed state $c = new Criteria(); $c->add(SubjectAccalPeer::SUBJECT_ID, $s->getId()); $c->add(StudentCoursePeer::STUDENT_ID, $student_id); $c->add(StudentCoursePeer::STATUS, StudentCourse::STATUS_CLOSED); $c->addJoin(StudentCoursePeer::SUBJECT_ACCAL_ID, SubjectAccalPeer::ID); $scs = StudentCoursePeer::doSelect($c); $isPassGrade = false; $isPassCredit = true; $isPassIndex = true; foreach ($scs as $sc) { $grade = $sc->getFinalGrade(); $gc = GradeConversionPeer::retrieveByName($grade[0]); // check prereq subject grade if ($gc && $gc->getGrade() >= $sp->getGradeConversion()->getGrade()) { $isPassGrade = true; } else { $isPassGrade = false; } // check credit requirement if ($sp->getTotalCredit() > 0) { if ($sc->getTotalCreditClosed() >= $sp->getTotalCredit()) { $isPassCredit = true; } else { $isPassCredit = false; } } // check index requirement if ($sp->getPerformanceIndex() > 0) { if ($sc->getPerformanceIndex() >= $sp->getPerformanceIndex()) { $isPassIndex = true; } else { $isPassIndex = false; } } } $s0 = $sp->getSubjectCurrRelatedBySubcurrPrereq()->getSubject()->toString(); $s1 = $sp->getSubjectCurrRelatedBySubcurr()->getSubject()->toString(); if (!$isPassGrade || !$isPassCredit || !$isPassIndex) { $disabled_sa[] = $o->getId(); } } } $actions = array(array('name' => 'save', 'type' => 'submit', 'options' => array('class' => 'save_button', 'onclick' => "action_type.value=this.value"))); if ($acl->getRemovePriv()) { array_push($actions, array('name' => 'delete', 'url' => 'student_course_s/delete?student_id=' . $student->getId() . '&id=' . $student_course->getId(), 'color' => 'red')); } array_push($actions, array('name' => 'cancel', 'url' => 'student_course_s/list?student_id=' . $student->getId(), 'color' => 'white')); $c = new Criteria(); $c->add(CourseSchedulePeer::SUBJECT_ACCAL_ID, $student_course->getSubjectAccalId()); $c->add(CourseSchedulePeer::CLASS_GROUP_ID, $student_course->getClassGroupId()); $objs = CourseSchedulePeer::doSelect($c); $schedules = array(); foreach ($objs as $o) { $schedules[$o->getId()] = $o->toStringLong(); } $this->subject_accal_options = $subject_accal_options; $this->accal_options = $accal_options; $this->disabled_sa = $disabled_sa; $this->subtitle = $student->toString() . ' - id:' . $student_course->getId(); $this->type = 'edit'; $this->student_course = $student_course; $this->actions = $actions; $this->schedules = $schedules; }
public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(SubjectAccalPeer::ID, $pks, Criteria::IN); $objs = SubjectAccalPeer::doSelect($criteria, $con); } return $objs; }