| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/fetchcurrency/ |
Upload File : |
<?php
$product_item = array();
$AgencySysId = isset($_POST['AgencySysId']) ? $_POST['AgencySysId'] : null;
$FCurrency = isset($_POST['FCurrency']) ? $_POST['FCurrency'] : null;
$TCurrency = isset($_POST['TCurrency']) ? $_POST['TCurrency'] : null;
if ($AgencySysId && $FCurrency && $TCurrency) {
$DBhost = "localhost";
$DBuser = "root";
$DBpassword = "At07Y#2zLWk@?mVP";
$DBname = "CommanDB";
$conn1 = mysqli_connect($DBhost, $DBuser, $DBpassword, $DBname);
if (!$conn1) {
die("Connection failed: " . mysqli_connect_error());
}
$selectQuery = "SELECT markup FROM tbl_currency_markup WHERE agency_id = $AgencySysId";
$resultQuery = mysqli_query($conn1, $selectQuery) or die(mysqli_error($conn1));
$markup = 0;
while ($val1 = mysqli_fetch_array($resultQuery)) {
$markup = $val1['markup'];
}
if(!empty($FCurrency) && is_array($FCurrency)){
$Condition = '';
foreach($FCurrency as $fcKey => $fcValue){
if($fcKey > 0){
$Condition .= ' OR ';
}
$Condition .= ' FCurrencyType = '.(int)$fcValue;
}
if($Condition != ''){
$selectQuery1 = "SELECT FCurrencyType,TCurrencyType,Rate FROM tbl_currency_rate WHERE ($Condition) AND TCurrencyType = $TCurrency ";
}
}else{
$selectQuery1 = "SELECT FCurrencyType,TCurrencyType,Rate FROM tbl_currency_rate WHERE FCurrencyType = $FCurrency AND TCurrencyType = $TCurrency ";
}
$resultQuery1 = mysqli_query($conn1, $selectQuery1) or die(mysqli_error($conn1));
$i = 0;
while ($row = mysqli_fetch_array($resultQuery1)) {
$product_item[$i]["FCurrencyType"] = $row['FCurrencyType'];
$product_item[$i]["TCurrencyType"] = $row['TCurrencyType'];
if ($row['FCurrencyType'] == $row['TCurrencyType']) {
$product_item[$i]["Rate"] = $row['Rate'];
} else {
$markupValue = 0;
if($markup > 0){
$markupValue = (((float)$row['Rate'] * $markup) / 100);
}
$product_item[$i]["Rate"] = (float)$row['Rate'] + $markupValue;
}
$i++;
}
}
echo json_encode($product_item); exit;
?>