コード例 #1
0
    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);
        }
    }
コード例 #2
0
ファイル: Registro.php プロジェクト: neeph/NoTengoNiUno
    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')),
            )
        ));
    }