Ejemplo n.º 1
0
 public function executeMedicalinformationProcess()
 {
     $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');
     }
     $applicantDetail = $applicant->getTestApplicantDetail();
     $param = $this->getAllRequestParameter();
     $valid = true;
     $error_message = array();
     /* Notes : No Mandatory field in this form */
     /* First Box */
     /* tested_speech */
     if (empty($param['tested_speech'])) {
         $param['tested_speech'] = 2;
     } else {
         if ($param['tested_speech'] != 1) {
             $param['tested_speech'] = 2;
         }
     }
     /* tested_add */
     if (empty($param['tested_add'])) {
         $param['tested_add'] = 2;
     } else {
         if ($param['tested_add'] != 1) {
             $param['tested_add'] = 2;
         }
     }
     /* tested_learning_disability */
     if (empty($param['tested_learning_disability'])) {
         $param['tested_learning_disability'] = 2;
     } else {
         if ($param['tested_learning_disability'] != 1) {
             $param['tested_learning_disability'] = 2;
         }
     }
     /* tested_reading */
     if (empty($param['tested_reading'])) {
         $param['tested_reading'] = 2;
     } else {
         if ($param['tested_reading'] != 1) {
             $param['tested_reading'] = 2;
         }
     }
     /* tested_emotional */
     if (empty($param['tested_emotional'])) {
         $param['tested_emotional'] = 2;
     } else {
         if ($param['tested_emotional'] != 1) {
             $param['tested_emotional'] = 2;
         }
     }
     /* Second Box */
     /* health_problem */
     if (empty($param['health_problem'])) {
         $param['health_problem'] = 2;
         $param['health_problem_detail'] = '';
     } else {
         if ($param['health_problem'] != 1) {
             $param['health_problem'] = 2;
             $param['health_problem_detail'] = '';
         } else {
             if (empty($param['health_problem_detail'])) {
                 $param['health_problem_detail'] = '';
             }
         }
     }
     /* regular_medication */
     if (empty($param['regular_medication'])) {
         $param['regular_medication'] = 2;
         $param['regular_medication_detail'] = '';
     } else {
         if ($param['regular_medication'] != 1) {
             $param['regular_medication'] = 2;
             $param['regular_medication_detail'] = '';
         } else {
             if (empty($param['regular_medication_detail'])) {
                 $param['regular_medication_detail'] = '';
             }
         }
     }
     /* allergy */
     if (empty($param['allergy'])) {
         $param['allergy'] = 2;
     } else {
         if ($param['allergy'] != 1) {
             $param['allergy'] = 2;
         }
     }
     /* medicine_allergy */
     if (empty($param['medicine_allergy'])) {
         $param['medicine_allergy'] = 2;
     } else {
         if ($param['medicine_allergy'] != 1) {
             $param['medicine_allergy'] = 2;
         }
     }
     /* asthma */
     if (empty($param['asthma'])) {
         $param['asthma'] = 2;
         $param['carry_inhaler'] = 2;
     } else {
         if ($param['asthma'] != 1) {
             $param['asthma'] = 2;
             $param['carry_inhaler'] = 2;
         } else {
             if (empty($param['carry_inhaler'])) {
                 $param['carry_inhaler'] = 2;
             }
         }
     }
     /* wear_glasses */
     if (empty($param['wear_glasses'])) {
         $param['wear_glasses'] = 2;
     } else {
         if ($param['wear_glasses'] != 1) {
             $param['wear_glasses'] = 2;
         }
     }
     /* wear_glasses */
     if (empty($param['asstist_comment'])) {
         $param['asstist_comment'] = '';
     }
     $medicalCriteria = new Criteria();
     $medicalCriteria->add(TestApplicantMedicalPeer::TEST_APPLICANT_ID, $applicant->getId(), Criteria::EQUAL);
     $medical = TestApplicantMedicalPeer::doSelectOne($medicalCriteria);
     if (!$medical) {
         $medical = new TestApplicantMedical();
         $medical->setTestApplicantId($applicant->getId());
     }
     if (!$valid) {
         $this->jsonwrapper->print_json(array('success' => false, 'code' => 'notvalid', 'error' => $error_message));
     }
     $medical->setSpeechLang($param['tested_speech']);
     $medical->setAddAdhd($param['tested_add']);
     $medical->setLearningDisability($param['tested_learning_disability']);
     $medical->setReading($param['tested_reading']);
     $medical->setEmotional($param['tested_emotional']);
     $medical->setHealthProblem($param['health_problem']);
     $medical->setRegularMedicate($param['regular_medication']);
     $medical->setAlergi($param['allergy']);
     $medical->setAlergiMedicine($param['medicine_allergy']);
     $medical->setAsthma($param['asthma']);
     $medical->setInhaler($param['carry_inhaler']);
     $medical->setSoftlens($param['wear_glasses']);
     $medical->setHealthProblemDetail($param['health_problem_detail']);
     $medical->setRegularMedicateDetail($param['regular_medication_detail']);
     $medical->setMedicalDetail($param['asstist_comment']);
     try {
         $medical->save();
     } catch (Exception $e) {
         $this->jsonwrapper->print_json(array('success' => false, 'code' => 'fail', 'message' => 'Error while save the data, please try again later.', 'data' => $medical->toArray(), 'param' => $param));
     }
     $this->jsonwrapper->print_json(array('success' => true, 'code' => 'success', 'message' => 'Data successfully saved', 'href' => $this->pmbTools->pmbUrl('data/relatedinformation'), 'data' => $medical->toArray(), 'param' => $param));
     /* ---- */
 }
Ejemplo n.º 2
0
 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');
 }