<?php 
if (!$_REQUEST['record'] || $_REQUEST['record']=='')
	die('Brak rekordu');
else
	$record = $_REQUEST['record'];

include_once("modules/EcmQuotes/PDFTemplate/helper.php");

$focus = new EcmQuote();
$focus -> retrieve($record);

$positions = formatPDFPositions($focus->getPositionList(true), $focus);

$user = new User();
$user -> retrieve($focus->assigned_user_id);

$b = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT document_bank_account as dba FROM accounts WHERE id='".$focus->parent_id."'"));
$bank = $b['dba'];

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, 'EcmQuotes');

//get header
$header = '';
include_once("modules/EcmQuotes/PDFTemplate/header.php");
$p->SetHTMLHeader($header);

//get footer
$footer = '';
include_once("modules/EcmQuotes/PDFTemplate/footer-".$focus->ecmlanguage.".php");
$p->SetHTMLFooter($footer);

//get content
$content = '';
include_once("modules/EcmQuotes/PDFTemplate/content.php");
//$p->WriteHTML($style);
$p->WriteHTML($content);


//draw PDF
$filename = str_replace(" ","_", str_replace("/", "_", $focus->document_no));
$p->Output ($filename, 'I');

