Add. Handle `b` legs in CDR. (#2626)

* Add. Handle `b` legs in CDR.

CDR list/statistic by default handle only `a` legs.
So it prevent display wrong result when b-leg turn on.
Add ability to write to db `b` legs only for specific call directions.

To be able see b-legs in CDR need set xml_cdr_b_leg permission.
To add specific call direction to filter need add element to `cdr/b_leg/array` in default/domain settings.

* Add. `b_leg` to defalut settings.
This commit is contained in:
Alexey Melnichuk 2017-06-03 07:31:20 +03:00 committed by FusionPBX
parent 8709d01fb0
commit 9050da03cc
14 changed files with 68 additions and 4 deletions

View File

@ -61,9 +61,37 @@
$y++;
$apps[$x]['permissions'][$y]['name'] = "xml_cdr_all";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "xml_cdr_b_leg";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
//default settings
$y=0;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = '0f208802-5f18-41f9-97a3-45e939e7a1b8';
$apps[$x]['default_settings'][$y]['default_setting_category'] = 'cdr';
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = 'b_leg';
$apps[$x]['default_settings'][$y]['default_setting_name'] = 'array';
$apps[$x]['default_settings'][$y]['default_setting_value'] = 'outbound';
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = 'false';
$apps[$x]['default_settings'][$y]['default_setting_description'] = '';
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = 'd9d09758-6deb-47e5-b5bb-812da3a8d196';
$apps[$x]['default_settings'][$y]['default_setting_category'] = 'cdr';
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = 'b_leg';
$apps[$x]['default_settings'][$y]['default_setting_name'] = 'array';
$apps[$x]['default_settings'][$y]['default_setting_value'] = 'inbound';
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = 'false';
$apps[$x]['default_settings'][$y]['default_setting_description'] = '';
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = '74e33709-da7d-4d46-a31f-6580ab9a7714';
$apps[$x]['default_settings'][$y]['default_setting_category'] = 'cdr';
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = 'b_leg';
$apps[$x]['default_settings'][$y]['default_setting_name'] = 'array';
$apps[$x]['default_settings'][$y]['default_setting_value'] = 'local';
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = 'false';
$apps[$x]['default_settings'][$y]['default_setting_description'] = '';
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = 'dbbadd02-f95d-480b-85d5-2a4113d4cccc';
$apps[$x]['default_settings'][$y]['default_setting_category'] = 'cdr';
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = 'format';

View File

@ -74,6 +74,19 @@
require_once "app/billing/resources/functions/rating.php";
}
function accept_b_leg($xml){
// if no filter set allow all for backward compatibility
if(empty($_SESSION['cdr']['b_leg'])){
return true;
}
// filter out by call direction
if(in_array(@$xml->variables->call_direction, $_SESSION['cdr']['b_leg'])){
return true;
}
// Disable cdr write
return false;
}
//define the process_xml_cdr function
function process_xml_cdr($db, $leg, $xml_string) {
//set global variable
@ -102,6 +115,13 @@
xml_cdr_log("\nfail loadxml: " . $e->getMessage() . "\n");
}
//filter out b-legs
if($leg == 'b'){
if(!accept_b_leg($xml)){
return;
}
}
//prepare the database object
require_once "resources/classes/database.php";
$database = new database;
@ -175,7 +195,7 @@
unset($x);
//if last_sent_callee_id_number is set use it for the destination_number
if (strlen($xml->variables->last_sent_callee_id_number) > 0) {
if (($leg == 'a') && (strlen($xml->variables->last_sent_callee_id_number) > 0)) {
$database->fields['destination_number'] = urldecode($xml->variables->last_sent_callee_id_number);
}

View File

@ -110,6 +110,7 @@
echo " <input type='hidden' name='remote_media_ip' value='".$remote_media_ip."'>\n";
echo " <input type='hidden' name='network_addr' value='".$network_addr."'>\n";
echo " <input type='hidden' name='bridge_uuid' value='".$bridge_uuid."'>\n";
echo " <input type='hidden' name='leg' value='".$leg."'>\n";
if (is_array($_SESSION['cdr']['field'])) {
foreach ($_SESSION['cdr']['field'] as $field) {
$array = explode(",", $field);
@ -524,7 +525,12 @@
else { $call_result = 'failed'; }
}
if (strlen($row['direction']) > 0) {
echo "<img src='".PROJECT_PATH."/themes/".$_SESSION['domain']['template']['name']."/images/icon_cdr_".$row['direction']."_".$call_result.".png' width='16' style='border: none; cursor: help;' title='".$text['label-'.$row['direction']].": ".$text['label-'.$call_result]."'>\n";
$image_name = "icon_cdr_" . $row['direction'] . "_" . $call_result;
if($row['leg'] == 'b'){
$image_name .= '_b';
}
$image_name .= ".png";
echo "<img src='".PROJECT_PATH."/themes/".$_SESSION['domain']['template']['name']."/images/$image_name' width='16' style='border: none; cursor: help;' title='".$text['label-'.$row['direction']].": ".$text['label-'.$call_result]. ($row['leg']=='b'?'(b)':'') . "'>\n";
}
}
else { echo "&nbsp;"; }

View File

@ -99,9 +99,12 @@
}
//$mos_comparison = check_str($_REQUEST["mos_comparison"]);
$mos_score = check_str($_REQUEST["mos_score"]);
$leg = check_str($_REQUEST["leg"]);
}
if(!permission_exists(xml_cdr_b_leg)){
$leg = 'a';
}
//build the sql where string
if (strlen($start_epoch) > 0 && strlen($stop_epoch) > 0) {
@ -205,6 +208,7 @@
if (strlen($remote_media_ip) > 0) { $sql_where_ands[] = "remote_media_ip like '%".$remote_media_ip."%'"; }
if (strlen($network_addr) > 0) { $sql_where_ands[] = "network_addr like '%".$network_addr."%'"; }
if (strlen($mos_comparison) > 0 && strlen($mos_score) > 0 ) { $sql_where_ands[] = "rtp_audio_in_mos " . $mos_comparison . " ".$mos_score.""; }
if (strlen($leg) > 0) { $sql_where_ands[] = "leg='$leg'"; }
//if not admin or superadmin, only show own calls
if (!permission_exists('xml_cdr_domain')) {
@ -369,6 +373,7 @@
$sql .= "caller_destination, ";
$sql .= "source_number, ";
$sql .= "destination_number, ";
$sql .= "leg, ";
$sql .= "(xml IS NOT NULL OR json IS NOT NULL) AS raw_data_exists, ";
if (is_array($_SESSION['cdr']['field'])) {
foreach ($_SESSION['cdr']['field'] as $field) {
@ -396,6 +401,7 @@
} else {
$sql .= "where domain_uuid = '".$domain_uuid."' ";
}
$sql .= $sql_where;
if (strlen($order_by)> 0) { $sql .= " order by ".$order_by." ".$order." "; }
if ($_REQUEST['export_format'] != "csv" && $_REQUEST['export_format'] != "pdf") {

View File

@ -50,7 +50,11 @@ else {
echo " <td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='xml_cdr.php'\" value='".$text['button-back']."'>\n";
if (permission_exists('xml_cdr_search_advanced')) {
echo " <input type='button' class='btn' value='".$text['button-advanced_search']."' onclick=\"window.location='xml_cdr_search.php?redirect=xml_cdr_statistics';\">\n";
$advenced_search_url = 'xml_cdr_search.php?redirect=xml_cdr_statistics';
if(permission_exists('xml_cdr_all') && (@$_GET['showall'] === 'true')){
$advenced_search_url .= '&showall=true';
}
echo " <input type='button' class='btn' value='".$text['button-advanced_search']."' onclick=\"window.location='$advenced_search_url';\">\n";
}
if (permission_exists('xml_cdr_all')) {
if ($_GET['showall'] != 'true') {

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B