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 despacharprojAction()
 {
     $auth = Zend_Auth::getInstance();
     // instancia da autenticação
     $idusuario = $this->getIdUsuario;
     $GrupoAtivo = new Zend_Session_Namespace('GrupoAtivo');
     // cria a sessão com o grupo ativo
     $codGrupo = $GrupoAtivo->codGrupo;
     //  Grupo ativo na sessão
     $codOrgao = $GrupoAtivo->codOrgao;
     //  Órgão ativo na sessão
     $destino = TramitarprojetosDAO::pesquisarDestinos(1);
     $this->view->Destino = $destino;
     $todosDestinos = TramitarprojetosDAO::pesquisarTodosDestinos();
     $this->view->TodosDestinos = $todosDestinos;
     $despacho = TramitarprojetosDAO::projetosDespachados(1, 4);
     $this->view->Despacho = $despacho;
     $db = Zend_Registry::get('db');
     if (isset($_POST)) {
         if ($_POST['projeto']) {
             try {
                 //Código novo - Jefferson
                 //VERIFICAR A EXISTENCIA DO PROJETO
                 $Projetos = new Projetos();
                 $dadosProjeto = $Projetos->buscarIdPronac($_POST['pronac']);
                 if (empty($dadosProjeto)) {
                     parent::message("Projeto inexistente.", "tramitarprojetos/despacharprojetos", "ALERT");
                 }
                 //CHECAR SE HÁ DOCUMENTO SEM ANEXACAO PARA O PROJETO
                 $whereHistorio = array();
                 $whereHistorio['idPronac = ?'] = $dadosProjeto->IdPRONAC;
                 $whereHistorio['idDocumento != ?'] = 0;
                 $whereHistorio['Acao < ?'] = 4;
                 $whereHistorio['stEstado = ?'] = 1;
                 $tbHistoricoDocumento = new tbHistoricoDocumento();
                 $dadosTbHistorico = $tbHistoricoDocumento->buscar($whereHistorio);
                 if (count($dadosTbHistorico) > 0) {
                     parent::message("O projeto não pode ser despachado, porque existe documento a ser juntado antes da sua tramitação para outra unidade.", "tramitarprojetos/despacharprojetos", "ALERT");
                 }
                 //CHECAR SE O PROJETO NAO ESTA DESPACHADO PARA OUTRA UNIDADE
                 $whereHistorio = array();
                 $whereHistorio['idPronac = ?'] = $dadosProjeto->IdPRONAC;
                 $whereHistorio['idDocumento = ?'] = 0;
                 $whereHistorio['Acao < ?'] = 3;
                 $whereHistorio['stEstado = ?'] = 1;
                 $dadosTbHistorico = $tbHistoricoDocumento->buscar($whereHistorio);
                 if (count($dadosTbHistorico) > 0) {
                     parent::message("O projeto não pode ser despachado novamente, transação cancelada.", "tramitarprojetos/despacharprojetos", "ALERT");
                 }
                 //SE EXISTIR ALGUM REGISTRO ATIVO, ELE TRANSFORMA PARA HISTORICO
                 $whereHistorio = array();
                 $whereHistorio['idPronac = ?'] = $dadosProjeto->IdPRONAC;
                 $whereHistorio['idDocumento = ?'] = 0;
                 $whereHistorio['stEstado = ?'] = 1;
                 $atualizaHistorico = $tbHistoricoDocumento->buscar($whereHistorio);
                 foreach ($atualizaHistorico as $a) {
                     $dadosAlteracao = array();
                     $dadosAlteracao['stEstado'] = 0;
                     $whereAlteracao = "idHistorico = {$a->idHistorico}";
                     $atualizaHistorico = $tbHistoricoDocumento->alterar($dadosAlteracao, $whereAlteracao);
                 }
                 //CADASTRA UM REGISTRO DE TRAMITACAO
                 $dados = array('idPronac' => $dadosProjeto->IdPRONAC, 'idDocumento' => 0, 'idOrigem' => $codOrgao, 'idUnidade' => $_POST['idunidade'], 'dtTramitacaoEnvio' => new Zend_Db_Expr('GETDATE()'), 'idUsuarioEmissor' => $idusuario, 'meDespacho' => $_POST['despacho'], 'Acao' => 1, 'stEstado' => 1);
                 if ($codOrgao == $_POST['idunidade']) {
                     parent::message("O projeto não pode ser despachado para sua própria unidade.", "tramitarprojetos/despacharprojetos", "ALERT");
                 } else {
                     $tbHistoricoDocumento->inserir($dados);
                 }
                 parent::message("Cadastro realizado com sucesso!", "tramitarprojetos/despacharprojetos", "CONFIRM");
             } catch (Exception $e) {
                 parent::message("Error: " . $e->getMessage(), "gerenciarpareceres/index", "ERROR");
                 die($e->getMessage());
             }
         }
     }
 }
 /**
  * Método buscarProjeto()
  * @access public
  * @param void
  * @return void
  */
 public function buscarprojetoAction()
 {
     $Pronac = $this->_request->getParam("Pronac");
     if (!empty($Pronac)) {
         $proj = new Projetos();
         $resp = $proj->buscarIdPronac($Pronac);
         if (!empty($resp)) {
             $this->_redirect('consultardadosprojeto/index?idPronac=' . $resp->IdPRONAC);
         } else {
             parent::message("Nenhum projeto encontrado com o n&uacute;mero de Pronac informado.", "principal/index", "ERROR");
         }
     } else {
         parent::message("Informe o Pronac.", "principal/index", "ERROR");
     }
 }
 public function cadastrarDocumentoAction()
 {
     $pronac = $this->_request->getParam("Pronac");
     $tpDocumento = $this->_request->getParam("tpDocumento");
     if (empty($pronac) || empty($tpDocumento)) {
         parent::message("Favor preencher os dados obrigatórios!", "anexardocumentosminc", "ERROR");
     }
     try {
         $projetos = new Projetos();
         $dadosProjeto = $projetos->buscarIdPronac($pronac);
         if (!empty($_FILES['arquivo']['tmp_name'])) {
             $arquivoNome = $_FILES['arquivo']['name'];
             // nome
             $arquivoTemp = $_FILES['arquivo']['tmp_name'];
             // nome temporário
             $arquivoTipo = $_FILES['arquivo']['type'];
             // tipo
             $arquivoTamanho = $_FILES['arquivo']['size'];
             // tamanho
             if (!empty($arquivoNome) && !empty($arquivoTemp)) {
                 $arquivoExtensao = Upload::getExtensao($arquivoNome);
                 // extensão
                 $arquivoBinario = Upload::setBinario($arquivoTemp);
                 // binário
                 $arquivoHash = Upload::setHash($arquivoTemp);
                 // hash
             }
             if (!isset($_FILES['arquivo'])) {
                 parent::message("O arquivo n&atilde;o atende os requisitos informados no formul&aacute;rio.", "anexardocumentosminc", "ERROR");
             }
             if (empty($_FILES['arquivo']['tmp_name'])) {
                 parent::message("Favor selecionar um arquivo.", "anexardocumentosminc", "ERROR");
             }
             $tipos = array('pdf');
             if (!in_array(strtolower($arquivoExtensao), $tipos)) {
                 parent::message("Favor selecionar o arquivo no formato PDF!", "anexardocumentosminc", "ERROR");
             }
             $dataString = file_get_contents($arquivoTemp);
             $arrData = unpack("H*hex", $dataString);
             $data = "0x" . $arrData['hex'];
             // ==================== PERSISTE DADOS DO ARQUIVO =================//
             $dadosArquivo = array('nmArquivo' => $arquivoNome, 'sgExtensao' => $arquivoExtensao, 'biArquivo' => $data, 'dsDocumento' => 'Anexar Documento - MINC', 'idPronac' => $dadosProjeto->IdPRONAC, 'idTipoDocumento' => $tpDocumento);
             $Arquivo = new Arquivo();
             $Arquivo->inserirUploads($dadosArquivo);
         }
         parent::message("Anexo cadastrado com sucesso!", "anexardocumentosminc", "CONFIRM");
     } catch (Exception $e) {
         parent::message("Erro ao salvar os dados.", "anexardocumentosminc", "ERROR");
     }
 }