public function xlsPareceresAction()
 {
     $this->view->tipos = TramitarDocumentosDAO::listaTipoDocumentos();
     /* ================== PAGINACAO ======================*/
     //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("DtConsolidacao", "PRONAC");
         $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 ======================*/
     function formatadata($data)
     {
         if ($data) {
             $dia = substr($data, 0, 2);
             $mes = substr($data, 3, 2);
             $ano = substr($data, 6, 4);
             $dataformatada = $ano . "/" . $mes . "/" . $dia;
         } else {
             $dataformatada = null;
         }
         return $dataformatada;
     }
     /** Usuario Logado ************************************************/
     $auth = Zend_Auth::getInstance();
     // instancia da 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
     $codGrupo = $GrupoAtivo->codGrupo;
     //  Perfil ativo na sessão
     $this->view->codOrgao = $codOrgao;
     $this->view->codGrupo = $codGrupo;
     $this->view->idUsuarioLogado = $idusuario;
     $orgSuperior = GerenciarPareceresDAO::buscarUnidades($codOrgao);
     //$orgSuperior = GerenciarPareceresDAO::buscarUnidades($idusuario);
     //xd($codOrgao);
     $org_superior = $orgSuperior[0]->org_superior;
     /******************************************************************/
     $tblProjeto = new Projetos();
     $post = Zend_Registry::get('post');
     $idPronac = $post->idpronac;
     $pronac = $post->pronac;
     $nometc = $post->nometc;
     $nomeP = $post->nomeP;
     $tipoPesqPronente = $post->tipoPesqPronente;
     $nomeProponente = $post->nomeProponente;
     $dtI = formatadata($post->dtI);
     $dtF = formatadata($post->dtF);
     $sutuacaotc = $post->situacaotc;
     $situacao = $post->situacao;
     $where = array();
     if (!empty($idPronac)) {
         $where['p.IdPRONAC = ?'] = $idPronac;
     }
     //Pronac **************************************************************
     if (!empty($pronac)) {
         $where['(p.AnoProjeto + p.Sequencial) = ?'] = $pronac;
     }
     //Nome do Projeto *****************************************************
     if (!empty($nomeP) && $nometc == 1) {
         $where['p.NomeProjeto LIKE ?'] = $nomeP . "%";
         //$sql .= " AND p.NomeProjeto like '".$nomeP."%' ";
     } else {
         if (!empty($nomeP) && $nometc == 2) {
             $where['p.NomeProjeto LIKE ?'] = "%" . $nomeP . "%";
         } else {
             if (!empty($nomeP) && $nometc == 3) {
                 $where['p.NomeProjeto <> ?'] = $nomeP;
             } else {
                 $where['p.NomeProjeto LIKE ?'] = "%" . $nomeP . "%";
             }
         }
     }
     //Nome do Proponente *****************************************************
     if (!empty($nomeProponente) && $tipoPesqPronente == 1) {
         $where['n.Descricao LIKE ?'] = $nomeProponente . "%";
         //$sql .= " AND p.NomeProjeto like '".$nomeP."%' ";
     }
     if (!empty($nomeProponente) && $tipoPesqPronente == 2) {
         $where['n.Descricao LIKE ?'] = "%" . $nomeProponente . "%";
     }
     if (!empty($nomeProponente) && $tipoPesqPronente == 3) {
         $where['n.Descricao <> ?'] = $nomeProponente;
     }
     //Data de consolidação
     if ($dtI && $dtF == null) {
         $where['convert(char(8),pa.DtParecer,112) = ?'] = str_replace("/", "", $dtI);
         //$sql .= " AND cast(convert(char(8),pa.DtParecer,112)as smalldatetime) = '".$dtI."'";
     }
     if ($dtI && $dtF) {
         $where['convert(char(8),pa.DtParecer,112) >= ?'] = str_replace("/", "", $dtI);
         $where['convert(char(8),pa.DtParecer,112) <= ?'] = str_replace("/", "", $dtF);
         //$sql .= " AND cast(convert(char(8),pa.DtParecer,112)as smalldatetime) between '".$dtI."' AND '".$dtF."' ";
     }
     /* Situação ************************************************************
      * C09 - Projeto fora da pauta - Proponente Inabilitado
      * C20 - Análise Técnica Concluida
      * C25 - Parecer Técnico desfavorável
      */
     if ($situacao && $sutuacaotc == 1) {
         $where['p.Situacao = ?'] = "'" . $situacao . "'";
     }
     if ($situacao && $sutuacaotc == 2) {
         $where['p.Situacao <> ?'] = "'" . $situacao . "'";
     }
     $where['p.Orgao = ?'] = $codOrgao;
     $where['p.Mecanismo = ?'] = 1;
     $where['p.AnoProjeto > ?'] = '08';
     $where['p.Situacao IN (?)'] = array("C09", "C20", "C25");
     $total = $tblProjeto->buscarProjetosConsolidados($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 = $tblProjeto->buscarProjetosConsolidados($where, $order, $tamanho, $inicio);
     $html = "<table cellspacing='0' cellpadding='2' border='1' align='center' width='99%'>\n                <tr>\n                    <th width='100' align='left'>PRONAC</th>\n                    <th width='50' align='left'>Nome do Projeto</th>\n                    <th width='100' align='left'>Situação</th>\n                    <th width='100' align='center'>Nome do Proponente</th>\n                    <th width='100' align='center'>Dt. Consolidação</th>\n                </tr>";
     foreach ($busca as $d) {
         $html .= "  <tr>\n                            <td>" . $d->PRONAC . "</td>\n                            <td>" . $d->NomeProjeto . "</td>\n                            <td>" . $d->Situacao . "</td>\n                            <td>" . $d->NomeProponente . "</td>\n                            <td align='center'>" . $d->DtConsolidacao . "</td>\n                    </tr>";
     }
     $html .= "</table>";
     $this->view->html = $html;
     $this->_helper->layout->disableLayout();
     // Desabilita o Zend Layout
 }