示例#1
0
 public function getServicoCombo()
 {
     $listaServico = new Application_Model_DbTable_Servico();
     return $listaServico->getAdapter()->fetchPairs($listaServico->select()->from('TB_SERVICO', array('ID_SERVICO', 'NM_SERVICO'))->order('NM_SERVICO'));
 }
 public function editServicoAction()
 {
     $form = new Application_Form_Servico();
     $form->getElement("FK_PROJETO")->setAttrib("disable", true);
     $form->getElement("FK_PROJETO")->setRequired(false);
     $form->submit->setLabel('Adicionar');
     // action body
     $servico = new Application_Model_DbTable_Servico();
     //$form->removeElement("tabela_contratacao");
     $this->view->form = $form;
     $noticia = new Application_Model_DbTable_Noticia();
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             $ID_SERVICO = $form->getValue('ID_SERVICO');
             $DS_SERVICO = $form->getValue('DS_SERVICO');
             $FK_OPERADOR = $this->user->getId();
             $NR_CARGA_HORARIA = $form->getValue('NR_CARGA_HORARIA');
             $FK_TIPO_SERVICO = $form->getValue('FK_TIPO_SERVICO');
             $DT_SERVICO = $form->getValue('DT_SERVICO');
             $data_cadastro = new Zend_Date($DT_SERVICO);
             $DT_SERVICO = $data_cadastro->get('YYYY-MM-dd');
             $FK_PROJETO = $form->getValue('FK_PROJETO');
             $FL_PCP = 0;
             try {
                 $servico->updateServicoSemProjeto($ID_SERVICO, $DS_SERVICO, $FK_OPERADOR, $NR_CARGA_HORARIA, $FK_TIPO_SERVICO, $DT_SERVICO, $FL_PCP);
                 $this->view->mensagem = "Atualizado com sucesso";
                 $this->view->erro = 0;
                 $id = $this->_getParam('id', 0);
                 if ($id > 0) {
                     $form->populate($servico->getServico($id));
                 }
                 $form->populate($formData);
                 //$this->_helper->redirector('lista-usuario');
             } catch (Exception $e) {
                 $this->view->mensagem = "Atualizar notícia";
                 $this->view->erro = 1;
                 $this->view->mensagemExcecao = $e->getMessage();
                 //  echo ($e->getCode()."teste".$e->getMessage() );
             }
         } else {
             $id = $this->_getParam('id', 0);
             if ($id > 0) {
                 $form->populate($servico->getServico($id));
             }
             $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>";
             }
         }
     } else {
         $id = $this->_getParam('id', 0);
         if ($id > 0) {
             $form->populate($servico->getServico($id));
         }
     }
 }