public function executePrevschoolPost() { $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 page'); } $param = $this->getAllRequestParameter(); $valid = true; $error_message = array(); /* School Name */ if (empty($param['schoolname'])) { $error_message[] = array('field' => 'schoolname', 'message' => 'Please enter School Name'); $valid = false; } /* Academic Year */ if (empty($param['acyear'])) { $error_message[] = array('field' => 'acyear', 'message' => 'Please enter Academic Year'); $valid = false; } /* Grade */ if (empty($param['grade'])) { $error_message[] = array('field' => 'grade', 'message' => 'Please enter Grade'); $valid = false; } /* Language of Instruction */ if (empty($param['lang'])) { $error_message[] = array('field' => 'lang', 'message' => 'Please enter Language of Instruction'); $valid = false; } if (!$valid) { $this->jsonwrapper->print_json(array('success' => false, 'code' => 'notvalid', 'message' => 'data anda belum lengkap', 'error' => $error_message)); } if (empty($param['id'])) { $education = new TestApplicantEducations(); } else { $c = new Criteria(); $c->add(TestApplicantEducationsPeer::ID, $param['id'], Criteria::EQUAL); $c->add(TestApplicantEducationsPeer::TEST_APPLICANT_ID, $applicant->getId(), Criteria::EQUAL); $education = TestApplicantEducationsPeer::doSelectOne($c); if (!$education) { $this->jsonwrapper->show_json_error('notfound', 'Education not found'); } } $connection = Propel::getConnection('propel'); $connection->begin(); $education->setTestApplicantId($applicant->getId()); $education->setSchoolOfOrigin($param['schoolname']); $education->setClassOfOrigin($param['grade']); $education->setLanguageInstruction($param['lang']); $education->setAcademicYear($param['acyear']); try { $education->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(); $education->save(); $data = $education->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 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'); }