query(“SELECT PR_EXCH_EURO as exch_rate FROM PR_VAT WHERE PR_COUNTRY_CODE =’$country_Code'”)->fetch_object()->exch_rate ;
$total = $exch_rate * $amount;
$total = round($total,2);
return $total;
}
function CalculateNETPrice($conn, $GrossPrice, $Country_Code){
$vat = $conn->query(“SELECT PR_VAT as vat_rate FROM PR_CURRENCY_TBL WHERE PR_COUNTRY_CODE =’$Country_Code'”)->fetch_object()->vat_rate ;
$NetPrice = ($GrossPrice / (($vat / 100) + 1 ));
$NetPrice = round($NetPrice,2);
return $NetPrice;
}
if ($prod_currency == “EUR”)
{
$ConvPrice = $prod_price ;
}
Else
{
$ConvPrice = convertCurrency($prod_price,$conn,$prod_country);
}
$CalcNetPrice = CalculateNETPrice($conn, $prod_price , $prod_country);
if ($prod_currency== “EUR”)
{
$ConvNetPrice = $CalcNetPrice ;
}
Else
{
$ConvNetPrice = convertCurrency($CalcNetPrice, $conn, $prod_country);
}
$sqlFinalUpd = “UPDATE `PR_PRICE_NET_TEMP` SET `PR_LAST_PRICE`=’$prod_price’, `PR_CONV_PRICE`=’$ConvPrice’, `PR_NET_PRICE`=’$CalcNetPrice’, `PR_CONV_NET`=’$ConvNetPrice’ WHERE PR_PRODUCT_ID = ‘$prod_id’ AND PR_URL_ID = ‘$prod_url’ AND PR_SHOP_NAME = ‘$prod_shop’ AND `PR_LAST_CHECKED`=’$newDate'”;
if ($conn->query($sqlFinalUpd) === TRUE) {
echo “Record Updated successfully”;
} else {
echo “Error updating record: ” . $conn->error;
}
mysqli_close($conn);
}
?>