public function configure() { ## WIDGETS ################### $this->widgetSchema['date_of_birth'] = new sfWidgetFormDate(array('can_be_empty' => true, 'years' => FormChoices::getYearsForDateOfBirth())); $this->widgetSchema['sex'] = new sfWidgetFormChoice(array('choices' => FormChoices::getGenderChoices(), 'expanded' => true)); $this->widgetSchema['admission_year'] = new sfWidgetFormChoice(array('choices' => FormChoices::getAdmissionYearChoices())); $this->widgetSchema['email'] = new sfWidgetFormInputText(); ## VALIDATORS ## $this->validatorSchema['name'] = new sfValidatorRegex(array('pattern' => '/^[a-zA-Z\\s]{2,}$/'), array('invalid' => 'Name is invalid, Enter Any character in the range a-z or A-Z, spaces and minimum two characters')); $this->validatorSchema['fathers_name'] = new sfValidatorRegex(array('pattern' => '/^[a-zA-Z\\s]{2,}$/'), array('invalid' => 'Father name is invalid, Enter Any character in the range a-z or A-Z, spaces and minimum two characters')); $this->validatorSchema['grandfathers_name'] = new sfValidatorRegex(array('pattern' => '/^[a-zA-Z\\s]{2,}$/', 'required' => false), array('invalid' => 'Grand Father name is invalid, Enter Any character in the range a-z or A-Z, spaces and minimum two characters')); $this->setValidatorSchema['date_of_birth'] = new sfValidatorDate(); $this->validatorSchema['sex'] = new sfValidatorChoice(array('choices' => array_keys(FormChoices::getGenderChoices()), 'required' => true)); $this->validatorSchema['admission_year'] = new sfValidatorChoice(array('choices' => array_keys(FormChoices::getAdmissionYearChoices()), 'required' => true)); $this->setValidatorSchema['email'] = new sfValidatorEmail(); $this->validatorSchema['nationality'] = new sfValidatorRegex(array('pattern' => '/^[a-zA-Z\\s]{2,}$/', 'required' => false), array('invalid' => 'Nationlity is invalid, Enter Any character in the range a-z or A-Z, spaces and minimum two characters')); $this->validatorSchema['birth_location'] = new sfValidatorRegex(array('pattern' => '/^[a-zA-Z\\s]{2,}$/', 'required' => false), array('invalid' => 'Birth location is invalid, Enter Any character in the range a-z or A-Z, spaces and minimum two characters')); $this->validatorSchema['residence_city'] = new sfValidatorRegex(array('pattern' => '/^[a-zA-Z\\s]{2,}$/', 'required' => false), array('invalid' => 'Residence city is invalid, Enter Any character in the range a-z or A-Z, spaces and minimum two characters')); $this->validatorSchema['residence_woreda'] = new sfValidatorRegex(array('pattern' => '/^[a-zA-Z\\s]{2,}$/', 'required' => false), array('invalid' => 'Woreda is invalid, Enter Any character in the range a-z or A-Z, spaces and minimum two characters')); $this->validatorSchema['ethnicity'] = new sfValidatorRegex(array('pattern' => '/^[a-zA-Z\\s]{2,}$/', 'required' => false), array('invalid' => 'Ethnicity is invalid, Enter Any character in the range a-z or A-Z, spaces and minimum two characters')); $this->validatorSchema['email'] = new sfValidatorEmail(array('required' => false)); $this->validatorSchema['telephone'] = new sfValidatorRegex(array('pattern' => '/\\+[0-9]{6,}/', 'required' => false)); ## PREVENT REPETITION IN REGISTRATION $this->validatorSchema->setPostValidator(new sfValidatorDoctrineUnique(array('model' => 'Student', 'column' => array('first_name', 'middle_name', 'last_name', 'date_of_birth')), array('invalid' => 'This student is already registered ! ! '))); $this->widgetSchema->setLabels(array('name' => 'Name *', 'fathers_name' => 'Fathers Name *', 'grandfathers_name' => 'Grandfathers Name *', 'mother_name' => 'Mother Name *', 'date_of_birth' => 'Date of Birth *', 'admission_year' => 'Admission Year *', 'nationality' => 'Nationality *', 'sex' => 'Sex *')); ## Unset some values not needed in the process unset($this['created_at'], $this['updated_at'], $this['photo'], $this['student_uid']); if (!is_null($this->sectionId)) { $sectionDetail = Doctrine_Core::getTable('ProgramSection')->findOneById($this->sectionId); $studentCenter = new StudentCenter(); $studentCenter->setCenterId($sectionDetail->getCenterId()); $studentCenter->Student = $this->getObject(); $studentCenterForm = new FrontendStudentCenterForm($studentCenter); $this->embedForm('studentcenter', $studentCenterForm); $enrollmentInfoObj = new EnrollmentInfo(); $enrollmentInfoObj->setProgramId($sectionDetail->getProgramId()); $enrollmentInfoObj->setAcademicYear($sectionDetail->getAcademicYear()); $enrollmentInfoObj->Student = $this->getObject(); $enrollmentForm = new FrontendEnrollmentInfoForm($enrollmentInfoObj, $this->departmentId); $this->embedForm('studentEnrollment', $enrollmentForm); } else { ## Embedd StudentCenterForm $studentCenter = new StudentCenter(); $studentCenter->Student = $this->getObject(); $studentCenterForm = new StudentCenterForm($studentCenter); $this->embedForm('studentcenter', $studentCenterForm); ## Embed EnrollmentInfoForm, some are to be saved to EnrollmentInfo Table $enrollmentInfoObj = new EnrollmentInfo(); $enrollmentInfoObj->Student = $this->getObject(); $enrollmentForm = new EnrollmentInfoForm($enrollmentInfoObj, $this->departmentId); $this->embedForm('studentEnrollment', $enrollmentForm); ## Embed EnrollmentInfoForm, some are to be saved to EnrollmentInfo Table $enrollmentInfoObj = new EnrollmentInfo(); $enrollmentInfoObj->Student = $this->getObject(); $enrollmentForm = new EnrollmentInfoForm($enrollmentInfoObj, $this->departmentId); $this->embedForm('studentEnrollment', $enrollmentForm); } }
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; } }