示例#1
0
 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');
     // add or update student_detail
     if ($action_type == $action_i18n || !$this->getRequestParameter('student_detail_id')) {
         $student_detail = new StudentDetail();
     } else {
         $student_detail = StudentDetailPeer::retrieveByPk($this->getRequestParameter('student_detail_id'));
         $this->forward404Unless($student_detail);
     }
     $student_detail->setId($this->getRequestParameter('student_detail_id'));
     $student_detail->setShortName($this->getRequestParameter('short_name'));
     $student_detail->setSex($this->getRequestParameter('sex'));
     $student_detail->setPob($this->getRequestParameter('pob'));
     if ($this->getRequestParameter('dob')) {
         $student_detail->setDob($this->getRequestParameter('dob'));
     }
     $student_detail->setReligionId($this->getRequestParameter('religion_id'));
     $student_detail->setNationality($this->getRequestParameter('nationality'));
     $student_detail->setSiblingsStatus($this->getRequestParameter('siblings_status'));
     $student_detail->setBloodSiblings($this->getRequestParameter('blood_siblings'));
     $student_detail->setStepSiblings($this->getRequestParameter('step_siblings'));
     $student_detail->setAdoptSiblings($this->getRequestParameter('adopt_siblings'));
     $student_detail->setNativeLanguage($this->getRequestParameter('native_language'));
     $student_detail->setBloodType($this->getRequestParameter('blood_type'));
     $student_detail->setIsAlazhar($this->getRequestParameter('is_alazhar'));
     $student_detail->setSchoolOfOrigin($this->getRequestParameter('school_of_origin'));
     $student_detail->setSchoolOfOriginAddress($this->getRequestParameter('school_of_origin_address'));
     if ($this->getRequestParameter('graduation_date')) {
         $student_detail->setGraduationDate($this->getRequestParameter('graduation_date'));
     }
     $student_detail->setAcceptanceClass($this->getRequestParameter('acceptance_class'));
     $student_detail->setResidenceStatus($this->getRequestParameter('residence_status'));
     $student_detail->setAddress($this->getRequestParameter('address'));
     $student_detail->setVillage($this->getRequestParameter('village'));
     $student_detail->setSubDistrict($this->getRequestParameter('sub_district'));
     $student_detail->setDistrict($this->getRequestParameter('district'));
     $student_detail->setPostCode($this->getRequestParameter('post_code'));
     $student_detail->setPhone($this->getRequestParameter('phone'));
     $student_detail->setHomeDistance($this->getRequestParameter('home_distance'));
     $student_detail->save();
     if ($action_type == $action_i18n || !$this->getRequestParameter('member_detail_id')) {
         $member_detail = new MemberDetail();
     } else {
         $member_detail = MemberDetailPeer::retrieveByPk($this->getRequestParameter('member_detail_id'));
         $this->forward404Unless($member_detail);
     }
     $member_detail->setId($this->getRequestParameter('member_detail_id'));
     $member_detail->setShortName($this->getRequestParameter('short_name'));
     $member_detail->setSex($this->getRequestParameter('sex'));
     $member_detail->setPob($this->getRequestParameter('pob'));
     if ($this->getRequestParameter('dob')) {
         $member_detail->setDob($this->getRequestParameter('dob'));
     }
     $member_detail->setReligionId($this->getRequestParameter('religion_id'));
     $member_detail->setNationality($this->getRequestParameter('nationality'));
     $member_detail->setBloodSiblings($this->getRequestParameter('blood_siblings'));
     $member_detail->setStepSiblings($this->getRequestParameter('step_siblings'));
     $member_detail->setAdoptSiblings($this->getRequestParameter('adopt_siblings'));
     $member_detail->setNativeLanguage($this->getRequestParameter('native_language'));
     $member_detail->setSchoolOfOrigin($this->getRequestParameter('school_of_origin'));
     $member_detail->setResidenceStatus($this->getRequestParameter('residence_status'));
     $member_detail->setAddress($this->getRequestParameter('address'));
     $member_detail->setPostCode($this->getRequestParameter('post_code'));
     $member_detail->setPhone($this->getRequestParameter('phone'));
     $member_detail->setHomeDistance($this->getRequestParameter('home_distance'));
     $member_detail->save();
     if ($action_type == $action_i18n || !$this->getRequestParameter('member_id')) {
         $member = new Member();
     } else {
         $member = MemberPeer::retrieveByPk($this->getRequestParameter('member_id'));
         $this->forward404Unless($member);
     }
     $member->setId($this->getRequestParameter('member_id'));
     $member->setCode($this->getRequestParameter('code'));
     $member->setName($this->getRequestParameter('name'));
     $member->setType('1');
     $member->setStatus($this->getRequestParameter('status'));
     $member->setMemberDetail($member_detail);
     $member->save();
     if ($action_type == $action_i18n || !$this->getRequestParameter('id')) {
         $student = new Student();
     } else {
         $student = StudentPeer::retrieveByPk($this->getRequestParameter('id'));
         $this->forward404Unless($student);
     }
     $student->setId($this->getRequestParameter('id'));
     $student->setCode($this->getRequestParameter('code'));
     $student->setCode2($this->getRequestParameter('code2'));
     $student->setCode3($this->getRequestParameter('code3'));
     $student->setNik($this->getRequestParameter('nik'));
     $student->setName($this->getRequestParameter('name'));
     $student->setClassName($this->getRequestParameter('class_name'));
     $student->setAcademicCalendarId($this->getRequestParameter('academic_calendar_id'));
     $student->setClassGroupId($this->getRequestParameter('class_group_id'));
     $student->setTestApplicantId($this->getRequestParameter('test_applicant_id'));
     #$old_status = $student->getStatus();
     #$student->setStatus($this->getRequestParameter('status'));
     $student->setYear($this->getRequestParameter('year'));
     $student->setStudentDetail($student_detail);
     $student->setMember($member);
     if ($this->getRequestParameter('password') != null && strlen($this->getRequestParameter('password')) > 0) {
         // password set
         $crypted = sha1(sfConfig::get('app_salt') . $this->getRequestParameter('password'));
         if ($student->getPassword() != $crypted && strlen($this->getRequestParameter('password')) > 0) {
             // password changed
             $student->setPassword($crypted);
         }
     } elseif ($student->getPassword() == null || $student->getPassword() == '') {
         // create
         $crypted = sha1(sfConfig::get('app_salt') . $student_detail->getDob('dmY'));
         $student->setPassword($crypted);
     }
     $student->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(StudentPhotoPeer::STUDENT_ID, $student->getId());
         $student_photo = StudentPhotoPeer::doSelectOne($c);
         if ($student_photo == null) {
             $student_photo = new StudentPhoto();
             $student_photo->setStudent($student);
         }
         // save photo
         imagepng($photo, $photo_file);
         $student_photo->setPhoto(base64_encode(file_get_contents($photo_file)));
         imagepng($thumb, $photo_file);
         $student_photo->setThumbnail(base64_encode(file_get_contents($photo_file)));
         $student_photo->save();
         unlink($photo_dir . 'tmp' . DIRECTORY_SEPARATOR . $this->getRequestParameter('photoFile'));
     }
     // 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'));
     }
     return $this->redirect('scholar/editParent?id=' . $student->getId());
 }
示例#2
0
 public function addMemberPhoto(MemberPhoto $l)
 {
     $this->collMemberPhotos[] = $l;
     $l->setMember($this);
 }
示例#3
0
 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');
     }
 }
示例#4
0
 public function executeUpdateProfile()
 {
     $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/update student_detail
     if ($action_type == $action_i18n || !$this->getRequestParameter('student_detail_id')) {
         $student_detail = new StudentDetail();
     } else {
         $student_detail = StudentDetailPeer::retrieveByPk($this->getRequestParameter('student_detail_id'));
         #$this->forward404Unless($student_detail);
     }
     $student_detail->setId($this->getRequestParameter('student_detail_id'));
     $student_detail->setPob($this->getRequestParameter('pob'));
     if ($this->getRequestParameter('dob')) {
         $student_detail->setDob($this->getRequestParameter('dob'));
     }
     $student_detail->setSex($this->getRequestParameter('sex'));
     $student_detail->setAddress($this->getRequestParameter('address'));
     $student_detail->setRegionId($this->getRequestParameter('region_id'));
     $student_detail->setPostCode($this->getRequestParameter('post_code'));
     $student_detail->setParentName($this->getRequestParameter('parent_name'));
     $student_detail->setPhone($this->getRequestParameter('phone'));
     $student_detail->setCellphone($this->getRequestParameter('cellphone'));
     $student_detail->setReligionId($this->getRequestParameter('religion_id'));
     $student_detail->setSchoolOfOrigin($this->getRequestParameter('school_of_origin'));
     $student_detail->setGraduationYear($this->getRequestParameter('graduation_year'));
     $student_detail->setGraduationGrade($this->getRequestParameter('graduation_grade'));
     $student_detail->setCompany($this->getRequestParameter('company'));
     $student_detail->setJobTitle($this->getRequestParameter('job_title'));
     $student_detail->setCollegeOfOrigin($this->getRequestParameter('college_of_origin'));
     $student_detail->setDepartmentOfOrigin($this->getRequestParameter('department_of_origin'));
     $student_detail->setRegYear($this->getRequestParameter('reg_year'));
     $student_detail->setResidenceStatus($this->getRequestParameter('residence_status'));
     $student_detail->setHomeDistance($this->getRequestParameter('home_distance'));
     $student_detail->setTransport($this->getRequestParameter('transport'));
     $student_detail->setNativeLanguage($this->getRequestParameter('native_language'));
     $student_detail->setChildNumber($this->getRequestParameter('child_number'));
     $student_detail->setBloodSiblings($this->getRequestParameter('blood_siblings'));
     $student_detail->setStepSiblings($this->getRequestParameter('step_siblings'));
     $student_detail->setAdoptSiblings($this->getRequestParameter('adopt_siblings'));
     $student_detail->setOrphanageStatus($this->getRequestParameter('orphanage_status'));
     $student_detail->setNationality($this->getRequestParameter('nationality'));
     $student_detail->setShortName($this->getRequestParameter('short_name'));
     $student_detail->setIntelligency($this->getRequestParameter('intelligency'));
     if ($this->getRequestParameter('test_date') != '') {
         $student_detail->setTestDate($this->getRequestParameter('test_date'));
     }
     $student_detail->save();
     ### Member Detail ###
     if ($action_type == $action_i18n || !$this->getRequestParameter('member_detail_id')) {
         $member_detail = new MemberDetail();
     } else {
         $member_detail = MemberDetailPeer::retrieveByPk($this->getRequestParameter('member_detail_id'));
         #$this->forward404Unless($member_detail);
     }
     $member_detail->setId($this->getRequestParameter('member_detail_id'));
     $member_detail->setPob($this->getRequestParameter('pob'));
     if ($this->getRequestParameter('dob')) {
         $member_detail->setDob($this->getRequestParameter('dob'));
     }
     $member_detail->setSex($this->getRequestParameter('sex'));
     $member_detail->setAddress($this->getRequestParameter('address'));
     $member_detail->setRegionId($this->getRequestParameter('region_id'));
     $member_detail->setPostCode($this->getRequestParameter('post_code'));
     $member_detail->setPhone($this->getRequestParameter('phone'));
     $member_detail->setCellphone($this->getRequestParameter('cellphone'));
     $member_detail->setReligionId($this->getRequestParameter('religion_id'));
     $member_detail->setSchoolOfOrigin($this->getRequestParameter('school_of_origin'));
     $member_detail->setGraduationYear($this->getRequestParameter('graduation_year'));
     $member_detail->setGraduationGrade($this->getRequestParameter('graduation_grade'));
     $member_detail->setCompany($this->getRequestParameter('company'));
     $member_detail->setJobTitle($this->getRequestParameter('job_title'));
     $member_detail->setCollegeOfOrigin($this->getRequestParameter('college_of_origin'));
     $member_detail->setDepartmentOfOrigin($this->getRequestParameter('department_of_origin'));
     $member_detail->setRegYear($this->getRequestParameter('reg_year'));
     $member_detail->setResidenceStatus($this->getRequestParameter('residence_status'));
     $member_detail->setHomeDistance($this->getRequestParameter('home_distance'));
     $member_detail->setTransport($this->getRequestParameter('transport'));
     $member_detail->setNativeLanguage($this->getRequestParameter('native_language'));
     $member_detail->setChildNumber($this->getRequestParameter('child_number'));
     $member_detail->setBloodSiblings($this->getRequestParameter('blood_siblings'));
     $member_detail->setStepSiblings($this->getRequestParameter('step_siblings'));
     $member_detail->setAdoptSiblings($this->getRequestParameter('adopt_siblings'));
     $member_detail->setOrphanageStatus($this->getRequestParameter('orphanage_status'));
     $member_detail->setNationality($this->getRequestParameter('nationality'));
     $member_detail->setShortName($this->getRequestParameter('short_name'));
     $member_detail->setIntelligency($this->getRequestParameter('intelligency'));
     if ($this->getRequestParameter('test_date') != '') {
         $member_detail->setTestDate($this->getRequestParameter('test_date'));
     }
     $member_detail->save();
     if ($action_type == $action_i18n || !$this->getRequestParameter('member_id')) {
         $member = new Member();
     } else {
         $member = MemberPeer::retrieveByPk($this->getRequestParameter('member_id'));
         #$this->forward404Unless($member);
     }
     $member->setId($this->getRequestParameter('member_id'));
     $member->setCode($this->getRequestParameter('code'));
     $member->setName($this->getRequestParameter('name'));
     $old_status = $member->getStatus();
     $member->setStatus($this->getRequestParameter('status'));
     $member->setType('1');
     $member->setMemberDetail($member_detail);
     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->save();
     if ($action_type == $action_i18n || !$this->getRequestParameter('id')) {
         $student = new Student();
     } else {
         $student = StudentPeer::retrieveByPk($this->getRequestParameter('id'));
         #$this->forward404Unless($student);
     }
     $student->setId($this->getRequestParameter('id'));
     $student->setCode($this->getRequestParameter('code'));
     $student->setCode2($this->getRequestParameter('code2'));
     $student->setName($this->getRequestParameter('name'));
     $student->setClassName($this->getRequestParameter('class_name'));
     $student->setAcademicCalendarId($this->getRequestParameter('academic_calendar_id'));
     $student->setClassGroupId($this->getRequestParameter('class_group_id'));
     $student->setTestApplicantId($this->getRequestParameter('test_applicant_id'));
     $old_status = $student->getStatus();
     $student->setStatus($this->getRequestParameter('status'));
     $student->setStudentDetail($student_detail);
     $student->setMember($member);
     if ($this->getRequestParameter('password') != null && strlen($this->getRequestParameter('password')) > 0) {
         // password set
         $crypted = sha1(sfConfig::get('app_salt') . $this->getRequestParameter('password'));
         if ($student->getPassword() != $crypted && strlen($this->getRequestParameter('password')) > 0) {
             // password changed
             $student->setPassword($crypted);
         }
     } elseif ($student->getPassword() == null || $student->getPassword() == '') {
         // create
         $crypted = sha1(sfConfig::get('app_salt') . $student_detail->getDob('dmY'));
         $student->setPassword($crypted);
     }
     $student->save();
     if ($student->getStatus() == Student::STATUS_FINAL) {
         $c = new Criteria();
         $c->add(SubjectPeer::IS_COMPREHENSIVE_SUBJECT, true);
         $c->addJoin(SubjectPeer::ID, SubjectAccalPeer::SUBJECT_ID);
         $c->addJoin(SubjectAccalPeer::ID, StudentCoursePeer::SUBJECT_ACCAL_ID);
         $c->add(StudentCoursePeer::STATUS, StudentCourse::STATUS_ACTIVE);
         $c->add(StudentCoursePeer::STUDENT_ID, $student->getId());
         $sc = StudentCoursePeer::doSelectOne($c);
         if ($sc) {
             $accal_id = $sc->getSubjectAccal()->getAcademicCalendarId();
             $st = new StudentThesis();
             $st->setStudentid($student->getId());
             $st->setStatus(StudentThesis::STATUS_ACTIVE);
             $st->setAcademicCalendarId($accal_id);
             $st->save();
         } else {
             $student->setStatus($old_status);
             $student->save();
         }
     } elseif ($student->getStatus() == Student::STATUS_GRADUATE) {
         $student->setGraduationDate(date('Y/m/d'));
         $student->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(StudentPhotoPeer::STUDENT_ID, $student->getId());
         $student_photo = StudentPhotoPeer::doSelectOne($c);
         if ($student_photo == null) {
             $student_photo = new StudentPhoto();
             $student_photo->setStudent($student);
         }
         // save photo
         imagepng($photo, $photo_file);
         $student_photo->setPhoto(base64_encode(file_get_contents($photo_file)));
         imagepng($thumb, $photo_file);
         $student_photo->setThumbnail(base64_encode(file_get_contents($photo_file)));
         $student_photo->save();
         unlink($photo_dir . 'tmp' . DIRECTORY_SEPARATOR . $this->getRequestParameter('photoFile'));
     }
     // 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'));
     }
     $filter_class = $this->getRequestParameter('filter_class');
     $filter_name = $this->getRequestParameter('filter_name');
     $filter_code = $this->getRequestParameter('filter_code');
     $filter_code2 = $this->getRequestParameter('filter_code2');
     if ($filter_class) {
         return $this->redirect('student/listProfile?filters[CLASS_NAME]=' . $filter_class);
     } elseif ($filter_name) {
         return $this->redirect('student/listProfile?filters[NAME]=' . $filter_name);
     } elseif ($filter_code) {
         return $this->redirect('student/listProfile?filters[CODE]=' . $filter_code);
     } elseif ($filter_code2) {
         return $this->redirect('student/listProfile?filters[CODE2]=' . $filter_code2);
     } else {
         return $this->redirect('student/listProfile');
     }
 }