public function dadosetiquetaAction()
 {
     //ini_set('max_execution_time', 500);
     $this->_helper->layout->disableLayout();
     // Desabilita o Zend Layout
     if (isset($_GET['pronac'])) {
         $pronac = $_GET['pronac'];
         $etiquetaApenas = "nao";
         if (!empty($_GET['etiqueta'])) {
             $etiquetaApenas = $_GET['etiqueta'];
         }
         $this->view->etiquetaApenas = $etiquetaApenas;
         $barcodeOptions = array('text' => $pronac);
         $rendererOptions = array();
         $documentRoot = explode("/index.php", $_SERVER["DOCUMENT_ROOT"] . $_SERVER["PHP_SELF"]);
         $documentRoot = str_replace("//", "/", $documentRoot[0]);
         $caminho = $documentRoot . "/public/barcode/imagem-" . $pronac . ".jpg";
         //            $caminho = "../public/barcode/imagem-".$pronac.".jpg";
         $imageResource = Zend_Barcode::draw('code39', 'image', $barcodeOptions, $rendererOptions);
         imagejpeg($imageResource, $caminho);
         $caminhoView = "../public/barcode/imagem-" . $pronac . ".jpg";
         $this->view->caminho = $caminhoView;
         $projetosDAO = new Projetos();
         $consulta = array('pro.AnoProjeto + pro.Sequencial = ?' => $pronac);
         $resp = $projetosDAO->buscarEditalProjeto($consulta);
         $idPreProjeto = $resp->idPreProjeto;
         if (!empty($resp->idEdital)) {
             $this->view->edital = true;
         } else {
             $this->view->edital = false;
         }
         //DADOS DA ETIQUETA
         $dados = GerenciarparecertecnicoDAO::dadosEtiqueta($pronac);
         $this->view->DadosEtiqueta = $dados;
         $dao = new AnalisarPropostaDAO();
         $this->view->itensGeral = $dao->buscarGeral($idPreProjeto);
         $propostaPorEdital = false;
         if ($this->view->itensGeral[0]->idEdital && $this->view->itensGeral[0]->idEdital != 0) {
             $propostaPorEdital = true;
         }
         $this->view->itensTelefone = $dao->buscarTelefone($this->view->itensGeral[0]->idAgente);
         $this->view->itensPlanosDistribuicao = $dao->buscarPlanoDeDistribucaoProduto($idPreProjeto);
         $this->view->itensFonteRecurso = $dao->buscarFonteDeRecurso($idPreProjeto);
         $this->view->itensLocalRealiazacao = $dao->buscarLocalDeRealizacao($idPreProjeto);
         $this->view->itensDeslocamento = $dao->buscarDeslocamento($idPreProjeto);
         $this->view->itensPlanoDivulgacao = $dao->buscarPlanoDeDivulgacao($idPreProjeto);
         $tblDocsPreProjeto = new tbDocumentosPreProjeto();
         $rsDocsPreProjeto = $tblDocsPreProjeto->buscar(array("idProjeto = ?" => $idPreProjeto));
         $this->view->itensDocumentoPreProjeto = $rsDocsPreProjeto;
         $this->view->itensDocumentoAgente = $dao->buscarDocumentoAgente($this->view->itensGeral[0]->idAgente);
         $this->view->itensHistorico = $dao->buscarHistorico($idPreProjeto);
         $this->view->itensPlanilhaOrcamentaria = $dao->buscarPlanilhaOrcamentaria($idPreProjeto);
         $buscarProduto = ManterorcamentoDAO::buscarProdutos($idPreProjeto);
         $this->view->Produtos = $buscarProduto;
         $buscarEtapa = ManterorcamentoDAO::buscarEtapasProdutos($idPreProjeto);
         $this->view->Etapa = $buscarEtapa;
         $buscarItem = ManterorcamentoDAO::buscarItensProdutos($idPreProjeto);
         $this->view->Item = $buscarItem;
         $this->view->AnaliseCustos = PreProjeto::analiseDeCustos($idPreProjeto);
         $this->view->idPreProjeto = $idPreProjeto;
         $buscarIdPronac = $projetosDAO->buscarIdPronac($pronac);
         $idPronac = $buscarIdPronac->IdPRONAC;
         $rst = $projetosDAO->buscarDadosUC75($idPronac);
         $this->view->projeto = $rst[0];
         //UNIDADES DE ANÁLISE
         $vwProjetoDistribuidoVinculada = new vwProjetoDistribuidoVinculada();
         $this->view->unidadesAnalise = $vwProjetoDistribuidoVinculada->buscarUnidades(array('Pronac = ?' => $pronac), array('Produto', 'DescricaoAnalise'));
         //VALORES DO PROJETO
         $planilhaproposta = new PlanilhaProposta();
         $planilhaprojeto = new PlanilhaProjeto();
         $planilhaAprovacao = new PlanilhaAprovacao();
         $rsPlanilhaAtual = $planilhaAprovacao->buscar(array('IdPRONAC = ?' => $idPronac), array('dtPlanilha DESC'))->current();
         $tpPlanilha = !empty($rsPlanilhaAtual) && $rsPlanilhaAtual->tpPlanilha == 'SE' ? 'SE' : 'CO';
         $arrWhereSomaPlanilha = array();
         $arrWhereSomaPlanilha['idPronac = ?'] = $idPronac;
         if ($this->bln_readequacao == "false") {
             $fonteincentivo = $planilhaproposta->somarPlanilhaProposta($idPreProjeto, 109);
             $outrasfontes = $planilhaproposta->somarPlanilhaProposta($idPreProjeto, false, 109);
             $parecerista = $planilhaprojeto->somarPlanilhaProjeto($idPreProjeto, 109);
         } else {
             $arrWhereFontesIncentivo = $arrWhereSomaPlanilha;
             $arrWhereFontesIncentivo['idPlanilhaItem <> ? '] = '206';
             //elaboracao e agenciamento
             $arrWhereFontesIncentivo['tpPlanilha = ? '] = 'SR';
             $arrWhereFontesIncentivo['stAtivo = ? '] = 'N';
             $arrWhereFontesIncentivo['NrFonteRecurso = ? '] = '109';
             $arrWhereFontesIncentivo["idPedidoAlteracao = (?)"] = new Zend_Db_Expr("(SELECT TOP 1 max(idPedidoAlteracao) from SAC.dbo.tbPlanilhaAprovacao where IdPRONAC = '{$idPronac}')");
             $arrWhereFontesIncentivo["tpAcao <> ('E') OR tpAcao IS NULL "] = '(?)';
             $fonteincentivo = $planilhaAprovacao->somarItensPlanilhaAprovacao($arrWhereFontesIncentivo);
             $arrWhereOutrasFontes = $arrWhereSomaPlanilha;
             $arrWhereOutrasFontes['idPlanilhaItem <> ? '] = '206';
             //elaboracao e agenciamento
             $arrWhereOutrasFontes['tpPlanilha = ? '] = 'SR';
             $arrWhereOutrasFontes['stAtivo = ? '] = 'N';
             $arrWhereOutrasFontes['NrFonteRecurso <> ? '] = '109';
             $arrWhereOutrasFontes["idPedidoAlteracao = (?)"] = new Zend_Db_Expr("(SELECT TOP 1 max(idPedidoAlteracao) from SAC.dbo.tbPlanilhaAprovacao where IdPRONAC = '{$idPronac}')");
             $arrWhereOutrasFontes["tpAcao <> ('E') OR tpAcao IS NULL "] = '(?)';
             $outrasfontes = $planilhaAprovacao->somarItensPlanilhaAprovacao($arrWhereOutrasFontes);
             $arrWherePlanilhaPA = $arrWhereSomaPlanilha;
             $arrWherePlanilhaPA['idPlanilhaItem <> ? '] = '206';
             //elaboracao e agenciamento
             $arrWherePlanilhaPA['tpPlanilha = ? '] = 'PA';
             $arrWherePlanilhaPA['stAtivo = ? '] = 'N';
             $arrWherePlanilhaPA['NrFonteRecurso = ? '] = '109';
             $arrWherePlanilhaPA["idPedidoAlteracao = (?)"] = new Zend_Db_Expr("(SELECT TOP 1 max(idPedidoAlteracao) from SAC.dbo.tbPlanilhaAprovacao where IdPRONAC = '{$idPronac}')");
             $arrWherePlanilhaPA["tpAcao <> ('E') OR tpAcao IS NULL "] = '(?)';
             $parecerista = $planilhaAprovacao->somarItensPlanilhaAprovacao($arrWherePlanilhaPA);
         }
         //valor do componetne
         $arrWhereSomaPlanilha = array();
         $arrWhereSomaPlanilha['idPronac = ?'] = $idPronac;
         $arrWhereSomaPlanilha['idPlanilhaItem <> ? '] = '206';
         //elaboracao e agenciamento
         $arrWhereSomaPlanilha['tpPlanilha = ? '] = $tpPlanilha;
         $arrWhereSomaPlanilha['NrFonteRecurso = ? '] = '109';
         $arrWhereSomaPlanilha['stAtivo = ? '] = 'S';
         $componente = $planilhaAprovacao->somarItensPlanilhaAprovacao($arrWhereSomaPlanilha);
         $valoresProjeto = new ArrayObject();
         $valoresProjeto['fontesincentivo'] = $fonteincentivo['soma'];
         $valoresProjeto['outrasfontes'] = $outrasfontes['soma'];
         $valoresProjeto['valorproposta'] = $fonteincentivo['soma'] + $outrasfontes['soma'];
         $valoresProjeto['valorparecerista'] = $parecerista['soma'];
         $valoresProjeto['valorcomponente'] = $componente['soma'];
         $this->view->valoresDoProjeto = $valoresProjeto;
         $tblCaptacao = new Captacao();
         $rsCount = $tblCaptacao->buscaCompleta(array('idPronac = ?' => $idPronac), array(), null, null, true);
         $this->view->totalGeralCaptado = $rsCount->totalGeralCaptado;
         /***************** FIM  - MODO NOVO ********************/
         if ($propostaPorEdital) {
             $tbFormDocumentoDAO = new tbFormDocumento();
             $edital = $tbFormDocumentoDAO->buscar(array('idEdital = ?' => $this->view->itensGeral[0]->idEdital, 'idClassificaDocumento not in (?,24,25)' => 23));
             $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 = ?' => $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;
         }
     }
     if (isset($_POST['html']) && isset($_POST['pronac']) && isset($_POST['caminho'])) {
         ini_set('max_execution_time', 500);
         $this->_helper->layout->disableLayout();
         $this->_helper->viewRenderer->setNoRender();
         /* converte para lê os arquivos html do word */
         //$html = mb_convert_encoding($_POST['html'], 'UTF-8', 'HTML-ENTITIES');
         //$html = $this->strip_quotes($this->unhtmlentities($_POST['html']));
         $filter = new Zend_Filter();
         //$filter->addFilter(new Zend_Filter_Alnum());
         //$filter->addFilter(new Zend_Filter_Alpha());
         //$filter->addFilter(new Zend_Filter_Digits());
         //$filter->addFilter(new Zend_Filter_HtmlEntities());
         $filter->addFilter(new Zend_Filter_StringTrim());
         $filter->addFilter(new Zend_Filter_StripTags());
         //            $html = $filter->filter($_POST['html']);
         $html = $_POST['html'];
         //            echo $html;
         //            die;
         $pdf = new PDFCreator($html);
         //            $pdf = new PDF($html, 'pdf');
         $pdf->gerarPdf();
         //            $pdf->gerarRelatorio();
         //            die;
         /*
                     $html = $_POST['html'];
                     $pdf = new PDF($html, 'pdf');
                     echo $pdf->gerarRelatorio();*/
     }
 }
 public function imprimirProjetosDistribuidosAction()
 {
     $this->_helper->layout->disableLayout();
     // Desabilita o Zend Layout
     $post = Zend_Registry::get('post');
     //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(2, 5, 6);
         //Pronac,Produto,DescricaoAnalise
         $ordenacao = null;
     }
     /* ================== PAGINACAO ======================*/
     $where = array();
     if (isset($post->pronac) && !empty($post->pronac)) {
         $where['Pronac = ?'] = $post->pronac;
         $this->view->pronac = $post->pronac;
     }
     if (isset($post->estado) && !empty($post->estado)) {
         if ($post->estado == 1) {
             $situacao = 'Em análise';
         } else {
             $situacao = '<font color=red>Concluida</font>';
         }
         $where['Situacao = ?'] = $situacao;
         $this->view->estado = $post->estado;
     }
     if (isset($post->orgao) && !empty($post->orgao)) {
         $where['idOrgao = ?'] = $post->orgao;
         $this->view->orgao = $post->orgao;
     }
     $vwProjetoDistribuidoVinculada = new vwProjetoDistribuidoVinculada();
     $busca = $vwProjetoDistribuidoVinculada->buscarUnidades($where, $order);
     $this->view->dados = $busca;
 }