public function executeSiblingsPost() { $this->getEnquirer(); if (!$this->filterUser(true)) { $this->jsonwrapper->print_json(array('success' => false, 'code' => 'security', 'message' => 'You must login to access this url.')); } $applicant = $this->pmbTools->getApplicant($this->user); if (!$applicant) { $this->jsonwrapper->show_json_error('Permission', 'You dont have permission to access this page'); } if ($applicant->getStatus() != StudentDetail::GRADUATE) { $this->jsonwrapper->show_json_error('Permission', 'You dont have permission to access this page2'); } $param = $this->getAllRequestParameter(); $valid = true; $error_message = array(); /* Sibling Name */ if (empty($param['name'])) { $param['name'] = ''; } /* Sibling Clid Number */ if (empty($param['child_number'])) { $param['child_number'] = ''; } /* Grade */ if (empty($param['grade'])) { $param['grade'] = ''; } /* status */ if (empty($param['status'])) { $param['status'] = ''; } /* year_attended */ if (empty($param['year_attended'])) { $param['year_attended'] = ''; } if (!$valid) { $this->jsonwrapper->print_json(array('success' => false, 'code' => 'notvalid', 'message' => 'data anda belum lengkap', 'error' => $error_message)); } if (empty($param['id'])) { $sibling = new TestApplicantSibling(); } else { $c = new Criteria(); $c->add(TestApplicantSiblingPeer::ID, $param['id'], Criteria::EQUAL); $c->add(TestApplicantSiblingPeer::TEST_APPLICANT_ID, $applicant->getId(), Criteria::EQUAL); $sibling = TestApplicantSiblingPeer::doSelectOne($c); if (!$sibling) { $this->jsonwrapper->show_json_error('notfound', 'Sibling not found'); } } $connection = Propel::getConnection('propel'); $connection->begin(); $sibling->setTestApplicantId($applicant->getId()); $sibling->setName($param['name']); $sibling->setChildrenNo($param['child_number']); $sibling->setClassName($param['grade']); $sibling->setTypeOfSibling($param['status']); $sibling->setDepartmentName($param['year_attended']); try { $sibling->save(); } catch (Exception $e) { $connection->rollback(); $this->jsonwrapper->print_json(array('success' => false, 'code' => 'fail', 'message' => 'Error while save the data, please try again later.', 'message2' => 'Error save education history - education history')); } $connection->commit(); $data = $sibling->toArray(); /* Hehehe */ $this->jsonwrapper->print_json(array('success' => true, 'code' => 'success', 'message' => 'Data successfully saved', 'data' => $data, 'href' => $this->pmbTools->pmbUrl('data/educationhistory'))); /* ---- */ }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = TestApplicantSiblingPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setTestApplicantId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setStudentRelated($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setName($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setSex($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setDepartmentId($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setClassGroupId($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setDepartmentName($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setClassName($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setNote($arr[$keys[9]]); } }
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(TestApplicantSiblingPeer::ID, $pks, Criteria::IN); $objs = TestApplicantSiblingPeer::doSelect($criteria, $con); } return $objs; }
public function executeRegistrationReceipt() { $ta_id = $this->getRequestParameter('id'); $ta = TestApplicantPeer::retrieveByPK($ta_id); $this->forward404Unless($ta); $this->ta = $ta; $this->ta_detail = $ta->getTestApplicantDetail(); $this->enquirer = $ta->getTestApplicantEnquirer(); $this->filename = $this->getActionName() . '_' . $ta->getName(); $cw = new Criteria(); $cw->add(DepartmentDetailPeer::DEPARTMENT_ID, $ta->getDepartment1()); $this->department_detail = DepartmentDetailPeer::doSelectOne($cw); $cm = new Criteria(); $cm->add(TestApplicantParentsPeer::TEST_APPLICANT_ID, $ta->getId()); $cm->add(TestApplicantParentsPeer::RELATION, StudentParents::RELATION_FATHER); $father = TestApplicantParentsPeer::doSelectOne($cm); if ($father == null) { $father = new TestApplicantParents(); } $cl = new Criteria(); $cl->add(TestApplicantParentsPeer::TEST_APPLICANT_ID, $ta->getId()); $cl->add(TestApplicantParentsPeer::RELATION, StudentParents::RELATION_MOTHER); $mother = TestApplicantParentsPeer::doSelectOne($cl); if ($mother == null) { $mother = new TestApplicantParents(); } $ck = new Criteria(); $ck->add(TestApplicantParentsPeer::TEST_APPLICANT_ID, $ta->getId()); $ck->add(TestApplicantParentsPeer::RELATION, StudentParents::RELATION_GUARDIAN); $guardian = TestApplicantParentsPeer::doSelectOne($ck); if ($guardian == null) { $guardian = new TestApplicantParents(); } $ct = new Criteria(); $ct->add(TestApplicantSiblingPeer::TEST_APPLICANT_ID, $ta->getId()); $siblings = TestApplicantSiblingPeer::doSelect($ct); $cti = new Criteria(); $cti->add(TestApplicantSiblingPeer::TEST_APPLICANT_ID, $ta->getId()); $cti->add(TestApplicantSiblingPeer::TYPE_OF_SIBLING, TestApplicantSibling::CURRENTLY); $current_sibling = TestApplicantSiblingPeer::doSelectOne($cti); if ($current_sibling == null) { $current_sibling = new TestApplicantSibling(); } $this->current_sibling = $current_sibling; $cte = new Criteria(); $cte->add(TestApplicantSiblingPeer::TEST_APPLICANT_ID, $ta->getId()); $cte->add(TestApplicantSiblingPeer::TYPE_OF_SIBLING, TestApplicantSibling::APPLIED); $applied_sibling = TestApplicantSiblingPeer::doSelectOne($cte); if ($applied_sibling == null) { $applied_sibling = new TestApplicantSibling(); } $this->applied_sibling = $applied_sibling; $ctr = new Criteria(); $ctr->add(TestApplicantSiblingPeer::TEST_APPLICANT_ID, $ta->getId()); $ctr->add(TestApplicantSiblingPeer::TYPE_OF_SIBLING, TestApplicantSibling::GRADUATED); $graduated_sibling = TestApplicantSiblingPeer::doSelectOne($ctr); if ($graduated_sibling == null) { $graduated_sibling = new TestApplicantSibling(); } $this->graduated_sibling = $graduated_sibling; $cmi = new Criteria(); $cmi->add(TestApplicantMedicalPeer::TEST_APPLICANT_ID, $ta->getId()); $medical = TestApplicantMedicalPeer::doSelectOne($cmi); if ($medical == null) { $medical = new TestApplicantMedical(); } $cdi = new Criteria(); $cdi->add(TestApplicantEducationsPeer::TEST_APPLICANT_ID, $ta->getId()); $this->ta_educations = TestApplicantEducationsPeer::doSelect($cdi); $this->ta_edu_counts = TestApplicantEducationsPeer::doCount($cdi); $cm = new Criteria(); $cm->add(TestApplicantParentsPeer::TEST_APPLICANT_ID, $ta->getId()); $cm->add(TestApplicantParentsPeer::RELATION, StudentParents::RELATION_GUARDIAN); $primary_contact = TestApplicantParentsPeer::doSelectOne($cm); if ($primary_contact == null) { $primary_contact = new TestApplicantParents(); } $cmi = new Criteria(); $cmi->add(TestApplicantParentsPeer::TEST_APPLICANT_ID, $ta->getId()); $cmi->add(TestApplicantParentsPeer::RELATION, StudentParents::RELATION_GUARDIAN2); $secondary_contact = TestApplicantParentsPeer::doSelectOne($cmi); if ($secondary_contact == null) { $secondary_contact = new TestApplicantParents(); } $cmt = new Criteria(); $cmt->add(TestApplicantParentsPeer::TEST_APPLICANT_ID, $ta->getId()); $cmt->add(TestApplicantParentsPeer::RELATION, StudentParents::RELATION_GUARDIAN3); $local_contact = TestApplicantParentsPeer::doSelectOne($cmt); if ($local_contact == null) { $local_contact = new TestApplicantParents(); } $this->primary_contact = $primary_contact; $this->secondary_contact = $secondary_contact; $this->local_contact = $local_contact; if ($ta->getStatus() == StudentDetail::BUY) { $this->setTemplate('enquiryReceipt'); } else { $this->setTemplate('registrationReceipt'); } $c = new Criteria(); $c->add(TestApplSchedPeer::TEST_APPLICANT_ID, $ta->getId()); $c->add(AcademicCalendarPeer::DEPARTMENT_ID, $ta->getDepartment1()); $c->addJoin(AcademicCalendarPeer::ID, RegPeriodPeer::ACADEMIC_CALENDAR_ID); $c->addJoin(RegPeriodPeer::ID, RegTestPeriodPeer::REG_PERIOD_ID); $c->addJoin(RegTestPeriodPeer::ID, TestSchedulePeer::REG_TEST_PERIOD_ID); $c->addJoin(TestSchedulePeer::ID, TestApplSchedPeer::TEST_SCHEDULE_ID); $appl_sched1 = TestApplSchedPeer::doSelectJoinTestSchedule($c); $this->sched1 = $appl_sched1; $this->siblings = $siblings; $this->father = $father; $this->mother = $mother; $this->guardian = $guardian; $this->medical = $medical; $this->setLayout(false); $this->papersize = 'a4'; $this->orientation = 'portrait'; $this->setViewClass('sfDomPDF'); }
public function getTestApplicantSiblingsJoinStudent($criteria = null, $con = null) { include_once 'lib/model/om/BaseTestApplicantSiblingPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collTestApplicantSiblings === null) { if ($this->isNew()) { $this->collTestApplicantSiblings = array(); } else { $criteria->add(TestApplicantSiblingPeer::CLASS_GROUP_ID, $this->getId()); $this->collTestApplicantSiblings = TestApplicantSiblingPeer::doSelectJoinStudent($criteria, $con); } } else { $criteria->add(TestApplicantSiblingPeer::CLASS_GROUP_ID, $this->getId()); if (!isset($this->lastTestApplicantSiblingCriteria) || !$this->lastTestApplicantSiblingCriteria->equals($criteria)) { $this->collTestApplicantSiblings = TestApplicantSiblingPeer::doSelectJoinStudent($criteria, $con); } } $this->lastTestApplicantSiblingCriteria = $criteria; return $this->collTestApplicantSiblings; }