public function init() { $this->setAttrib('class', 'horizontal-form'); $elements = array(); $elements[] = $this->createElement('hidden', 'fk_id_fefop_contract')->setAttrib('class', 'no-clear')->setDecorators(array('ViewHelper')); $mapperStatus = new Fefop_Model_Mapper_Status(); $rows = $mapperStatus->getStatuses(); $optStatuses[''] = ''; foreach ($rows as $row) { $optStatuses[$row['id_fefop_status']] = $row['status_description']; } $elements[] = $this->createElement('select', 'fk_id_fefop_status')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Status')->addMultiOptions($optStatuses); $elements[] = $this->createElement('textarea', 'description')->setDecorators($this->getDefaultElementDecorators())->addFilter('StringTrim')->addFilter('StringToUpper')->setAttrib('maxlength', 600)->setAttrib('rows', 5)->setAttrib('class', 'm-wrap span12 focused')->setLabel('Deskrisaun'); $this->addElements($elements); App_Form_Toolbar::build($this, self::ID); $this->setDecorators($this->getDefaultFormDecorators()); }
/** * * @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; } }
/** * * @return int|bool */ public function save() { $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter(); $dbAdapter->beginTransaction(); try { $dataForm = $this->_data; $id = $this->saveFollowUp($this->_data['fk_id_fefop_contract'], $this->_data['description']); // If the status was changed if (!empty($dataForm['fk_id_fefop_status'])) { $dataStatus = array('contract' => $dataForm['fk_id_fefop_contract'], 'status' => $dataForm['fk_id_fefop_status'], 'id_fefop_followup' => $id); // Save the new Status $mapperStatus = new Fefop_Model_Mapper_Status(); $mapperStatus->setData($dataStatus)->save(); } $dbAdapter->commit(); return true; } 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(); $elements[] = $this->createElement('hidden', 'minimum_amount')->setValue(0)->setDecorators(array('ViewHelper')); $elements[] = $this->createElement('hidden', 'maximum_amount')->setValue(200000)->setDecorators(array('ViewHelper')); $mapperStatus = new Fefop_Model_Mapper_Status(); $rows = $mapperStatus->getStatuses(); $optStatuses[''] = ''; foreach ($rows as $row) { $optStatuses[$row['id_fefop_status']] = $row['status_description']; } $elements[] = $this->createElement('select', 'fk_id_fefop_status')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->setLabel('Status')->addMultiOptions($optStatuses); $dbFefopProgram = App_Model_DbTable_Factory::get('FEFOPPrograms'); $programs = $dbFefopProgram->fetchAll(); $optPrograms[''] = ''; foreach ($programs as $program) { $optPrograms[$program['id_fefop_programs']] = $program['acronym']; } $elements[] = $this->createElement('select', 'fk_id_fefop_programs')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->setLabel('Programa')->addMultiOptions($optPrograms); $dbFefopModule = App_Model_DbTable_Factory::get('FEFOPModules'); $modules = $dbFefopModule->fetchAll(); $optModules[''] = ''; foreach ($modules as $module) { $optModules[$module['id_fefop_modules']] = $module['acronym']; } $elements[] = $this->createElement('select', 'fk_id_fefop_modules')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->setLabel('Modules')->addMultiOptions($optModules); // List Districts just from Timor $mapperDistrict = new Register_Model_Mapper_AddDistrict(); $districts = $mapperDistrict->listAll(1); $optDistrict[''] = ''; foreach ($districts as $district) { $optDistrict[$district->acronym] = $district->acronym; } $elements[] = $this->createElement('select', 'num_district')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12')->setLabel('Distritu')->addMultiOptions($optDistrict)->setRegisterInArrayValidator(false); $elements[] = $this->createElement('text', 'num_year')->setDecorators($this->getDefaultElementDecorators())->setAttrib('maxlength', 2)->setLabel('Tinan')->setAttrib('class', 'm-wrap span12 text-numeric4'); $elements[] = $this->createElement('text', 'num_sequence')->setDecorators($this->getDefaultElementDecorators())->setAttrib('maxlength', 4)->setLabel('Sequence')->setAttrib('class', 'm-wrap span12'); $this->addElements($elements); }
/** * * @return array */ public function getStatuses() { $mapper = new Fefop_Model_Mapper_Status(); $rows = $mapper->getStatuses(); $statuses = array(); foreach ($rows as $row) { $statuses[$row->id_fefop_status] = $row->status_description; } return $statuses; }
/** * * @param int $idContract * @return boolean */ protected function _tryUpdateStatusContract($idContract) { $mapperContract = new Fefop_Model_Mapper_Contract(); $contract = $mapperContract->detail($idContract); if (Fefop_Model_Mapper_Status::INITIAL != $contract->id_fefop_status) { return false; } $mapperStatus = new Fefop_Model_Mapper_Status(); $dataStatus = array('id_fefop_followup' => null, 'contract' => $idContract, 'status' => Fefop_Model_Mapper_Status::PROGRESS, 'description' => 'PRIMEIRO LANSAMENTU FINANSEIRU'); $mapperStatus->setData($dataStatus)->save(); }