public function getAction()
 {
     if ($this->_isUserAllowed(null, null)) {
         if ($this->_hasParam('id') || $this->_hasParam('person')) {
             $id = $this->_getParam('id') ? $this->_getParam('id') : $this->_getParam('person');
             $domain = new Staff_Domain_Employee();
             $emp = $domain->getById($id);
             $this->view->employee = $emp;
         }
     }
 }
예제 #2
0
 /**
  * Adds an element EmployeeId as a Combobox.
  * Defaults:
  * name         = employee_id
  * requires     = true
  * label        = Employee
  * placeholder  = Chosse an employee
  * dimension    = 6
  * modelfield   = employee_id
  * 
  * @param Zend_Form $form The Zend_Form object where the element will be added
  * @param array $options The options to pass in the element
  * @return Zend_Form_Element Zend Form element just created
  */
 public function addElementEmployeeIdCombo($form, $options = array())
 {
     $elementName = isset($options['name']) ? $options['name'] : 'employee_id';
     $modelField = isset($options['modelfield']) ? $options['modelfield'] : 'employee_id';
     $form->addElement('select', $elementName, array('filters' => array('StringTrim'), 'label' => isset($options['label']) ? $options['label'] : 'Employee', 'dimension' => isset($options['dimension']) ? $options['dimension'] : 6, 'placeholder' => 'Choose an employee', 'required' => isset($options['required']) ? $options['required'] : true, 'value' => $this->_model ? $this->_model->{$modelField} : ''));
     $el = $form->getElement($elementName);
     $employeeDomain = new Staff_Domain_Employee();
     $employeeList = $employeeDomain->getAll('name');
     $el->addMultiOption(null, null);
     foreach ($employeeList as $employee) {
         $el->addMultiOption($employee->getId(), $employee->getPerson()->getName());
     }
     if ($this->_model && $this->_model->{$modelField}) {
         $el->setValue($this->_model->{$modelField});
     } else {
         $el->setValue(null);
     }
     return $el;
 }