more support to fussion schema
This commit is contained in:
parent
3fea9a0cb6
commit
1ded40211e
|
|
@ -36,7 +36,7 @@ else {
|
|||
}
|
||||
|
||||
if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/billing/app_config.php")){
|
||||
require_once "app/billing/functions.php";
|
||||
require_once "app/billing/resources/functions/currency.php";
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
}
|
||||
|
||||
//set debug
|
||||
$debug = false; //true //false
|
||||
$debug = true; //true //false
|
||||
if($debug){
|
||||
$time5 = microtime(true);
|
||||
$insert_time=$insert_count=0;
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
|
||||
if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/billing/app_config.php")){
|
||||
require_once "app/billing/functions.php";
|
||||
require_once "app/billing/resources/functions/rating.php";
|
||||
}
|
||||
//define the process_xml_cdr function
|
||||
function process_xml_cdr($db, $leg, $xml_string) {
|
||||
|
|
@ -259,9 +259,10 @@
|
|||
$db2->result = $db2->execute();
|
||||
|
||||
// If selling rate is found, then we fill with data, otherwise rate will be 0
|
||||
$lcr_user_rate = (strlen($$db2->result[0]['rate']))?strlen($$db2->result[0]['rate']):0;
|
||||
$lcr_user_first_increment = (strlen($$db2->result[0]['connect_increment']))?strlen($$db2->result[0]['connect_increment']):60;
|
||||
$lcr_user_second_increment = (strlen($$db2->result[0]['talk_increment']))?strlen($$db2->result[0]['talk_increment']):60;
|
||||
$lcr_currency = (strlen($db2->result[0]['currency'])?check_str($db2->result[0]['currency']):'USD');
|
||||
$lcr_user_rate = (strlen($db2->result[0]['rate']))?strlen($db2->result[0]['rate']):0;
|
||||
$lcr_user_first_increment = (strlen($db2->result[0]['connect_increment']))?strlen($db2->result[0]['connect_increment']):60;
|
||||
$lcr_user_second_increment = (strlen($db2->result[0]['talk_increment']))?strlen($db2->result[0]['talk_increment']):60;
|
||||
|
||||
// Actually, there is no way to detect what carrier is the calling comming from using current information
|
||||
$lcr_rate = 0; $lcr_first_increment = 0; $lcr_second_increment = 0;
|
||||
|
|
@ -278,9 +279,10 @@
|
|||
$db2->result = $db2->execute();
|
||||
|
||||
// If selling rate is found, then we fill with data, otherwise rate will be 0
|
||||
$lcr_user_rate = (strlen($$db2->result[0]['rate']))?strlen($$db2->result[0]['rate']):0;
|
||||
$lcr_user_first_increment = (strlen($$db2->result[0]['connect_increment']))?strlen($$db2->result[0]['connect_increment']):60;
|
||||
$lcr_user_second_increment = (strlen($$db2->result[0]['talk_increment']))?strlen($$db2->result[0]['talk_increment']):60;
|
||||
$lcr_currency = (strlen($db2->result[0]['currency'])?check_str($db2->result[0]['currency']):'USD');
|
||||
$lcr_user_rate = (strlen($db2->result[0]['rate']))?strlen($$db2->result[0]['rate']):0;
|
||||
$lcr_user_first_increment = (strlen($db2->result[0]['connect_increment']))?strlen($db2->result[0]['connect_increment']):60;
|
||||
$lcr_user_second_increment = (strlen($db2->result[0]['talk_increment']))?strlen($db2->result[0]['talk_increment']):60;
|
||||
|
||||
// Actually, internal calls have 0 cost
|
||||
$lcr_rate = 0; $lcr_first_increment = 0; $lcr_second_increment = 0;
|
||||
|
|
@ -294,29 +296,28 @@
|
|||
$time = check_str(urldecode($xml->variables->billsec));
|
||||
$call_buy = call_cost($lcr_rate, $lcr_first_increment, $lcr_second_increment, $time);
|
||||
$call_sell = call_cost($lcr_user_rate, $lcr_user_first_increment, $lcr_user_second_increment, $time);
|
||||
// Costs/Sell call is in original LCR currency, needs to be converted
|
||||
|
||||
$database->fields['call_buy'] = check_str($call_buy);
|
||||
$database->fields['call_sell'] = check_str($call_sell);
|
||||
|
||||
$db2->table = "v_xml_cdr";
|
||||
$accountcode = (strlen(urldecode($xml->variables->accountcode)))?check_str(urldecode($xml->variables->accountcode)):$domain_name;
|
||||
$db2->sql = "SELECT currency FROM v_billings WHERE type_value='$accountcode'";
|
||||
$db2->result = $database->execute();
|
||||
$billing_currency = (strlen($database->result[0]['currency'])?$database->result[0]['currency']:'USD');
|
||||
unset($database->sql);
|
||||
unset($database->result);
|
||||
|
||||
if ($debug) {
|
||||
echo "c ".$database->fields['carrier_name']."\n";
|
||||
echo "t $time\n";
|
||||
echo "b r:$lcr_rate - $lcr_first_increment - $lcr_first_increment = $call_buy\n";
|
||||
echo "s r:$lcr_user_rate - $lcr_user_first_increment - $lcr_user_second_increment = $call_sell\n";
|
||||
echo "lc $lcr_currency\n";
|
||||
}
|
||||
|
||||
unset($db2->sql);
|
||||
unset($db2->result);
|
||||
|
||||
$db2->sql = "SELECT currency FROM v_billings WHERE type_value='".check_str(urldecode($xml->variables->accountcode))."'";
|
||||
$db2->result = $database->execute();
|
||||
$billing_currency = (strlen($database->result[0]['currency'])?$database->result[0]['currency']:'USD');
|
||||
|
||||
if ($debug) {
|
||||
echo "bc $billing_currency\n";
|
||||
}
|
||||
|
||||
|
||||
$sql_balance = "SELECT balance, old_balance FROM v_billings WHERE type_value='".check_str(urldecode($xml->variables->accountcode))."'";
|
||||
$db2->sql = $sql_balance;
|
||||
$db2->result = $db2->execute();
|
||||
|
|
@ -332,6 +333,10 @@
|
|||
// Lets convert rate from lcr_currency to billing_currency
|
||||
$billing_call_sell = currency_convert($call_sell, $billing_currency, $lcr_currency);
|
||||
|
||||
if ($debug) {
|
||||
echo "bcs: $billing_call_sell $billing_currency\n";
|
||||
}
|
||||
|
||||
// Remember that old_balance is using billing_currency
|
||||
$updated_balance = (double)$old_balance - (double)$billing_call_sell;
|
||||
unset($db2->sql);
|
||||
|
|
@ -345,7 +350,6 @@
|
|||
$db2->result = $db2->execute();
|
||||
unset($db2->sql);
|
||||
unset($db2->result);
|
||||
|
||||
}
|
||||
|
||||
//insert xml_cdr into the db
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ else {
|
|||
}
|
||||
echo "</tr>\n";
|
||||
if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/billing/app_config.php")){
|
||||
require_once "app/billing/functions.php";
|
||||
require_once "app/billing/resources/functions/rating.php";
|
||||
require_once "resources/classes/database.php";
|
||||
$database = new database;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue