public function getAvailableStudentsForCourseSubjectCriteria(CourseSubject $course_subject, $criteria = null, $filter_by_orientation = true)
 {
     if ($course_subject->getCareerSubjectSchoolYear()->getCareerSubject()->getIsOption() || $course_subject->getCareerSubjectSchoolYear()->getCareerSubject()->getHasOptions()) {
         $filter_by_orientation = false;
     }
     return parent::getAvailableStudentsForCourseSubjectCriteria($course_subject, $criteria, false);
 }
 public static function setAvailableStudentsForCourse(CourseSubject $course_subject)
 {
     $course = $course_subject->getCourse();
     $school_year = $course->getSchoolYear();
     $pathways = $school_year->getPathways();
     $available_pathway_students = array();
     foreach ($pathways as $pathway) {
         $c = new Criteria();
         $c->addJoin(PathwayStudentPeer::STUDENT_ID, StudentCareerSubjectAllowedPathwayPeer::STUDENT_ID);
         $c->add(PathwayStudentPeer::PATHWAY_ID, $pathway->getId());
         $c->add(PathwayStudentPeer::YEAR, $course_subject->getYear());
         $c->add(StudentCareerSubjectAllowedPathwayPeer::CAREER_SUBJECT_ID, $course_subject->getCareerSubjectSchoolYear()->getCareerSubject()->getId());
         foreach (PathwayStudentPeer::doSelect($c) as $ps) {
             $available_pathway_students[] = $ps->getStudent();
         }
     }
     self::$_students = array_merge($course_subject->getPathwayStudents(), $available_pathway_students);
 }
 /**
  * This method returns the available students for a course subject. If $filter_by_orientation == true then filter by orientation too.
  *
  * @param CourseSubject $course_subject
  * @param Criteria $criteria
  * @param Boolean $filter_by_orientation
  * @return Criteria
  */
 public function getAvailableStudentsForCourseSubjectCriteria(CourseSubject $course_subject, $criteria = null, $filter_by_orientation = true)
 {
     $criteria = is_null($criteria) ? new Criteria() : $criteria;
     //IF the course_subject is a option, the cheks are in the parent optional
     //die(var_dump($course_subject->getCareerSubjectSchoolYear()->getCareerSubject()->getIsOption()));
     $career_subject_school_year = $course_subject->getCareerSubjectSchoolYear()->getCareerSubject()->getIsOption() ? $course_subject->getCareerSubjectSchoolYear()->getOptionalCareerSubjectSchoolYear() : $course_subject->getCareerSubjectSchoolYear();
     $career_subject = $career_subject_school_year->getCareerSubject();
     //Students inscripted in the career
     $criteria->addJoin(StudentPeer::ID, CareerStudentPeer::STUDENT_ID, Criteria::INNER_JOIN);
     $criteria->addAnd(CareerStudentPeer::CAREER_ID, $career_subject->getCareerId());
     //If $filter_by_orientation == true then checks for orientation in the criteria
     if ($filter_by_orientation && !is_null($career_subject->getOrientation())) {
         $criteria->addJoin(CareerStudentPeer::ORIENTATION_ID, $career_subject->getOrientationId());
     }
     if ($filter_by_orientation && !is_null($career_subject->getSubOrientation())) {
         $criteria->addJoin(CareerStudentPeer::SUB_ORIENTATION_ID, $career_subject->getSubOrientationId());
     }
     //Students inscripted in the school_year
     $criteria->addJoin(StudentPeer::ID, SchoolYearStudentPeer::STUDENT_ID, Criteria::INNER_JOIN);
     $criteria->addAnd(SchoolYearStudentPeer::SCHOOL_YEAR_ID, $career_subject_school_year->getCareerSchoolYear()->getSchoolYearId());
     //Check if the students has the corresponds allows required to course this subject
     $criteria->addJoin(StudentPeer::ID, StudentCareerSubjectAllowedPeer::STUDENT_ID);
     $criteria->addAnd(StudentCareerSubjectAllowedPeer::CAREER_SUBJECT_ID, $career_subject->getId());
     //Criteria for eliminate students inscripted in other course_subject of the same course
     $already_criteria = new Criteria();
     $already_criteria->clearSelectColumns();
     $already_criteria->addSelectColumn(CourseSubjectStudentPeer::STUDENT_ID);
     $already_criteria->addJoin(CourseSubjectPeer::ID, CourseSubjectStudentPeer::COURSE_SUBJECT_ID);
     $already_criteria->add(CourseSubjectPeer::COURSE_ID, $course_subject->getCourseId());
     $already_criteria->add(CourseSubjectStudentPeer::COURSE_SUBJECT_ID, $course_subject->getId(), Criteria::NOT_EQUAL);
     $pdo_statement = CourseSubjectStudentPeer::doSelectStmt($already_criteria);
     $student_already_ids = $pdo_statement->fetchAll(PDO::FETCH_COLUMN);
     if (count($student_already_ids)) {
         $criteria->addAnd(StudentPeer::ID, $student_already_ids, Criteria::NOT_IN);
     }
     return $criteria;
 }