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(StudentMedicalPeer::ID, $pks, Criteria::IN); $objs = StudentMedicalPeer::doSelect($criteria, $con); } return $objs; }
public function executeSave() { $counsel_id = $this->getRequestParameter('counseling_id'); $counseling = CounselingPeer::retrieveByPK($counsel_id); $this->forward404Unless($counseling); $this->counseling = $counseling; $accal_id = $this->getRequestParameter('accal_id'); $academic_calendar = AcademicCalendarPeer::retrieveByPK($accal_id); $this->forward404Unless($academic_calendar); $this->academic_calendar = $academic_calendar; $scores = $this->getRequestParameter('score'); foreach ($scores as $k => $score) { if ($score != null) { if ($score != '-') { $ids = split('_', $k); ## $ids[0] = Student Id ## $ids[1] = Spec Id $c = new Criteria(); $c->add(StudentMedicalPeer::ACADEMIC_CALENDAR_ID, $academic_calendar->getId()); $c->add(StudentMedicalPeer::CLASS_GROUP_ID, $counseling->getClassGroupId()); $c->add(StudentMedicalPeer::STUDENT_ID, $ids[0]); $student_medical = StudentMedicalPeer::doSelectOne($c); if ($student_medical == null) { $student_medical = new StudentMedical(); } ## Height if ($ids[1] == 1) { $student_medical->setHeight($score); } elseif ($ids[1] == 2) { $student_medical->setWeight($score); } elseif ($ids[1] == 3) { $student_medical->setListening($score); } elseif ($ids[1] == 4) { $student_medical->setVisual($score); } elseif ($ids[1] == 5) { $student_medical->setDental($score); } $student_medical->setStudentId($ids[0]); $student_medical->setClassGroupId($counseling->getClassGroupId()); $student_medical->setAcademicCalendarId($academic_calendar->getId()); $student_medical->save(); } else { $ids = split('_', $k); ## $ids[0] = Student Id ## $ids[1] = Spec Id $c = new Criteria(); $c->add(StudentMedicalPeer::ACADEMIC_CALENDAR_ID, $academic_calendar->getId()); $c->add(StudentMedicalPeer::CLASS_GROUP_ID, $counseling->getClassGroupId()); $c->add(StudentMedicalPeer::STUDENT_ID, $ids[0]); $student_medical = StudentMedicalPeer::doSelectOne($c); if ($student_medical != null) { $student_medical->delete(); } } } } return $this->redirect('counseling_sd/listPhysical?accal_id=' . $academic_calendar->getId() . '&counseling_id=' . $counseling->getId()); }
public function getStudentMedicalsJoinAcademicCalendar($criteria = null, $con = null) { include_once 'lib/model/om/BaseStudentMedicalPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collStudentMedicals === null) { if ($this->isNew()) { $this->collStudentMedicals = array(); } else { $criteria->add(StudentMedicalPeer::STUDENT_HEALTH_ID, $this->getId()); $this->collStudentMedicals = StudentMedicalPeer::doSelectJoinAcademicCalendar($criteria, $con); } } else { $criteria->add(StudentMedicalPeer::STUDENT_HEALTH_ID, $this->getId()); if (!isset($this->lastStudentMedicalCriteria) || !$this->lastStudentMedicalCriteria->equals($criteria)) { $this->collStudentMedicals = StudentMedicalPeer::doSelectJoinAcademicCalendar($criteria, $con); } } $this->lastStudentMedicalCriteria = $criteria; return $this->collStudentMedicals; }
public function filterMedical($c, $filters) { $filters_key = array_keys($filters); foreach ($filters_key as $key) { $value = $filters[$key]; if ($value == '' || $value == null) { continue; } $column = StudentMedicalPeer::getTableMap()->getColumn($key); $name = $column->getFullyQualifiedName(); $creoleType = $column->getCreoleType(); if ($creoleType == CreoleTypes::TIMESTAMP) { $from = $value['from']; $to = $value['to']; if ($from != '' && $from != null) { $c->add($name, $from, Criteria::GREATER_EQUAL); } if ($to != '' && $to != null) { $c->add($name, $to, Criteria::LESS_EQUAL); } } else { if ($creoleType == CreoleTypes::INTEGER) { if ($name == StudentPeer::CLASS_GROUP_ID) { $cg = ClassGroupPeer::retrieveByPK($value); $c->add($name, $cg->getChildRecurs(), Criteria::IN); } else { $c->add($name, $value, Criteria::EQUAL); } } else { if ($creoleType == CreoleTypes::VARCHAR || $creoleType == CreoleTypes::CHAR) { $c->add($name, "%{$value}%", Criteria::LIKE); } } } } }
public function executeDelete() { $student_medical = StudentMedicalPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($student_medical); $ref_error = 0; foreach ($student_medical->getRefCountMethods() as $ref) { $method = "count" . $ref['affix']; $count = $student_medical->{$method}(); if ($count > 0) { ++$ref_error; $this->getRequest()->setError('student_medical/delete/' . sfInflector::camelize($ref['table']), $count); } } if ($ref_error > 0) { $this->getRequest()->setError('student_medical/delete?student_id=' . $student_medical->getStudentId(), '_ERR_DELETE_ (' . $student_medical->toString() . ' - id:' . $student_medical->getId() . ')'); } else { $student_medical->delete(); } return $this->forward('student_medical', 'list'); }
public static function getMedicalStudent($studentAccal) { $c = new Criteria(); $c->add(StudentMedicalPeer::STUDENT_ID, $studentAccal->getStudentId(), Criteria::EQUAL); $c->add(StudentMedicalPeer::ACADEMIC_CALENDAR_ID, $studentAccal->getAcademicCalendarId(), Criteria::EQUAL); return StudentMedicalPeer::doSelectOne($c); }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = StudentMedicalPeer::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->setIllnessId($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setClassGroupId($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setAcademicCalendarId($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setLength($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setDescription($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setHeight($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setWeight($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setDateIn($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setVisual($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setListening($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setDental($arr[$keys[12]]); } }