Files
crm.twinpol.com/modules/EcmPrepaymentInvoices/createPDF.php
2025-05-12 15:44:39 +00:00

74 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')
createEcmPrepaymentInvoicePdf($_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 createEcmPrepaymentInvoicePdf($record, $outputtype) {
if (! $record || $record == '')
die ( 'Brak rekordu' );
include_once ("modules/EcmPrepaymentInvoices/PDFTemplate/helper.php");
include_once ("modules/EcmSysInfos/EcmSysInfo.php");
$focus = new EcmPrepaymentInvoice ();
$focus->retrieve ( $record );
$positions = formatPDFPositions ( $focus->getPositionList ( true ), $focus );
$oo_avaiable = checkIsOO($focus->getPositionList(true), $focus);
if($oo_avaiable==true){
$focus->pdf_text = '<br> OO - Odwrotne obciążenie zgodnie z art. 17 ust. 1 pkt 7 ustawy o vat.';
}
$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, 'EcmPrepaymentInvoices' );
// get header
// get footer
//$footer = '';
//include ("modules/EcmPrepaymentInvoices/PDFTemplate/footer-" . $focus->ecmlanguage . ".php");
//$p->SetHTMLFooter ( $footer );
// get content
$content = '';
include ("modules/EcmPrepaymentInvoices/PDFTemplate/content.php");
$EcmSysInfo = new EcmSysInfo();
$header = $EcmSysInfo->getHeaderForModule('EcmPrepaymentInvoices');
$p->SetHTMLHeader ( $header );
$p->WriteHTML ( $content );
$p->SetHTMLFooter ( $EcmSysInfo->getFooterForModule('EcmPrepaymentInvoices') );
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 . 'EcmPrepaymentInvoices_' . $focus->id. '_' . create_guid() . '.pdf';
break;
};
$p->Output ($path, "F" );
return $path;
}