AddPage();
$p->SetMargins(6,0,0,0);
$p->SetDrawColor(0,0,0);
$p->Image("modules/EcmProducts/card_images/background.jpg",0,0,283);
//get product informations
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select th,product_category_id,srp_price,name,code,product_picture,packing_front_picture, ean, ean2 from ecmproducts where id='".$id."' and deleted='0'"));
if($price=="srp_price" || $price==""){
$price=number_format($r['srp_price'], 2, ',', ' ');
}else if($price=="pricebook_price"){
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT price FROM crm.ecmpricebooks_ecmproducts where ecmpricebook_id='".$_SESSION['pricebook_id']."' and ecmproduct_id='".$id."'"));
$price=number_format($r['price'], 2, ',', ' ');
}
if($symbol=="")$symbol="PLN";
$product_picture='modules/EcmProducts/upload/images/big/'.$r['product_picture'];
if(file_exists('modules/EcmProducts/upload/images/big/'.$r['packing_front_picture']))$packing_front_picture='modules/EcmProducts/upload/images/big/'.$r['packing_front_picture'];
$rr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select ean,long_description,short_description from ecmproduct_language where ecmproduct_id='".$id."' and deleted='0' and lower(language)='".$lang."'"));
$ld=str_replace("<","<",str_replace(">",">",$rr['long_description']));
if(!$rr['ean']){
$rrr=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select ean from ecmproduct_language where ecmproduct_id='".$id."' and language='pl'"));
$rr['ean']=$rrr['ean'];
}
if ($ean==2) {
$r['ean'] = $r['ean2'];
}
if ($rr['short_description'] && $rr['short_description']!='')
$r['name'] = $rr['short_description'];
//
$r['name']=str_replace("<","<",str_replace(">",">",$r['name']));
$r['name'] = str_replace('
', '
', $r['name']);
//image border
$p->SetLeftMargin(120);
//$p->Image("modules/EcmProducts/card_images/border.jpg",100,40,160, 130);
//if(file_exists($product_picture) && is_file($product_picture))$p->Image($product_picture,200,100,50);
//product name
$p->SetFont("arialpl","B",16);
$p->SetTextColor(0,148,225);
$p->SetXY(15,45);
$p->Multicell(130,8,prepareName($r['name']), 0, "L");
$p->SetTextColor(0,0,0);
if ($r['product_category_id'] == '77b2bbbc-7ae1-47c3-a5d9-484da1665e3e') {
$cur_x = 80;
} else
$cur_x = 60;
//Index + EAN
//insert red
$p->Image("modules/EcmProducts/card_images/red.jpg", 5+10,$cur_x, 2,10);
//index
$p->SetFont("arialpl","B",9);
$p->SetXY(8+10, $cur_x);
$p->Cell(15,6,"INDEX:",0,0,'L',1);
$p->SetFont("arialpl","",9);
$p->Cell(40,6,$r['code'],0,1,'L',1);
//ean
$p->SetFont("arialpl","B",9);
$p->SetXY(8+10, $cur_x+5);
$p->Cell(15,6,"EAN:",0,0,'L',1);
$p->SetFont("arialpl","",9);
$p->Cell(40,6,$r['ean'],0,1,'L',1);
$cur_x = 95;
//opis
$text=blockToPrint($description_label,$ld);
$lines = sizeof($text);
foreach($text as $tt){
$tt=str_replace("• ","- ",$tt);
$tt=str_replace(""",'"',$tt);
$tt=str_replace(" "," ",$tt);
//$ttext[]=wordwrap($tt,110,"\n ");
$t.= "\n".$tt;
$lines++;
}
$t=trim($t);
$t=iconv("UTF-8","ISO-8859-2",$t);
//$t = "select ean,long_description,short_description from ecmproduct_language where ecmproduct_id='".$id."' and deleted='0' and lower(language)='".$lang."'";
//blue point
$p->SetXY(8+10,$cur_x+5);
$p->Image("modules/EcmProducts/card_images/blue.jpg", 5+10,$cur_x, 2,2);
$p->SetXY(8+10,$cur_x-2);
$p->SetFont("arialpl","B",9);
$p->Cell(200,6,$description_label);
$p->SetXY(8+10,$cur_x+5);
$p->SetFont("arialpl","",9);
$lines = $p->MultiCell(110,4,$t, 0, "L");
//specyfikacja
$cur_x = 100 + $lines * 3;
//$cur_x = 115;
$text=blockToPrint($specification_label,$ld);
$t='';
foreach($text as $tt){
$tt=str_replace("• ","- ",$tt);
$tt=str_replace(""",'"',$tt);
$tt=str_replace(" "," ",$tt);
//$ttext[]=wordwrap($tt,110,"\n ");
$t.= "\n".$tt;
}
//$price = $lines;
$t=trim($t);
$t=iconv("UTF-8","ISO-8859-2",$t);
//blue point
$p->SetXY(8+10,$cur_x+5);
$p->Image("modules/EcmProducts/card_images/blue.jpg", 5+10,$cur_x+10, 2,2);
$p->SetXY(8+10,$cur_x+8);
$p->SetFont("arialpl","B",9);
$p->Cell(200,6,$specification_label);
$p->SetXY(8+10,$cur_x+15);
$p->SetFont("arialpl","",9);
$p->MultiCell(110,4,$t, 0, "L");
//product main picture
$p->SetLeftMargin(147);
if ($show_price==1) {
$p->SetXY(235,15);
$p->SetFont("arialpl","B",18);
$p->Cell(50,6,$price.' '.$symbol);
}
//get image size
//$size = getimagesize($product_picture);
if(file_exists($product_picture) && is_file($product_picture))
$p->Image($product_picture,120,42,130);
return $p;
}
function blockToPrint($name,$str){
$str=str_replace(" "," ",$str);
$str=str_replace("
",$t); $p=explode("
",$p[1]); $p=$p[0]; $u=explode("