init
This commit is contained in:
74
modules/EcmSales/createPDF.php
Normal file
74
modules/EcmSales/createPDF.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?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) {
|
||||
|
||||
include_once("modules/EcmSales/PDFTemplate/helper.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);
|
||||
$p->mirrorMargins = 1;
|
||||
|
||||
//get languages
|
||||
$labels = return_module_language($focus->ecmlanguage, 'EcmSales');
|
||||
|
||||
//get header
|
||||
$header = '';
|
||||
include("modules/EcmSales/PDFTemplate/tpl/header.php");
|
||||
$p->SetHTMLHeader($header);
|
||||
|
||||
//get footer
|
||||
$footer = '';
|
||||
include("modules/EcmSales/PDFTemplate/tpl/footer-".$focus->ecmlanguage.".php");
|
||||
$p->SetHTMLFooter($footer);
|
||||
|
||||
//get content
|
||||
$content = '';
|
||||
if ($_REQUEST['pdf_type']=='2')
|
||||
include("modules/EcmSales/PDFTemplate/tpl/proforma-content.php");
|
||||
else
|
||||
include("modules/EcmSales/PDFTemplate/tpl/content.php");
|
||||
//$p->WriteHTML($style);
|
||||
|
||||
$p->WriteHTML($content);
|
||||
|
||||
switch ($outputtype) {
|
||||
case "BROSWER" :
|
||||
$p->Output ();
|
||||
return true;
|
||||
case "FILE" :
|
||||
$path = 'upload/zs_' . $focus->number . '.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;
|
||||
};
|
||||
echo $p->Output ($path, "F" );
|
||||
|
||||
return $path;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user