コード例 #1
0
 /**
  * Add / update employee customFields
  *
  * @param int $empNumber Employee number
  *
  * @return boolean true if successfully assigned, false otherwise
  */
 public function execute($request)
 {
     // this should probably be kept in session?
     $screen = $request->getParameter('screen');
     $customFieldsService = new CustomFieldsService();
     $customFieldList = $customFieldsService->getCustomFieldList($screen);
     $this->form = new EmployeeCustomFieldsForm(array(), array('customFields' => $customFieldList), true);
     if ($this->getRequest()->isMethod('post')) {
         // Handle the form submission
         $this->form->bind($request->getPostParameters());
         if ($this->form->isValid()) {
             $empNumber = $this->form->getValue('EmpID');
             if (!$this->IsActionAccessible($empNumber)) {
                 $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
             }
             $this->form->save();
             $this->getUser()->setFlash('customFieldsMessage', array('success', __(TopLevelMessages::UPDATE_SUCCESS)));
         } else {
             $this->getUser()->setFlash('customFieldsMessage', array('warning', __('Failed to Save: Length Exceeded')));
         }
     }
     $this->redirect($this->getRequest()->getReferer() . '#custom');
 }
コード例 #2
0
 /**
  * Delete Custom fields
  * @param sfWebRequest $request
  * @return unknown_type
  */
 public function executeDeleteCustomFields(sfWebRequest $request)
 {
     if (count($request->getParameter('chkLocID')) > 0) {
         $customFieldsService = new CustomFieldsService();
         $customFieldsService->deleteCustomField($request->getParameter('chkLocID'));
         $this->setMessage('SUCCESS', array(TopLevelMessages::DELETE_SUCCESS));
     } else {
         $this->setMessage('NOTICE', array(TopLevelMessages::SELECT_RECORDS));
     }
     $this->redirect('admin/listCustomFields');
 }