277 lines
7.1 KiB
PHP
277 lines
7.1 KiB
PHP
<?php
|
|
function productCardNew($p, $id, $lang, $show_description = true, $show_specification = true, $price = "", $symbol = "", $show_price = 1, $ean = 1, $parent_item_id="", $parent_type="") {
|
|
|
|
// set languages
|
|
if ($lang == "en") {
|
|
$features_label = "Features";
|
|
$description_label = "Product Description";
|
|
$specification_label = "Specification";
|
|
$specification_lbl = "Description";
|
|
$index_lbl = "INDEX";
|
|
} else {
|
|
$features_label = "Cechy";
|
|
$description_label = "Opis produktu";
|
|
$specification_label = "Specyfikacja";
|
|
$specification_lbl = "Opis";
|
|
$index_lbl = "INDEKS";
|
|
}
|
|
// get product informations
|
|
if ($symbol == "")
|
|
$symbol = "PLN";
|
|
$r = $GLOBALS ['db']->fetchByAssoc ( $GLOBALS ['db']->query ( "select srp_price_eur,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 == "") {
|
|
if ($symbol == 'PLN')
|
|
$price = number_format ( $r ['srp_price'], 2, ',', ' ' );
|
|
else if ($symbol == 'EUR')
|
|
$price = number_format ( $r ['srp_price_eur'], 2, ',', ' ' );
|
|
$price.=' '.$symbol;
|
|
} else if ($price == "pricebook_price") {
|
|
$pr = $GLOBALS ['db']->fetchByAssoc ( $GLOBALS ['db']->query ( "SELECT pp.price, p.currency_value FROM ecmpricebooks_ecmproducts as pp INNER JOIN ecmpricebooks AS p ON pp.ecmpricebook_id=p.id where pp.ecmpricebook_id='" . $_SESSION ['pricebook_id'] . "' and pp.ecmproduct_id='" . $id . "' and pp.deleted='0'" ) );
|
|
if ($pr['currency_value']=='' || is_null($pr['currency_value']))
|
|
$pr['currency_value'] = 1;
|
|
if ($symbol != 'PLN')
|
|
$pr['price'] = $pr['price'] / $pr['currency_value'];
|
|
$price = format_number($pr['price']);
|
|
$price.=' '.$symbol;
|
|
} else {
|
|
$pr = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT pp.price, p.exchange_rate_id FROM ecmprices_ecmproducts AS pp INNER JOIN ecmprices AS p ON pp.ecmprice_id=p.id WHERE pp.ecmprice_id='$price' AND pp.ecmproduct_id='$id'"));
|
|
$c = new Currency;
|
|
$c->retrieve($pr['exchange_rate_id']);
|
|
$symbol = $c->iso4217;
|
|
unset($c);
|
|
$price = format_number($pr['price']).' '.$symbol;
|
|
}
|
|
|
|
if ($parent_type=='EcmQuotes') {
|
|
$pr = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT price_netto FROM ecmquoteitems WHERE id='$parent_item_id' AND deleted='0'"));
|
|
$price = format_number($pr['price_netto']).' '.$symbol;
|
|
}
|
|
|
|
$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 = $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 ($ean == 0) {
|
|
$r['ean'] = '';
|
|
}
|
|
|
|
if ($rr ['short_description'] && $rr ['short_description'] != '')
|
|
$r ['name'] = $rr ['short_description'];
|
|
|
|
//create description
|
|
$tmp = explode('
|
|
', $ld);
|
|
|
|
$description = '';
|
|
$paste = false;
|
|
foreach ($tmp as $line) {
|
|
if ($paste && strpos($line,'strong')!=false) break;
|
|
if ($paste) $description.=$line;
|
|
if (strpos($line, trim($description_label))) $paste = true;
|
|
}
|
|
|
|
$specification = '';
|
|
$paste = false;
|
|
foreach ($tmp as $line) {
|
|
if ($paste && strpos($line,'strong')!=false) break;
|
|
if ($paste) $specification.=$line;
|
|
if (strpos($line, trim($specification_label))) $paste = true;
|
|
}
|
|
|
|
//$specification = str_replace("</", "<<<", $specification);
|
|
//$specification = str_replace("/", "//", $specification);
|
|
//$specification = str_replace("<<<<", "</", $specification);
|
|
$html = '
|
|
<style>
|
|
@page {
|
|
margin: 5mm;
|
|
}
|
|
div.div_main_style {
|
|
width:289mm;
|
|
min-width:289mm;
|
|
height:200mm;
|
|
min-height:200mm ;
|
|
!important;
|
|
background: url("https://'.$_SERVER['HTTP_HOST'].'/modules/EcmProducts/card_images/background.jpg") 50% 0 no-repeat;
|
|
background-size: contain;
|
|
}
|
|
table.table_main_style {
|
|
margin-top: 25mm;
|
|
width:289mm;
|
|
min-width:289mm;
|
|
height:150mm;
|
|
min-height:150mm
|
|
!important;
|
|
}
|
|
* {
|
|
font-family: chelvetica;
|
|
}
|
|
</style>
|
|
<div class="div_main_style">
|
|
';
|
|
if ($show_price==1) {
|
|
//$html.='
|
|
//<div style="font-size: 20; position: absolute; top: 15mm; right: 25mm;">'.$price.'</div>
|
|
//';
|
|
$html.='<table><tr><td style="width: 230mm;"></td><td>
|
|
<p style="font-size: 25; color: rgb(0,148,225); font-weight: bold;">
|
|
'.$price.'
|
|
</p></td></tr></table>';
|
|
}
|
|
$html.='
|
|
<table class="table_main_style">
|
|
<tr>
|
|
<td width=50% valign="top">
|
|
<p style="font-size: 25; color: rgb(0,148,225); font-weight: bold;">
|
|
' . html_entity_decode($r['name']) . '
|
|
</p>
|
|
<table style="width: 100%;">
|
|
<-- indeks, ean -->
|
|
<tr>
|
|
<td style="width: 20%" valign="center">
|
|
<img style="height: 10mm;" src="https://' . $_SERVER ['HTTP_HOST'] . '/modules/EcmProducts/card_images/red.jpg"/>
|
|
</td>
|
|
<td>
|
|
<b>'.$index_lbl.': </b>'.$r['code'].'<br>
|
|
<b>EAN</b>: '.$r['ean'].'
|
|
<br>
|
|
<br>
|
|
</td>
|
|
</tr>
|
|
<!-- opis -->
|
|
<tr>
|
|
<td style="width: 20%" valign="top">
|
|
<img style="height: 3mm;" src="https://' . $_SERVER ['HTTP_HOST'] . '/modules/EcmProducts/card_images/blue.jpg"/>
|
|
</td>
|
|
<td>
|
|
<b>'.$description_label.'</b>
|
|
<br>
|
|
<br>
|
|
'.html_entity_decode($description).'
|
|
<br>
|
|
<br>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="width: 20%" valign="top">
|
|
<img style="height: 3mm;" src="https://' . $_SERVER ['HTTP_HOST'] . '/modules/EcmProducts/card_images/blue.jpg"/>
|
|
</td>
|
|
<td>
|
|
<b>'.$specification_label.'</b>
|
|
<br>
|
|
'.html_entity_decode($specification).'
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
|
|
<td width=50% align="center" valign="center">
|
|
|
|
<img style="max-height: 145mm; height: 140mm" src="https://' . $_SERVER ['HTTP_HOST'] .'/' .$product_picture.'"/>
|
|
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
';
|
|
|
|
$p->WriteHTML ( $html );
|
|
|
|
// echo $html;
|
|
return $p;
|
|
}
|
|
|
|
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 );
|
|
}
|
|
|
|
?>
|