/**
  * 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 CustomFieldConfigurationService();
     $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');
 }
Ejemplo n.º 2
0
 /**
  * List Custom fields
  * @param sfWebRequest $request
  * @return void
  */
 public function executeListCustomFields(sfWebRequest $request)
 {
     $customFieldsService = new CustomFieldConfigurationService();
     $this->sorter = new ListSorter('propoerty.sort', 'admin_module', $this->getUser(), array('field_num', ListSorter::ASCENDING));
     if ($request->getParameter('sort')) {
         $this->sorter->setSort(array($request->getParameter('sort'), $request->getParameter('order')));
         $this->listCustomField = $customFieldsService->getCustomFieldList($request->getParameter('sort'), $request->getParameter('order'));
     } else {
         $this->listCustomField = $customFieldsService->getCustomFieldList();
     }
 }