/** * * @return int|bool */ public function save() { $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter(); $dbAdapter->beginTransaction(); try { $row = $this->_checkDivision($this->_data); if (!empty($row)) { $this->_message->addMessage('Divizaun iha tiha ona.', App_Message::ERROR); return false; } $mapperSection = new Register_Model_Mapper_IsicSection(); $section = $mapperSection->fetchRow($this->_data['fk_id_isicsection']); $this->_data['acronym'] = $section->acronym . $this->_data['acronym']; if (empty($this->_data['id_isicdivision'])) { $history = 'REJISTRU DIVISAUN: %s'; } else { $history = 'ALTERA DIVISAUN: %s'; } $id = parent::_simpleSave(); $history = sprintf($history, $this->_data['name_disivion']); $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'); $elements = array(); $elements[] = $this->createElement('hidden', 'id_isicdivision')->setDecorators(array('ViewHelper')); $mapperSection = new Register_Model_Mapper_IsicSection(); $sections = $mapperSection->fetchAll(); $optSections[''] = ''; foreach ($sections as $section) { $optSections[$section['id_isicsection']] = $section['name_section']; } $elements[] = $this->createElement('select', 'fk_id_isicsection')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Sesaun')->addMultiOptions($optSections)->setRequired(true); $elements[] = $this->createElement('text', 'name_disivion')->setDecorators($this->getDefaultElementDecorators())->addFilter('StringTrim')->addFilter('StringToUpper')->setAttrib('maxlength', 200)->setAttrib('class', 'm-wrap span12 focused')->setLabel('Naran Divizaun')->setRequired(true); $elements[] = $this->createElement('text', 'acronym')->setDecorators($this->getDefaultElementDecorators())->addFilter('StringTrim')->addFilter('StringToUpper')->setAttrib('maxlength', 1)->setAttrib('class', 'm-wrap span4')->setLabel('Sigla')->setRequired(true); $elements[] = $this->createElement('textarea', 'description')->setDecorators($this->getDefaultElementDecorators())->addFilter('StringTrim')->addFilter('StringToUpper')->setAttrib('class', 'span12')->setAttrib('cols', 100)->setAttrib('rows', 5)->setLabel('Deskrisaun'); $this->addElements($elements); App_Form_Toolbar::build($this, self::ID); $this->setDecorators($this->getDefaultFormDecorators()); }
public function init() { $this->setAttrib('class', 'horizontal-form'); $elements = array(); $elements[] = $this->createElement('hidden', 'id_addsucu')->setDecorators(array('ViewHelper')); $mapperSection = new Register_Model_Mapper_IsicSection(); $section = $mapperSection->fetchAll(); $mapperCountry = new Register_Model_Mapper_AddCountry(); $countries = $mapperCountry->fetchAll(); $optNations[''] = ''; foreach ($countries as $country) { $optNations[$country['id_addcountry']] = $country['country']; } $elements[] = $this->createElement('select', 'fk_id_addcountry')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Nasaun')->addMultiOptions($optNations)->setRequired(true); $elements[] = $this->createElement('select', 'fk_id_adddistrict')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Distritu')->setRegisterInArrayValidator(false)->setRequired(true); $elements[] = $this->createElement('select', 'fk_id_addsubdistrict')->setDecorators($this->getDefaultElementDecorators())->setAttrib('class', 'm-wrap span12 chosen')->setLabel('Sub-Distritu')->setRegisterInArrayValidator(false)->setRequired(true); $elements[] = $this->createElement('text', 'sucu')->setDecorators($this->getDefaultElementDecorators())->addFilter('StringTrim')->addFilter('StringToUpper')->setAttrib('maxlength', 200)->setAttrib('class', 'm-wrap span12 focused')->setLabel('Naran Suku')->setRequired(true); $this->addElements($elements); App_Form_Toolbar::build($this, self::ID); }