Files
crm.twinpol.com/modules/EcmReceipts2/downloadXML.php

30 lines
1.1 KiB
PHP
Raw Normal View History

2025-05-12 15:44:39 +00:00
<?
//error_reporting(E_ALL);
include_once("modules/EcmReceipts/createXML.php");
//header('Content-type: application/xml');
//header('Content-Disposition: attachment; filename="invoice.xml"');
$file="cache/upload/invoice_xml_".str_replace(" ","_",str_replace(".","_",microtime())).".xml";
fopen($file);
$r=$GLOBALS[db]->fetchByAssoc($GLOBALS[db]->query("select type,document_no from ecmreceipts where id='".$_GET['record']."'"));
if($r['type']=="correct")$xml=createCorrectInvoiceXml($_GET['record']);
else $xml=createInvoiceXml($_GET['record']);
file_put_contents($file,$xml);
chmod($file,0777);
//header("Location: ".$file);
if($_REQUEST['duplicate']){
$r['document_no']=str_replace("FV","FVDUP",$r['document_no']);
}
header("Pragma: public");
header("Cache-Control: maxage=1, post-check=0, pre-check=0");
header("Content-type: application/force-download");
header("Content-Length: " . filesize($file));
header("Content-disposition: attachment; filename=\"".str_replace(" ","",str_replace("/","",$r['document_no'])).".xml\";");
header("Expires: 0");
set_time_limit(0);
@ob_end_clean();
ob_start();
echo file_get_contents($file);
@ob_flush();
?>