Files
crm.twinpol.com/modules/EcmProducts/DetailView.php

498 lines
26 KiB
PHP
Raw Normal View History

2025-05-12 15:44:39 +00:00
<?php
if (!defined('sugarEntry') || !sugarEntry)
die('Not A Valid Entry Point');
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings, $current_user, $app_list_strings, $db;
$app_list_strings['ecmproducts_parent_dom'] = array(
'Accounts' => $app_list_strings['moduleList']['Accounts'],
'Leads' => $app_list_strings['moduleList']['Leads'],
);
require_once('modules/EcmProducts/EcmProduct.php');
require_once('modules/EcmProducts/Forms.php');
require_once('include/time.php');
require_once('include/json_config.php');
2025-05-29 20:21:38 +02:00
function getConsignmentsDocs($prod_id, $stock_id, $jm)
{
$documents_map = array(
'EcmStockDocIns' => 'PZ',
'EcmStockDocCorrects' => 'KS',
'EcmStockDocMoves' => 'MM',
'EcmStockDocInsideIns' => 'PW'
2025-05-12 15:44:39 +00:00
);
2025-05-29 20:21:38 +02:00
2025-05-12 15:44:39 +00:00
global $db;
$query = "
select i.id, i.parent_id, i.parent_type, i.parent_name, i.price, i.quantity as in_qty, i.part_no, ifnull(sum(o.quantity),0) as out_qty, p.unit_id
from ecmstockoperations as i
left join ecmstockoperations as o
on i.id = o.in_id
inner join ecmproducts as p
on i.product_id = p.id
where
i.product_id='$prod_id' and
i.stock_id='$stock_id' and
i.used = '0' and
i.type='0'
group by i.id
order by i.date_entered;";
2025-05-29 20:21:38 +02:00
$res = $db->query($query);
$result = array();
2025-05-12 15:44:39 +00:00
global $app_list_strings, $sugar_config;
2025-05-29 20:21:38 +02:00
while ($row = $db->fetchByAssoc($res)) {
$availability = (floatval($row['in_qty']) - floatval($row['out_qty']));
2025-05-12 15:44:39 +00:00
if ($availability <= 0)
continue;
2025-05-29 20:21:38 +02:00
$tmp = array();
if ($row['parent_type'] == 'EcmStockDocInsideIns') {
2025-05-12 15:44:39 +00:00
$accountQuery = "SELECT name FROM ecmstockdocinsideins WHERE id='" . $row['parent_id'] . "'";
$accountResult = $db->query($accountQuery);
2025-05-29 20:21:38 +02:00
if ($accountResult->num_rows > 0) {
$accountRow = $db->fetchByAssoc($accountResult);
$tmp['account_name'] = $accountRow['name'];
} else {
$tmp['account_name'] = '';
2025-05-12 15:44:39 +00:00
}
2025-05-29 20:21:38 +02:00
} else {
$accountQuery = "SELECT parent_id, parent_name FROM " . strtolower($row['parent_type']) . " WHERE id='" . $row['parent_id'] . "'";
2025-05-12 15:44:39 +00:00
$accountResult = $db->query($accountQuery);
2025-05-29 20:21:38 +02:00
if ($accountResult->num_rows > 0) {
$accountRow = $db->fetchByAssoc($accountResult);
$tmp['account_name'] = '<a href="index.php?module=Accounts&action=DetailView&record=' . $accountRow['parent_id'] . '">' . $accountRow['parent_name'] . '</a>';
} else {
$tmp['account_name'] = '';
2025-05-12 15:44:39 +00:00
}
}
2025-05-29 20:21:38 +02:00
$tmp['operation_id'] = $row['id'];
$tmp['parent_name'] = '<a href="index.php?module=' . $row['parent_type'] . '&action=DetailView&record=' . $row['parent_id'] . '">' . $documents_map[$row['parent_type']] . ' ' . $row['parent_name'] . '</a>';
$tmp['part_no'] = $row['part_no'];
$tmp['availability'] = $availability;
$tmp['parent_id'] = $row['parent_id'];
$tmp['parent_type'] = $row['parent_type'];
$tmp['price'] = $row['price'];
$tmp['unit'] = $app_list_strings['ecmproducts_unit_dom'][$row['unit_id']];
$tmp['currency'] = $sugar_config['default_currency_iso4217'];
$result[] = $tmp;
2025-05-12 15:44:39 +00:00
}
// number_format($tmp, 2, ",", ".")
$html = '
<div style="text-align: center; display: none"><font size="4">Struktura zapasu</font><br>
<table name="Pztki">
<tr>
<td style="text-align: center"><b>Dokument</b></td>
<td style="text-align: center"><b>Dostawca/Nazwa dokumentu</b></td>
<td style="text-align: center; width:10%"><b>Partia</b></td>
<td style="text-align: center; width:10%"><b>Ilość</b></td>
<td style="text-align: center; width:10%"><b>Cena</b></td>
<td style="text-align: center; width:10%"><b>Wartość</b></td>
</tr>';
2025-05-29 20:21:38 +02:00
foreach ($result as $key => $value) {
$tmp = $value['availability'] * $value['price'];
$html .= '<tr>';
$html .= '<td>' . $value['parent_name'] . '</td>';
$html .= '<td>' . $value['account_name'] . '</td>';
$html .= '<td>' . $value['part_no'] . '</td>';
$html .= '<td style="text-align: right">' . number_format($value['availability'], $app_list_strings['ecmproducts_unit_dom_precision'][$jm], ",", ".") . ' ' . $value['unit'] . '</td>'; //FormatNumber(c.availability) + ' ' + c.unit
$html .= '<td style="text-align: right">' . number_format($value['price'], 2, ",", ".") . ' ' . $value['currency'] . ' / ' . $value['unit'] . '</td>'; //FormatNumber(c.price) + ' ' + c.currency + ' / ' + c.unit
$html .= '<td style="text-align: right">' . number_format($tmp, 2, ",", ".") . ' zł</td>';
$html .= '</tr>';
2025-05-12 15:44:39 +00:00
}
$html .= '</table><br><br></div>';
return $html;
}
2025-05-29 20:21:38 +02:00
function getStockOperations($product_id, $stock_id, $jm)
{
global $db, $app_list_strings;
2025-05-12 15:44:39 +00:00
$query = "SELECT date_entered, quantity, type, parent_name, parent_type, parent_id, price FROM ecmstockoperations so where so.product_id='" . $product_id . "' AND so.stock_id ='" . $stock_id . "'order by counter";
2025-05-29 20:21:38 +02:00
$res = $db->query($query);
$result = array();
2025-05-12 15:44:39 +00:00
$html = '
<div style="text-align: center; display: none"><font size="4">Operacje magazynowe</font><br>
<table name="stockOperations">
<tr>
<td style="text-align: center"><b>Dokument</b></td>
<td style="text-align: center"><b>Kontrahent</b></td>
<td style="text-align: center; width:10%"><b>Data</b></td>
<td style="text-align: center; width:10%"><b>Cena</b></td>
<td style="text-align: center; width:10%"><b>Ilość</b></td>
<td style="text-align: center; width:10%"><b>Stan po</b></td>
</tr>';
2025-05-29 20:21:38 +02:00
$stanpo = 0;
$doc_name = array(
'EcmStockDocInsideIns' => 'PW',
'EcmStockDocMoves' => 'MM',
'EcmStockDocCorrects' => 'KS',
'EcmStockDocIns' => 'PZ',
'EcmStockDocOuts' => 'WZ',
'EcmStockDocInsideOuts' => 'RW',
'EcmInvoiceOuts' => 'FK'
2025-05-12 15:44:39 +00:00
);
2025-05-29 20:21:38 +02:00
while ($row = $db->fetchByAssoc($res)) {
2025-05-12 15:44:39 +00:00
$subquery = '';
2025-05-29 20:21:38 +02:00
$subquery = 'SELECT parent_id, parent_name, parent_type FROM ' . strtolower($row['parent_type']) . ' WHERE id = "' . $row['parent_id'] . '"';
$result = $db->query($subquery);
if (!$result) {
$subquery = 'SELECT parent_id, parent_name FROM ' . strtolower($row['parent_type']) . ' WHERE id = "' . $row['parent_id'] . '"';
$result = $db->query($subquery);
2025-05-12 15:44:39 +00:00
}
2025-05-29 20:21:38 +02:00
$kontrahent = $db->fetchByAssoc($result);
if ($kontrahent['parent_type'] == NULL || $kontrahent['parent_type'] == '') {
switch ($row['parent_type']) {
case 'EcmStockDocIns': {
$kontrahent['parent_type'] = 'Accounts';
$tmp = '<a href="index.php?module=' . $kontrahent['parent_type'] . '&action=DetailView&record=' . $kontrahent['parent_id'] . '">' . $kontrahent['parent_name'] . '</a>';
break;
}
default: {
$tmp = $kontrahent['parent_name'];
}
2025-05-12 15:44:39 +00:00
}
2025-05-29 20:21:38 +02:00
} else {
$tmp = '<a href="index.php?module=' . $kontrahent['parent_type'] . '&action=DetailView&record=' . $kontrahent['parent_id'] . '">' . $kontrahent['parent_name'] . '</a>';
2025-05-12 15:44:39 +00:00
}
$nazwa = '';
2025-05-29 20:21:38 +02:00
if ($row['type'] == 0) {
$nazwa = '<a href="index.php?module=' . $row['parent_type'] . '&action=DetailView&record=' . $row['parent_id'] . '"><font color="green">' . $doc_name[$row['parent_type']] . ' ' . $row['parent_name'] . '</font></a>';
$stanpo += $row['quantity'];
} elseif ($row['type'] == 1) {
$nazwa = '<a href="index.php?module=' . $row['parent_type'] . '&action=DetailView&record=' . $row['parent_id'] . '"><font color="red">' . $doc_name[$row['parent_type']] . ' ' . $row['parent_name'] . '</font></a>';
$stanpo -= $row['quantity'];
2025-05-12 15:44:39 +00:00
}
2025-05-29 20:21:38 +02:00
$data = substr($row['date_entered'], 0, 10);
2025-05-12 15:44:39 +00:00
$data = explode('-', $data);
2025-05-29 20:21:38 +02:00
$data = $data[2] . '.' . $data[1] . '.' . $data[0];
$html .= '<tr>';
$html .= '<td>' . $nazwa . '</td>';
$html .= '<td>' . $tmp . '</td>';
$html .= '<td style="text-align: right">' . $data . '</td>'; //FormatNumber(c.availability) + ' ' + c.unit
$html .= '<td style="text-align: right">' . number_format($row['price'], 2, ",", ".") . '</td>';
$html .= '<td style="text-align: right">' . number_format($row['quantity'], $app_list_strings['ecmproducts_unit_dom_precision'][$jm], ",", ".") . '</td>';
$html .= '<td style="text-align: right">' . number_format($stanpo, $app_list_strings['ecmproducts_unit_dom_precision'][$jm], ",", ".") . '</td>';
$html .= '</tr>';
2025-05-12 15:44:39 +00:00
}
$html .= '</table><br><br></div>';
return $html;
}
$json_config = new json_config();
$focus = new EcmProduct();
if (isset($_REQUEST['record'])) {
$focus->retrieve($_REQUEST['record']);
//if(isset($focus->id) && $focus->id != '')$focus->format_all_fields();
}
$json = getJSONobj();
require_once('include/MVC/View/SugarView.php');
require_once('modules/EcmProducts/views/DetailView/view.detail.ecmproducts.php');
$detail = new ViewDetailEcmProducts();
$detail->ss = new Sugar_Smarty();
$detail->bean = $focus;
$detail->preDisplay();
$uunit_array = array();
$uunit = '';
$result = $db->query("select id,name from ecmproductusageunits order by name asc");
foreach ($app_list_strings['ecmproducts_unit_dom'] as $key => $value) {
2025-05-29 20:21:38 +02:00
$uunit .= '<option value="' . $key . '"';
2025-05-12 15:44:39 +00:00
if ($focus->usage_unit_id == $key) {
2025-05-29 20:21:38 +02:00
$uunit .= ' selected';
2025-05-12 15:44:39 +00:00
}
2025-05-29 20:21:38 +02:00
$uunit .= '>' . $value . '</option>';
2025-05-12 15:44:39 +00:00
$uunit_array[$key] = $value;
}
$detail->ss->assign("USAGE_UNIT_ID", $uunit);
$fbas = '';
$result = $db->query("select id,name from ecmproductbasis order by name asc");
while (($row = $db->fetchByAssoc($result)) != null) {
2025-05-29 20:21:38 +02:00
$fbas .= '<option value="' . $row['id'] . '"';
2025-05-12 15:44:39 +00:00
if ($focus->fob_basis_id == $row['id'])
2025-05-29 20:21:38 +02:00
$fbas .= ' selected';
$fbas .= '>' . $row['name'] . '</option>';
2025-05-12 15:44:39 +00:00
}
$detail->ss->assign("FOB_BASIS_ID", $fbas);
$pack = '';
$result = $db->query("select id,name from ecmproductpackingtypes order by name asc");
while (($row = $db->fetchByAssoc($result)) != null) {
2025-05-29 20:21:38 +02:00
$pack .= '<option value="' . $row['id'] . '"';
2025-05-12 15:44:39 +00:00
if ($focus->packing_type_id == $row['id'])
2025-05-29 20:21:38 +02:00
$pack .= ' selected';
$pack .= '>' . $row['name'] . '</option>';
2025-05-12 15:44:39 +00:00
}
$detail->ss->assign("PACKING_TYPE_ID", $pack);
//load currencies
require_once('modules/Currencies/Currency.php');
$currency = new Currency();
$currency_list = $currency->get_full_list('name');
$currency->retrieve('-99');
if (is_array($currency_list)) {
2025-05-29 20:21:38 +02:00
$currency_list = array_merge(array($currency), $currency_list);
2025-05-12 15:44:39 +00:00
} else {
2025-05-29 20:21:38 +02:00
$currency_list = array($currency);
2025-05-12 15:44:39 +00:00
}
$arr = array();
foreach ($currency_list as $key => $value) {
$arr[$value->id] = $value->name;
}
$detail->ss->assign("EXCHANGE_RATE_NAME", $arr[$focus->exchange_rate_id]);
2025-05-29 20:21:38 +02:00
function show_image($img)
{
2025-05-12 15:44:39 +00:00
if (is_file($img)) {
$obraz = @GetImageSize($img);
if ($obraz[0] >= 180) {
$szerokosc = 180;
$wysokosc = $obraz[1] * $szerokosc / $obraz[0];
} else {
$szerokosc = $obraz[0];
$wysokosc = $obraz[1];
}
$height = $obraz[1] + 20;
$width = $obraz[0] + 20;
2025-05-29 20:21:38 +02:00
return '<a style="cursor:pointer;" onclick="window.open(\'' . $img . '\',\'Image\',\'height=' . $height . ',width=' . $width . '\');"><img src="' . $img . '" width="' . $szerokosc . '" height=" ' . $wysokosc . '"></a>';
2025-05-12 15:44:39 +00:00
}
}
$detail->ss->assign("PRODUCT_PICTURE", show_image("modules/EcmProducts/upload/images/" . $focus->product_picture));
$detail->ss->assign("PACKING_FRONT_PICTURE", show_image("modules/EcmProducts/upload/images/" . $focus->packing_front_picture));
$detail->ss->assign("DRIVER_1", $focus->driver_1);
if ($focus->driver_1)
$detail->ss->assign("DRIVER_1_DOWNLOAD", '<a href="modules/EcmProducts/upload/' . $focus->driver_1 . '">Download</a>');
$detail->ss->assign("DRIVER_2", $focus->driver_2);
if ($focus->driver_2)
$detail->ss->assign("DRIVER_2_DOWNLOAD", '<a href="modules/EcmProducts/upload/' . $focus->driver_2 . '">Download</a>');
//add mz
$pl3 = $this->bean->showPositions3();
$detail->ss->assign('POSITIONS3', $pl3);
$pl4 = $this->bean->showPrices();
$detail->ss->assign('POSITIONS4', $pl4);
$ii = '<table id="stock_info" cellspacing="0" cellpadding="0" border="0" width="400">
<tr>
2025-05-29 20:21:38 +02:00
<td style="text-align: left"><b>' . $mod_strings['LBL_II_STOCK'] . '</b></td>
<td style="text-align: right; width:10%"><b>' . $mod_strings['LBL_II_QTY'] . '</b></td>
<td style="text-align: right; width:10%"><b>Cena</b></td>
2025-05-12 15:44:39 +00:00
</tr>';
$w = $GLOBALS['db']->query("SELECT
s.name AS stockname,
s.id AS stockid,
2025-05-29 20:21:38 +02:00
ss.quantity AS quantity ,
ss.price AS price
2025-05-12 15:44:39 +00:00
FROM
2025-05-29 20:21:38 +02:00
ecmstockstates ss,
2025-05-12 15:44:39 +00:00
ecmstocks s
WHERE
2025-05-29 20:21:38 +02:00
ss.product_id = '" . $focus->id . "'
AND ss.stock_id = s.id AND ss.quantity IS NOT NULL");
2025-05-12 15:44:39 +00:00
$stocksplus = array();
while ($r = $GLOBALS['db']->fetchByAssoc($w)) {
2025-05-29 20:21:38 +02:00
$ii .= '
<tr>
<td>'.$r['stockname'].'</td>
<td style="text-align: right">'.$r['quantity'].'</td>
<td style="text-align: right">'.$r['price'].'</td>
<tr>
';
/*
// if ($value['quantity'] > 0){
$ii .= '<tr>
2025-05-12 15:44:39 +00:00
<td>
<a href="index.php?query=true&module=EcmStockOperations&action=&searchFormTab=basic_search&product_id_basic=' . $_REQUEST['record'] . '&product_name_basic=' . $focus->name . '&stock_id_basic=' . $value['stockid'] . '&stock_name_basic=' . $value['stockname'] . '">' . $value['stockname'] . "</a>
</td>
2025-05-29 20:21:38 +02:00
<td style='text-align: right'>" . number_format($value['quantity'], $app_list_strings['ecmproducts_unit_dom_precision'][$focus->unit_id], ",", ".") . ' ' . $app_list_strings['ecmproducts_unit_dom'][$focus->unit_id] . "</td>
2025-05-12 15:44:39 +00:00
<td style='text-align: right'>
" . number_format($value['pricequantity'], 2, ",", ".") . "
</td>
<td>&nbsp;<img title='Struktura zapasu' alt='Struktura zapasu' src='modules/EcmSales/images/search.gif' onclick='trigerDocumentsPZ(this)'>&nbsp;<img title='Operacje magazynowe' alt='Operacje magazynowe' src='modules/EcmSales/images/search.gif' onclick='trigerStockOperations(this)'></td>
</tr>
<tr><td colspan='4'>" . getConsignmentsDocs($focus->id, $value['stockid'], $focus->unit_id) . "</td></tr>
<tr><td colspan='4'>" . getStockOperations($focus->id, $value['stockid'], $focus->unit_id) . "</td></tr>";
2025-05-29 20:21:38 +02:00
';
*/
2025-05-12 15:44:39 +00:00
}
2025-05-29 20:21:38 +02:00
$ii .= '</table>';
2025-05-12 15:44:39 +00:00
unset($stocksplus);
$detail->ss->assign("INVENTORY_INFORMATION", $ii);
$rp_app = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select sum(p.product_quantity) as s from ecmproducts_ecmpurchaseorders as p inner join ecmpurchaseorders as e on e.id=p.ecmpurchaseorder_id where p.ecmproduct_id='" . $focus->id . "' and p.deleted='0' and e.status='accepted'"));
$rp_cr = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select sum(p.product_quantity) as s from ecmproducts_ecmpurchaseorders as p inner join ecmpurchaseorders as e on e.id=p.ecmpurchaseorder_id where p.ecmproduct_id='" . $focus->id . "' and p.deleted='0' and e.status='registered'"));
$detail->ss->assign("ORDERED", $rp_app['s'] + $rp_cr['s']);
$detail->ss->assign("CARTON_DIMENSIONS_1", $focus->carton_dimensions_1);
$detail->ss->assign("CARTON_DIMENSIONS_2", $focus->carton_dimensions_2);
$detail->ss->assign("CARTON_DIMENSIONS_3", $focus->carton_dimensions_3);
$detail->ss->assign("PACKING_DIMENSIONS_1", $focus->packing_dimensions_1);
$detail->ss->assign("PACKING_DIMENSIONS_2", $focus->packing_dimensions_2);
$detail->ss->assign("PACKING_DIMENSIONS_3", $focus->packing_dimensions_3);
if ($focus->product_picture)
$detail->ss->assign("PRODUCT_PICTURE_UPLOAD", $mod_strings['LBL_UPLOADED']);
if ($focus->packing_front_picture)
$detail->ss->assign("PACKING_FRONT_PICTURE_UPLOAD", $mod_strings['LBL_UPLOADED']);
if ($focus->driver_1)
$detail->ss->assign("DRIVER_1_UPLOAD", $mod_strings['LBL_UPLOADED']);
if ($focus->driver_2)
$detail->ss->assign("DRIVER_2_UPLOAD", $mod_strings['LBL_UPLOADED']);
$result = $GLOBALS['db']->query("select ean,remarks,short_description,long_description,language,price from ecmproduct_language where ecmproduct_id='" . $_REQUEST['record'] . "'");
while ($row = $GLOBALS['db']->fetchByAssoc($result)) {
$detail->ss->assign("EAN_" . $row['language'], $row['ean']);
$detail->ss->assign("REMARKS_" . $row['language'], $row['remarks']);
$detail->ss->assign("SHORT_DESCRIPTION_" . $row['language'], $row['short_description']);
$detail->ss->assign("LONG_DESCRIPTION_" . $row['language'], str_replace("&lt;", "<", str_replace("&gt;", ">", $row['long_description'])));
$detail->ss->assign("PRICE_" . $row['language'], number_format($row['price'], 2, ",", "."));
}
$send_xml = true;
if (!file_exists("modules/EcmProducts/upload/images/big/" . $focus->product_picture))
$send_xml = false;
if (!file_exists("modules/EcmProducts/upload/images/big/" . $focus->packing_front_picture))
$send_xml = false;
$r = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select ean,remarks,short_description,long_description,language,price from ecmproduct_language where language='pl' and ecmproduct_id='" . $_REQUEST['record'] . "'"));
if (!$r['ean'] || !$r['short_description'] || !$r['long_description'] || !$r['price'])
$send_xml = false;
if ($send_xml)
$detail->ss->assign("SEND_XML", 1);
else
$detail->ss->assign("SEND_XML", 0);
/*
$desc='';
$desc.='<input title="Product Card" class="button" onclick="if(document.getElementById(\'div_desc\').style.display==\'none\')document.getElementById(\'div_desc\').style.display=\'block\';else document.getElementById(\'div_desc\').style.display=\'none\';" type="button" name="productcard" id="productcard" value="Create Catalogue">';
$desc.='<div id="div_desc" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
$desc.='Show header: <select name="show_header" id="show_header"><option value="1">Yes</option><option value="0" selected>No</option></select><br /><br />';
$desc.='Show content: <select name="show_content" id="show_content"><option value="1">Yes</option><option value="0" selected>No</option></select><br /><br />';
$desc.='To image: <select name="image" id="image"><option value="1">Yes</option><option value="0" selected>No</option></select><br /><br />';
$desc.='Title page: <select name="title" id="title"><option value="1">Yes</option><option value="0" selected>No</option></select><br /><br />';
$desc.='Show price: <select name="show_price" id="show_price"><option value="1">Yes</option><option value="0" selected>No</option></select><br /><br />';
$desc.='Extra info: <select name="extra" id="extra"><option value="1">Yes</option><option value="0" selected>No</option></select><br /><br />';
$desc.='Price: <select name="price" id="price"><option value="srp_price">SRP Price</option></select><br /><br />';
$desc.='Language: <select name="language" id="language"><option value="pl">pl</option><option value="en">en</option></select><br /><br />';
$desc.='EAN: <select name="ean" id="ean"><option value="1">1</option><option value="2">2</option></select><br /><br />';
$desc.='<input type="button" class="button" name="generate" id="generate" value="Generate" onclick="window.open(\'index.php?module=EcmProducts&action=generateProductCardsFromProduct&record='.$_REQUEST['record'].'&to_pdf=1&price=\'+document.getElementById(\'price\').value+\'&header=\'+document.getElementById(\'show_header\').value+\'&content=\'+document.getElementById(\'show_content\').value+\'&extra=\'+document.getElementById(\'extra\').value+\'&create_img=\'+document.getElementById(\'image\').value+\'&show_price=\'+document.getElementById(\'show_price\').value+\'&title=\'+document.getElementById(\'title\').value+\'&language=\'+document.getElementById(\'language\').value+\'&ean=\'+document.getElementById(\'ean\').value);"></div>';
$detail->ss->assign("CATALOGUE",$desc);
*/
//add mz - nowa karta produktu
global $mod_strings;
$desc = '';
2025-05-29 20:21:38 +02:00
$desc .= '<input title="Product Card" class="button" onclick="if(document.getElementById(\'div_desc2\').style.display==\'none\')document.getElementById(\'div_desc2\').style.display=\'block\';else document.getElementById(\'div_desc2\').style.display=\'none\';" type="button" name="productcard" id="productcard" value="' . $mod_strings['LBL_PRODUCT_CARD'] . '">';
$desc .= '<div id="div_desc2" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
$desc .= 'Zdjęcie: <select name="new_image" id="new_image"><option value="1">Tak</option><option value="0" selected>Nie</option></select><br /><br />';
$desc .= 'Pokaż cene: <select name="new_show_price" id="new_show_price"><option value="1">Tak</option><option value="0" selected>Nie</option></select><br /><br />';
$desc .= 'Cena: <select name="new_price" id="new_price"><option value="srp_price">SRP Price</option></select><br /><br />';
$desc .= 'Język: <select name="new_language" id="new_language"><option value="pl">pl</option><option value="en">en</option></select><br /><br />';
$desc .= 'EAN: <select name="new_ean" id="new_ean"><option value="1">1</option><option value="2">2</option></select><br /><br />';
2025-05-12 15:44:39 +00:00
2025-05-29 20:21:38 +02:00
$desc .= '<input type="button" class="button" name="generate" id="generate" value="Generuj" onclick="window.open(\'index.php?module=EcmProducts&action=generateCard&record=' . $_REQUEST['record'] . '&to_pdf=1&price=\'+document.getElementById(\'new_price\').value+\'&create_img=\'+document.getElementById(\'new_image\').value+\'&show_price=\'+document.getElementById(\'new_show_price\').value+\'&language=\'+document.getElementById(\'new_language\').value+\'&ean=\'+document.getElementById(\'new_ean\').value);"></div>';
2025-05-12 15:44:39 +00:00
$detail->ss->assign("CATALOGUE_NEW", $desc);
$desc = '<div id="div_desc" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
2025-05-29 20:21:38 +02:00
$desc .= '<input type="checkbox" name="show_characteristic" id="show_characteristic" value="1" checked">Show attributes<br />';
$desc .= '<input type="checkbox" name="show_description" id="show_description" value="1" checked">Show description<br />';
$desc .= '<input type="checkbox" name="show_specification" id="show_specification" value="1" checked">Show specification<br />';
$desc .= '<input type="checkbox" name="print_version" id="print_version" value="1" checked">Print version<br />';
$desc .= 'Language: <select name="language" id="language"><option value="">pl</option><option value="en">en</option></select><br /><br />';
$desc .= '<input type="button" class="button" name="generate" id="generate" value="Generate" onclick="window.open(\'index.php?module=EcmProducts&action=productCard&record=' . $_REQUEST['record'] . '&to_pdf=1&show_characteristic=\'+document.getElementById(\'show_characteristic\').checked+\'&show_specification=\'+document.getElementById(\'show_specification\').checked+\'&show_description=\'+document.getElementById(\'show_description\').checked+\'&print_version=\'+document.getElementById(\'print_version\').checked+\'&language=\'+document.getElementById(\'language\').value);"></div>';
2025-05-12 15:44:39 +00:00
$detail->ss->assign("DIV_DESC", $desc);
$desc = '<div id="div_desc_card" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
2025-05-29 20:21:38 +02:00
$desc .= '<input type="checkbox" name="show_characteristic_card" id="show_characteristic_card" value="1" checked">Show attributes<br />';
$desc .= '<input type="checkbox" name="show_description_card" id="show_description_card" value="1" checked">Show description<br />';
$desc .= '<input type="checkbox" name="show_specification_card" id="show_specification_card" value="1" checked">Show specification<br />';
$desc .= 'Language: <select name="language" id="language"><option value="">pl</option><option value="en">en</option></select><br /><br />';
$desc .= '<input type="button" class="button" name="generate_card" id="generate_card" value="Generate" onclick="window.open(\'index.php?module=EcmProducts&action=productCard&record=' . $_REQUEST['record'] . '&to_pdf=1&show_characteristic=\'+document.getElementById(\'show_characteristic_card\').checked+\'&show_specification=\'+document.getElementById(\'show_specification_card\').checked+\'&show_description=\'+document.getElementById(\'show_description_card\').checked+\'&html=1\'+\'&language=\'+document.getElementById(\'language\').value,\'create_html\',\'location=0,status=0,scrollbars=0,width=640,height=500\');"></div>';
2025-05-12 15:44:39 +00:00
$detail->ss->assign("DIV_DESC_CARD", $desc);
//Added for Graduated Prices - Begin
/* require_once('modules/EcmProducts/EcmProductGraduatedPrices.php');
$epgp = new EcmProductGraduatedPrices($focus->graduated_prices);
$detail->ss->assign("PRODUCT_GRADUATED_PRICES_HTML", $epgp->getHtmlDetail()); */
//Added for Graduated Prices - End
//Added for Components
$detail->ss->assign("POSITION_LIST", $focus->getPositionList());
$file = 'modules/EcmGroupSales/EcmGroupSale.php';
if (file_exists($file)) {
$cc = array();
require_once($file);
$cc = EcmGroupSale::loadSettings();
}
$OPT = array();
$OPT['row_item_height'] = $cc['row_item_height'];
$OPT['row_item_height_selected'] = $cc['row_item_height_selected'];
$OPT['rows_on_item_list'] = $cc['rows_on_item_list'];
$OPT['position_table_height'] = $OPT['row_item_height'] * $OPT['rows_on_item_list'] + 40 + $OPT['rows_on_item_list'] * 4;
$OPT['quick_product_item_adding'] = $cc['quick_product_item_adding'];
global $current_user;
$tmp = $current_user->getPreference('num_grp_sep');
if (!isset($tmp) || $tmp == '' || $tmp == NULL)
$tmp = $sugar_config['default_number_grouping_seperator'];
$OPT['sep_1000'] = $tmp;
$tmp = $current_user->getPreference('dec_sep');
if (!isset($tmp) || $tmp == '' || $tmp == NULL)
$tmp = $sugar_config['default_decimal_seperator'];
$OPT['dec_sep'] = $tmp;
$tmp = $current_user->getPreference('default_currency_significant_digits');
if (!isset($tmp) || $tmp == '' || $tmp == NULL)
$tmp = $sugar_config['default_currency_significant_digits'];
$OPT['dec_len'] = $tmp;
$OPT['default_unit'] = "1";
$OPT['default_vat'] = "19.00";
$OPT['default_category'] = "";
$OPT['default_currency'] = "-99";
$OPT['type'] = $focus->type;
$OPT['to_is_vat_free'] = $focus->to_is_vat_free;
$OPT['ecmproduct_usage_units_options'] = $uunit_array;
$scriptOpt = '
<script language="javascript">
var VAT = ' . str_replace('&quot;', '\"', $json->encode($VAT)) . ';
var OPT = ' . str_replace('&quot;', '\"', $json->encode($OPT)) . ';
var MOD = ' . str_replace('&quot;', '\"', $json->encode($mod_strings)) . ';
var N;
</script>';
echo $scriptOpt;
include('modules/EcmProducts/phpqrcode/qrlib.php');
$tempDir = EXAMPLE_TMP_SERVERPATH;
// create new PDF document
// displaying
$detail->ss->assign("QRGEN", $desc2);
$detail->ss->assign("QRCODE", $desc);
$detail->ss->assign("OPT", $OPT);
//Added for Components
global $current_user;
echo $detail->display();
require_once('include/SubPanel/SubPanelTiles.php');
$subpanel = new SubPanelTiles($focus, "EcmProducts");
echo $subpanel->display();