public function listaprojetosAction() { //** Usuario Logado ************************************************/ $auth = Zend_Auth::getInstance(); // pega a autenticação $idusuario = $auth->getIdentity()->usu_codigo; $GrupoAtivo = new Zend_Session_Namespace('GrupoAtivo'); // cria a sessão com o grupo ativo $codOrgao = $GrupoAtivo->codOrgao; // Órgão ativo na sessão $this->view->codOrgao = $codOrgao; $this->view->idUsuarioLogado = $idusuario; /******************************************************************/ //DEFINE PARAMETROS DE ORDENACAO / QTDE. REG POR PAG. / PAGINACAO if ($this->_request->getParam("qtde")) { $this->intTamPag = $this->_request->getParam("qtde"); } $order = array(); //==== 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"); $order = array($campo . " " . $ordem); $ordenacao = "&campo=" . $campo . "&ordem=" . $ordem; } else { $campo = null; // $order = array('stPrincipal desc', 'DtDevolucao', 'DtEnvio'); $order = array('IdPRONAC', 'stPrincipal desc', 'DtDevolucao', 'DtEnvio'); $ordenacao = null; } $pag = 1; $get = Zend_Registry::get('get'); if (isset($get->pag)) { $pag = $get->pag; } $inicio = $pag > 1 ? ($pag - 1) * $this->intTamPag : 0; /* ================== PAGINACAO ======================*/ $where = array(); $where['t.stEstado = ?'] = 0; $where['t.FecharAnalise NOT IN (?)'] = array(1); $where['t.tipoanalise IN (?)'] = array(3, 1); $where['p.Situacao IN (?)'] = array("B11", "B14"); $where['t.idOrgao = ?'] = $codOrgao; if (isset($_POST['pronac']) && !empty($_POST['pronac']) || isset($_GET['pronac']) && !empty($_GET['pronac'])) { $where['AnoProjeto+Sequencial = ?'] = isset($_POST['pronac']) ? $_POST['pronac'] : $_GET['pronac']; $this->view->pronacProjeto = isset($_POST['pronac']) ? $_POST['pronac'] : $_GET['pronac']; } if (isset($_POST['tipoFiltro']) || isset($_GET['tipoFiltro'])) { $situacaoProjeto = isset($_POST['tipoFiltro']) ? $_POST['tipoFiltro'] : $_GET['tipoFiltro']; $this->view->situacaoProjeto = $situacaoProjeto; switch ($situacaoProjeto) { case 0: break; case 1: $where['SAC.dbo.fnChecarDistribuicaoProjeto(p.IdPRONAC, t.idProduto, t.TipoAnalise)= ?'] = 'Aguardando distribuição'; break; case 2: $where['SAC.dbo.fnChecarDistribuicaoProjeto(p.IdPRONAC, t.idProduto, t.TipoAnalise)= ?'] = 'Análise concluída'; break; case 3: $where['SAC.dbo.fnChecarDistribuicaoProjeto(p.IdPRONAC, t.idProduto, t.TipoAnalise)= ?'] = 'Devolvida p/nova análise'; break; } } else { $where['SAC.dbo.fnChecarDistribuicaoProjeto(p.IdPRONAC, t.idProduto, t.TipoAnalise)= ?'] = 'Aguardando distribuição'; $this->view->situacaoProjeto = 1; } $tbDistribuirParecer = new tbDistribuirParecer(); $total = $tbDistribuirParecer->painelAnaliseTecnica($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; $busca = $tbDistribuirParecer->painelAnaliseTecnica($where, $order, $tamanho, $inicio); $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; $this->view->qtdDocumentos = $total; $this->view->dados = $busca; $this->view->intTamPag = $this->intTamPag; }