223 lines
6.7 KiB
PHP
223 lines
6.7 KiB
PHP
<?php
|
|
error_reporting(0);
|
|
function productCardNew($p,$id,$lang,$show_description=true,$show_specification=true,$price="",$symbol="",$show_price=1, $ean=1, $simage){
|
|
|
|
//set languages
|
|
if($lang=="en"){
|
|
$features_label="Features";
|
|
$description_label="Product Description";
|
|
$specification_label="Specification";
|
|
$specification_lbl="Description";
|
|
}
|
|
else {
|
|
$features_label="Cechy";
|
|
$description_label="Opis produktu";
|
|
$specification_label="Specyfikacja";
|
|
$specification_lbl="Opis";
|
|
}
|
|
//create page, add background
|
|
$p->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'];
|
|
|
|
//<br>
|
|
$r['name']=str_replace("<","<",str_replace(">",">",$r['name']));
|
|
$r['name'] = str_replace('<br>', '
|
|
', $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("<ul> ","<ul>",$str);
|
|
$str=str_replace("<ul></ul>","",$str);
|
|
$str=str_replace("<ul> </ul>","",$str);
|
|
$numc=99999;
|
|
$e=explode("<strong>".trim($name),$str);
|
|
$ee=explode("<strong>",$e[1]);
|
|
if(!$ee[0])$ee=explode("</div>",$e[1]);
|
|
$e=$ee;
|
|
$e=explode("</strong>",$e[0]);
|
|
$t=$e[1];
|
|
$p=explode("<p>",$t);
|
|
$p=explode("</p>",$p[1]);
|
|
$p=$p[0];
|
|
$u=explode("<ul>",$t);
|
|
$u=explode("</ul>",$u[1]);
|
|
$u=$u[0];
|
|
$u=str_replace(" "," ",$u);
|
|
$u=str_replace("<li>","",str_replace("</li>","",$u));
|
|
$l=explode("
|
|
",$u);
|
|
$p=str_replace("
|
|
","",$p);
|
|
if($p){
|
|
$tt=wordwrap(strip_tags($p),$numc,"\n");
|
|
$ee=explode("\n",$tt);
|
|
if(count($ee)>0){
|
|
foreach($ee as $e){
|
|
$text[]=$e;
|
|
$cc++;
|
|
}
|
|
}
|
|
}
|
|
if(count($l)>0){
|
|
foreach($l as $list){
|
|
if(!$list || $list==" " || strlen(strip_tags($list))<2)continue;
|
|
if(eregi("<span>",$list))$tt="".wordwrap(str_replace("<span>","",str_replace("</span>","",$list)),34,"\n ");
|
|
else $tt="• ".wordwrap($list,$numc,"\n ");
|
|
$ee=explode("\n",$tt);
|
|
foreach($ee as $e){
|
|
$text[]=$e;
|
|
}
|
|
}
|
|
}
|
|
return $text;
|
|
}
|
|
|
|
function prepareName($t){
|
|
$a1=array(""","a","ą","b","c","ć","d","e","ę","f","g","h","i","j","k","l","ł","m","n","ń","o","ó","p","q","r","s","ś","t","u","v","w","x","y","z","ż","ź");
|
|
$a2=array('"',"A","Ą","B","C","Ć","D","E","Ę","F","G","H","I","J","K","L","Ł","M","N","Ń","O","Ó","P","Q","R","S","Ś","T","U","V","W","X","Y","Z","Ż","Ź");
|
|
$t=str_replace($a1,$a2,$t);
|
|
return iconv("UTF-8","ISO-8859-2",$t);
|
|
}
|
|
?>
|