LogErrorReader::factory()->clearAllCache()->getLog('Cache removido com sucesso!'); exit; break; case 'logoffAll': //Remove Cache das sessões $pattern = __BASE_PATH__ . "/cache/sessions/sess_*"; $arrSessionFiles = glob($pattern); foreach ($arrSessionFiles as $key => $absoluteFileName) { @unlink($absoluteFileName); } LogErrorReader::factory()->getLog('Logoff efetuado com sucesso!'); exit; break; case 'getImagesSituation': $digital = $_REQUEST['digital']; $documentoImagemTmp = new \Documento\Imagem\DocumentoImagemPDF(); $documentoImagemTmp->setDigital($digital); $sourcePath = $documentoImagemTmp->getUploadPath(); $documentoImagemTmp = null; $sql = "\r\n SELECT *\r\n FROM TB_DOCUMENTOS_IMAGEM \r\n WHERE \r\n DIGITAL = ? \r\n ORDER BY ID\r\n "; // AND DAT_INCLUSAO > TO_DATE('2014-01-11', 'YYYY-MM-DD') // AND DAT_INCLUSAO < TO_TIMESTAMP('2014-01-16 14:00:00','YYYY-MM-DD HH24:MI:SS') $stmt = \Controlador::getInstance()->getConnection()->connection->prepare($sql); $stmt->bindParam(1, $digital, \PDO::PARAM_STR); $stmt->execute(); $arrDocumentoImagem = $stmt->fetchAll(\PDO::FETCH_ASSOC); //Remove Cache da Digital $pattern = $sourcePath . '*'; $arrArquivosExistentes = glob($pattern); $i = 0; while ($i < count($arrArquivosExistentes)) {
/** * Realiza merge entre mais de um Documento Imagem que compõe as Imagens do * Documento. Esta versão é anterior à implementação do DocumentoImagemAggregator * e por este motivo está depreciada. Sua utilização não é recomendada. * * @todo Remover daqui. Não é função de Fábrica. * @deprecated since version 4.2.14 * @param string $parDigital * @param array $parDocumentoImagens * @return \Documento\DocumentoImagemAggregator */ private static function _appendImages($parDigital, $parDocumentoImagens = array()) { $cfg = \Config::factory(); // $pdfMergedAbsoluteDest = $cfg->getParam('config.basepath') . '/cache/TEMP_PDF_DOCUMENTO_' . preg_replace( '/[., ]/', '', $parDigital . '_' . microtime() ); $pdfMergedAbsoluteDest = $cfg->getParam('config.basepath') . '/cache/TESTE'; if (!is_dir($pdfMergedAbsoluteDest)) { @mkdir($pdfMergedAbsoluteDest, 0777, true); } $arrPDFs = array(); $i = 0; foreach ($parDocumentoImagens as $parDocumentoImagem) { $pdfPartialDocAbsoluteFilename = sprintf("{$pdfMergedAbsoluteDest}/%04d.pdf", ++$i); $arrPDFs[] = $pdfPartialDocAbsoluteFilename; //Reune nomes dos arquivos PDFs //Salva em arquivos PDFs temporários $retorno = file_put_contents($pdfPartialDocAbsoluteFilename, $parDocumentoImagem->getPDF()->getData()); } $finalFileName = "{$pdfMergedAbsoluteDest}/final.pdf"; $cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile={$finalFileName} "; foreach ($arrPDFs as $pdfFilename) { $cmd .= $pdfFilename . " "; } shell_exec($cmd); foreach ($arrPDFs as $pdfFilename) { @unlink($pdfFilename); } //Recupera FLG_PUBLICO do ultimo documento enviado $rowLastImage = $parDocumentoImagens[count($parDocumentoImagens) - 1]->getRowSet(); /** * @TODO: REFAZER */ $documentoImagemPDF = new \Documento\Imagem\DocumentoImagemPDF(); $documentoImagemPDF->newImage($parDigital, $finalFileName, $rowLastImage[0]['FLG_PUBLICO']); // @rmdir($pdfMergedAbsoluteDest); // unlink($pdfMersgedAbsoluteFilename);//apaga o diretório return self::factory($parDigital); }
/* this is where regular request code goes.. */ $response = null; if (isset($_FILES)) { //&& count($_FILES) try { $fileDigitais = array('name' => $_FILES['files']['name'][0], 'type' => $_FILES['files']['type'][0], 'tmp_name' => $_FILES['files']['tmp_name'][0], 'error' => $_FILES['files']['error'][0], 'size' => $_FILES['files']['size'][0]); /** * Utilizada criação de objeto concreto por ser permitido somente o * upload de arquivos PDF. Caso seja liberado para outros tipos, * utilizar fábrica para criação de objetos. */ $session = \Session::get('_upload'); $digital = $session['digital']; //Crio documento Imagem Anterior para qualquer tipo de conversão de passivo necessária $documentoImagemAnterior = \Documento\Imagem\DocumentoImagemFactory::factory($digital); $documentoImagemNovo = new \Documento\Imagem\DocumentoImagemPDF(); $documentoImagemNovo->upload($fileDigitais); // Make Result $response = array('name' => $_FILES['files']['name'][0], 'size' => $_FILES['files']['size'][0], 'type' => $_FILES['files']['type'][0], 'status' => 'success'); } catch (Exception $e) { // Make Result $response = array('name' => $_FILES['files']['name'][0], 'size' => $_FILES['files']['size'][0], 'type' => $_FILES['files']['type'][0], 'error' => $e->getMessage()); } } else { $response = array('name' => 'Não existe', 'size' => '0 KB', 'type' => 'Não existe', 'error' => "Não foi possível efetuar o Upload"); } // Print Result print '[' . json_encode($response) . ']'; /* end where regular request code runs.. */ /* ------------------------------------------ */ //$iSize = ob_get_length();
/** * Recupera informações das imagens * @return array * @param string $digital * @param booleano $all booleano que define se serão retornados todos os registros * @param date $date formato yyyy-mm-dd hh:mm:ss * @param array between array de 2 elementos para definir os documentos que serão mostrados ex: páginas de 1 a 15 */ public function recoverInformationDBByDigital($digital, $all = false, $date = '2000-01-01 00:00:00', $between = array()) { $status = $all == false ? 2 : -1; $sql = "SELECT ORDEM, DIGITAL, MD5, FLG_PUBLICO, IMG_WIDTH, IMG_HEIGHT, DAT_INCLUSAO, IMG_TYPE, TOTAL_PAGINAS\r\n FROM TB_DOCUMENTOS_IMAGEM \r\n WHERE DIGITAL = ? AND FLG_PUBLICO != ? AND DAT_INCLUSAO >= ? "; if (count($between) == 2) { $sql .= " AND ORDEM >= {$between[0]} "; } $sql .= " ORDER BY ORDEM ASC"; if (count($between) == 2) { $between[1]++; $sql .= " LIMIT {$between[1]} "; } try { $stmt = Controlador::getInstance()->getConnection()->connection->prepare($sql); $stmt->bindParam(1, $digital, PDO::PARAM_STR); $stmt->bindParam(2, $status, PDO::PARAM_INT); $stmt->bindParam(3, $date, PDO::PARAM_STR); $stmt->execute(); $objAssoc = $stmt->fetchAll(PDO::FETCH_ASSOC); if ($objAssoc[0]['IMG_TYPE'] == '9') { $documentoImagemPDF = new Documento\Imagem\DocumentoImagemPDF(); return $documentoImagemPDF->setRowSet($objAssoc)->getImageList(); } else { return $objAssoc; } } catch (Exception $e) { throw $e; } }