Exemplo n.º 1
0
 public function fillLists($id)
 {
     $department = new Application_Model_DbTable_Department();
     $departments = $department->getDepartmentsForDepartment($id);
     foreach ($departments as $dep) {
         $this->departmentList->addMultiOption($dep[id], $dep[name]);
     }
     $employee = new Application_Model_DbTable_Employee();
     $employees = $employee->getEmployeesForDepartment($id);
     foreach ($employees as $emp) {
         if ($emp[manager] == 0) {
             $this->employeeList->addMultiOption($emp[id], $emp[name]);
         }
     }
 }
Exemplo n.º 2
0
 public function employeeAction()
 {
     $employee = new Application_Model_DbTable_Employee();
     $form = new Application_Form_Employee();
     $form->setAction('index/employee');
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         $form->isValid($formData);
         if ($form->isValid($formData) && $form->save->isChecked()) {
             $id = (int) $form->getValue('id');
             $name = $form->getValue('name');
             $address = $form->getValue('address');
             $salary = $form->getValue('salary');
             $errorMessage = $employee->updateEmployee($id, $name, $address, $salary);
             if ($errorMessage != "") {
                 echo $errorMessage;
             } else {
                 $this->_helper->redirector('employee', 'index', null, array('id' => $id));
             }
         } else {
             if ($form->cut->isChecked()) {
                 $id = (int) $form->getValue('id');
                 $employee->cutEmployee($id);
                 $this->_helper->redirector('employee', 'index', null, array('id' => $id));
             }
         }
     } else {
         $id = $this->_getParam('id', 0);
         $e = $employee->getEmployee($id);
         $form->populate($e);
     }
 }