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

global $mod_strings, $app_list_strings;
include_once ("include/MPDF57/mpdf.php");

$EcmSysInfo = new EcmSysInfo();
$EcmInventory = new EcmInventory ();
$EcmInventory->retrieve($record);

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

$EcmStock = new EcmStock();
$EcmStock->retrieve($EcmInventory->stock_id);

$smarty = new Sugar_Smarty ();
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP_LIST_STRINGS", $app_list_strings);
$smarty->assign("EcmSysInfo", $EcmSysInfo);
$smarty->assign("EcmInventory", $EcmInventory);
$smarty->assign("EcmStock", $EcmStock);

switch($_REQUEST['pdf_type']){
	case '0': $content = $smarty->fetch('modules/EcmInventorys/PDFTemplate/niedobory.tpl'); break;
	case '1': $content = $smarty->fetch('modules/EcmInventorys/PDFTemplate/nadwyzki.tpl'); break;
	case '2': $content = $smarty->fetch('modules/EcmInventorys/PDFTemplate/roznice.tpl'); break;
	case '3': $content = $smarty->fetch('modules/EcmInventorys/PDFTemplate/wszystko.tpl'); break;
}
$mPDF = new mPDF ( 'pl', 'A4', 10, 'arial',  10, 10,30, 45, 5, 5);
$mPDF->setAutoTopMargi = 'stretch';
$mPDF->setAutoBottomMargin = 'stretch';
$mPDF->mirrorMargins = 1;
$mPDF->WriteHTML($content);
$mPDF->Output();