示例#1
0
 public function executeEdit(sfWebRequest $request)
 {
     if ($request->isMethod('Post')) {
         $employee = EmployeePeer::retrieveByPk($this->getRequestParameter('employee_id'));
         // Setting Department from Selected Designation
         $a = new Criteria();
         $a->add(DesignationPeer::ID, $this->getRequestParameter('designation_id'));
         $designation_record = DesignationPeer::DoSelectOne($a);
         $department_id = $designation_record->getDepartmentId();
         $employee->setName($this->getRequestParameter('name'));
         $employee->setCnic($this->getRequestParameter('cnic'));
         $employee->setDob($this->getRequestParameter('dob'));
         $employee->setGender($this->getRequestParameter('gender[0]'));
         $employee->setContactCell($this->getRequestParameter('contact_cell'));
         $employee->setContactRes($this->getRequestParameter('contact_res'));
         $employee->setContactOff($this->getRequestParameter('contact_off'));
         $employee->setEmergencyContact($this->getRequestParameter('emergency_contact'));
         $employee->setMailAddress($this->getRequestParameter('mail_address'));
         $employee->setDesignationId($this->getRequestParameter('designation_id'));
         $employee->setDepartmentId($department_id);
         $employee->setEmploymentDate($this->getRequestParameter('employment_date'));
         $employee->setLocalResident($this->getRequestParameter('local[0]'));
         $employee->setQualification($this->getRequestParameter('qualification'));
         if ($employee->save()) {
             $this->getUser()->setFlash('SUCCESS_MESSAGE', Constant::RECORD_EDITED_SUCCESSFULLY);
         } else {
             $this->getUser()->setFlash('ERROR_MESSAGE', Constant::DB_ERROR);
         }
         $this->redirect('Employee/list');
     } else {
         $this->employee = EmployeePeer::retrieveByPk(Utility::DecryptQueryString($request->getParameter('employee')));
     }
     // end else
 }