public function cadastrarAction()
 {
     $form = new Application_Form_Categoria();
     $var = $this->getAllParams();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($var)) {
             $dados = $form->getValues();
             $inserir = array('categoria' => $dados['categoria']);
             $tb = new Application_Model_DbTable_Categoria();
             $tb->insert($inserir);
             $this->_helper->redirector->gotoSimpleAndExit('index');
         }
     }
     $this->view->form = $form;
 }
Пример #2
0
 public function editarAction()
 {
     $id = $this->_getParam('id');
     $where = 'id=' . $id;
     $categoria = $this->_categoria->fetchRow($where);
     $this->view->c = $categoria->toArray();
     $form = new Application_Form_Categoria();
     if (!is_null($categoria)) {
         if ($this->_request->isPost() && $form->isValid($this->_request->getPost())) {
             $this->_categoria->update($form->getValues(), $where);
             $this->_helper->FlashMessenger('Se modificó una categoría');
             $this->_redirect($this->URL);
         }
         $form->setDefaults($categoria->toArray());
         $this->view->form = $form;
     } else {
         $this->_helper->FlashMessenger('No existe esta categoría');
         $this->_redirect($this->URL);
     }
 }
Пример #3
0
    public function addAction() {
        $request = $this->getRequest();
        $form = new Application_Form_Categoria();

        if ($this->getRequest()->isPost()) {
            if ($form->isValid($request->getPost())) {
                $data = new Application_Model_Categoria($form->getValues());
//                $data->setIdProyecto($this->me["id_usuario"]);
                $MP = new Application_Model_CategoriaMP();
                $cat = $MP->save($data);
                $out["idCategoria"] = $cat["ID_CATEGORIA"];
                $out["ingresos"] = 0;
                $out["egresos"] = 0;
                $out["categoria"] = $cat["CATEGORIA"];
                $this->view->res = $out;
//                return $this->_helper->redirector('index');
            }
        }

        $this->view->form = $form;
    }