81 lines
2.4 KiB
PHP
Executable File
81 lines
2.4 KiB
PHP
Executable File
<?php
|
|
// changed mz 2014-12-13
|
|
// auto create PDF only when action=createPDF are not empty
|
|
// otherise wait from function call
|
|
$type = isset($_REQUEST['file'])?'FILE':'BROSWER';
|
|
if ($_REQUEST['action']=='createPDF')
|
|
createEcmSalePdf($_REQUEST['record'], $type);
|
|
|
|
// outputtype:
|
|
// BROSWER - open doc in broswer - return true if OK
|
|
// FILE - save in uploads \
|
|
// EMAIL - save in emails temp dir > return file path if OK
|
|
// MULTIPDF - save in MultiPdf temp dir /
|
|
function createEcmSalePdf($record, $outputtype, $pdf_type = null) {
|
|
if (! $record || $record == '')
|
|
die ( 'Brak rekordu' );
|
|
|
|
if (isset($pdf_type)) {
|
|
$_REQUEST['pdf_type'] = $pdf_type;
|
|
}
|
|
|
|
include_once ("modules/EcmSales/PDFTemplate/helper.php");
|
|
include_once ("modules/EcmSysInfos/EcmSysInfo.php");
|
|
$focus = new EcmSale ();
|
|
$focus->retrieve ( $record );
|
|
|
|
$positions = formatPDFPositions ( $focus->getPositionList ( true ), $focus );
|
|
|
|
$user = new User ();
|
|
$user->retrieve ( $focus->assigned_user_id );
|
|
|
|
include_once ("include/MPDF57/mpdf.php");
|
|
$p = new mPDF ( '', 'A4', null, 'helvetica', 10, 10, 30, 45, 5, 5 );
|
|
$mpdf->mirrorMargins = 1;
|
|
|
|
// get languages
|
|
$labels = return_module_language ( $focus->ecmlanguage, 'EcmSales' );
|
|
|
|
// get header
|
|
|
|
// get footer
|
|
//$footer = '';
|
|
//include ("modules/EcmSales/PDFTemplate/footer-" . $focus->ecmlanguage . ".php");
|
|
//$p->SetHTMLFooter ( $footer );
|
|
|
|
// get content
|
|
$content = '';
|
|
include ("modules/EcmSales/PDFTemplate/content.php");
|
|
$EcmSysInfo = new EcmSysInfo();
|
|
$header = $EcmSysInfo->getHeaderForModule('EcmSales');
|
|
if($_REQUEST['pdf_type']=='0'){
|
|
$header = $EcmSysInfo->getHeaderForModule('EcmInvoiceOuts');
|
|
$p->SetHTMLHeader ( $header );
|
|
} else {
|
|
$p->SetHTMLHeader ( $header );
|
|
}
|
|
|
|
$p->WriteHTML ( $content );
|
|
$p->SetHTMLFooter ( $EcmSysInfo->getFooterForModule('EcmSales') );
|
|
|
|
|
|
switch ($outputtype) {
|
|
case "BROSWER" :
|
|
$p->Output ();
|
|
return true;
|
|
case "FILE" :
|
|
$path = 'upload/zs_' . str_replace("/", "-", $focus->document_no) . '.pdf';
|
|
break;
|
|
case "EMAIL" :
|
|
include_once 'include/ECM/EcmSendMail/EcmSendMail.inc';
|
|
$path = EcmSendMail::TEMP_DIR . 'ZS_' . $focus->number . '.pdf';
|
|
break;
|
|
case "MULTIPDF" :
|
|
include_once 'include/ECM/EcmMultiPdf/EcmMultiPdf.inc';
|
|
$path = EcmMultiPdf::TEMP_DIR . 'EcmSales_' . $focus->id. '_' . create_guid() . '.pdf';
|
|
break;
|
|
};
|
|
$p->Output ($path, "F" );
|
|
|
|
return $path;
|
|
} |