Beispiel #1
0
    public function saveAction() {
        $this->_helper->layout->disableLayout();
        $this->me = $this->fb->api('/me','GET');
        if($this->me) {
            $authNamespace = new Zend_Session_Namespace('Zend_Auth');
            $authNamespace->id = $this->me["id"];
            $authNamespace->name = $this->me["name"];
            $data = new Application_Model_Usuario();
            $data->setNomUsuario($this->me["first_name"]);
            $data->setApeUsuario($this->me["last_name"]);
            $data->setEmaUsuario($this->me["email"]);
            $data->setFbAccessToken($this->fb->getAccessToken());
            $data->setFbSecret($this->fb->getApiSecret());
            $data->setFbUid($this->me["id"]);
            $MP = new Application_Model_UsuarioMP();
            $nuevo = $MP->save($data);
            $this->me["id_usuario"] = $nuevo->ID_USUARIO;
            $authNamespace->id_usuario = $nuevo->ID_USUARIO;
            Zend_Registry::getInstance()->set('me', $this->me);
//            print_r($this->me);
            if($nuevo->NUEVO) {
                $proy = new Application_Model_Proyecto();
                $proy->setNomProyecto("Principal");
                $proy->setDescProyecto("Proyecto principal");
                $proy->setIdTipoMoneda(1);
                $proy->setEstadoProyecto(0);
                $MPProy = new Application_Model_ProyectoMP();
                $idPro = $MPProy->save($proy);
                
                $usPro = new Application_Model_UsuarioProyecto();
                $usPro->setIdUsuario($nuevo->ID_USUARIO);
                $usPro->setIdProyecto($idPro);
                $usPro->setIdNivelAcceso(1);
                $MPUsPro = new Application_Model_UsuarioProyectoMP();
                $MPUsPro->save($usPro);
                
                $usCat = new Application_Model_Categoria();
                $usCat->setCategoria("Sin categoria");
                $usCat->setIdProyecto($idPro);
                $MPCat = new Application_Model_CategoriaMP();
                $MPCat->save($usCat);
                
                try {
                    $this->fb->api('/me/feed', 'POST', array(
                        'link' => 'www.melogaste.com',
                        'message' => 'Estoy usando Me lo Gaste! para registrar mis finanzas, tu puedes usarlo tambien, es gratis!',
                        'icon' => 'http://www.melogaste.com/img/money_bag_ico.png',
                        'picture' => 'http://www.melogaste.com/img/money_bag.png'
                    ));
                } catch(FacebookApiException $e) {}
            }
            $this->_redirect("/Index");
        } else {
            $this->_redirect("/Log");
        }
    }
 public function modAction() {
     $this->_helper->layout->disableLayout();
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest();
         $data = new Application_Model_Categoria();
         $data->setIdProyecto($this->me["id_usuario"]);
         $data->setIdCategoria($request->getParam('id'));
         $data->setCategoria($request->getParam('nomCat'));
         $MP = new Application_Model_CategoriaMP();
         $MP->save($data);
         echo $data->getCategoria();
     }
 }
    public function categoriaAction() {
        $request = $this->getRequest();
        if ($this->getRequest()->isGet()) {
            $id = $request->getParam('id');
            $this->view->id = $id;
            Zend_View_Helper_PaginationControl::setDefaultViewPartial('controls.phtml');
            $regMP = new Application_Model_RegistroMP();
            $formReg = new Application_Form_Registro();
            $this->view->formReg = $formReg;
            $this->view->categoria = new stdClass();
            $this->view->categoria->ing = $regMP->fetchSumTipo(1, $this->me['id_usuario'], $id);
            $this->view->categoria->gas = $regMP->fetchSumTipo(2, $this->me['id_usuario'], $id);
            $this->view->categoria->bal = $this->view->categoria->ing - $this->view->categoria->gas;
            $where = array('ID_PROYECTO' => $this->me['id_usuario'], 'ID_CATEGORIA' => $id);
            $this->view->reg = $regMP->fetchAll(null, $where);
            $attr = array('ID_CATEGORIA', 'CATEGORIA');
            $where = array('ID_PROYECTO' => $this->me["id_usuario"]);
            $catMP = new Application_Model_CategoriaMP();
            $cat = $catMP->fetchAll($attr, $where);
            $this->view->cat = $cat;
            $catArr = array();
            foreach ($cat as $c) {
                $catArr[$c->getIdCategoria()] = $c->getCategoria();
            }
            $this->view->catArr = $catArr;
            $this->view->categoria->nombre = $catArr[$id];
            $paginator = Zend_Paginator::factory($this->view->reg);
            $paginator->setItemCountPerPage(20);
            $paginator->setCurrentPageNumber($this->_getParam('page', 1));
            $this->view->paginator = $paginator;

//            $catMP = new Application_Model_CategoriaMP();
//            $attr = array("ID_CATEGORIA", "CATEGORIA");
//            $where = array('ID_PROYECTO' => $this->me['id_usuario']);
//            $this->view->cat = $catMP->fetchAll($attr, $where);
//            print_r($this->view->cat);
        }
    }
Beispiel #4
0
    public function init() {
        $authNamespace = new Zend_Session_Namespace('Zend_Auth');
        $me = Zend_Registry::get('me');
        $this->clearDecorators()
                ->addDecorator('FormElements')
                ->addDecorator('Form', array('class' => 'form', 'id' => 'trans'))
                ->setElementDecorators(array(
                    array('ViewHelper'),
                    array('Errors'),
                    array('Description', array('tag' => 'span', 'class' => 'hint')),
                    array('Label', array('separator' => ' ', 'style' => 'width: 70px; margin-right: 10px')),
                    array('HtmlTag', array('tag' => 'div', 'class' => 'clearfix')
                    ),
                ));

        $this->setMethod('post');
        
        $usProMP = new Application_Model_ProyectoMP();
        $select = $usProMP->getDbTable()->select();
        $select->from('PROYECTO')
                ->join('USUARIO_PROYECTO', 'PROYECTO.ID_PROYECTO = USUARIO_PROYECTO.ID_PROYECTO', array())
                ->where('USUARIO_PROYECTO.ID_USUARIO = ?', $authNamespace->id_usuario);
        
        $usPro = $usProMP->fetchAll($select);
//        print_r($usPro);
        $selUsPro = array();
        foreach ($usPro as $c) {
            $selUsPro[$c->getIdProyecto()] = $c->getNomProyecto();
        }
        $this->addElement('select', 'idProyecto', array(
            'label' => 'Proyecto:',
            'required' => true,
            'multiOptions' => $selUsPro,
            'class' => 'small-input'
        ));
        
        $attr = array('ID_TIPO_REGISTRO', 'TIPO_REGISTRO');
        $trMP = new Application_Model_TipoRegistroMP();
        $tr = $trMP->fetchAll($attr);
        $selTr = array();
        foreach ($tr as $c) {
            $selTr[$c->getIdTipoRegistro()] = $c->getTipoRegistro();
        }
        $this->addElement('select', 'idTipoRegistro', array(
            'label' => 'Tipo:',
            'required' => true,
            'multiOptions' => $selTr,
            'class' => 'small-input'
        ));

        $attr = array('ID_CATEGORIA', 'CATEGORIA');
        $where = array('ID_PROYECTO' => $me["id_usuario"]);
        $catMP = new Application_Model_CategoriaMP();
        $cat = $catMP->fetchAll($attr, $where);
        $selCat = array();
        foreach ($cat as $c) {
            $selCat[$c->getIdCategoria()] = $c->getCategoria();
        }
        $this->addElement('select', 'idCategoria', array(
            'label' => 'Categoria:',
            'required' => true,
            'multiOptions' => $selCat,
            'class' => 'small-input'
        ));

        $this->addElement('hidden', 'idRegistro', array(
            'value' => null
        ));
        
        $this->addElement('text', 'fechaRegistro', array(
            'label' => 'Fecha:',
            'required' => true,
            'readonly' => true,
            'class' => 'text-input small-input required'
        ));

        $this->addElement('text', 'montoRegistro', array(
            'label' => 'Monto:',
            'required' => true,
            'class' => 'text-input small-input required number'
        ));


        $this->addElement('text', 'descRegistro', array(
            'label' => 'Descripción:',
            'required' => false,
            'class' => 'text-input small-input'
        ));

        $this->addElement('submit', 'submit', array(
            'ignore' => true,
            'description' => '<label style="width:80px;"></label><a href="#" onClick="limpiaTransaccion(); return false;" class="negativo">Cancelar</a>',
            'label' => 'Guardar',
            'class' => 'btn primary',
            'decorators' => array(
                array('ViewHelper'),
                array('Description', array('escape' => false, 'tag' => 'span', 'class' => 'element-cancel-link')),
            )
        ));
    }