$app_list_strings['moduleList']['Accounts'],
'Leads' => $app_list_strings['moduleList']['Leads'],
);
require_once('modules/EcmProductB2Bs/EcmProductB2B.php');
require_once('modules/EcmProductB2Bs/Forms.php');
require_once('include/time.php');
require_once('include/json_config.php');
$json_config = new json_config();
$focus = new EcmProductB2B();
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/EcmProductB2Bs/views/DetailView/view.detail.ecmproductb2bs.php');
$detail = new ViewDetailEcmProductB2Bs();
$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");
while(($row=$db->fetchByAssoc($result))!=null)
{
$uunit.='';
$uunit_array[$row['id']] = $row['name'];
}
$detail->ss->assign("USAGE_UNIT_ID",$uunit);
$tax='';
$result = $db->query("select id,name from ecmvats where deleted='0' order by name asc");
while(($row=$db->fetchByAssoc($result))!=null)
{
$tax.='';
}
$detail->ss->assign("VAT_ID",$tax);
$fbas='';
$result = $db->query("select id,name from ecmproductbasis order by name asc");
while(($row=$db->fetchByAssoc($result))!=null)
{
$fbas.='';
}
$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)
{
$pack.='';
}
$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))
{
$currency_list = array_merge(Array($currency), $currency_list);
}
else
{
$currency_list = Array($currency);
}
$arr = array();
foreach($currency_list as $key=>$value)
{
$arr[$value->id] = $value->name;
}
$detail->ss->assign("EXCHANGE_RATE_NAME", $arr[$focus->exchange_rate_id]);
function show_image($img)
{
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;
return '';
}
}
$detail->ss->assign("PRODUCT_PICTURE", show_image("modules/EcmProductB2Bs/upload/images/".$focus->product_picture));
$detail->ss->assign("PACKING_FRONT_PICTURE", show_image("modules/EcmProductB2Bs/upload/images/".$focus->packing_front_picture));
$detail->ss->assign("DRIVER_1", $focus->driver_1);
if($focus->driver_1)$detail->ss->assign("DRIVER_1_DOWNLOAD",'Download');
$detail->ss->assign("DRIVER_2", $focus->driver_2);
if($focus->driver_2)$detail->ss->assign("DRIVER_2_DOWNLOAD",'Download');
//add mz
$pl3 = $this->bean->showPositions3();
$detail->ss->assign('POSITIONS3', $pl3);
$pl4 = $this->bean->showPrices();
$detail->ss->assign('POSITIONS4', $pl4);
$ii='
'.$mod_strings['LBL_II_STOCK'].'
'.$mod_strings['LBL_II_QTY'].'
'.$mod_strings['LBL_II_PRICE'].'
';
$w=$GLOBALS['db']->query("select ecmstocks.name as sname,ecmstocks.id as sid,sum(ecmstockstates.quantity) as q,avg(ecmstockstates.price) as p from ecmstockstates inner join ecmstocks on ecmstocks.id=ecmstockstates.stock_id where ecmstockstates.deleted='0' and ecmstockstates.product_id='".$focus->id."' group by ecmstockstates.stock_id order by ecmstocks.name asc");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
if($r['q']>0)$ii.='
';
$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("<","<",str_replace(">",">",$row['long_description'])));
$detail->ss->assign("PRICE_".$row['language'],number_format($row['price'],2,",","."));
}
$send_xml=true;
if(!file_exists("modules/EcmProductB2Bs/upload/images/big/".$focus->product_picture))$send_xml=false;
if(!file_exists("modules/EcmProductB2Bs/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.='';
$desc.='
';
$desc.='Show header:
';
$desc.='Show content:
';
$desc.='To image:
';
$desc.='Title page:
';
$desc.='Show price:
';
$desc.='Extra info:
';
$desc.='Price:
';
$desc.='Language:
';
$desc.='EAN:
';
$desc.='
';
$detail->ss->assign("CATALOGUE",$desc);
*/
//add mz - nowa karta produktu
global $mod_strings;
$desc='';
$desc.='';
$desc.='