Ejemplo n.º 1
0
 public function addGradCeremony(GradCeremony $l)
 {
     $this->collGradCeremonys[] = $l;
     $l->setAcademicCalendar($this);
 }
Ejemplo n.º 2
0
 public function executeUpdate()
 {
     $i18n = new sfI18N();
     $i18n->initialize($this->getContext());
     $i18n->setCulture($this->getUser()->getCulture());
     $action_i18n = $i18n->globalMessageFormat->format('save as new');
     $action_type = $this->getRequestParameter('action_type');
     if ($action_type == $action_i18n || !$this->getRequestParameter('id')) {
         $comprehensive_exam = new ComprehensiveExam();
     } else {
         $comprehensive_exam = ComprehensiveExamPeer::retrieveByPk($this->getRequestParameter('id'));
         $this->forward404Unless($comprehensive_exam);
     }
     $comprehensive_exam->setId($this->getRequestParameter('id'));
     $comprehensive_exam->setStudentId($this->getRequestParameter('student_id'));
     if ($this->getRequestParameter('exam_date')) {
         $comprehensive_exam->setExamDate($this->getRequestParameter('exam_date'));
     }
     $comprehensive_exam->setStatus($this->getRequestParameter('status'));
     $comprehensive_exam->save();
     $c = new Criteria();
     $c->add(ComprehensiveReviewerPeer::COMPREHENSIVE_EXAM_ID, $comprehensive_exam->getId());
     ComprehensiveReviewerPeer::doDelete($c);
     $reviewers = $this->getRequestParameter('isSelected');
     if ($reviewers) {
         foreach ($reviewers as $id) {
             $cr = new ComprehensiveReviewer();
             $cr->setComprehensiveExam($comprehensive_exam);
             $cr->setEmployeeId($id);
             $cr->save();
         }
     }
     if ($comprehensive_exam->getStatus() == ComprehensiveExam::STATUS_ACTIVE) {
         // add payment journal
         $job = JobPeer::retrieveByCode($this->getModuleName());
         $academic_process = $job->getAcademicProcess();
         $c = new Criteria();
         $c->add(AcademicCostPeer::ACADEMIC_PROCESS_ID, $academic_process->getId());
         $c->add(AcademicCostPeer::ACADEMIC_CALENDAR_ID, $comprehensive_exam->getAcademicCalendarId());
         $costs = AcademicCostPeer::doSelect($c);
         foreach ($costs as $c) {
             $pj = new PaymentJournal();
             $pj->setPayer($comprehensive_exam->getStudent()->getId());
             $pj->setAcademicCost($c);
             $pj->setJob($job);
             $pj->setAmount($c->getAmount());
             $pj->setPaid($c->getAmount());
             $pj->setReceivable(0);
             $pj->setAcademicProcess($academic_process);
             $pj->setPayerType(PaymentJournal::PAYER_TYPE_STUDENT);
             $pj->save();
             $ph = new PaymentHistory();
             $ph->setPaymentJournal($pj);
             $ph->setAmount($pj->getPaid());
             $ph->save();
         }
     } elseif ($comprehensive_exam->getStatus() == ComprehensiveExam::STATUS_PASSED) {
         $s = $comprehensive_exam->getStudent();
         $s->setStatus(Student::STATUS_GRADUATE);
         $s->save();
         $gc = new GradCeremony();
         $gc->setStudent($s);
         $gc->setStatus(GradCeremony::STATUS_UNLISTED);
         $gc->setAcademicCalendarId($comprehensive_exam->getAcademicCalendarId());
         $gc->save();
     }
     return $this->redirect('comprehensive_exam/list');
 }