99 lines
3.2 KiB
PHP
99 lines
3.2 KiB
PHP
<?php
|
|
|
|
if (! $_REQUEST ['record'] || $_REQUEST ['record'] == '')
|
|
die ( 'Brak rekordu' );
|
|
else
|
|
$record = $_REQUEST ['record'];
|
|
|
|
include_once ("modules/EcmInsideOrders/PDFTemplate/helper.php");
|
|
|
|
$focus = new EcmInsideOrder ();
|
|
$focus->retrieve ( $record );
|
|
|
|
$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;
|
|
|
|
$db = $GLOBALS ['db'];
|
|
// document pdf
|
|
// document already exist?
|
|
$res = $db->query ( "SELECT footer, content FROM ecminsideorder_pdf WHERE id='$record'" );
|
|
if ($res->num_rows == 0) {
|
|
// create and save document
|
|
$positions = formatPDFPositions ( $focus->getPositionList ( true ), $focus );
|
|
// get header
|
|
$header = '';
|
|
include_once ("modules/EcmInsideOrders/PDFTemplate/header.php");
|
|
$content = '';
|
|
include_once ("modules/EcmInsideOrders/PDFTemplate/content.php");
|
|
|
|
global $current_user;
|
|
$db->query ( "INSERT INTO ecminsideorder_pdf VALUES ('$record','$current_user->id', NOW(),'" . urlencode ( $header ) . "', '" . urlencode( $content ) . "')" );
|
|
} else {
|
|
$row = $db->fetchByAssoc ( $res );
|
|
$header = urldecode ( $row ['footer'] ); // punk rock!
|
|
$content = urldecode ( $row ['content'] );
|
|
}
|
|
|
|
$p->SetHTMLHeader ( $header );
|
|
$p->WriteHTML ( $content );
|
|
if($focus->rw_id!='' && $focus->pw_id!=''){
|
|
$rw_id=$focus->rw_id;
|
|
$pw_id=$focus->pw_id;
|
|
unset($focus);
|
|
$focus = new EcmStockDocInsideIn();
|
|
$focus->retrieve ( $pw_id);
|
|
$res = $db->query ( "SELECT footer, content FROM ecmstockdocinsidein_pdf WHERE id='$pw_id'" );
|
|
if ($res->num_rows == 0) {
|
|
// create and save document
|
|
$positions = formatPDFPositions ( $focus->getPositionList ( true ), $focus );
|
|
// get header
|
|
$content = '';
|
|
include_once ("modules/EcmStockDocInsideIns/PDFTemplate/content.php");
|
|
|
|
global $current_user;
|
|
$db->query ( "INSERT INTO ecmstockdocinsidein_pdf VALUES ('$pw_id','$current_user->id', NOW(),'" . urlencode ( $header ) . "', '" . urlencode( $content ) . "')" );
|
|
} else {
|
|
|
|
$row = $db->fetchByAssoc ( $res );
|
|
$header = urldecode ( $row ['footer'] ); // punk rock!
|
|
$content = urldecode ( $row ['content'] );
|
|
}
|
|
$p->AddPage();
|
|
$p->WriteHTML ( $content );
|
|
$content = '';
|
|
unset($focus);
|
|
|
|
$focus = new EcmStockDocInsideOut();
|
|
$focus->retrieve ( $rw_id);
|
|
$res = $db->query ( "SELECT footer, content FROM ecmstockdocinsideout_pdf WHERE id='$rw_id'" );
|
|
if ($res->num_rows == 0) {
|
|
// create and save document
|
|
$positions = formatPDFPositions ( $focus->getPositionList ( true ), $focus );
|
|
// get header
|
|
$content = '';
|
|
include_once ("modules/EcmStockDocInsideOuts/PDFTemplate/content.php");
|
|
|
|
global $current_user;
|
|
$db->query ( "INSERT INTO ecmstockdocinsideout_pdf VALUES ('$rw_id','$current_user->id', NOW(),'" . urlencode ( $header ) . "', '" . urlencode( $content ) . "')" );
|
|
} else {
|
|
$row = $db->fetchByAssoc ( $res );
|
|
|
|
$content = urldecode ( $row ['content'] );
|
|
|
|
}
|
|
|
|
$p->AddPage();
|
|
$p->WriteHTML ( $content );
|
|
|
|
}
|
|
|
|
|
|
// draw PDF
|
|
$p->Output ();
|
|
|
|
|