77 lines
2.4 KiB
PHP
Executable File
77 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) {
|
|
if (! $record || $record == '')
|
|
die ( 'Brak rekordu' );
|
|
|
|
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 );
|
|
$mpdf->mirrorMargins = 1;
|
|
|
|
// get languages
|
|
$labels = return_module_language ( $focus->ecmlanguage, 'EcmSales' );
|
|
|
|
// get header
|
|
$header = '';
|
|
include_once ("modules/EcmSales/PDFTemplate/header.php");
|
|
$p->SetHTMLHeader ( $header );
|
|
|
|
// get footer
|
|
$footer = '';
|
|
include_once ("modules/EcmSales/PDFTemplate/footer-" . $focus->ecmlanguage . ".php");
|
|
$p->SetHTMLFooter ( $footer );
|
|
|
|
// get content
|
|
$content = '';
|
|
include_once ("modules/EcmSales/PDFTemplate/content.php");
|
|
// $p->WriteHTML($style);
|
|
$footer = '<hr><table style="font-size: 8pt; width: 100%;vertical-align:top;">
|
|
<tr><td width="25%">Saas SystemS Sp. z o.o.<br />
|
|
ul. Lipnowska 21-23<br />
|
|
87-100 Toruń<br />
|
|
NIP: 9562307719</td><td width="25%"></td><td width="20%">Bank: <br>Numer konta:</td><td>PKO BP<br> 53 1020 5011 0000 9002 0270 6323</td></tr></table>';
|
|
$p->SetHTMLFooter ( $footer );
|
|
// echo $content; die();
|
|
$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;
|
|
};
|
|
$p->Output ($path, "F" );
|
|
|
|
return $path;
|
|
} |