<?
$sugarEntry=true;
global $db;
function priceToDb($v){
	$v=str_replace(".","",$v);
	$v=str_replace(",",".",$v);
	return floatval($v);
}
for($i=1;$i<=1000;$i++){
	if (!$_REQUEST['product_id_'.$i]) continue;
	$prod = $_REQUEST['product_id_'.$i];
	if($_REQUEST['product_id_'.$i]){
		$rp=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select ecmproduct_id,price from ecmdevices_ecmproducts where id='".$_REQUEST['product_id_'.$i]."' and deleted='0'"));
		$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select vat_value from ecmproducts where id='".$rp['ecmproduct_id']."'"));
		$price=priceToDb($_REQUEST['price_brutto_'.$i])/(1+$r['vat_value']/100);
		if($rp['price']!=priceToDb($_REQUEST['price_'.$i]) || $_REQUEST['price_'.$i]=="")$price=priceToDb($_REQUEST['price_'.$i]);
		$GLOBALS['db']->query("update ecmdevices_ecmproducts set popular='".$_REQUEST['popular_'.$i]."',recipient_code='".$_REQUEST['recipient_code_'.$i]."',remarks_pl='".$_REQUEST['remarks_pl_'.$i]."',remarks_en='".$_REQUEST['remarks_en_'.$i]."',remarks_de='".$_REQUEST['remarks_de_'.$i]."',price='".$price."' where id='".$_REQUEST['product_id_'.$i]."'");
		$_SESSION['EcmDevices_high'][$_REQUEST['product_id_'.$i]]=true;
	}
}
$_REQUEST['customview_id']=$_COOKIE['customview_id'];
$_GET['customview_id']=$_COOKIE['customview_id'];

$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select ecmdevice_id from ecmdevices_ecmproducts where id='".$prod."'"));

header("Location: index.php?module=EcmDevices&action=DetailView&record=".$r['ecmdevice_id']."&tab=items");
?>
