/** * */ public function fundPlanningAction() { $this->_helper->layout()->disableLayout(); $form = new Fefop_Form_FundPlanning(); $form->setAction($this->_helper->url('save-planning')); $this->view->form = $form; $mapperModule = new Fefop_Model_Mapper_Module(); $this->view->programs = $mapperModule->listModulesGrouped(); }
/** * * @return int|bool */ public function save() { $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter(); $dbAdapter->beginTransaction(); try { $dataForm = $this->_data; // If there is no business plan yet if (empty($dataForm['id_businessplan'])) { $mapperModule = new Fefop_Model_Mapper_Module(); $module = $mapperModule->fetchModule($dataForm['module']); // Get the District $mapperDistrict = new Register_Model_Mapper_AddDistrict(); $district = $mapperDistrict->fetchRow($dataForm['fk_id_adddistrict']); $dataForm += array('fk_id_fefop_modules' => $module->id_fefop_modules, 'num_district' => $district->acronym, 'num_module' => $module->num_module, 'num_year' => date('y')); $dataForm['num_sequence'] = str_pad($this->_getNumSequence($dataForm), 4, '0', STR_PAD_LEFT); $dataForm['bussines_plan_developer'] = $dataForm['fk_id_perdata']; //If it is not CEG, fetch the first contract if (Fefop_Model_Mapper_Module::CEG != $dataForm['module']) { $dbPceContract = App_Model_DbTable_Factory::get('PCEContract'); $whereContract = array('fk_id_fefop_modules = ?' => $dataForm['module'], 'fk_id_perdata = ?' => $dataForm['fk_id_perdata']); $pceContract = $dbPceContract->fetchRow($whereContract); $dataForm['fk_id_pce_contract'] = $pceContract->id_pce_contract; } } // If it is CED module, check to see if the client has any disability if (Fefop_Model_Mapper_Module::CED == $dataForm['module'] && !Client_Model_Mapper_Client::isHandicapped($dataForm['fk_id_perdata'])) { $this->_message->addMessage("Benefisiariu ne'e la iha defisiénsia ba halo modulu CED.", App_Message::ERROR); return false; } // Check to see if there are another participants $dataForm['partisipants'] = !empty($dataForm['clients']) ? 'G' : 'S'; if (!empty($dataForm['clients'])) { $dataForm['total_partisipants'] = count($dataForm['clients']) + 1; } else { $dataForm['total_partisipants'] = 1; } $this->_data = $dataForm; $id = parent::_simpleSave(); $dataForm['id_businessplan'] = $id; if (!empty($dataForm['clients']) && count($dataForm['clients']) > 5) { throw new Exception('More then five clients'); } // save participants in the Business Plan $this->_saveParticipants($dataForm); $history = "INSERE PLANU NEGOSIU: %s BA PROGRAMA PCE IHA MODULU: %s"; $history = sprintf($history, $id, $dataForm['id_businessplan']); $this->_sysAudit($history); $dbAdapter->commit(); return $id; } catch (Exception $e) { $dbAdapter->rollBack(); $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR); return false; } }
public function init() { $this->setAttrib('class', 'horizontal-form')->setName('search'); $elements = array(); $dbDistrict = App_Model_DbTable_Factory::get('AddDistrict'); $districts = $dbDistrict->fetchAll(); $optCountry[''] = ''; foreach ($districts as $district) { $optCountry[$district['id_adddistrict']] = $district['District']; } $elements[] = $this->createElement('select', 'fk_id_adddistrict')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->addMultiOptions($optCountry)->setLabel('Distritu'); $optModule[''] = ''; $mapperModule = new Fefop_Model_Mapper_Module(); $rows = $mapperModule->listModules(Fefop_Model_Mapper_Program::PCE); foreach ($rows as $row) { $optModule[$row['id_fefop_modules']] = $row['num_module'] . ' - ' . $row['module']; } $elements[] = $this->createElement('select', 'fk_id_fefop_modules')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->addMultiOptions($optModule)->setLabel('Modulu'); $mapperIsicDivision = new Register_Model_Mapper_IsicDivision(); $rows = $mapperIsicDivision->listAll(); $optDivisionTimor[''] = ''; foreach ($rows as $row) { $optDivisionTimor[$row->id_isicdivision] = $row->name_disivion; } $elements[] = $this->createElement('select', 'fk_id_isicdivision')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Setór atividade nian')->setAttrib('onchange', 'Fefop.PceContract.searchIsicClass(this)')->addMultiOptions($optDivisionTimor); $elements[] = $this->createElement('select', 'fk_id_isicclasstimor')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Área negósiu nian')->setRegisterInArrayValidator(false); $optPartisipants[''] = ''; $optPartisipants['S'] = 'Ema ida'; $optPartisipants['G'] = 'Grupu'; $elements[] = $this->createElement('select', 'partisipants')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->setLabel('Grupu')->addMultiOptions($optPartisipants); $mapperPce = new External_Model_Mapper_Pce(); $rows = $mapperPce->listBeneficiaries(); $optBeneficiaries[''] = ''; foreach ($rows as $row) { $optBeneficiaries[$row->id_perdata] = Client_Model_Mapper_Client::buildNumRow($row) . ' - ' . Client_Model_Mapper_Client::buildName($row); } $elements[] = $this->createElement('select', 'bussines_plan_developer')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel("Naran ema ne'ebé dezenvolve Planu Negósiu nian")->addMultiOptions($optBeneficiaries); $optIsSubmitted[''] = ''; $optIsSubmitted['1'] = 'Tiha ona'; $optIsSubmitted['0'] = 'Seidauk'; $elements[] = $this->createElement('select', 'submitted')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->setLabel('Submit')->addMultiOptions($optIsSubmitted); $optIsSubmitted[''] = ''; $optIsSubmitted['1'] = 'Tiha ona'; $optIsSubmitted['0'] = 'Seidauk'; $elements[] = $this->createElement('select', 'contract')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->setLabel('Iha Kontratu')->addMultiOptions($optIsSubmitted); $this->addElements($elements); }
/** * * @return int|bool */ public function save($dataExternal) { try { // Get the Module $mapperModule = new Fefop_Model_Mapper_Module(); $module = $mapperModule->fetchModule($dataExternal['module']); // Get the District $mapperDistrict = new Register_Model_Mapper_AddDistrict(); $district = $mapperDistrict->fetchRow($dataExternal['district']); $data = array('fk_id_fefop_modules' => $module->id_fefop_modules, 'fk_id_fefop_programs' => $module->id_fefop_programs, 'fk_id_sysuser' => Zend_Auth::getInstance()->getIdentity()->id_sysuser, 'num_district' => $district->acronym, 'num_program' => $module->num_program, 'num_module' => $module->num_module, 'num_year' => date('y')); $data['num_sequence'] = str_pad($this->_getNumSequence($data), 4, '0', STR_PAD_LEFT); $this->_data = $data; $id = parent::_simpleSave($this->_dbTable, false); $dataStatus = array('contract' => $id, 'status' => !empty($dataExternal['status']) ? $dataExternal['status'] : Fefop_Model_Mapper_Status::ANALYSIS, 'description' => 'Kontraktu rejistu'); $mapperStatus = new Fefop_Model_Mapper_Status(); $mapperStatus->setData($dataStatus)->save(); return $id; } catch (Exception $ex) { throw $ex; } }