public function abrirDocumentosAnexadosAdmissibilidadeAction()
 {
     $this->_helper->layout->disableLayout();
     // Desabilita o Zend Layout
     $idProjeto = $this->_request->getParam("idProjeto");
     $id = $this->_request->getParam('id');
     $tipo = $this->_request->getParam('tipo');
     $tipoDoc = null;
     $bln = "false";
     if ($tipo == '1') {
         $tipoDoc = "tbDocumentosAgentes";
         //SAC.dbo.tbDocumentosAgentes
     } else {
         if ($tipo == '2') {
             $tipoDoc = "tbDocumentosPreProjeto";
             //SAC.dbo.tbDocumentosPreProjeto
         } else {
             if ($tipo == '3') {
                 $tipoDoc = "tbDocumento";
                 //SAC.dbo.tbDocumento
             }
         }
     }
     // Configuração o php.ini para 10MB
     @ini_set("mssql.textsize", 10485760);
     @ini_set("mssql.textlimit", 10485760);
     @ini_set("upload_max_filesize", "10M");
     // busca o arquivo
     $resultado = UploadDAO::abrirdocumentosanexados($id, $tipoDoc);
     if (count($resultado) > 0) {
         $this->_forward("abrirdocumentosanexados", "upload", "", array('id' => $id, 'busca' => $tipoDoc));
         $bln = "true";
     }
     if ($bln == "false") {
         $url = Zend_Controller_Front::getInstance()->getBaseUrl() . "/consultardadosprojeto/?idPronac={$idPronac}";
         $this->_helper->viewRenderer->setNoRender(true);
         $this->_helper->flashMessenger->addMessage("Não foi possível abrir o arquivo especificado. Tente anexá-lo novamente.");
         $this->_helper->flashMessengerType->addMessage("ERROR");
         JS::redirecionarURL($url);
         exit;
     }
 }
 public function abrirdocumentosanexadosbinarioAction()
 {
     // recebe o id do arquivo via get
     $get = Zend_Registry::get('get');
     $id = (int) $get->id;
     $busca = $this->_request->getParam('busca');
     //$get->busca;
     // Configuração o php.ini para 10MB
     @ini_set("mssql.textsize", 10485760);
     @ini_set("mssql.textlimit", 10485760);
     @ini_set("upload_max_filesize", "10M");
     $response = new Zend_Controller_Response_Http();
     // busca o arquivo
     $resultado = UploadDAO::abrirdocumentosanexados($id, $busca);
     if (!$resultado) {
         if ($busca == "documentosanexadosminc") {
             $resultado = UploadDAO::abrirdocumentosanexados($id, "documentosanexadosminc");
         } else {
             $resultado = UploadDAO::abrirdocumentosanexados($id, "documentosanexados");
         }
     }
     // erro ao abrir o arquivo
     if (!$resultado) {
         $this->_helper->layout->disableLayout();
         // Desabilita o Zend Layout
         $this->_helper->viewRenderer->setNoRender();
         // Desabilita o Zend Render
         die("Não existe o arquivo especificado");
         $this->view->message = 'Não foi possível abrir o arquivo!';
         $this->view->message_type = 'ERROR';
     } else {
         // lê os cabeçalhos formatado
         foreach ($resultado as $r) {
             $this->_helper->layout->disableLayout();
             // Desabilita o Zend Layout
             $this->_helper->viewRenderer->setNoRender();
             // Desabilita o Zend Render
             Zend_Layout::getMvcInstance()->disableLayout();
             // Desabilita o Zend MVC
             $this->_response->clearBody();
             // Limpa o corpo html
             $this->_response->clearHeaders();
             // Limpa os headers do Zend
             $hashArquivo = $r->biArquivo ? $r->biArquivo : $r->biArquivo2;
             $this->getResponse()->setHeader('Content-Type', 'application/pdf')->setHeader('Content-Disposition', 'attachment; filename="' . $r->nmArquivo . '"')->setHeader("Connection", "close")->setHeader("Content-transfer-encoding", "binary")->setHeader("Cache-control", "private");
             if ($r->biArquivo2 == 1) {
                 if (strtolower(substr($r->biArquivo, 0, 4)) == '%pdf') {
                     $this->getResponse()->setBody($hashArquivo);
                 } else {
                     $this->getResponse()->setBody(base64_decode($hashArquivo));
                 }
             } else {
                 $this->getResponse()->setBody($hashArquivo);
             }
             //                        $this->getResponse()->setBody($hashArquivo);
             //->setBody(base64_decode($hashArquivo));
         }
         // fecha foreach
     }
     // fecha else
 }