<?php 
error_reporting(0);
set_time_limit (99999999);
ini_set('memory_limit', '-1');
include_once("modules/EcmProducts/productCardUltraNew.php");
include_once("include/MPDF57/mpdf.php");
$p=new mPDF('utf-8','A4-L', null, 'helvetica');
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select c.iso4217 as s from currencies as c inner join ecmnewinvoiceouts as q on q.currency_id=c.id where q.id='".$_REQUEST['record']."'"));
$symbol=$rr['s'];

$db = $GLOBALS['db'];

$focus = new EcmNewInvoiceOut();
$focus->retrieve($_REQUEST['record']);
if ($focus->ecmlanguage=='pl_pl')
	$lang = "pl";
if ($focus->ecmlanguage=='en_us')
	$lang = "en";

$products = $db->query("SELECT id,ecmproduct_id FROM ecmnewinvoiceoutitems WHERE ecmnewinvoiceout_id='".$_REQUEST['record']."' AND deleted='0' ORDER BY position");

while ($prod = $db->fetchByAssoc($products)) {
	$p=productCardNew($p,$prod['ecmproduct_id'],$lang,true,true,"",$symbol,true, $_REQUEST['show_ean'], $prod['id'], "EcmNewInvoiceOuts");
}

if($_REQUEST['create_img']==1){
	$guid=create_guid();
	$type="F";
	$file="cache/upload/Catalogue".$guid.".pdf";
}
else{
	$type="D";
	$file="Catalogue".date("YmdHi").".pdf";
}
$p->Output($file,$type);
