Files
crm.e5.pl/modules/EcmProducts/generateProductCardsFromQuote.php
2024-04-27 09:23:34 +02:00

60 lines
2.0 KiB
PHP

<?php
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 ecmquotes as q on q.currency_id=c.id where q.id='".$_REQUEST['record']."'"));
$symbol=$rr['s'];
$w=$GLOBALS['db']->query("select i.ecmproduct_id,i.price,p.product_category_id,p.th from ecmquoteitems as i inner join ecmproducts as p on p.id=i.ecmproduct_id where i.ecmquote_id='".$_REQUEST['record']."' and i.deleted='0' order by i.position asc");
$cat="";
if($_REQUEST['header']==1){
$rwt=$GLOBALS['db']->fetchByAssoc($wt);
$p=catalogueHeader($p,$rwt['th']);
}
echo 'lol';
while($r=$GLOBALS['db']->fetchByAssoc($w)){
$id=$r['ecmproduct_id'];
if($_GET['price']=="srp_price")$r['price']="";
/*
if(($cat!=$r['product_category_id'] || $cat=="") && $_REQUEST['title']==1){
if($_REQUEST['extra']==1 && $cat!=""){
if(categoryExtra($p,$cat,$th)){
$p->AddPage();
$p->Image("modules/EcmProducts/".categoryExtra($p,$cat,$th),5,0,283);
}
}
$p->AddPage();
$p=categoryTitle($p,$r['product_category_id'],$r['th']);
}
*/
$cat=$r['product_category_id'];
$th=$r['th'];
$p=productCardNew($p,$id,$_GET['language'],true,true,$r['price'],$symbol,$_GET['show_price']);
}
if($_REQUEST['extra']==1){
if(categoryExtra($p,$cat,$th)){
$p->AddPage();
$p->Image("modules/EcmProducts/".categoryExtra($p,$cat,$th),5,0,283);
}
}
if($_REQUEST['create_img']==1){
$guid=create_guid();
$type="F";
$file="cache/upload/Catalogue".$guid.".pdf";
}
else{
$type="D";
$file="Catalogue.pdf";
}
$p->Output($file,$type);
if($_REQUEST['create_img']==1){
exec("convert -density 120 -quality 100 /var/www/html/e5crm/".$file." /var/www/html/e5crm/".str_replace(".pdf",".jpg",$file));
chmod(str_replace(".pdf",".jpg",$file),0777);
header("Location: index.php?module=EcmProducts&action=showProductsCardImages&to_pdf=1&guid=".$guid);
}
?>