private function attachment(&$datosMail, $pathQR = "", $tmp = "") { $contadorAdjuntos = 1; global $SITE_ROOT; if (isset($datosMail['xml']) && !empty($datosMail['xml'])) { $nombreXML = $datosMail['serie'] . $datosMail['folio'] . ".xml"; $archivoXML = dirname(dirname(__FILE__)) . "/f4/extensiones/tmp/" . $nombreXML; $fp = fopen($archivoXML, "w+"); fputs($fp, base64_decode($datosMail['facturaTimbrada'])); fclose($fp); $datosMail['attachment[' . $contadorAdjuntos . ']'] = '@' . $archivoXML; $contadorAdjuntos++; } if (isset($datosMail['pdf']) && !empty($datosMail['pdf'])) { require_once dirname(dirname(__FILE__)) . "/f4/extensiones/formatopdfcfdi.php"; $archivos = creaPDF($datosMail['idFactura'], 2, "../", ""); error_log(print_r($SITE_ROOT . "gui/" . $archivos[1], TRUE)); $datosMail['attachment[' . $contadorAdjuntos . ']'] = '@' . $SITE_ROOT . "gui/" . $archivos[1]; $contadorAdjuntos++; } }
$zipfile = new ZipArchive(); if ($zipfile->open($SITE_ROOT . "gui/tmp/" . $filename, ZipArchive::CREATE) !== true) { throw new Exception("No se pudo crear el archivo"); } $download = false; $downloadfile = ""; $zipfileok = false; require_once '../f4/extensiones/formatopdfcfdi.php'; foreach ($factura['respuesta'] as $row_factura) { // add the binary data stored in the string 'filedata' $filedata = base64_decode($row_factura['factura_timbrada']); $plain = $row_factura['serie'] . "-" . $row_factura['folio'] . ".xml"; $formatopdf = $row_factura['serie'] . "-" . $row_factura['folio'] . ".pdf"; $zipfile->addFromString($plain, $filedata); error_log("Creacion {$formatopdf}"); $archivos = creaPDF($row_factura['idfactura'], 2, "../", ""); //no se para que esta pero hasta otra orden lo dejo chs error_log("archivos-----------------> {$formatopdf}"); error_log(print_r($SITE_ROOT, true)); error_log(print_r($archivos, true)); error_log(print_r($SITE_ROOT . "gui/tmp/" . $archivos[0], true)); //$contents = file_get_contents($SITE_ROOT."gui/".$archivos[1]); if (file_exists($SITE_ROOT . "gui/tmp/" . $archivos[0])) { $zipfile->addFile($SITE_ROOT . "gui/tmp/" . $archivos[0], $formatopdf); error_log("archivos en zip -----------------> {$formatopdf}"); } } // the next three lines force an immediate download of the zip file: $zipfile->close(); ob_clean(); set_time_limit(0);
$colname_idempresa = base64_decode($_SESSION['idempresa']); $path = "../../"; $pathQR = $path . "gui/"; //determina formato. $formato = "formatopdfcfdi"; require_once $path . 'Controller/FacturaController.php'; require_once $path . 'Controller/SelloController.php'; require_once $path . 'Controller/EmpresaController.php'; require_once $path . 'Controller/SucursalController.php'; if (isset($_GET['lote'])) { require_once $formato . '.php'; $archivos = creaPDF($_GET['idsLote'], true, $path, $pathQR); } else { log_action("FORMATO: " . $formato . '.php'); require_once $formato . '.php'; $archivos = creaPDF($_GET['idf'], true, $path, $pathQR); } ?> <html> <head><script>function go_now(){ window.location.href="<?php echo $archivos[1]; ?> ";} </script> </head> <body onLoad="go_now()";> <a href="<?php echo $archivos[1]; ?> ">presione aquí si no abre en 5 segundos</a> </body> </html>