コード例 #1
0
 public function listarprojetosAction()
 {
     $this->_helper->layout->disableLayout();
     // desabilita o Zend_Layout
     //DEFINE PARAMETROS DE ORDENACAO / QTDE. REG POR PAG. / PAGINACAO
     if ($this->_request->getParam("qtde")) {
         $this->intTamPag = $this->_request->getParam("qtde");
     }
     $order = array();
     $pag = 1;
     $get = Zend_Registry::get('get');
     //xd($get);
     if (isset($get->pag)) {
         $pag = $get->pag;
     }
     $inicio = $pag > 1 ? ($pag - 1) * $this->intTamPag : 0;
     //==== parametro de ordenacao  ======//
     if ($this->_request->getParam("ordem")) {
         $ordem = $this->_request->getParam("ordem");
         if ($ordem == "ASC") {
             $novaOrdem = "DESC";
         } else {
             $novaOrdem = "ASC";
         }
     } else {
         $ordem = "ASC";
         $novaOrdem = "ASC";
     }
     //==== campo de ordenacao  ======//
     if ($this->_request->getParam("campo")) {
         $campo = $this->_request->getParam("campo");
         //xd($campo);
         $order = array($campo . " " . $ordem);
         $ordenacao = "&campo=" . $campo . "&ordem=" . $ordem;
     } else {
         $campo = null;
         $order = array("12 DESC");
         //ordenado por Nota
         $ordenacao = null;
     }
     $this->view->filtros = '';
     $where = array();
     $where['pro.Situacao = ? '] = 'G51';
     //SE ENVIOU EDITAL
     if ($this->_request->getParam("edital")) {
         //$where['fod.nmFormDocumento = ? ']=$this->_request->getParam("edital");
         $where['edi.idEdital = ? '] = $this->_request->getParam("edital");
         $this->view->Edital = $this->_request->getParam("edital");
         $this->view->filtros = '&edital=' . $this->_request->getParam("edital");
     }
     //SE ENVIOU REGIAO
     $regiao = trim($this->_request->getParam("regiao"));
     if (!empty($regiao)) {
         $arrUfs = AvaliarProjetosComissaoDAO::buscaUF($regiao);
         foreach ($arrUfs as $uf) {
             $arrFiltroUfs[] = $uf->Uf;
         }
         $where['pro.UfProjeto in (?) '] = $arrFiltroUfs;
         $this->view->Edital = $this->_request->getParam("edital");
         $this->view->RegiaoSel = $regiao;
         $this->view->buscaUF = $arrUfs;
         $this->view->filtros .= '&regiao=' . $regiao;
     } else {
         $buscaUF = AvaliarProjetosComissaoDAO::buscaUF();
         $this->view->buscaUF = $buscaUF;
     }
     //SE ENVIOU UF
     if ($this->_request->getParam("uf")) {
         $where['pro.UfProjeto = ? '] = $this->_request->getParam("uf");
         $this->view->UfSel = $this->_request->getParam("uf");
         $this->view->filtros .= '&uf=' . $this->_request->getParam("uf");
     }
     $tblProjeto = new Projetos();
     $total = $tblProjeto->buscaProjetosComissao($where, $order, null, null, true);
     $fim = $inicio + $this->intTamPag;
     $totalPag = (int) ($total % $this->intTamPag == 0 ? $total / $this->intTamPag : $total / $this->intTamPag + 1);
     $tamanho = $fim > $total ? $total - $inicio : $this->intTamPag;
     $buscaProjetosComissao = $tblProjeto->buscaProjetosComissao($where, $order, $tamanho, $inicio);
     //$tblProjeto->buscarProjetosConsolidados($where, $order, $tamanho, $inicio);
     $this->view->buscaProjetos = $buscaProjetosComissao;
     $buscaRegiao = AvaliarProjetosComissaoDAO::buscaRegiao();
     $this->view->buscaRegiao = $buscaRegiao;
     $buscaEdital = AvaliarProjetosComissaoDAO::buscaEdital();
     $this->view->buscaEdital = $buscaEdital;
     $paginacao = array("pag" => $pag, "qtde" => $this->intTamPag, "campo" => $campo, "ordem" => $ordem, "ordenacao" => $ordenacao, "novaOrdem" => $novaOrdem, "total" => $total, "inicio" => $inicio + 1, "fim" => $fim, "totalPag" => $totalPag, "Itenspag" => $this->intTamPag, "tamanho" => $tamanho);
     $this->view->paginacao = $paginacao;
 }