public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = EmployeeParentsPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setEmployeeId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setName($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setPob($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setDob($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setReligionId($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setCountryId($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setRelation($arr[$keys[7]]); } }
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(EmployeeParentsPeer::ID, $pks, Criteria::IN); $objs = EmployeeParentsPeer::doSelect($criteria, $con); } return $objs; }
public function executeSave() { $i18n = new sfI18N(); $i18n->initialize($this->getContext()); $i18n->setCulture($this->getUser()->getCulture()); $action_i18n = $i18n->globalMessageFormat->format('save as new'); $action_type = $this->getRequestParameter('action_type'); if ($action_type == $action_i18n || !$this->getRequestParameter('id')) { $employee_parents = new EmployeeParents(); } else { $employee_parents = EmployeeParentsPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($employee_parents); } $employee_parents->setId($this->getRequestParameter('id')); $employee_parents->setEmployeeId($this->getRequestParameter('employee_id')); if ($this->getRequestParameter('dob')) { $employee_parents->setDob($this->getRequestParameter('dob')); } $employee_parents->setName($this->getRequestParameter('name')); $employee_parents->setPob($this->getRequestParameter('pob')); $employee_parents->setReligionId($this->getRequestParameter('religion_id')); $employee_parents->setCountryId($this->getRequestParameter('country_id')); $employee_parents->setRelation($this->getRequestParameter('relation')); $employee_parents->save(); return $this->redirect('user_profile_l/listFamilly?employee_id=' . $this->getRequestParameter('employee_id')); }
public function executeUpdate() { $i18n = new sfI18N(); $i18n->initialize($this->getContext()); $i18n->setCulture($this->getUser()->getCulture()); $action_i18n = $i18n->globalMessageFormat->format('save as new'); $action_type = $this->getRequestParameter('action_type'); if ($action_type == $action_i18n || !$this->getRequestParameter('id')) { $employee = new Employee(); } else { $employee = EmployeePeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($employee); } $employee->setId($this->getRequestParameter('id')); $employee->setName($this->getRequestParameter('name')); $employee->setDepartmentId($this->getRequestParameter('department_id')); $employee->setStaffTypeId($this->getRequestParameter('staff_type_id')); $employee->setEmpNo($this->getRequestParameter('emp_no')); $employee->setCode($this->getRequestParameter('code')); $employee->setIsCounselor($this->getRequestParameter('is_counselor')); $employee->setIsThesisAdvisor($this->getRequestParameter('is_thesis_advisor')); $employee->setIsComprehensiveReviewer($this->getRequestParameter('is_comprehensive_reviewer')); $employee->save(); // fd3cf92194f1a6b8b5fa60a1aba8129c1753d6e2 = admin if ($this->getRequestParameter('password') != null && strlen($this->getRequestParameter('password')) > 0) { // password set $crypted = sha1(sfConfig::get('app_salt') . $this->getRequestParameter('password')); if ($employee->getPassword() != $crypted && strlen($this->getRequestParameter('password')) > 0) { // password changed $employee->setPassword($crypted); } } elseif ($employee->getPassword() == null || $employee->getPassword() == '') { // create $crypted = sha1(sfConfig::get('app_salt') . $employee->getEmpNo()); $employee->setPassword($crypted); } $employee->save(); if ($action_type == $action_i18n || !$this->getRequestParameter('employee_detail_id')) { $employee_detail = new EmployeeDetail(); } else { $employee_detail = EmployeeDetailPeer::retrieveByPk($this->getRequestParameter('employee_detail_id')); $this->forward404Unless($employee_detail); } $employee_detail->setId($this->getRequestParameter('employee_detail_id')); $employee_detail->setEmployee($employee); if ($this->getRequestParameter('date_in')) { $employee_detail->setDateIn($this->getRequestParameter('date_in')); } if ($this->getRequestParameter('date_out')) { $employee_detail->setDateOut($this->getRequestParameter('date_out')); } $employee_detail->setNickname($this->getRequestParameter('nickname')); $employee_detail->setSex($this->getRequestParameter('sex')); $employee_detail->setPob($this->getRequestParameter('pob')); if ($this->getRequestParameter('dob')) { $employee_detail->setDob($this->getRequestParameter('dob')); } $employee_detail->setReligionId($this->getRequestParameter('religion_id')); $employee_detail->setNationality($this->getRequestParameter('nationality')); $employee_detail->setStatusInFamily($this->getRequestParameter('status_in_family')); $employee_detail->setMotherLanguage($this->getRequestParameter('mother_language')); $employee_detail->setHobby($this->getRequestParameter('hobby')); $employee_detail->setAddress($this->getRequestParameter('address')); $employee_detail->setPhone($this->getRequestParameter('phone')); $employee_detail->setResidenceStatus($this->getRequestParameter('residence_status')); $employee_detail->setVehicle($this->getRequestParameter('vehicle')); $employee_detail->setWorkplaceDistance($this->getRequestParameter('workplace_distance')); $employee_detail->setLastEducation($this->getRequestParameter('last_education')); $employee_detail->setGraduationYear($this->getRequestParameter('graduation_year')); $employee_detail->setCertificateNumber($this->getRequestParameter('certificate_number')); $employee_detail->setFaculty($this->getRequestParameter('faculty')); $employee_detail->setProgram($this->getRequestParameter('program')); $employee_detail->setMayor($this->getRequestParameter('mayor')); $employee_detail->setTeachingLicense($this->getRequestParameter('teaching_license')); $employee_detail->setMaritalStatusId($this->getRequestParameter('marital_status_id')); $employee_detail->setSpouseName($this->getRequestParameter('spouse_name')); $employee_detail->setBloodType($this->getRequestParameter('blood_type')); $employee_detail->setSpousePob($this->getRequestParameter('spouse_pob')); if ($this->getRequestParameter('spouse_dob')) { $employee_detail->setSpouseDob($this->getRequestParameter('spouse_dob')); } $employee_detail->setContactDetail($this->getRequestParameter('contact_detail')); $employee_detail->setSpouseEducation($this->getRequestParameter('spouse_education')); $employee_detail->setSpouseReligionId($this->getRequestParameter('spouse_religion_id')); $employee_detail->setNumberOfChild($this->getRequestParameter('number_of_child')); $employee_detail->setChild1Name($this->getRequestParameter('child1_name')); $employee_detail->setChild2Name($this->getRequestParameter('child2_name')); $employee_detail->setTall($this->getRequestParameter('tall')); $employee_detail->setWeight($this->getRequestParameter('weight')); $employee_detail->setIllness($this->getRequestParameter('illness')); $employee_detail->setEmployeeDivisionId($this->getRequestParameter('employee_division_id')); $employee_detail->setEmployeeLevelId($this->getRequestParameter('employee_level_id')); $employee_detail->setExtraCode($this->getRequestParameter('extra_code')); $employee_detail->setAccountNumber($this->getRequestParameter('account_number')); $employee_detail->setGroups($this->getRequestParameter('groups')); $employee_detail->setFingercode($this->getRequestParameter('fingercode')); $employee_detail->setStatus($this->getRequestParameter('status')); $employee_detail->save(); // save photo $photo_dir = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'photos' . DIRECTORY_SEPARATOR; if ($this->hasRequestParameter('photoFile') && $this->getRequestParameter('photoFile') != '' && $this->getRequestParameter('photoFile') != null) { // get photo content $photo_file = $photo_dir . 'tmp' . DIRECTORY_SEPARATOR . $this->getRequestParameter('photoFile'); $content = file_get_contents($photo_file); $im = imagecreatefromstring($content); list($w, $h) = getimagesize($photo_file); // generate photo $photo = imagecreatetruecolor(150, 195); imagecopyresized($photo, $im, 0, 0, 0, 0, 150, 195, $w, $h); // generate thumbnail $thumb = imagecreatetruecolor(100, 130); imagecopyresized($thumb, $im, 0, 0, 0, 0, 100, 130, $w, $h); // get photo record $c = new Criteria(); $c->add(EmployeePhotoPeer::EMPLOYEE_ID, $employee_detail->getEmployeeId()); $employee_photo = EmployeePhotoPeer::doSelectOne($c); if ($employee_photo == null) { $employee_photo = new EmployeePhoto(); $employee_photo->setEmployee($employee_detail->getEmployee()); } // save photo imagepng($photo, $photo_file); $employee_photo->setPhoto(base64_encode(file_get_contents($photo_file))); imagepng($thumb, $photo_file); $employee_photo->setThumbnail(base64_encode(file_get_contents($photo_file))); $employee_photo->save(); unlink($photo_dir . 'tmp' . DIRECTORY_SEPARATOR . $this->getRequestParameter('photoFile')); } ## Ayah if ($this->hasRequestParameter('father') && $this->getRequestParameter('father')) { $cdi = new Criteria(); $cdi->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $cdi->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_FATHER); $father = EmployeeParentsPeer::doSelectOne($cdi); if ($father == null) { $father = new EmployeeParents(); } $father->setName($this->getRequestParameter('father')); $father->setEmployee($employee); $father->setRelation(EmployeeParents::RELATION_FATHER); $father->save(); } # Ibu if ($this->hasRequestParameter('mother') && $this->getRequestParameter('mother')) { $cti = new Criteria(); $cti->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $cti->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_MOTHER); $mother = EmployeeParentsPeer::doSelectOne($cti); if ($mother == null) { $mother = new EmployeeParents(); } $mother->setName($this->getRequestParameter('mother')); $mother->setEmployee($employee); $mother->setRelation(EmployeeParents::RELATION_MOTHER); $mother->save(); } # Ayah Mertua if ($this->hasRequestParameter('father_inlaw_name') && $this->getRequestParameter('father_inlaw_name')) { $cmi = new Criteria(); $cmi->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $cmi->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_FATHER_INLAW); $father_inlaw = EmployeeParentsPeer::doSelectOne($cmi); if ($father_inlaw == null) { $father_inlaw = new EmployeeParents(); } $father_inlaw->setName($this->getRequestParameter('father_inlaw_name')); $father_inlaw->setEmployee($employee); $father_inlaw->setRelation(EmployeeParents::RELATION_FATHER_INLAW); $father_inlaw->save(); } # Ibu Mertua if ($this->hasRequestParameter('mother_inlaw_name') && $this->getRequestParameter('mother_inlaw_name')) { $cki = new Criteria(); $cki->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $cki->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_MOTHER_INLAW); $mother_inlaw = EmployeeParentsPeer::doSelectOne($cki); if ($mother_inlaw == null) { $mother_inlaw = new EmployeeParents(); } $mother_inlaw->setName($this->getRequestParameter('mother_inlaw_name')); $mother_inlaw->setEmployee($employee); $mother_inlaw->setRelation(EmployeeParents::RELATION_MOTHER_INLAW); $mother_inlaw->save(); } # Anak 1 if ($this->hasRequestParameter('child1_name') && $this->getRequestParameter('child1_name')) { $cwi = new Criteria(); $cwi->add(EmployeeChildsPeer::EMPLOYEE_ID, $employee->getId()); $cwi->add(EmployeeChildsPeer::RELATION, EmployeeChilds::RELATION_SON1); $son1 = EmployeeChildsPeer::doSelectOne($cwi); if ($son1 == null) { $son1 = new EmployeeChilds(); } $son1->setName($this->getRequestParameter('child1_name')); $son1->setPob($this->getRequestParameter('pob1')); $son1->setDob($this->getRequestParameter('dob1')); $son1->setEmployee($employee); $son1->setRelation(EmployeeChilds::RELATION_SON1); $son1->setSex($this->getRequestParameter('sex1')); $son1->save(); } # Anak 2 if ($this->hasRequestParameter('child2_name') && $this->getRequestParameter('child2_name')) { $cwi = new Criteria(); $cwi->add(EmployeeChildsPeer::EMPLOYEE_ID, $employee->getId()); $cwi->add(EmployeeChildsPeer::RELATION, EmployeeChilds::RELATION_SON2); $son2 = EmployeeChildsPeer::doSelectOne($cwi); if ($son2 == null) { $son2 = new EmployeeChilds(); } $son2->setName($this->getRequestParameter('child2_name')); $son2->setPob($this->getRequestParameter('pob2')); $son2->setDob($this->getRequestParameter('dob2')); $son2->setEmployee($employee); $son2->setRelation(EmployeeChilds::RELATION_SON2); $son2->setSex($this->getRequestParameter('sex2')); $son2->save(); } # Anak 3 if ($this->hasRequestParameter('child3_name') && $this->getRequestParameter('child3_name')) { $cwi = new Criteria(); $cwi->add(EmployeeChildsPeer::EMPLOYEE_ID, $employee->getId()); $cwi->add(EmployeeChildsPeer::RELATION, EmployeeChilds::RELATION_SON3); $son3 = EmployeeChildsPeer::doSelectOne($cwi); if ($son3 == null) { $son3 = new EmployeeChilds(); } $son3->setName($this->getRequestParameter('child3_name')); $son3->setPob($this->getRequestParameter('pob3')); $son3->setDob($this->getRequestParameter('dob3')); $son3->setEmployee($employee); $son3->setRelation(EmployeeChilds::RELATION_SON3); $son3->setSex($this->getRequestParameter('sex3')); $son3->save(); } # Anak 4 if ($this->hasRequestParameter('child4_name') && $this->getRequestParameter('child4_name')) { $cwi = new Criteria(); $cwi->add(EmployeeChildsPeer::EMPLOYEE_ID, $employee->getId()); $cwi->add(EmployeeChildsPeer::RELATION, EmployeeChilds::RELATION_SON4); $son4 = EmployeeChildsPeer::doSelectOne($cwi); if ($son4 == null) { $son4 = new EmployeeChilds(); } $son4->setName($this->getRequestParameter('child4_name')); $son4->setPob($this->getRequestParameter('pob4')); $son4->setDob($this->getRequestParameter('dob4')); $son4->setEmployee($employee); $son4->setRelation(EmployeeChilds::RELATION_SON4); $son4->setSex($this->getRequestParameter('sex4')); $son4->save(); } # Anak 5 if ($this->hasRequestParameter('child5_name') && $this->getRequestParameter('child5_name')) { $cwi = new Criteria(); $cwi->add(EmployeeChildsPeer::EMPLOYEE_ID, $employee->getId()); $cwi->add(EmployeeChildsPeer::RELATION, EmployeeChilds::RELATION_SON5); $son5 = EmployeeChildsPeer::doSelectOne($cwi); if ($son5 == null) { $son5 = new EmployeeChilds(); } $son5->setName($this->getRequestParameter('child5_name')); $son5->setPob($this->getRequestParameter('pob5')); $son5->setDob($this->getRequestParameter('dob5')); $son5->setEmployee($employee); $son5->setRelation(EmployeeChilds::RELATION_SON5); $son5->setSex($this->getRequestParameter('sex5')); $son5->save(); } return $this->redirect('employee/list'); }
public function executeShowEmployee() { $group_id = $this->getContext()->getUser()->getAttribute('group_id', null, 'bo'); $c = new Criteria(); #$c->add(JobPeer::CODE, $this->getModuleName()); $c->add(JobPeer::ID, 208); $job = JobPeer::doSelectOne($c); $acl = AclPeer::retrieveByPK($group_id, $job->getId()); if (!$acl) { $this->forward('default', 'error404'); } #$member = MemberPeer::retrieveByPk($this->getRequestParameter('id')); #$this->forward404Unless($member); #$this->subtitle = $member->toString().' - id:'.$member->getId(); $employee = EmployeePeer::retrieveByPK($this->getRequestParameter('id')); $this->forward404Unless($employee); $this->subtitle = $employee->toString() . ' - id:' . $employee->getId(); $c = new Criteria(); $c->add(EmployeeDetailPeer::EMPLOYEE_ID, $employee->getId()); $employee_detail = EmployeeDetailPeer::doSelectOne($c); if ($this->hasRequestParameter('no_reg') && $this->getRequestParameter('no_reg') != '' && $this->getRequestParameter('no_reg') != null) { $actions = array(array('name' => 'back', 'url' => 'member/listEmployee?filters[NO_REG]=' . $this->getRequestParameter('no_reg'), 'color' => 'white')); } elseif ($this->hasRequestParameter('code') && $this->getRequestParameter('code') != '' && $this->getRequestParameter('code') != null) { $actions = array(array('name' => 'back', 'url' => 'member/listEmployee?filters[CODE]=' . $this->getRequestParameter('code'), 'color' => 'white')); } elseif ($this->hasRequestParameter('dept_id') && $this->getRequestParameter('dept_id') != '' && $this->getRequestParameter('dept_id') != null) { $actions = array(array('name' => 'back', 'url' => 'member/listEmployee?filters[DEPARTMENT_ID]=' . $this->getRequestParameter('dept_id'), 'color' => 'white')); } elseif ($this->hasRequestParameter('staff_type') && $this->getRequestParameter('staff_type') != '' && $this->getRequestParameter('staff_type') != null) { $actions = array(array('name' => 'back', 'url' => 'member/listEmployee?filters[STAFF_TYPE_ID]=' . $this->getRequestParameter('staff_type'), 'color' => 'white')); } elseif ($this->hasRequestParameter('name') && $this->getRequestParameter('name') != '' && $this->getRequestParameter('name') != null) { $actions = array(array('name' => 'back', 'url' => 'member/listEmployee?filters[NAME]=' . $this->getRequestParameter('name'), 'color' => 'white')); } else { $actions = array(array('name' => 'back', 'url' => 'member/listEmployee', 'color' => 'white')); } $this->actions = $actions; $this->employee = $employee; $this->employee_detail = $employee_detail; #Father $cw = new Criteria(); $cw->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $cw->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_FATHER); $father = EmployeeParentsPeer::doSelectOne($cw); if ($father == null) { $father = new EmployeeParents(); } #Mother $ct = new Criteria(); $ct->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $ct->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_MOTHER); $mother = EmployeeParentsPeer::doSelectOne($ct); if ($mother == null) { $mother = new EmployeeParents(); } #Father In Law $cwi = new Criteria(); $cwi->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $cwi->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_FATHER_INLAW); $father_inlaw = EmployeeParentsPeer::doSelectOne($cwi); if ($father_inlaw == null) { $father_inlaw = new EmployeeParents(); } #Mother In Law $cti = new Criteria(); $cti->add(EmployeeParentsPeer::EMPLOYEE_ID, $employee->getId()); $cti->add(EmployeeParentsPeer::RELATION, EmployeeParents::RELATION_MOTHER_INLAW); $mother_inlaw = EmployeeParentsPeer::doSelectOne($cti); if ($mother_inlaw == null) { $mother_inlaw = new EmployeeParents(); } $this->father = $father; $this->mother = $mother; $this->father_inlaw = $father_inlaw; $this->mother_inlaw = $mother_inlaw; $cli = new Criteria(); $cli->add(EmployeeChildsPeer::EMPLOYEE_ID, $employee->getId()); $employee_childs = EmployeeChildsPeer::doSelect($cli); $childs = array(); foreach ($employee_childs as $emp_child) { $childs[$emp_child->getRelation()] = $emp_child->getId(); } $this->childs = $childs; $this->employee_childs = $employee_childs; }