Ejemplo n.º 1
0
 public function makeEnrollment($enrollmentObj = null, $toAcademicYear = null, $toYear = null, $toSemester = null, $toSectionId = null, $enrollmentAction = null, $studentId = null, $programSectionObj = null)
 {
     switch ($enrollmentAction) {
         case sfConfig::get('app_admission_enrollment'):
             $this->setStudentId($studentId);
             $this->setAcademicYear($toAcademicYear);
             $this->setYear($toYear);
             $this->setSemester($toSemester);
             $this->setProgramId($programSectionObj->getProgramId());
             $this->setSemesterAction(sfConfig::get('app_enrolled_semester_action'));
             $this->setEnrollmentAction(sfConfig::get('app_admission_enrollment'));
             $this->save();
             $studentCenter = new StudentCenter();
             $studentCenter->setStudentId($studentId);
             $studentCenter->setCenterId($programSectionObj->getCenterId());
             $studentCenter->save();
             break;
         case sfConfig::get('app_promotion_enrollment'):
             $this->setStudentId($enrollmentObj->getStudentId());
             $this->setAcademicYear($toAcademicYear);
             $this->setYear($toYear);
             $this->setSemester($toSemester);
             $this->setSectionId($toSectionId);
             $this->setProgramId($enrollmentObj->getProgramId());
             $this->setTotalChrs($enrollmentObj->getTotalChrs());
             $this->setTotalGradePoints($enrollmentObj->getTotalGradePoints());
             $this->setTotalRepeatedChrs($enrollmentObj->getTotalRepeatedChrs());
             $this->setTotalRepeatedGradePoints($enrollmentObj->getTotalRepeatedGradePoints());
             $this->setPreviousChrs($enrollmentObj->getSemesterChrs());
             $this->setPreviousGradePoints($enrollmentObj->getSemesterGradePoints());
             $this->setPreviousRepeatedChrs($enrollmentObj->getSemesterRepeatedChrs());
             $this->setPreviousRepeatedGradePoints($enrollmentObj->getSemesterRepeatedGradePoints());
             $this->setSemesterAction(sfConfig::get('app_enrolled_semester_action'));
             $this->setEnrollmentAction(sfConfig::get('app_promotion_enrollment'));
             $this->save();
             ##Also mark previous enrollment as promotted.
             $enrollmentObj->setSemesterAction(sfConfig::get('app_promoted_semester_action'));
             $enrollmentObj->save();
             break;
         case sfConfig::get('app_readmission_enrollment'):
             $pSection = Doctrine_Core::getTable('ProgramSection')->findOneById($toSectionId);
             ## new enrollment
             $this->setStudentId($enrollmentObj->getStudentId());
             $this->setAcademicYear($pSection->getAcademicYear());
             $this->setYear($pSection->getYear());
             $this->setSemester($pSection->getSemester());
             $this->setSectionId($pSection->getId());
             $this->setProgramId($enrollmentObj->getProgramId());
             $this->setTotalChrs($enrollmentObj->getTotalChrs());
             $this->setTotalGradePoints($enrollmentObj->getTotalGradePoints());
             $this->setTotalRepeatedChrs($enrollmentObj->getTotalRepeatedChrs());
             $this->setTotalRepeatedGradePoints($enrollmentObj->getTotalRepeatedGradePoints());
             $this->setPreviousChrs($enrollmentObj->getSemesterChrs());
             $this->setPreviousGradePoints($enrollmentObj->getSemesterGradePoints());
             $this->setPreviousRepeatedChrs($enrollmentObj->getSemesterRepeatedChrs());
             $this->setPreviousRepeatedGradePoints($enrollmentObj->getSemesterRepeatedGradePoints());
             $this->setSemesterAction(sfConfig::get('app_enrolled_semester_action'));
             $this->setEnrollmentAction(sfConfig::get('app_readmission_enrollment'));
             ##increment leftout enrollment chrs, gpts from previous chrs ...
             $leftoutEnrollments = Doctrine_Core::getTable('EnrollmentInfo')->getLeftoutEnrollments($enrollmentObj);
             if (!is_null($leftoutEnrollments)) {
                 foreach ($leftoutEnrollments as $loe) {
                     ##modify existing $enrollment Module
                     $enrollmentObj->setTotalChrs($enrollmentObj->getTotalChrs() + $loe->getTotalChrs());
                     $enrollmentObj->setTotalGradePoints($enrollmentObj->getTotalGradePoints() + $loe->getTotalGradePoints());
                     $enrollmentObj->setTotalRepeatedChrs($enrollmentObj->getTotalRepeatedChrs() + $loe->getTotalRepeatedChrs());
                     $enrollmentObj->setTotalRepeatedGradePoints($enrollmentObj->getTotalRepeatedGradePoints() + $loe->getTotalRepeatedGradePoints());
                 }
             }
             ## previous Enrollment
             $enrollmentObj->setLeftout(TRUE);
             $this->save();
             $enrollmentObj->save();
             break;
         case sfConfig::get('app_transfer_enrollment'):
             $pSection = Doctrine_Core::getTable('ProgramSection')->findOneById($toSectionId);
             $this->setYear($pSection->getYear());
             $this->setSemester($pSection->getSemester());
             $this->setAcademicYear($pSection->getAcademicYear());
             $this->setSectionId($pSection->getId());
             $this->setSemesterAction(sfConfig::get('app_enrolled_semester_action'));
             $this->setEnrollmentAction($enrollmentAction);
             $this->setProgramId($pSection->getProgramId());
             $this->setStudentId($studentId);
             $this->save();
             break;
         case sfConfig::get('app_clearance_enrollment'):
             $this->setEnrollmentAction($enrollmentAction);
             $this->setLeftout(1);
             foreach ($enrollmentObj->getRegistrations() as $registration) {
                 foreach ($registration->getStudentCourseGrades() as $scg) {
                     $courseChr = $scg->getCourse()->getCreditHoure();
                     $courseGradeValue = $scg->getGrade()->getValue();
                 }
             }
             $this->setTotalRepeatedChrs($courseChr);
             $this->setTotalRepeatedGradePoints($courseChr * $courseGradeValue);
             $this->setSemesterAction(sfConfig::get('app_enrolled_semester_action'));
             $this->setStudentId($enrollmentObj->getStudentId());
             $this->setProgramId($enrollmentObj->getProgramId());
             ## student is enrolled to his/her Program
             $this->setSectionId($toSectionId);
             ## but this time student is enrolled to a different section for one course
             $this->setAcademicYear($toAcademicYear);
             $this->setYear($toYear);
             $this->setSemester($toSemester);
             break;
         case sfConfig::get('app_add_enrollment'):
             break;
     }
 }