public function companyAction() { $form = new Application_Form_Company(); $form->setAction('index/company'); $this->view->form = $form; $company = new Application_Model_DbTable_Company(); $employee = new Application_Model_DbTable_Employee(); $department = new Application_Model_DbTable_Department(); if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if ($form->isValid($formData) && $form->save->isChecked()) { $id = (int) $form->getValue('id'); $name = $form->getValue('name'); $company->updateCompany($id, $name); $this->_helper->redirector('index'); } else { if ($form->isValid($formData) && $form->cut->isChecked()) { $id = (int) $form->getValue('id'); $employee->cutCompany($id); $this->_helper->redirector('index'); } else { if ($form->isValid($formData) && $form->select->isChecked()) { $depId = (int) $form->getValue('departments'); $this->_helper->redirector('department', 'index', null, array('id' => $depId)); } } } } else { $id = 1; $c = $company->getCompany($id); $c[total] = $employee->getTotalForCompany($id); $form->populate($c); $form->fillLists($id); } }
public function getOneBySubIdLot($subId, $lot) { if (empty($subId) || empty($lot)) { return array(); } $table =& $this->dbTable; $where = $table->getAdapter()->quoteInto('sub_id=?', $subId); $where .= ' AND ' . $table->getAdapter()->quoteInto('lot=?', $lot); $antique = $table->fetchAll($table->select()->from($table, '*')->where($where))->toArray(); $antique = $antique[0]; if (!empty($antique)) { if ($this->withActivity) { $tableActivity = new Application_Model_DbTable_Activity(); $activity = $tableActivity->find($antique['activity_id'])->toArray(); $antique['activity'] = $activity[0]; } if ($this->withSubActivity) { $tableSubActivity = new Application_Model_DbTable_SubActivity(); $subActivity = $tableSubActivity->find($antique['sub_id'])->toArray(); $antique['sub'] = $subActivity[0]; } if ($this->withCompany) { $tableCompany = new Application_Model_DbTable_Company(); $company = $tableCompany->find($antique['activity']['company_id'])->toArray(); $antique['company'] = $company[0]; } if ($this->withPhoto) { $modelPhoto = new Application_Model_Photo(); $photo = $modelPhoto->getByAntiqueIds($id); $antique['photo'] = $photo; } } return $antique; }