/** * */ public function informationAction() { // Form Information $formInformation = $this->_getForm($this->_helper->url('save')); $id = $this->_getParam('id'); if (!empty($id)) { $row = $this->_mapper->detail($id); $data = $row->toArray(); $data['date_start'] = $this->view->date($data['date_start']); $data['date_finish'] = $this->view->date($data['date_finish']); $mapperIsicTimor = new Register_Model_Mapper_IsicTimor(); $classTimor = $mapperIsicTimor->listClassByDisivion($data['fk_id_isicdivision']); $classes = array(); if (!empty($classTimor[$data['fk_id_isicdivision']]['classes'])) { $classes = $classTimor[$data['fk_id_isicdivision']]['classes']; } $opt = array('' => ''); foreach ($classes as $class) { $opt[$class->id_isicclasstimor] = $class->name_classtimor; } $formInformation->getElement('fk_id_isicclasstimor')->addMultiOptions($opt); $formInformation->populate($data); $formInformation->getElement('fk_id_adddistrict')->setAttrib('readonly', true); $formInformation->getElement('fk_id_fefop_modules')->setAttrib('readonly', true); // List the expenses related to the contract $this->view->expenses = $this->_mapper->listExpenses($id); // List the items expense detailed $itensExpense = $this->_mapper->listItemExpenses($id); $dataItensExpense = array(); foreach ($itensExpense as $item) { if (!array_key_exists($item->fk_id_budget_category, $dataItensExpense)) { $dataItensExpense[$item->fk_id_budget_category] = array(); } $dataItensExpense[$item->fk_id_budget_category][] = $item; } $this->view->itemsExpense = $dataItensExpense; if (!$this->view->fefopContract($data['id_fefop_contract'])->isEditable()) { $formInformation->removeDisplayGroup('toolbar'); } } else { $module = $this->_getParam('module'); if (!empty($module)) { $formInformation->getElement('fk_id_fefop_modules')->setValue($module); $constant = Fefop_Model_Mapper_Expense::CONFIG_PCE_CEC_FASE_I; if (Fefop_Model_Mapper_Module::CED == $module) { $constant = Fefop_Model_Mapper_Expense::CONFIG_PCE_CED_FASE_I; } // Fetch the Expenses related to the module $mapperBudgetCategory = new Fefop_Model_Mapper_Expense(); $this->view->expenses = $mapperBudgetCategory->expensesInItem($constant); } else { foreach ($formInformation->getElements() as $element) { $element->setAttrib('disabled', true); } $formInformation->getElement('fk_id_fefop_modules')->setAttrib('disabled', null); } } $this->view->form = $formInformation; }
/** * * @param int $id * @return array */ public function aggregateItemsExpense($itemsExpense, $businessPlan) { $clients = $this->listClientBusinessPlan($businessPlan->id_businessplan); if ($clients->count() > 0) { foreach ($clients as $client) { if (empty($client->business_plan)) { continue; } $itemsSubPlan = $this->listItemExpenses($client->business_plan); foreach ($itemsSubPlan as $item) { if (!array_key_exists($item->fk_id_budget_category, $itemsExpense)) { $itemsExpense[$item->fk_id_budget_category] = array(); } $itemsExpense[$item->fk_id_budget_category][] = $item; } } } if (!empty($businessPlan->fk_id_pce_contract)) { $mapperPceContract = new Fefop_Model_Mapper_PCEContract(); $itemPceContract = $mapperPceContract->listItemExpenses($businessPlan->fk_id_pce_contract); foreach ($itemPceContract as $item) { if (!array_key_exists($item->fk_id_budget_category, $itemsExpense)) { $itemsExpense[$item->fk_id_budget_category] = array(); } $itemsExpense[$item->fk_id_budget_category][] = $item; } } return $itemsExpense; }