示例#1
0
 public function executeParentsProcess()
 {
     $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();
     /* Name */
     /* Mother Name */
     if (empty($param['mother_name'])) {
         $error_message[] = array('field' => 'mother_name', 'message' => 'Please enter mother name');
         $valid = false;
     }
     /* Father Name */
     if (empty($param['father_name'])) {
         $error_message[] = array('field' => 'father_name', 'message' => 'Please enter father name');
         $valid = false;
     }
     /* POB */
     /* mother_pob */
     if (empty($param['mother_pob'])) {
         $error_message[] = array('field' => 'mother_pob', 'message' => 'Please enter mother pob');
         $valid = false;
     }
     /* father_pob */
     if (empty($param['father_pob'])) {
         $error_message[] = array('field' => 'father_pob', 'message' => 'Please enter father pob');
         $valid = false;
     }
     /* DOB */
     /* mother_dob */
     if (empty($param['mother_dob'])) {
         $error_message[] = array('field' => 'mother_dob', 'message' => 'Please enter mother dob');
         $valid = false;
     }
     /* father_dob */
     if (empty($param['father_dob'])) {
         $error_message[] = array('field' => 'father_dob', 'message' => 'Please enter father dob');
         $valid = false;
     }
     /* Religion */
     /* mother_religion */
     if (empty($param['mother_religion'])) {
         $error_message[] = array('field' => 'mother_religion', 'message' => 'Please enter mother religion');
         $valid = false;
     }
     /* father_religion */
     if (empty($param['father_religion'])) {
         $error_message[] = array('field' => 'father_religion', 'message' => 'Please enter father religion');
         $valid = false;
     }
     /* Nationality */
     /* mother_nationality */
     if (empty($param['mother_nationality'])) {
         $error_message[] = array('field' => 'mother_nationality', 'message' => 'Please enter mother nationality');
         $valid = false;
     }
     /* father_nationality */
     if (empty($param['father_nationality'])) {
         $error_message[] = array('field' => 'father_nationality', 'message' => 'Please enter father nationality');
         $valid = false;
     }
     /* KTP */
     /* mother_ktp */
     if (empty($param['mother_ktp'])) {
         $error_message[] = array('field' => 'mother_ktp', 'message' => 'Please enter mother ktp number');
         $valid = false;
     }
     /* father_ktp */
     if (empty($param['father_ktp'])) {
         $error_message[] = array('field' => 'father_ktp', 'message' => 'Please enter father ktp number');
         $valid = false;
     }
     /* KITAS */
     /* mother_kitas */
     if (empty($param['mother_kitas'])) {
         $error_message[] = array('field' => 'mother_kitas', 'message' => 'Please enter mother kitas number');
         $valid = false;
     }
     /* father_kitas */
     if (empty($param['father_kitas'])) {
         $error_message[] = array('field' => 'father_kitas', 'message' => 'Please enter father kitas number');
         $valid = false;
     }
     /* Home Address */
     /* mother_home_address */
     if (empty($param['mother_home_address'])) {
         $error_message[] = array('field' => 'mother_home_address', 'message' => 'Please enter mother home address');
         $valid = false;
     }
     /* father_home_address */
     if (empty($param['father_home_address'])) {
         $error_message[] = array('field' => 'father_home_address', 'message' => 'Please enter father home address');
         $valid = false;
     }
     /* Home Phone */
     /* mother_home_phone */
     if (empty($param['mother_home_phone'])) {
         $error_message[] = array('field' => 'mother_home_phone', 'message' => 'Please enter mother home phone');
         $valid = false;
     }
     /* father_home_phone */
     if (empty($param['father_home_phone'])) {
         $error_message[] = array('field' => 'father_home_phone', 'message' => 'Please enter father home phone');
         $valid = false;
     }
     /* Cellphone */
     /* mother_cellphone */
     if (empty($param['mother_cellphone'])) {
         $error_message[] = array('field' => 'mother_cellphone', 'message' => 'Please enter mother cellphone');
         $valid = false;
     }
     /* father_cellphone */
     if (empty($param['father_cellphone'])) {
         $error_message[] = array('field' => 'father_cellphone', 'message' => 'Please enter father cellphone');
         $valid = false;
     }
     /* Occupation */
     /* mother_occupation */
     if (empty($param['mother_occupation'])) {
         $error_message[] = array('field' => 'mother_cellphone', 'message' => 'Please enter mother occupation');
         $valid = false;
     }
     /* father_occupation */
     if (empty($param['father_occupation'])) {
         $error_message[] = array('field' => 'father_occupation', 'message' => 'Please enter father occupation');
         $valid = false;
     }
     /* Job Title */
     /* mother_job_title */
     if (empty($param['mother_job_title'])) {
         $error_message[] = array('field' => 'mother_job_title', 'message' => 'Please enter mother Job Title');
         $valid = false;
     }
     /* father_job_title */
     if (empty($param['father_job_title'])) {
         $error_message[] = array('field' => 'father_job_title', 'message' => 'Please enter father Job Title');
         $valid = false;
     }
     /* Company Name */
     /* mother_company_name */
     if (empty($param['mother_company_name'])) {
         $error_message[] = array('field' => 'mother_company_name', 'message' => 'Please enter mother Company Name');
         $valid = false;
     }
     /* father_company_name */
     if (empty($param['father_company_name'])) {
         $error_message[] = array('field' => 'father_company_name', 'message' => 'Please enter father Company Name');
         $valid = false;
     }
     /* Company Address */
     /* mother_company_address */
     if (empty($param['mother_company_address'])) {
         $error_message[] = array('field' => 'mother_company_address', 'message' => 'Please enter mother Company Address');
         $valid = false;
     }
     /* father_company_address */
     if (empty($param['father_company_address'])) {
         $error_message[] = array('field' => 'father_company_address', 'message' => 'Please enter father Company Address');
         $valid = false;
     }
     /* Company Phone */
     /* mother_company_phone */
     if (empty($param['mother_company_phone'])) {
         $error_message[] = array('field' => 'mother_company_phone', 'message' => 'Please enter mother Company Phone');
         $valid = false;
     }
     /* father_company_phone */
     if (empty($param['father_company_phone'])) {
         $error_message[] = array('field' => 'father_company_phone', 'message' => 'Please enter father Company Phone');
         $valid = false;
     }
     /* Email */
     /* mother_email */
     if (empty($param['mother_email'])) {
         $error_message[] = array('field' => 'mother_email', 'message' => 'Please enter mother Email');
         $valid = false;
     }
     /* father_email */
     if (empty($param['father_email'])) {
         $error_message[] = array('field' => 'father_email', 'message' => 'Please enter father Email');
         $valid = false;
     }
     /* If not valid */
     if (!$valid) {
         $this->jsonwrapper->print_json(array('success' => false, 'code' => 'notvalid', 'error' => $error_message));
     }
     /* Start Transaction */
     $connection = Propel::getConnection('propel');
     $connection->begin();
     $father = $this->getFather($applicant);
     if (!$father) {
         $father = new TestApplicantParents();
         $father->setTestApplicantId($applicant->getId());
         $father->setRelation(StudentParents::RELATION_FATHER);
         try {
             $father->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 create father - process1'));
         }
     }
     $mother = $this->getMother($applicant);
     if (!$mother) {
         $mother = new TestApplicantParents();
         $mother->setTestApplicantId($applicant->getId());
         $mother->setRelation(StudentParents::RELATION_MOTHER);
         try {
             $mother->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 create mother - process2'));
         }
     }
     $mother->setName($param['mother_name']);
     $mother->setPob($param['mother_pob']);
     $motherDob = date('Y-m-d H:i:s', strtotime($param['mother_dob']));
     $mother->setDob($motherDob);
     $mother->setReligionId($param['mother_religion']);
     $mother->setCountryId($param['mother_nationality']);
     $mother->setIdcardNo($param['mother_ktp']);
     $mother->setKitasNo($param['mother_kitas']);
     $mother->setAddress($param['mother_home_address']);
     $mother->setHomePhone($param['mother_home_phone']);
     $mother->setCellphone($param['mother_cellphone']);
     $mother->setJob($param['mother_occupation']);
     $mother->setJob($param['mother_occupation']);
     $mother->setNoteDetail($param['mother_job_title']);
     $mother->setCompanyName($param['mother_company_name']);
     $mother->setCompanyAddress($param['mother_company_address']);
     $mother->setOfficePhone($param['mother_company_phone']);
     $mother->setEmail($param['mother_email']);
     $father->setName($param['father_name']);
     $father->setPob($param['father_pob']);
     $fatherDob = date('Y-m-d H:i:s', strtotime($param['father_dob']));
     $father->setDob($fatherDob);
     $father->setReligionId($param['father_religion']);
     $father->setCountryId($param['father_nationality']);
     $father->setIdcardNo($param['father_ktp']);
     $father->setKitasNo($param['father_kitas']);
     $father->setAddress($param['father_home_address']);
     $father->setHomePhone($param['father_home_phone']);
     $father->setCellphone($param['father_cellphone']);
     $father->setJob($param['father_occupation']);
     $father->setJob($param['father_occupation']);
     $father->setNoteDetail($param['father_job_title']);
     $father->setCompanyName($param['father_company_name']);
     $father->setCompanyAddress($param['father_company_address']);
     $father->setOfficePhone($param['father_company_phone']);
     $father->setEmail($param['father_email']);
     try {
         $mother->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 mother - process3'));
     }
     try {
         $father->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 father - process4'));
     }
     /* Commit Transaction */
     $connection->commit();
     /* Hehehe */
     $this->jsonwrapper->print_json(array('success' => true, 'code' => 'success', 'message' => 'Data successfully saved', 'href' => $this->pmbTools->pmbUrl('data/medicalinformation')));
     /* ---- */
     /* Start Transaction */
 }