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

43 lines
1.6 KiB
PHP

<?php
set_time_limit(99999);
error_reporting(0);
$bag1='modules/EcmProducts/bag1.png';
$bag2='modules/EcmProducts/bag2.png';
$_REQUEST['html']=1;
$_GET['no_print']=1;
$where="";
if(count($_SESSION['pricebook_check'][$_SESSION['pricebook_id']])>0)
{
foreach($_SESSION['pricebook_check'][$_SESSION['pricebook_id']] as $key=>$value){
if($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]!="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']=="true"){
$where_clauses[]="i.id!='".$key."'";
$orand=' and ';
}
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']][$key]=="true" && $_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true"){
$where_clauses[]="i.id='".$key."'";
$orand=' or ';
}
}
if(count($where_clauses)>0)$where="(".implode($orand,$where_clauses).") and ";
elseif($_SESSION['pricebook_check'][$_SESSION['pricebook_id']]['all']!="true" && count($where_clauses)==0)$where="ecmprices_ecmproducts.id='9999999999999999' and ";
}
else $where="i.id='9999999999999999' and ";
$w=$GLOBALS['db']->query("select i.ecmproduct_id from ecmprices_ecmproducts as i inner join ecmproducts as p on p.id=i.ecmproduct_id where ".$where." i.ecmprice_id='".$_REQUEST['record']."' and i.deleted='0' order by p.product_category_name asc,p.code asc");
include_once("include/html2fpdf/html2fpdf.php");
include_once("modules/EcmProducts/productCard.php");
$p=new HTML2FPDF();
$i=0;
while($r=$GLOBALS['db']->fetchByAssoc($w)){
$i++;
$id=$r['ecmproduct_id'];
if($i%2>0)$p->AddPage();
$p=printCatalogue($p,$id,$_REQUEST['language'],true,true,false);
}
$p->Output("Catalogue.pdf","D");
?>