示例#1
0
文件: Company.php 项目: nuzil/101repo
 public function fillLists($id)
 {
     $department = new Application_Model_DbTable_Department();
     $departments = $department->getDepartmentsForCompany(1);
     foreach ($departments as $dep) {
         $this->departmentList->addMultiOption($dep[id], $dep[name]);
     }
 }
示例#2
0
 public function cutDepartment($id)
 {
     $id = (int) $id;
     $this->_db->query("UPDATE employee SET salary = salary / 2 WHERE did = " . $id);
     $department = new Application_Model_DbTable_Department();
     $subdepartments = $department->getDepartmentsForDepartment($id);
     foreach ($subdepartments as $dep) {
         $depId = $dep[id];
         $this->cutDepartment($depId);
     }
 }
示例#3
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]);
         }
     }
 }
示例#4
0
 public function departmentAction()
 {
     $department = new Application_Model_DbTable_Department();
     $employee = new Application_Model_DbTable_Employee();
     $form = new Application_Form_Department();
     $form->setAction('index/department');
     $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');
             $errorMessage = $department->updateDepartment($id, $name);
             if ($errorMessage != "") {
                 echo $errorMessage;
             } else {
                 $this->_helper->redirector('department', 'index', null, array('id' => $id));
             }
         } else {
             if ($form->cut->isChecked()) {
                 $id = (int) $form->getValue('id');
                 $employee->cutDepartment($id);
                 $this->_helper->redirector('department', 'index', null, array('id' => $id));
             } else {
                 if ($form->selectDepartment->isChecked()) {
                     $depId = (int) $form->getValue('departments');
                     $this->_helper->redirector('department', 'index', null, array('id' => $depId));
                 } else {
                     if ($form->selectEmployee->isChecked()) {
                         $empId = (int) $form->getValue('employees');
                         $this->_helper->redirector('employee', 'index', null, array('id' => $empId));
                     } else {
                         if ($form->edit->isChecked()) {
                             $empId = (int) $form->getValue('managerId');
                             $this->_helper->redirector('employee', 'index', null, array('id' => $empId));
                         } else {
                             if ($form->back->isChecked()) {
                                 $id = (int) $form->getValue('id');
                                 $depTemp = $department->getDepartment($id);
                                 if ($depTemp[did] == null) {
                                     $this->_helper->redirector('index');
                                 } else {
                                     $this->_helper->redirector('department', 'index', null, array('id' => $depTemp[did]));
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         $id = $this->_getParam('id', 0);
         $d = $department->getDepartment($id);
         $manager = $employee->getManagerForDepartment($id);
         $d[manager] = $manager[name];
         $d[managerId] = $manager[id];
         $d[total] = $employee->getTotalForDepartment($id);
         $form->populate($d);
         $form->fillLists($id);
     }
 }