public function init()
 {
     /* Form Elements & Other Definitions Here ... */
     if (!isset($this->_PROJETOS)) {
         $projeto = new Application_Model_DbTable_Projeto();
         $this->_PROJETOS = $projeto->getProjetoCombo();
     }
     $this->setName('FormularioServico');
     $FL_VALIDAR_SERVICO = new Zend_Form_Element_Hidden('FL_VALIDAR_SERVICO');
     $FL_VALIDAR_SERVICO->addFilter('Int');
     $FL_VALIDAR_SERVICO->removeDecorator('Label');
     $ID_SERVICO = new Zend_Form_Element_Hidden('ID_SERVICO');
     $ID_SERVICO->addFilter('Int');
     $ID_SERVICO->removeDecorator('Label');
     $FK_OPERADOR = new Zend_Form_Element_Hidden('FK_OPERADOR');
     $FK_OPERADOR->addFilter('Int');
     $FK_OPERADOR->removeDecorator('Label');
     $FL_PCP = new Zend_Form_Element_Hidden('FL_PCP');
     $FL_PCP->addFilter('Int');
     $FL_PCP->removeDecorator('Label');
     /* 
      */
     $FK_TIPO_SERVICO = new Zend_Form_Element_Select('FK_TIPO_SERVICO');
     $tipoServico = new Application_Model_DbTable_TipoServico();
     $FK_TIPO_SERVICO->setLabel('TIPO PCP');
     $FK_TIPO_SERVICO->setMultiOptions($tipoServico->getTipoServicoCombo())->setRequired(true)->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('Label')->setAttrib('class', 'form-control select2');
     $FK_PROJETO = new Zend_Form_Element_Hidden('FK_PROJETO');
     $FK_PROJETO->addFilter('Int');
     $FK_PROJETO->removeDecorator('Label');
     $FK_PROJETO1 = new Zend_Form_Element_Text('FK_PROJETO1');
     $FK_PROJETO1->setLabel('PROJETO')->setAttrib('class', 'form-control');
     $DS_SERVICO = new Zend_Form_Element_Textarea('DS_SERVICO');
     $DS_SERVICO->setLabel('PCP')->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('Label')->setAttrib('class', 'form-control ')->setAttrib('rows', '20');
     $DT_SERVICO = new Zend_Form_Element_Text('DT_SERVICO');
     $DT_SERVICO->setLabel('DATA')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('Label')->setAttrib('class', 'form-control')->addPrefixPath('Aplicacao_Validate', 'Aplicacao/Validate/', 'validate')->addValidator(new Aplicacao_Validate_Data())->setAttrib('placeholder', 'Enter serviço ');
     $NR_CARGA_HORARIA = new Zend_Form_Element_Text('NR_CARGA_HORARIA');
     $NR_CARGA_HORARIA->setLabel('CARGA HORARIA')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('Label')->addValidator('float', true, array('locale' => 'en_US'))->setAttrib('class', 'form-control')->setAttrib('placeholder', 'Enter carga horária ');
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel("Adiconar");
     $submit->setAttrib('id', 'submitbutton');
     $submit->removeDecorator('DtDdWrapper')->setAttrib('class', 'btn btn-primary button')->removeDecorator('HtmlTag')->removeDecorator('Label');
     $this->addElements(array($FK_PROJETO1, $FL_VALIDAR_SERVICO, $ID_SERVICO, $FK_PROJETO, $DS_SERVICO, $FK_OPERADOR, $FK_TIPO_SERVICO, $DT_SERVICO, $FL_PCP, $NR_CARGA_HORARIA, $submit));
     $this->setDecorators(array(array('ViewScript', array('viewScript' => '/forms/formularioPcpProjeto.phtml'))));
 }
 public function getTipoServicoCombo()
 {
     $listaTipoServico = new Application_Model_DbTable_TipoServico();
     return $listaTipoServico->getAdapter()->fetchPairs($listaTipoServico->select()->from('TB_TIPO_SERVICO', array('ID_TIPO_SERVICO', 'NM_TIPO_SERVICO'))->order('NM_TIPO_SERVICO'));
 }
 public function addTipoServicoAction()
 {
     $form = new Application_Form_TipoServico();
     $form->submit->setLabel('Adicionar');
     //$form->removeElement("tabela_contratacao");
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         Zend_Registry::get('logger')->log($formData, Zend_Log::INFO);
         if ($form->isValid($formData)) {
             try {
                 $NM_TIPO_SERVICO = $form->getValue('NM_TIPO_SERVICO');
                 $tipoServico = new Application_Model_DbTable_TipoServico();
                 $tipoServico->addTipoServico($NM_TIPO_SERVICO);
                 //$descricao=$form->getValue('descricao');
                 //$centroCusto->addCentroCusto($descricao);
                 $this->view->erro = 0;
                 $this->view->mensagem = "Adicionado com sucesso";
                 $form->reset();
             } catch (Exception $erro) {
                 Zend_Registry::get('logger')->log("Erroooooooooooooooo", Zend_Log::INFO);
                 $this->view->mensagem = $erro->getMessage();
                 $this->view->erro = 1;
                 //exit;
             }
         } else {
             Zend_Registry::get('logger')->log("formulario inválido", Zend_Log::INFO);
             $form->populate($formData);
             $arrMessages = $form->getMessages();
             foreach ($arrMessages as $field => $arrErrors) {
                 $this->view->erro = 1;
                 $this->view->mensagem = $this->view->mensagem . $form->getElement($field)->getLabel() . $this->view->formErrors($arrErrors) . "<br>";
             }
         }
     }
 }