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 executeNew(sfWebRequest $request) { $programSectionId = $request->getParameter('sectionId'); $this->sectionDetail = Doctrine_Core::getTable('ProgramSection')->findOneById($programSectionId); $this->forward404Unless($this->sectionDetail); ## New Form $this->studentForm = new FrontendStudentForm(); if ($request->isMethod('POST')) { $this->studentForm->bind($request->getParameter('studentform')); if ($this->studentForm->isValid()) { $formData = $this->studentForm->getValues(); $student = new Student(); $name = $formData['name']; $fathersName = $formData['fathers_name']; $grandfathersName = $formData['grandfathers_name']; $motherName = $formData['mother_name']; $dateOfBirth = $formData['date_of_birth']; $sex = $formData['sex']; $nationality = $formData['nationality']; $birthLocation = $formData['birth_location']; $residenceCity = $formData['residence_city']; $residenceWoreda = $formData['residence_woreda']; $residenceKebele = $formData['residence_kebele']; $residenceHourseNumber = $formData['residence_house_number']; $ethnicity = $formData['ethnicity']; $telephone = $formData['telephone']; $email = $formData['email']; $student->setName($name); $student->setFathersName($fathersName); $student->setGrandfathersName($grandfathersName); $student->setMotherName($motherName); $student->setDateOfBirth($dateOfBirth); $student->setSex($sex); $student->setAdmissionYear(date('Y')); $student->setNationality($nationality); $student->setBirthLocation($birthLocation); $student->setResidenceCity($residenceCity); $student->setResidenceWoreda($residenceWoreda); $student->setResidenceKebele($residenceKebele); $student->setResidenceHouseNumber($residenceHourseNumber); $student->setEthinicity($ethnicity); $student->setTelephone($telephone); $student->setEmail($email); $student->save(); $enrollment = new EnrollmentInfo(); $enrollment->makeEnrollment(null, null, null, null, $programSectionId, sfConfig::get('app_transfer_enrollment'), $student->getId()); $auditlog = new AuditLog(); $auditlog->addNewLogInfo($this->getUser()->getAttribute('userId'), 'Performed Enrollment of Transfered Student'); $this->getUser()->setFlash('notice', 'Transfer Enrollment Was Successful '); $this->redirect('transfer/sectiondetail/?id=' . $programSectionId); } else { $this->getUser()->setFlash('error', 'Error with Transfer Enrollment Form'); } } }
public function executeDoPromotion(sfWebRequest $request) { ## find section detail $studentIdsArray = array(); $this->programSectionId = $request->getParameter('id'); $this->sectionDetail = Doctrine_Core::getTable('ProgramSection')->findOneById($this->programSectionId); $this->forward404Unless($this->sectionDetail); foreach ($this->sectionDetail->getEnrollmentInfos() as $enrollmentInfo) { if (!$enrollmentInfo->getLeftout()) { $studentIdsArray[] = $enrollmentInfo->getStudentId(); } } ##GET ALL students, in given sectionId, year and semester, with all enrollmentInfos $this->students = Doctrine_Core::getTable('Student')->getStudents($studentIdsArray, $this->sectionDetail); ## Get promotion information if available for existing class, $this->promotionInfo = Doctrine_Core::getTable('PromotionSetting')->getOnePromotionSetting($this->sectionDetail->getProgramId(), $this->sectionDetail->getYear(), $this->sectionDetail->getSemester()); $this->forward404Unless($this->promotionInfo); //$this->enrollmentsToCreate[] = Array(); ## Create section, $this->sectionToCreate = new ProgramSection(); $this->sectionToCreate->setProgramId($this->sectionDetail->getProgramId()); $this->sectionToCreate->setCenterId($this->sectionDetail->getCenterId()); $this->sectionToCreate->setAcademicCalendarId($this->sectionDetail->getAcademicCalendarId()); $academicYearToSave = ProgramSectionActions::getNextACYearForSection($this->promotionInfo->getCurrentYear(), $this->promotionInfo->getCurrentSemester(), $this->sectionDetail->getAcademicYear()); $this->sectionToCreate->setAcademicYear($academicYearToSave); $this->sectionToCreate->setYear($this->promotionInfo->getToYear()); $this->sectionToCreate->setSemester($this->promotionInfo->getToSemester()); $this->sectionToCreate->setSectionNumber($this->sectionDetail->getSectionNumber()); $this->sectionToCreate->setIsActivated(TRUE); $this->sectionToCreate->save(); $this->sectionDetail->setIsPromoted(TRUE); $this->sectionDetail->setIsActivated(FALSE); $this->sectionDetail->save(); foreach ($this->students as $student) { foreach ($student->getEnrollmentInfos() as $enrollmentObj) { if (!$enrollmentObj->getLeftout()) { $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()); } } } } } foreach ($this->students as $student) { foreach ($student->getEnrollmentInfos() as $enrollment) { if (!$enrollment->getLeftout()) { ## get student status with given ENROLLMENT, $status = Statuses::getStudentStatus($student->getEnrollmentInfos(), $this->sectionDetail->getYear(), $this->sectionDetail->getSemester()); if ($status == 'PASS' || $status == 'WARNING') { $enrollmentsToCreate = new EnrollmentInfo(); $toAcademicYear = ProgramSectionActions::getNextACYearForSection($this->promotionInfo->getCurrentYear(), $this->promotionInfo->getCurrentSemester(), $this->sectionDetail->getAcademicYear()); if ($status == 'PASS') { $enrollment->setAcademicStatus(sfConfig::get('app_passing_status')); } if ($status == 'WARNING') { $enrollment->setAcademicStatus(sfConfig::get('app_warning_status')); } $enrollmentsToCreate->makeEnrollment($enrollment, $toAcademicYear, $this->promotionInfo->getToYear(), $this->promotionInfo->getToSemester(), $this->sectionToCreate->getId(), sfConfig::get('app_promotion_enrollment')); } else { if ($status == 'AD') { $enrollment->setAcademicStatus(sfConfig::get('app_ad_status')); } if ($status == 'ADR') { $enrollment->setAcademicStatus(sfConfig::get('app_adr_status')); $enrollment->setSemesterAction(sfConfig::get('app_dismissed_semester_action')); $enrollment->setLeftout(TRUE); } if ($status == 'WITHDRAWAL') { $enrollment->setAcademicStatus(sfConfig::get('app_withdrawal_status')); } if ($status == 'DROPOUT') { $enrollment->setAcademicStatus(sfConfig::get('app_dropout_status')); } $enrollment->setSemesterAction(sfConfig::get('app_dismissed_semester_action')); $enrollment->save(); } } } } $this->getUser()->setFlash('notice', 'Promotion was successfull'); $this->redirect('programsection/index'); }
public function executeAdd(sfWebRequest $request) { $this->failedCoursesIdNamePairArray = array(); $failedCourseIdsArray = array(); $this->programSectionsIdNamePairArray = array(); $this->coursePoolsArray = array(); $this->showFailedCourses = FALSE; $this->showClearanceEnrollmentForm = FALSE; $this->showAddEnrollmentForm = FALSE; $this->programSectionId = $request->getParameter('sectionId'); ##SECTION $this->studentId = $request->getParameter('studentId'); ##STUDENT $this->courseId = $request->getParameter('courseId'); ##COURSE BEING ADDED ##1 $this->sectionDetail = Doctrine_Core::getTable('ProgramSection')->findOneById($this->programSectionId); ##GET SECTION $this->forward404Unless($this->programSectionId); ##2 && 3 $this->student = Doctrine_Core::getTable('Student')->findOneById($this->studentId)->getWithActiveCourses(); $this->forward404Unless($this->student); ##4 $this->courseDetail = Doctrine_Core::getTable('Course')->findOneById($this->courseId); $this->forward404Unless($this->courseDetail); $this->failedCoursesIdNamePairArray[$this->courseDetail->getId()] = $this->courseDetail->getName(); //$this->studentInfo = $this->student->getSectionEnrollmentInfo($this->sectionDetail->getId()); $coursesInPool = Doctrine_Core::getTable('CoursePool')->getCoursesInCoursePool(); if (!is_null($coursesInPool)) { foreach ($coursesInPool as $coursePool) { $this->coursePoolsArray[] = $coursePool->getCourseId(); } } #1. Display Failed courses! foreach ($this->student->getEnrollmentInfos() as $enrollment) { foreach ($enrollment->getRegistrations() as $registration) { foreach ($registration->getStudentCourseGrades() as $scg) { if ($scg->checkIfStudentCourseIsFailed()) { $this->showFailedCourses = TRUE; if (!in_array($scg->getCourseId(), $this->coursePoolsArray)) { $failedCourseIdsArray[] = $scg->getCourseId(); } } } } } if ($this->showFailedCourses) { #Get ProgramSections offering these courses! $departments = Doctrine_Core::getTable('Department')->getAllDepartments(); $this->forward404Unless($departments); foreach ($departments as $department) { if ($department->checkCourseOffering($failedCourseIdsArray, $this->sectionDetail->getId())) { $this->showClearanceEnrollmentForm = TRUE; foreach ($department->getWithActiveProgramSectionCourseOfferings($failedCourseIdsArray, $this->sectionDetail->getId())->getPrograms() as $program) { foreach ($program->getProgramSections() as $programSection) { $section = $programSection->getProgram() . ' at ' . $programSection->getCenter() . ' center, Year-' . $programSection->getYear() . ' Sem-' . $programSection->getSemester(); $this->programSectionsIdNamePairArray[$programSection->getId()] = $section; } } } } } ##Display form if there are available active sections! if ($this->showClearanceEnrollmentForm) { $this->courseAddEnrollmentForm = new FrontendCourseAddEnrollmentForm($this->student->getId(), $this->programSectionsIdNamePairArray, $this->failedCoursesIdNamePairArray, sfConfig::get('app_clearance_enrollment')); } if ($request->isMethod('POST')) { $this->courseAddEnrollmentForm->bind($request->getParameter('courseaddenrollmentform')); if ($this->courseAddEnrollmentForm->isValid()) { $formData = $this->courseAddEnrollmentForm->getValues(); $courseId = $formData['course_id']; $sectionId = $formData['section_id']; $enrollmentAction = $formData['enrollment_action']; $studentId = $formData['student_id']; if ($courseId == '' || $sectionId == '' || $enrollmentAction == '' || $studentId == '') { $this->getUser()->setFlash('error', 'Error with Add Form'); $this->redirect('dropadd/add/?studentId=' . $this->student->getId() . '§ionId=' . $this->sectionDetail->getId()); } ## 1. find enrollment for the course to clear $studentWithEnrollment = Doctrine_Core::getTable('Student')->findOneById($studentId)->getEnrollmentInfoByCourse($courseId); $this->forward404Unless($studentWithEnrollment); foreach ($studentWithEnrollment->getEnrollmentInfos() as $enrollment) { $studentCourseEnrollment = $enrollment; } ## 2. find section to which student is going to enrolled to $newSection = Doctrine_Core::getTable('ProgramSection')->findOneById($sectionId); $this->forward404Unless($newSection); #makeEnrollment $newEnrollment = new EnrollmentInfo(); $newEnrollment->makeEnrollment($studentCourseEnrollment, $this->sectionDetail->getAcademicYear(), $this->sectionDetail->getYear(), $this->sectionDetail->getSemester(), $newSection->getId(), $enrollmentAction); $newEnrollment->save(); ## 2. createCoursePool $coursePool = new CoursePool(); $coursePool->createCoursePool($newEnrollment->getId(), $courseId); $coursePool->save(); ##Do Logging!! $newLog = new AuditLog(); $action = 'User has performed add enrollment for student '; $newLog->addNewLogInfo($this->getUser()->getAttribute('userId'), $action); $this->getUser()->setFlash('notice', 'Add was successful - studentId:' . $studentId . ' courseId:' . $courseId . ' sectionId:' . $sectionId . ' enrollmentAction:' . $enrollmentAction); $this->redirect('dropadd/sectiondetail/?id=' . $this->sectionDetail->getId()); } else { $this->getUser()->setFlash('error', 'Error with Add Form'); } } }
public function executeAdmission(sfWebRequest $request) { $departmentId = $this->getUser()->getAttribute('departmentId'); $this->programs = Doctrine_Core::getTable('Program')->getProgramsByDepartmentId($departmentId); ## Pass Program infomation $this->centers = Doctrine_Core::getTable('Center')->getAllCenters(); $this->years = FormChoices::getYearChoices(); $this->academicYears = FormChoices::getAcademicYear(); $this->semesters = FormChoices::getSemesterChoices(); $departmentId = $this->getUser()->getAttribute('departmentId'); $this->programs = Doctrine_Core::getTable('Program')->getProgramsByDepartmentId($departmentId); $sectionId = $request->getParameter('sectionId'); $this->program_section = Doctrine_Core::getTable('ProgramSection')->findOneById($sectionId); $this->frontendStudentForm = new FrontendStudentForm(); if ($request->isMethod('POST')) { $this->frontendStudentForm->bind($request->getParameter('studentform')); if ($this->frontendStudentForm->isValid()) { $formData = $this->frontendStudentForm->getValues(); $studentUID = $formData['student_uid']; $name = $formData['name']; $fathersName = $formData['fathers_name']; $grandfathersName = $formData['grandfathers_name']; $motherName = $formData['mother_name']; $dateOfBirth = $formData['date_of_birth']; $sex = $formData['sex']; $nationality = $formData['nationality']; $birthLocation = $formData['birth_location']; $residenceCity = $formData['residence_city']; $residenceWoreda = $formData['residence_woreda']; $residenceKebele = $formData['residence_kebele']; $residenceHourseNumber = $formData['residence_house_number']; $ethnicity = $formData['ethnicity']; $telephone = $formData['telephone']; $email = $formData['email']; $this->student = new Student(); $this->student->setStudentUid($studentUID); $this->student->setName($name); $this->student->setFathersName($fathersName); $this->student->setGrandfathersName($grandfathersName); $this->student->setMotherName($motherName); $this->student->setDateOfBirth($dateOfBirth); $this->student->setSex($sex); $this->student->setAdmissionYear(date('Y')); $this->student->setNationality($nationality); $this->student->setBirthLocation($birthLocation); $this->student->setResidenceCity($residenceCity); $this->student->setResidenceWoreda($residenceWoreda); $this->student->setResidenceKebele($residenceKebele); $this->student->setResidenceHouseNumber($residenceHourseNumber); $this->student->setEthinicity($ethnicity); $this->student->setTelephone($telephone); $this->student->setEmail($email); $this->student->save(); $enrollment = new EnrollmentInfo(); ## MAKE ADMISSION ENROLLMENT //makeEnrollment($enrollmentObj, $toAcademicYear, $toYear, $toSemester, $toSectionId, $enrollmentAction, $studentId) $enrollment->makeEnrollment($enrollment, $this->program_section->getAcademicYear(), $this->program_section->getYear(), $this->program_section->getSemester(), null, sfConfig::get('app_admission_enrollment'), $this->student->getId(), $this->program_section); $auditlog = new AuditLog(); $auditlog->addNewLogInfo($this->getUser()->getAttribute('userId'), 'Performed Student Student Admission'); $this->getUser()->setFlash('notice', 'Student Admission Was Successful '); $this->redirect('student/admissionList/?sectionId=' . $sectionId); } else { $this->getUser()->setFlash('error', 'Error With Student Admission Form'); } } }
public function executeReadmitstudent(sfWebRequest $request) { $this->showReadmissionForm = FALSE; $programSectionIdNamePairArray = array(); $programSectionIdNamePairArray[''] = 'Select Program Section'; ## Create form $enrollmentId = $request->getParameter('enrollmentId'); $this->enrollmentDetail = Doctrine_Core::getTable('EnrollmentInfo')->findOneById($enrollmentId); $this->forward404Unless($this->enrollmentDetail); $this->student = $this->enrollmentDetail->getStudent(); ## get sections available $programSections = Doctrine_Core::getTable('ProgramSection')->getActiveProgramSectionsForReadmission($this->enrollmentDetail->getProgramId(), $this->enrollmentDetail->getYear(), $this->enrollmentDetail->getSemester()); if (!is_null($programSections)) { $this->showReadmissionForm = TRUE; foreach ($programSections as $ps) { $programSectionIdNamePairArray[$ps->getId()] = $ps->getProgram() . ' at ' . $ps->getCenter() . ' Year' . $ps->getYear() . ' Semester' . $ps->getSemester() . ', ' . $ps->getAcademicYear(); } } ## the form $this->readmissionForm = new FrontendReadmissionForm($enrollmentId, $programSectionIdNamePairArray); if ($request->isMethod('POST')) { $this->readmissionForm->bind($request->getParameter('readmissionform')); if ($this->readmissionForm->isValid()) { $formData = $this->readmissionForm->getValues(); $sectionId = $formData['section_id']; $enrollmentId = $formData['enrollment_id']; ##ID of either ADR or WITHDRAWAL if ($enrollmentId == '' || $sectionId == '') { $this->getUser()->setFlash('error', 'Error with Add Form'); $this->redirect('readmission/readmitstudent/?enrollmentId=' . $this->enrollmentDetail->getId()); } $auditlog = new AuditLog(); $auditlog->addNewLogInfo($this->getUser()->getAttribute('userId'), 'Performed Student Readmission'); $enrollment = new EnrollmentInfo(); $enrollment->makeEnrollment($this->enrollmentDetail, null, null, null, $sectionId, sfConfig::get('app_readmission_enrollment')); $this->getUser()->setFlash('notice', 'Student Readmission was Successful ' . $enrollmentId . ' ' . $sectionId); $this->redirect('readmission/index'); } else { $this->getUser()->setFlash('error', 'Error with Readmission Form'); } } }