public function listararquivosAction()
 {
     $opcao = !empty($_GET['classificao']) ? $_GET['classificao'] : -1;
     $where = array('Opcao = ?' => $opcao);
     $tblDocumentos = new DocumentosExigidos();
     $Documento = $tblDocumentos->buscar($where, 'Descricao desc');
     foreach ($Documento as $doc) {
         echo utf8_encode('<option value="' . $doc->Codigo . '" >' . $doc->Descricao . '</option>');
     }
     exit(0);
 }
 public function imprimirAction()
 {
     $this->_helper->layout->disableLayout();
     // Desabilita o Zend Layout
     $verificacaodao = new Verificacao();
     $Projetosdao = new Projetos();
     $PreProjetodao = new PreProjeto();
     $DocumentosExigidosDao = new DocumentosExigidos();
     $post = Zend_Registry::get('post');
     $this->view->idPronac = $this->idPronac;
     $this->view->idPreProjeto = $this->idPreProjeto;
     $this->view->idProduto = $this->idProduto;
     $this->view->idDiligencia = $post->idDiligencia;
     $this->view->idAvaliacaoProposta = $post->idAvaliacaoProposta;
     if ($this->view->idDiligencia) {
         $resp = $Projetosdao->listarDiligencias(array('pro.IdPRONAC = ?' => $this->view->idPronac, 'dil.idDiligencia in (?)' => $this->view->idDiligencia));
         $this->view->nmCodigo = 'PRONAC';
         $this->view->nmTipo = 'DO PROJETO';
         $this->view->dadosDiligencia = $resp;
     }
     if ($this->view->idAvaliacaoProposta) {
         if ($this->idPronac) {
             $projeto = $Projetosdao->buscar(array('IdPRONAC = ?' => $this->idPronac));
             $idPreProjeto = $projeto[0]->idProjeto;
         }
         if ($projeto[0]->idProjeto) {
             $idPreProjeto = $projeto[0]->idProjeto;
         }
         $resp = $PreProjetodao->listarDiligenciasPreProjeto(array('pre.idPreProjeto = ?' => $idPreProjeto, ' aval.idAvaliacaoProposta in (?)' => $this->view->idAvaliacaoProposta));
         $this->view->nmCodigo = 'Nr PROPOSTA';
         $this->view->nmTipo = 'DA PROPOSTA';
         $this->view->dadosDiligencia = $resp;
     }
     if ($resp[0]->idCodigoDocumentosExigidos) {
         $documento = $DocumentosExigidosDao->listarDocumentosExigido($resp[0]->idCodigoDocumentosExigidos);
         $this->view->DocumentosExigido = $documento[0]->Descricao;
         $this->view->Opcao = $documento[0]->Opcao;
     }
     $arquivos = array();
     if ($this->view->idDiligencia) {
         $arquivo = new Arquivo();
         foreach ($post->idDiligencia as $ids) {
             $arquivos[$ids] = $arquivo->buscarAnexosDiligencias($ids);
         }
     }
     $this->view->arquivos = $arquivos;
 }
 /**
  * Metodo que mostra tela de consulta
  * @param void
  * @return objeto
  */
 public function tabelasAction()
 {
     $get = Zend_Registry::get("get");
     if (!empty($get->consulta)) {
         //header("Content-Type: text/html; charset=ISO-8859-1");
         $this->_helper->viewRenderer->setNoRender(true);
         $this->_helper->layout->disableLayout();
         $post = Zend_Registry::get("post");
         if ($get->consulta == "itens") {
             $tbl = new Produto();
             if ($post->tipo == 'xls' || $post->tipo == 'pdf') {
                 //buscando os registros no banco de dados
                 $tamanho = -1;
                 $inicio = -1;
                 $pag = 0;
                 $totalPag = 0;
                 $fim = 0;
                 $rs = $tbl->buscar(array("stEstado = ?" => 0), array(), $tamanho, $inicio);
                 $this->_forward('preparar-xls-pdf', null, null, array('dados' => $rs, 'view' => 'operacional/preparar-xls-pdf-itensproduto.phtml', 'tipo' => $post->tipo));
             } else {
                 //controlando a paginacao
                 $this->intTamPag = 10;
                 $pag = 1;
                 if (isset($post->pag)) {
                     $pag = $post->pag;
                 }
                 if (isset($post->tamPag)) {
                     $this->intTamPag = $post->tamPag;
                 }
                 $inicio = $pag > 1 ? ($pag - 1) * $this->intTamPag : 0;
                 $fim = $inicio + $this->intTamPag;
                 //Varifica se foi solicitado a ordenação
                 if (!empty($post->ordenacao)) {
                     $ordem[] = "{$post->ordenacao} {$post->tipoOrdenacao}";
                 } else {
                     $ordem = array('1 ASC');
                 }
                 $rs = $tbl->buscar(array("stEstado = ?" => 0), $ordem, null, null);
                 $total = count($rs);
                 //xd($total);
                 if ($fim > $total) {
                     $fim = $total;
                 }
                 $totalPag = (int) ($total % $this->intTamPag == 0 ? $total / $this->intTamPag : $total / $this->intTamPag + 1);
                 $tamanho = $fim > $total ? $total - $inicio : $this->intTamPag;
                 if ($fim > $total) {
                     $fim = $total;
                 }
                 $rs2 = $tbl->buscar(array("stEstado = ?" => 0), $ordem, $tamanho, $inicio);
                 $arrDados = array("dados" => $rs2, "pag" => $pag, "total" => $total, "inicio" => $inicio + 1, "fim" => $fim, "totalPag" => $totalPag, "parametrosBusca" => $_POST, "urlPaginacao" => $this->_urlPadrao . "/operacional/tabelas");
                 $this->montaTela("operacional/itensproduto.phtml", $arrDados);
             }
         }
         if ($get->consulta == "documentos") {
             $tbl = new DocumentosExigidos();
             if ($post->tipo == 'xls' || $post->tipo == 'pdf') {
                 //buscando os registros no banco de dados
                 $tamanho = -1;
                 $inicio = -1;
                 $pag = 0;
                 $totalPag = 0;
                 $fim = 0;
                 $arrBusca = array();
                 $arrBusca['Codigo > ?'] = 0;
                 $rs = $tbl->buscar($arrBusca, array(), $tamanho, $inicio);
                 $this->_forward('preparar-xls-pdf', null, null, array('dados' => $rs, 'view' => 'operacional/preparar-xls-pdf-documentosexigidos.phtml', 'tipo' => $post->tipo));
             } else {
                 //controlando a paginacao
                 $this->intTamPag = 10;
                 $pag = 1;
                 if (isset($post->pag)) {
                     $pag = $post->pag;
                 }
                 if (isset($post->tamPag)) {
                     $this->intTamPag = $post->tamPag;
                 }
                 $inicio = $pag > 1 ? ($pag - 1) * $this->intTamPag : 0;
                 $fim = $inicio + $this->intTamPag;
                 //Varifica se foi solicitado a ordenação
                 if (!empty($post->ordenacao)) {
                     $ordem[] = "{$post->ordenacao} {$post->tipoOrdenacao}";
                 } else {
                     $ordem = array('1 ASC');
                 }
                 $rs = $tbl->buscar();
                 $total = count($rs);
                 if ($fim > $total) {
                     $fim = $total;
                 }
                 $totalPag = (int) ($total % $this->intTamPag == 0 ? $total / $this->intTamPag : $total / $this->intTamPag + 1);
                 $tamanho = $fim > $total ? $total - $inicio : $this->intTamPag;
                 if ($fim > $total) {
                     $fim = $total;
                 }
                 $arrBusca = array();
                 $arrBusca['Codigo > ?'] = 0;
                 $rs2 = $tbl->buscar($arrBusca, $ordem, $tamanho, $inicio);
                 if ($rs2->count() > 0) {
                     foreach ($rs2 as $area) {
                         $idsAreas[] = $area->Area;
                     }
                     $tblArea = new Area();
                     $rsArea = $tblArea->buscar(array("Codigo IN (?)" => $idsAreas));
                     $arrAreas = array(0 => array("NomeArea" => "Todas as &Aacute;reas"));
                     foreach ($rsArea as $area) {
                         $arrAreas[$area->Codigo]["NomeArea"] = $area->Descricao;
                     }
                 }
                 $arrDados = array("dados" => $rs2, "areas" => $arrAreas, "pag" => $pag, "total" => $total, "inicio" => $inicio + 1, "fim" => $fim, "totalPag" => $totalPag, "parametrosBusca" => $_POST, "urlPaginacao" => $this->_urlPadrao . "/operacional/tabelas");
                 $this->montaTela("operacional/documentosexigidos.phtml", $arrDados);
             }
         }
         if ($get->consulta == "produtos") {
             $tbl = new Produto();
             if ($post->tipo == 'xls' || $post->tipo == 'pdf') {
                 //buscando os registros no banco de dados
                 $tamanho = -1;
                 $inicio = -1;
                 $pag = 0;
                 $totalPag = 0;
                 $fim = 0;
                 $arrBusca = array();
                 $rs = $tbl->buscar($arrBusca, array(), $tamanho, $inicio);
                 if ($rs->count() > 0) {
                     foreach ($rs as $produto) {
                         $idsOrgaos[] = $produto->Idorgao;
                     }
                     $tblOrgao = new Orgaos();
                     $rsOrgao = $tblOrgao->buscar(array("Codigo IN (?)" => $idsOrgaos));
                     $arrOrgaos = array();
                     foreach ($rsOrgao as $orgao) {
                         $arrOrgaos[$orgao->Codigo]["SiglaOrgao"] = $orgao->Sigla;
                     }
                 }
                 $this->_forward('preparar-xls-pdf', null, null, array('dados' => $rs, 'view' => 'operacional/preparar-xls-pdf-produtos.phtml', 'tipo' => $post->tipo, 'orgaos' => $arrOrgaos));
             } else {
                 //controlando a paginacao
                 $this->intTamPag = 10;
                 $pag = 1;
                 if (isset($post->pag)) {
                     $pag = $post->pag;
                 }
                 if (isset($post->tamPag)) {
                     $this->intTamPag = $post->tamPag;
                 }
                 $inicio = $pag > 1 ? ($pag - 1) * $this->intTamPag : 0;
                 $fim = $inicio + $this->intTamPag;
                 //Varifica se foi solicitado a ordenação
                 if (!empty($post->ordenacao)) {
                     $ordem[] = "{$post->ordenacao} {$post->tipoOrdenacao}";
                 } else {
                     $ordem = array('1 ASC');
                 }
                 $rs = $tbl->buscar();
                 $total = count($rs);
                 if ($fim > $total) {
                     $fim = $total;
                 }
                 $totalPag = (int) ($total % $this->intTamPag == 0 ? $total / $this->intTamPag : $total / $this->intTamPag + 1);
                 $tamanho = $fim > $total ? $total - $inicio : $this->intTamPag;
                 if ($fim > $total) {
                     $fim = $total;
                 }
                 $arrBusca = array();
                 $rs2 = $tbl->buscar($arrBusca, $ordem, $tamanho, $inicio);
                 if ($rs2->count() > 0) {
                     foreach ($rs2 as $produto) {
                         $idsOrgaos[] = $produto->Idorgao;
                     }
                     $tblOrgao = new Orgaos();
                     $rsOrgao = $tblOrgao->buscar(array("Codigo IN (?)" => $idsOrgaos));
                     $arrOrgaos = array();
                     foreach ($rsOrgao as $orgao) {
                         $arrOrgaos[$orgao->Codigo]["SiglaOrgao"] = $orgao->Sigla;
                     }
                 }
                 $arrDados = array("dados" => $rs2, "orgaos" => $arrOrgaos, "pag" => $pag, "total" => $total, "inicio" => $inicio + 1, "fim" => $fim, "totalPag" => $totalPag, "parametrosBusca" => $_POST, "urlPaginacao" => $this->_urlPadrao . "/operacional/tabelas");
                 $this->montaTela("operacional/produtos.phtml", $arrDados);
             }
         }
         if ($get->consulta == "situacoes") {
             $tbl = new Situacao();
             if ($post->tipo == 'xls' || $post->tipo == 'pdf') {
                 //buscando os registros no banco de dados
                 $tamanho = -1;
                 $inicio = -1;
                 $pag = 0;
                 $totalPag = 0;
                 $fim = 0;
                 $arrBusca = array();
                 $rs = $tbl->buscar($arrBusca, array(), $tamanho, $inicio);
                 $this->_forward('preparar-xls-pdf', null, null, array('dados' => $rs, 'view' => 'operacional/preparar-xls-pdf-situacao.phtml', 'tipo' => $post->tipo));
             } else {
                 //controlando a paginacao
                 $this->intTamPag = 10;
                 $pag = 1;
                 if (isset($post->pag)) {
                     $pag = $post->pag;
                 }
                 if (isset($post->tamPag)) {
                     $this->intTamPag = $post->tamPag;
                 }
                 $inicio = $pag > 1 ? ($pag - 1) * $this->intTamPag : 0;
                 $fim = $inicio + $this->intTamPag;
                 //Varifica se foi solicitado a ordenação
                 if (!empty($post->ordenacao)) {
                     $ordem[] = "{$post->ordenacao} {$post->tipoOrdenacao}";
                 } else {
                     $ordem = array('1');
                 }
                 $rs = $tbl->buscar();
                 $total = count($rs);
                 if ($fim > $total) {
                     $fim = $total;
                 }
                 $totalPag = (int) ($total % $this->intTamPag == 0 ? $total / $this->intTamPag : $total / $this->intTamPag + 1);
                 $tamanho = $fim > $total ? $total - $inicio : $this->intTamPag;
                 if ($fim > $total) {
                     $fim = $total;
                 }
                 $arrBusca = array();
                 $rs2 = $tbl->buscar($arrBusca, $ordem, $tamanho, $inicio);
                 $arrDados = array("dados" => $rs2, "pag" => $pag, "total" => $total, "inicio" => $inicio + 1, "fim" => $fim, "totalPag" => $totalPag, "parametrosBusca" => $_POST, "urlPaginacao" => $this->_urlPadrao . "/operacional/tabelas");
                 $this->montaTela("operacional/situacoes.phtml", $arrDados);
             }
         }
         if ($get->consulta == "segmentos") {
             $tbl = new Segmento();
             if ($post->tipo == 'xls' || $post->tipo == 'pdf') {
                 //buscando os registros no banco de dados
                 $tamanho = -1;
                 $inicio = -1;
                 $pag = 0;
                 $totalPag = 0;
                 $fim = 0;
                 $arrBusca = array();
                 $rs = $tbl->buscar($arrBusca, array(), $tamanho, $inicio);
                 if ($rs->count() > 0) {
                     foreach ($rs as $segmento) {
                         $idsOrgaos[] = $segmento->idOrgao;
                     }
                     $tblOrgao = new Orgaos();
                     $rsOrgao = $tblOrgao->buscar(array("Codigo IN (?)" => $idsOrgaos));
                     $arrOrgaos = array();
                     foreach ($rsOrgao as $orgao) {
                         $arrOrgaos[$orgao->Codigo]["SiglaOrgao"] = $orgao->Sigla;
                     }
                 }
                 $this->_forward('preparar-xls-pdf', null, null, array('dados' => $rs, 'view' => 'operacional/preparar-xls-pdf-segmentos.phtml', 'tipo' => $post->tipo, 'orgaos' => $arrOrgaos));
             } else {
                 //controlando a paginacao
                 $this->intTamPag = 10;
                 $pag = 1;
                 if (isset($post->pag)) {
                     $pag = $post->pag;
                 }
                 if (isset($post->tamPag)) {
                     $this->intTamPag = $post->tamPag;
                 }
                 $inicio = $pag > 1 ? ($pag - 1) * $this->intTamPag : 0;
                 $fim = $inicio + $this->intTamPag;
                 //Varifica se foi solicitado a ordenação
                 if (!empty($post->ordenacao)) {
                     $ordem[] = "{$post->ordenacao} {$post->tipoOrdenacao}";
                 } else {
                     $ordem = array('1 ASC');
                 }
                 $rs = $tbl->buscar();
                 $total = count($rs);
                 if ($fim > $total) {
                     $fim = $total;
                 }
                 $totalPag = (int) ($total % $this->intTamPag == 0 ? $total / $this->intTamPag : $total / $this->intTamPag + 1);
                 $tamanho = $fim > $total ? $total - $inicio : $this->intTamPag;
                 if ($fim > $total) {
                     $fim = $total;
                 }
                 $arrBusca = array();
                 $rs2 = $tbl->buscar($arrBusca, $ordem, $tamanho, $inicio);
                 if ($rs2->count() > 0) {
                     foreach ($rs2 as $segmento) {
                         $idsOrgaos[] = $segmento->idOrgao;
                     }
                     $tblOrgao = new Orgaos();
                     $rsOrgao = $tblOrgao->buscar(array("Codigo IN (?)" => $idsOrgaos));
                     $arrOrgaos = array();
                     foreach ($rsOrgao as $orgao) {
                         $arrOrgaos[$orgao->Codigo]["SiglaOrgao"] = $orgao->Sigla;
                     }
                 }
                 $arrDados = array("dados" => $rs2, "orgaos" => $arrOrgaos, "pag" => $pag, "total" => $total, "inicio" => $inicio + 1, "fim" => $fim, "totalPag" => $totalPag, "parametrosBusca" => $_POST, "urlPaginacao" => $this->_urlPadrao . "/operacional/tabelas");
                 $this->montaTela("operacional/segmentos.phtml", $arrDados);
             }
         }
         if ($get->consulta == "tiposdocumento") {
             $tbl = new tbTipoDocumento();
             if ($post->tipo == 'xls' || $post->tipo == 'pdf') {
                 //buscando os registros no banco de dados
                 $tamanho = -1;
                 $inicio = -1;
                 $pag = 0;
                 $totalPag = 0;
                 $fim = 0;
                 $arrBusca = array();
                 $rs = $tbl->buscar($arrBusca, array(), $tamanho, $inicio);
                 $this->_forward('preparar-xls-pdf', null, null, array('dados' => $rs, 'view' => 'operacional/preparar-xls-pdf-tiposdocumento.phtml', 'tipo' => $post->tipo));
             } else {
                 //controlando a paginacao
                 $this->intTamPag = 10;
                 $pag = 1;
                 if (isset($post->pag)) {
                     $pag = $post->pag;
                 }
                 if (isset($post->tamPag)) {
                     $this->intTamPag = $post->tamPag;
                 }
                 $inicio = $pag > 1 ? ($pag - 1) * $this->intTamPag : 0;
                 $fim = $inicio + $this->intTamPag;
                 //Varifica se foi solicitado a ordenação
                 if (!empty($post->ordenacao)) {
                     $ordem[] = "{$post->ordenacao} {$post->tipoOrdenacao}";
                 } else {
                     $ordem = array('2 ASC');
                 }
                 $rs = $tbl->buscar();
                 $total = count($rs);
                 if ($fim > $total) {
                     $fim = $total;
                 }
                 $totalPag = (int) ($total % $this->intTamPag == 0 ? $total / $this->intTamPag : $total / $this->intTamPag + 1);
                 $tamanho = $fim > $total ? $total - $inicio : $this->intTamPag;
                 if ($fim > $total) {
                     $fim = $total;
                 }
                 $arrBusca = array();
                 $rs2 = $tbl->buscar($arrBusca, $ordem, $tamanho, $inicio);
                 $arrDados = array("dados" => $rs2, "pag" => $pag, "total" => $total, "inicio" => $inicio + 1, "fim" => $fim, "totalPag" => $totalPag, "parametrosBusca" => $_POST, "urlPaginacao" => $this->_urlPadrao . "/operacional/tabelas");
                 $this->montaTela("operacional/tiposdocumento.phtml", $arrDados);
             }
         }
         if ($get->consulta == "pecasdivulgacao") {
             $tbl = new Verificacao();
             if ($post->tipo == 'xls' || $post->tipo == 'pdf') {
                 //buscando os registros no banco de dados
                 $tamanho = -1;
                 $inicio = -1;
                 $pag = 0;
                 $totalPag = 0;
                 $fim = 0;
                 $arrBusca = array();
                 $arrBusca = array("idTipo = ?" => 1, "stEstado = ?" => 1);
                 $rs = $tbl->buscar($arrBusca, array(), $tamanho, $inicio);
                 $this->_forward('preparar-xls-pdf', null, null, array('dados' => $rs, 'view' => 'operacional/preparar-xls-pdf-pecasdivulgacao.phtml', 'tipo' => $post->tipo));
             } else {
                 //controlando a paginacao
                 $this->intTamPag = 10;
                 $pag = 1;
                 if (isset($post->pag)) {
                     $pag = $post->pag;
                 }
                 if (isset($post->tamPag)) {
                     $this->intTamPag = $post->tamPag;
                 }
                 $inicio = $pag > 1 ? ($pag - 1) * $this->intTamPag : 0;
                 $fim = $inicio + $this->intTamPag;
                 //Varifica se foi solicitado a ordenação
                 if (!empty($post->ordenacao)) {
                     $ordem[] = "{$post->ordenacao} {$post->tipoOrdenacao}";
                 } else {
                     $ordem = array('1 ASC');
                 }
                 $rs = $tbl->buscar(array("idTipo = ?" => 1, "stEstado = ?" => 1));
                 $total = count($rs);
                 if ($fim > $total) {
                     $fim = $total;
                 }
                 $totalPag = (int) ($total % $this->intTamPag == 0 ? $total / $this->intTamPag : $total / $this->intTamPag + 1);
                 $tamanho = $fim > $total ? $total - $inicio : $this->intTamPag;
                 if ($fim > $total) {
                     $fim = $total;
                 }
                 $arrBusca = array("idTipo = ?" => 1, "stEstado = ?" => 1);
                 $rs2 = $tbl->buscar($arrBusca, $ordem, $tamanho, $inicio);
                 $arrDados = array("dados" => $rs2, "pag" => $pag, "total" => $total, "inicio" => $inicio + 1, "fim" => $fim, "totalPag" => $totalPag, "parametrosBusca" => $_POST, "urlPaginacao" => $this->_urlPadrao . "/operacional/tabelas");
                 $this->montaTela("operacional/pecasdivulgacao.phtml", $arrDados);
             }
         }
         if ($get->consulta == "veiculosdivulgacao") {
             $tbl = new Verificacao();
             if ($post->tipo == 'xls' || $post->tipo == 'pdf') {
                 //buscando os registros no banco de dados
                 $tamanho = -1;
                 $inicio = -1;
                 $pag = 0;
                 $totalPag = 0;
                 $fim = 0;
                 $arrBusca = array();
                 $arrBusca = array("idTipo = ?" => 2, "stEstado = ?" => 1);
                 $rs = $tbl->buscar($arrBusca, array(), $tamanho, $inicio);
                 $this->_forward('preparar-xls-pdf', null, null, array('dados' => $rs, 'view' => 'operacional/preparar-xls-pdf-veiculosdivulgacao.phtml', 'tipo' => $post->tipo));
             } else {
                 //controlando a paginacao
                 $this->intTamPag = 10;
                 $pag = 1;
                 if (isset($post->pag)) {
                     $pag = $post->pag;
                 }
                 if (isset($post->tamPag)) {
                     $this->intTamPag = $post->tamPag;
                 }
                 $inicio = $pag > 1 ? ($pag - 1) * $this->intTamPag : 0;
                 $fim = $inicio + $this->intTamPag;
                 //Varifica se foi solicitado a ordenação
                 if (!empty($post->ordenacao)) {
                     $ordem[] = "{$post->ordenacao} {$post->tipoOrdenacao}";
                 } else {
                     $ordem = array('1 ASC');
                 }
                 $rs = $tbl->buscar(array("idTipo = ?" => 2, "stEstado = ?" => 1));
                 $total = count($rs);
                 if ($fim > $total) {
                     $fim = $total;
                 }
                 $totalPag = (int) ($total % $this->intTamPag == 0 ? $total / $this->intTamPag : $total / $this->intTamPag + 1);
                 $tamanho = $fim > $total ? $total - $inicio : $this->intTamPag;
                 if ($fim > $total) {
                     $fim = $total;
                 }
                 $arrBusca = array("idTipo = ?" => 2, "stEstado = ?" => 1);
                 $rs2 = $tbl->buscar($arrBusca, $ordem, $tamanho, $inicio);
                 $arrDados = array("dados" => $rs2, "pag" => $pag, "total" => $total, "inicio" => $inicio + 1, "fim" => $fim, "totalPag" => $totalPag, "parametrosBusca" => $_POST, "urlPaginacao" => $this->_urlPadrao . "/operacional/tabelas");
                 $this->montaTela("operacional/veiculosdivulgacao.phtml", $arrDados);
             }
         }
     }
 }
 public function imprimirpropostaculturalAction()
 {
     $this->_helper->layout->disableLayout();
     $idPreProjeto = $this->idPreProjeto;
     $dao = new AnalisarPropostaDAO();
     $this->view->itensGeral = AnalisarPropostaDAO::buscarGeral($idPreProjeto);
     $propostaPorEdital = false;
     if ($this->view->itensGeral[0]->idEdital && $this->view->itensGeral[0]->idEdital != 0) {
         $propostaPorEdital = true;
     }
     $this->view->itensTelefone = AnalisarPropostaDAO::buscarTelefone($this->view->itensGeral[0]->idAgente);
     $this->view->itensPlanosDistribuicao = AnalisarPropostaDAO::buscarPlanoDeDistribucaoProduto($idPreProjeto);
     $this->view->itensFonteRecurso = AnalisarPropostaDAO::buscarFonteDeRecurso($idPreProjeto);
     $this->view->itensLocalRealiazacao = AnalisarPropostaDAO::buscarLocalDeRealizacao($idPreProjeto);
     $this->view->itensDeslocamento = AnalisarPropostaDAO::buscarDeslocamento($idPreProjeto);
     $this->view->itensPlanoDivulgacao = AnalisarPropostaDAO::buscarPlanoDeDivulgacao($idPreProjeto);
     $tblAvaliacaoProposta = new AvaliacaoProposta();
     $rsAvaliacaoProposta = $tblAvaliacaoProposta->buscar(array("idProjeto = ?" => $idPreProjeto, "idArquivo ?" => new Zend_Db_Expr("IS NOT NULL")));
     $tbArquivo = new tbArquivo();
     $arrDadosArquivo = array();
     $arrRelacionamentoAvaliacaoDocumentosExigidos = array();
     if (count($rsAvaliacaoProposta) > 0) {
         foreach ($rsAvaliacaoProposta as $avaliacao) {
             $arrDadosArquivo[$avaliacao->idArquivo] = $tbArquivo->buscar(array("idArquivo = ?" => $avaliacao->idArquivo));
             $arrRelacionamentoAvaliacaoDocumentosExigidos[$avaliacao->idArquivo] = $avaliacao->idCodigoDocumentosExigidos;
         }
     }
     $this->view->relacionamentoAvaliacaoDocumentosExigidos = $arrRelacionamentoAvaliacaoDocumentosExigidos;
     $this->view->itensDocumentoPreProjeto = $arrDadosArquivo;
     //PEGANDO RELACAO DE DOCUMENTOS EXIGIDOS(GERAL, OU SEJA, TODO MUNDO)
     $tblDocumentosExigidos = new DocumentosExigidos();
     $rsDocumentosExigidos = $tblDocumentosExigidos->buscar()->toArray();
     $arrDocumentosExigidos = array();
     foreach ($rsDocumentosExigidos as $documentoExigido) {
         $arrDocumentosExigidos[$documentoExigido["Codigo"]] = $documentoExigido;
     }
     $this->view->documentosExigidos = $arrDocumentosExigidos;
     $this->view->itensHistorico = AnalisarPropostaDAO::buscarHistorico($idPreProjeto);
     /*
      * PEGANDO DOCUMENTOS ANEXADOS
      */
     $tblAvaliacaoProposta = new AvaliacaoProposta();
     $rsAvaliacaoProposta = $tblAvaliacaoProposta->buscar(array("idProjeto = ?" => $idPreProjeto, "idArquivo ?" => new Zend_Db_Expr("IS NOT NULL")));
     $tbArquivo = new tbArquivo();
     $arrDadosArquivo = array();
     $arrRelacionamentoAvaliacaoDocumentosExigidos = array();
     if (count($rsAvaliacaoProposta) > 0) {
         foreach ($rsAvaliacaoProposta as $avaliacao) {
             $arrDadosArquivo[$avaliacao->idArquivo] = $tbArquivo->buscar(array("idArquivo = ?" => $avaliacao->idArquivo));
             $arrRelacionamentoAvaliacaoDocumentosExigidos[$avaliacao->idArquivo] = $avaliacao->idCodigoDocumentosExigidos;
         }
     }
     //x($arrRelacionamentoAvaliacaoDocumentosExigidos);
     $this->view->relacionamentoAvaliacaoDocumentosExigidos = $arrRelacionamentoAvaliacaoDocumentosExigidos;
     $this->view->itensDocumentoPreProjeto = $arrDadosArquivo;
     //PEGANDO RELACAO DE DOCUMENTOS EXIGIDOS(GERAL, OU SEJA, TODO MUNDO)
     $tblDocumentosExigidos = new DocumentosExigidos();
     $rsDocumentosExigidos = $tblDocumentosExigidos->buscar()->toArray();
     $arrDocumentosExigidos = array();
     foreach ($rsDocumentosExigidos as $documentoExigido) {
         $arrDocumentosExigidos[$documentoExigido["Codigo"]] = $documentoExigido;
     }
     //xd($arrDocumentosExigidos);
     $this->view->documentosExigidos = $arrDocumentosExigidos;
     //xd($rsDocumentosExigidos);
     /*
      * FINAL - PEGANDO DOCUMENTOS ANEXADOS
      */
     $this->view->itensPlanilhaOrcamentaria = $dao->buscarPlanilhaOrcamentaria($idPreProjeto);
     $buscarProduto = ManterorcamentoDAO::buscarProdutos($this->idPreProjeto);
     $this->view->Produtos = $buscarProduto;
     $buscarEtapa = ManterorcamentoDAO::buscarEtapasProdutos($this->idPreProjeto);
     $this->view->Etapa = $buscarEtapa;
     $buscarItem = ManterorcamentoDAO::buscarItensProdutos($this->idPreProjeto);
     $this->view->Item = $buscarItem;
     $this->view->AnaliseCustos = PreProjeto::analiseDeCustos($this->idPreProjeto);
     $this->view->idPreProjeto = $this->idPreProjeto;
     //========== inicio codigo dirigente ================
     /*==================================================*/
     $arrMandatos = array();
     $this->view->mandatos = $arrMandatos;
     $preProjeto = new PreProjeto();
     $rsDirigentes = array();
     $Empresa = $preProjeto->buscar(array('idPreProjeto = ?' => $this->idPreProjeto))->current();
     $idEmpresa = $Empresa->idAgente;
     if (isset($this->view->itensGeral[0]->CNPJCPFdigirente) && $this->view->itensGeral[0]->CNPJCPFdigirente != "") {
         $tblAgente = new Agentes();
         $tblNomes = new Nomes();
         foreach ($this->view->itensGeral as $v) {
             $rsAgente = $tblAgente->buscarAgenteNome(array('CNPJCPF=?' => $v->CNPJCPFdigirente))->current();
             $rsDirigentes[$rsAgente->idAgente]['CNPJCPFDirigente'] = $rsAgente->CNPJCPF;
             $rsDirigentes[$rsAgente->idAgente]['idAgente'] = $rsAgente->idAgente;
             $rsDirigentes[$rsAgente->idAgente]['NomeDirigente'] = $rsAgente->Descricao;
         }
         $tbDirigenteMandato = new tbAgentesxVerificacao();
         foreach ($rsDirigentes as $dirigente) {
             $rsMandato = $tbDirigenteMandato->listarMandato(array('idEmpresa = ?' => $idEmpresa, 'idDirigente = ?' => $dirigente['idAgente'], 'stMandato = ?' => 0));
             $NomeDirigente = $dirigente['NomeDirigente'];
             $arrMandatos[$NomeDirigente] = $rsMandato;
         }
     }
     //$tbDirigentes = $geral->buscarDirigentes($idPronac);
     $this->view->dirigentes = $rsDirigentes;
     $this->view->mandatos = $arrMandatos;
     //============== fim codigo dirigente ================
     /*==================================================*/
     if ($propostaPorEdital) {
         $tbFormDocumentoDAO = new tbFormDocumento();
         $edital = $tbFormDocumentoDAO->buscar(array('idEdital = ?' => $this->view->itensGeral[0]->idEdital, 'idClassificaDocumento = ?' => $this->COD_CLASSIFICACAO_DOCUMENTO));
         $arrPerguntas = array();
         $arrRespostas = array();
         $tbPerguntaDAO = new tbPergunta();
         $tbRespostaDAO = new tbResposta();
         foreach ($edital as $registro) {
             $questoes = $tbPerguntaDAO->montarQuestionario($registro["nrFormDocumento"], $registro["nrVersaoDocumento"]);
             $questionario = '';
             if (is_object($questoes) and count($questoes) > 0) {
                 foreach ($questoes as $questao) {
                     $resposta = '';
                     $where = array('nrFormDocumento = ?' => $registro["nrFormDocumento"], 'nrVersaoDocumento = ?' => $registro["nrVersaoDocumento"], 'nrPergunta = ?' => $questao->nrPergunta, 'idProjeto = ?' => $this->idPreProjeto);
                     $resposta = $tbRespostaDAO->buscar($where);
                     $arrPerguntas[$registro["nrFormDocumento"]]["titulo"] = $registro["nmFormDocumento"];
                     $arrPerguntas[$registro["nrFormDocumento"]]["pergunta"][] = $questao->toArray();
                     $arrRespostas[] = $resposta->toArray();
                 }
             }
         }
         $this->view->perguntas = $arrPerguntas;
         $this->view->respostas = $arrRespostas;
         $this->montaTela("admissibilidade/imprimir-proposta-por-edital.phtml");
     } else {
         $this->montaTela("admissibilidade/imprimir-proposta-por-incentivo-fiscal.phtml");
     }
 }
 public function visualizarDiligenciaAction()
 {
     $this->_helper->layout->disableLayout();
     // Desabilita o Zend Layout
     $idPronac = $this->_request->getParam("idPronac");
     if (strlen($idPronac) > 7) {
         $idPronac = Seguranca::dencrypt($idPronac);
     }
     $idDiligencia = $this->_request->getParam("idDiligencia");
     $idDiligenciaPreProjeto = $this->_request->getParam("idDiligenciaPreProjeto");
     if (!empty($idPronac) && !empty($idDiligencia)) {
         $Projetosdao = new Projetos();
         $PreProjetodao = new PreProjeto();
         $DocumentosExigidosDao = new DocumentosExigidos();
         if (!empty($idDiligencia) && empty($idDiligenciaPreProjeto)) {
             $resp = $Projetosdao->listarDiligencias(array('pro.IdPRONAC = ?' => $this->view->idPronac, 'dil.idDiligencia = ?' => $idDiligencia));
             $this->view->nmCodigo = 'PRONAC';
             $this->view->nmTipo = 'DO PROJETO';
             $this->view->tipoDiligencia = $resp[0]->tipoDiligencia;
         }
         if (!empty($idDiligenciaPreProjeto)) {
             if ($idPronac) {
                 $projeto = $Projetosdao->buscar(array('IdPRONAC = ?' => $idPronac));
                 $idPreProjeto = $projeto[0]->idProjeto;
             }
             if (isset($projeto[0]->idProjeto)) {
                 $idPreProjeto = $projeto[0]->idProjeto;
             }
             $resp = $PreProjetodao->listarDiligenciasPreProjeto(array('pre.idPreProjeto = ?' => $idPreProjeto, ' aval.idAvaliacaoProposta = ?' => $idDiligencia));
             $this->view->nmCodigo = 'Nr PROPOSTA';
             $this->view->nmTipo = 'DA PROPOSTA';
             $this->view->Descricao = $resp[0]->Descricao;
         }
         //fecha if Diligencia PreProjeto
         $this->view->stEnviado = $resp[0]->stEnviado;
         $this->view->pronac = $resp[0]->pronac;
         $this->view->nomeProjeto = $resp[0]->nomeProjeto;
         //$this->view->Proponente = $rd[0]->Proponente;
         $this->view->dataSolicitacao = date('d/m/Y H:i', strtotime($resp[0]->dataSolicitacao));
         if (isset($resp[0]->dataResposta) && $resp[0]->dataResposta != '') {
             $this->view->dataResposta = date('d/m/Y H:i', strtotime($resp[0]->dataResposta));
         }
         $this->view->solicitacao = $resp[0]->Solicitacao;
         $this->view->resposta = $resp[0]->Resposta;
         if (isset($resp[0]->idCodigoDocumentosExigidos) && !empty($resp[0]->idCodigoDocumentosExigidos)) {
             $documento = $DocumentosExigidosDao->listarDocumentosExigido($resp[0]->idCodigoDocumentosExigidos);
             $this->view->DocumentosExigido = $documento[0]->Descricao;
             $this->view->Opcao = $documento[0]->Opcao;
         }
     }
     $arquivo = new Arquivo();
     $arquivos = $arquivo->buscarAnexosDiligencias($idDiligencia);
     $this->view->arquivos = $arquivos;
 }