Example #1
0
 public function executeDelete()
 {
     $student_leave = StudentLeavePeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($student_leave);
     $student = StudentPeer::retrieveByPK($this->getRequestParameter('student_id'));
     $this->forward404Unless($student);
     $this->student = $student;
     $ref_error = 0;
     foreach ($student_leave->getRefCountMethods() as $ref) {
         $method = "count" . $ref['affix'];
         $count = $student_leave->{$method}();
         if ($count > 0) {
             ++$ref_error;
             $this->getRequest()->setError('student_leave_s/delete/' . sfInflector::camelize($ref['table']), $count);
         }
     }
     if ($ref_error > 0) {
         $this->getRequest()->setError('student_leave_s/delete', '_ERR_DELETE_ (' . $student_leave->toString() . ' - id:' . $student_leave->getId() . ')');
     } else {
         $student_leave->delete();
     }
     $this->getRequest()->setParameter('student_id', $student->getId());
     return $this->forward('student_leave', 'list');
 }
Example #2
0
 public function getStudentLeavesJoinStudent($criteria = null, $con = null)
 {
     include_once 'lib/model/om/BaseStudentLeavePeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collStudentLeaves === null) {
         if ($this->isNew()) {
             $this->collStudentLeaves = array();
         } else {
             $criteria->add(StudentLeavePeer::ACADEMIC_CALENDAR_ID, $this->getId());
             $this->collStudentLeaves = StudentLeavePeer::doSelectJoinStudent($criteria, $con);
         }
     } else {
         $criteria->add(StudentLeavePeer::ACADEMIC_CALENDAR_ID, $this->getId());
         if (!isset($this->lastStudentLeaveCriteria) || !$this->lastStudentLeaveCriteria->equals($criteria)) {
             $this->collStudentLeaves = StudentLeavePeer::doSelectJoinStudent($criteria, $con);
         }
     }
     $this->lastStudentLeaveCriteria = $criteria;
     return $this->collStudentLeaves;
 }
Example #3
0
 public function executeUpdateStatus()
 {
     $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');
     $student = StudentPeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($student);
     $student->setStatus($this->getRequestParameter('status'));
     $student->save();
     $c = new Criteria();
     $c->add(StudentLeavePeer::STUDENT_ID, $student->getId());
     $student_leave = StudentLeavePeer::doSelectOne($c);
     if ($student_leave == null) {
         $student_leave = new StudentLeave();
     }
     $student_leave->setAcademicCalendarId($this->getRequestParameter('academic_calendar_id'));
     $student_leave->setStatus($this->getRequestParameter('status'));
     $student_leave->setYear($this->getRequestParameter('year'));
     $student_leave->setEndDate($this->getRequestParameter('end_date'));
     $student_leave->setDetail($this->getRequestParameter('detail'));
     $student_leave->setNextSchool($this->getRequestParameter('next_school'));
     $student_leave->setNextLevel($this->getRequestParameter('next_level'));
     $student_leave->save();
     if ($student->getStatus() == Student::STATUS_OVERDUE) {
         $c = new Criteria();
         $c->add(StudentAccalPeer::STUDENT_ID, $student->getId());
         $c->add(StudentAccalPeer::CLASS_GROUP_ID, $student->getClassGroupId());
         $c->add(StudentAccalPeer::ACADEMIC_CALENDAR_ID, $student_leave->getAcademicCalendarId());
         $student_accal = StudentAccalPeer::doSelectOne($c);
         if ($student_accal) {
             $student_accal->setStatus(Student::STATUS_OVERDUE);
             $student_accal->save();
             /**
             				$student_accal->delete();
             				**/
         }
     }
     return $this->redirect('scholar/list');
 }
Example #4
0
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(StudentLeavePeer::ID, $pks, Criteria::IN);
         $objs = StudentLeavePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Example #5
0
 public function executePaymentSlip()
 {
     $stu_leave = StudentLeavePeer::retrieveByPK($this->getRequestParameter('id'));
     $stu = $stu_leave->getStudent();
     $job = JobPeer::retrieveByCode($this->getModuleName());
     $academic_process = $job->getAcademicProcess();
     $this->forward404Unless($stu && $job && $academic_process);
     $c = new Criteria();
     $c->add(AcademicProcessPeer::CODE, $academic_process->getCode());
     $c->addJoin(AcademicProcessPeer::ID, AcademicCostPeer::ACADEMIC_PROCESS_ID);
     $c->addJoin(AcademicCostPeer::ACADEMIC_CALENDAR_ID, StudentLeavePeer::ACADEMIC_CALENDAR_ID);
     $c->add(StudentLeavePeer::STATUS, StudentLeave::STATUS_APPROVED);
     $c->add(StudentLeavePeer::STUDENT_ID, $stu->getId());
     $costs = AcademicCostPeer::doSelect($c);
     $total_cost = 0;
     foreach ($costs as $c) {
         $total_cost += $c->getAmount();
     }
     $this->stu = $stu;
     $this->costs = $costs;
     $this->total_cost = $total_cost;
     $this->setViewClass('sfDomPDF');
 }
Example #6
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = StudentLeavePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setStudentId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setAcademicCalendarId($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setStatus($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setYear($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setEndDate($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setNextSchool($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setNextLevel($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setDetail($arr[$keys[8]]);
     }
 }