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 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_detail = new EmployeeDetail(); } else { $employee_detail = EmployeeDetailPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($employee_detail); } $employee_detail->setId($this->getRequestParameter('id')); $employee_detail->setEmployeeId($this->getRequestParameter('employee_id')); 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->setMaritalStatus($this->getRequestParameter('marital_status')); $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->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->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')); } return $this->redirect('employee_detail/show?employee_id=' . $employee_detail->getEmployeeId()); }
public function executeUpdateEmployee() { $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'); // add employee if ($action_type == $action_i18n || !$this->getRequestParameter('employee_id')) { $employee = new Employee(); } else { $employee = EmployeePeer::retrieveByPk($this->getRequestParameter('employee_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->setIsCounselor($this->getRequestParameter('is_counselor')); $employee->setIsThesisAdvisor($this->getRequestParameter('is_thesis_advisor')); $employee->setIsComprehensiveReviewer($this->getRequestParameter('is_comprehensive_reviewer')); $employee->setCode($this->getRequestParameter('code')); $employee->save(); 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(); // add employee_detail 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('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->setMaritalStatus($this->getRequestParameter('marital_status')); $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->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->save(); if ($action_type == $action_i18n || !$this->getRequestParameter('id')) { $member = new Member(); } else { $member = MemberPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($member); } $member->setId($this->getRequestParameter('id')); $member->setEmployeeDetail($employee_detail); $member->setCode($this->getRequestParameter('code')); $member->setNoReg($this->getRequestParameter('no_reg')); $member->setName($this->getRequestParameter('name')); $member->setClassName($this->getRequestParameter('class_name')); $member->setDepartmentId($this->getRequestParameter('department_id')); $member->setStaffTypeId($this->getRequestParameter('staff_type_id')); $member->setEmpNo($this->getRequestParameter('emp_no')); $member->setIsCounselor($this->getRequestParameter('is_counselor')); $member->setIsThesisAdvisor($this->getRequestParameter('is_thesis_advisor')); $member->setIsComprehensiveReviewer($this->getRequestParameter('is_comprehensive_reviewer')); $old_status = $member->getStatus(); $member->setStatus($this->getRequestParameter('status')); $member->setType('2'); // $member->setMemberDetail($member_detail); // fd3cf92194f1a6b8b5fa60a1aba8129c1753d6e2 = admin if ($this->getRequestParameter('password') != null && strlen($this->getRequestParameter('password')) > 0) { // password set $crypted = sha1(sfConfig::get('app_salt') . $this->getRequestParameter('password')); if ($member->getPassword() != $crypted && strlen($this->getRequestParameter('password')) > 0) { // password changed $member->setPassword($crypted); } } elseif ($member->getPassword() == null || $member->getPassword() == '') { // create $crypted = sha1(sfConfig::get('app_salt') . $this->getRequestParameter('code') . $member_detail->getDob('dm')); $member->setPassword($crypted); } #$member->setEmployeeDetail($employee_detail); $member->save(); // save member 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, 200); imagecopyresized($photo, $im, 0, 0, 0, 0, 150, 200, $w, $h); // generate thumbnail $thumb = imagecreatetruecolor(100, 150); imagecopyresized($thumb, $im, 0, 0, 0, 0, 100, 150, $w, $h); // get photo record $c = new Criteria(); $c->add(MemberPhotoPeer::MEMBER_ID, $member->getId()); $member_photo = MemberPhotoPeer::doSelectOne($c); if ($member_photo == null) { $member_photo = new MemberPhoto(); $member_photo->setMember($member); } // save photo imagepng($photo, $photo_file); $member_photo->setPhoto(base64_encode(file_get_contents($photo_file))); imagepng($thumb, $photo_file); $member_photo->setThumbnail(base64_encode(file_get_contents($photo_file))); $member_photo->save(); unlink($photo_dir . 'tmp' . DIRECTORY_SEPARATOR . $this->getRequestParameter('photoFile')); } // save Employee 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')); } if ($this->hasRequestParameter('filter_noreg') && $this->getRequestParameter('filter_noreg') != '' && $this->getRequestParameter('filter_noreg') != null) { return $this->redirect('member/listEmployee?filters[NO_REG]=' . $this->getRequestParameter('no_reg')); } elseif ($this->hasRequestParameter('filter_code') && $this->getRequestParameter('filter_code') != '' && $this->getRequestParameter('filter_code') != null) { return $this->redirect('member/listEmployee?filters[CODE]=' . $this->getRequestParameter('filter_code')); } elseif ($this->hasRequestParameter('filter_deptid') && $this->getRequestParameter('filter_deptid') != '' && $this->getRequestParameter('filter_deptid') != null) { return $this->redirect('member/listEmployee?filters[DEPARTMENT_ID]=' . $this->getRequestParameter('filter_deptid')); } elseif ($this->hasRequestParameter('filter_stafftype') && $this->getRequestParameter('filter_stafftype') != '' && $this->getRequestParameter('filter_stafftype') != null) { return $this->redirect('member/listEmployee?filters[STAFF_TYPE_ID]=' . $this->getRequestParameter('filter_stafftype')); } elseif ($this->hasRequestParameter('filter_name') && $this->getRequestParameter('filter_name') != '' && $this->getRequestParameter('filter_name') != null) { return $this->redirect('member/listEmployee?filters[NAME]=' . $this->getRequestParameter('name')); } else { return $this->redirect('member/listEmployee'); } }