Files
crm.e5.pl/modules/EcmPriceKopias/SavePrices.php
2024-04-27 09:23:34 +02:00

28 lines
1.5 KiB
PHP

<?
$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 ecmpricekopias_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 ecmpricekopias_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['EcmPriceKopias_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 ecmpricekopia_id from ecmpricekopias_ecmproducts where id='".$prod."'"));
header("Location: index.php?module=EcmPriceKopias&action=DetailView&record=".$r['ecmpricekopia_id']."&tab=items");
?>