better billing decition, specially to allow tollfree billing
This commit is contained in:
parent
4ab72c66ae
commit
e3562cd32b
|
|
@ -230,6 +230,8 @@ function call_cost($rate, $i1, $i2, $t){
|
|||
//billing information
|
||||
if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/billings/app_config.php")){
|
||||
|
||||
switch(check_str(urldecode($xml->variables->call_direction))){
|
||||
case "outbound":
|
||||
$database->fields['carrier_name'] = check_str(urldecode($xml->variables->lcr_carrier));
|
||||
$sql_rate ="SELECT connect_increment, talk_increment FROM v_lcr, v_carriers WHERE v_carriers.carrier_name = '".$xml->variables->lcr_carrier."' AND v_lcr.rate=".$xml->variables->lcr_rate." AND v_lcr.lcr_direction = '".check_str(urldecode($xml->variables->call_direction))."' AND digits in (".check_str(urldecode($xml->variables->lcr_query_expanded_digits)).") AND v_lcr.carrier_uuid = v_carriers.carrier_uuid ORDER BY digits DESC, rate ASC limit 1";
|
||||
$sql_user_rate = "SELECT connect_increment, talk_increment FROM v_lcr WHERE carrier_uuid='' AND v_lcr.lcr_direction = '".check_str(urldecode($xml->variables->call_direction))."' AND digits IN (".check_str(urldecode($xml->variables->lcr_query_expanded_digits)).") ORDER BY digits DESC, rate ASC limit 1";
|
||||
|
|
@ -250,12 +252,25 @@ function call_cost($rate, $i1, $i2, $t){
|
|||
|
||||
$db2->sql = $sql_user_rate;
|
||||
$db2->result = $db2->execute();
|
||||
$lcr_user_rate = (strlen($xml->variables->lcr_user_rate)?$xml->variables->lcr_user_rate:(check_str(urldecode($xml->variables->call_direction)) == "outbound"?0.01:0.0));
|
||||
$lcr_user_rate = (strlen($xml->variables->lcr_user_rate)?$xml->variables->lcr_user_rate:0.01);
|
||||
$lcr_user_first_increment = (strlen($db2->result[0]['connect_increment'])?check_str($db2->result[0]['connect_increment']):60);
|
||||
$lcr_user_second_increment = (strlen($db2->result[0]['talk_increment'])?check_str($db2->result[0]['talk_increment']):60);
|
||||
|
||||
unset($db2->sql);
|
||||
unset($db2->result);
|
||||
break;
|
||||
case "inbound":
|
||||
// Need to add code for tollfree number, unique case when we bill inbound
|
||||
$lcr_rate = 0; $lcr_first_increment = 0; $lcr_second_increment = 0;
|
||||
$lcr_user_rate = 0; $lcr_user_first_increment = 0; $lcr_user_second_increment = 0;
|
||||
|
||||
break;
|
||||
case "local":
|
||||
$lcr_rate = 0; $lcr_first_increment = 0; $lcr_second_increment = 0;
|
||||
$lcr_user_rate = 0; $lcr_user_first_increment = 0; $lcr_user_second_increment = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
$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, check_str(urldecode($xml->variables->billsec)));
|
||||
|
|
|
|||
Loading…
Reference in New Issue