From 5d43f73134e50c3cf0681dfaa78016b718694434 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Sat, 3 Jun 2017 07:31:20 +0300 Subject: [PATCH] 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. --- app/xml_cdr/app_config.php | 28 ++++++++++++++++++ app/xml_cdr/v_xml_cdr_import.php | 22 +++++++++++++- app/xml_cdr/xml_cdr.php | 8 ++++- app/xml_cdr/xml_cdr_inc.php | 8 ++++- app/xml_cdr/xml_cdr_statistics.php | 6 +++- .../images/icon_cdr_inbound_answered_b.png | Bin 0 -> 290 bytes .../images/icon_cdr_inbound_cancelled_b.png | Bin 0 -> 298 bytes .../images/icon_cdr_inbound_failed_b.png | Bin 0 -> 209 bytes .../images/icon_cdr_local_answered_b.png | Bin 0 -> 300 bytes .../images/icon_cdr_local_cancelled_b.png | Bin 0 -> 295 bytes .../images/icon_cdr_local_failed_b.png | Bin 0 -> 242 bytes .../images/icon_cdr_outbound_answered_b.png | Bin 0 -> 269 bytes .../images/icon_cdr_outbound_cancelled_b.png | Bin 0 -> 271 bytes .../images/icon_cdr_outbound_failed_b.png | Bin 0 -> 204 bytes 14 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 themes/default/images/icon_cdr_inbound_answered_b.png create mode 100644 themes/default/images/icon_cdr_inbound_cancelled_b.png create mode 100644 themes/default/images/icon_cdr_inbound_failed_b.png create mode 100644 themes/default/images/icon_cdr_local_answered_b.png create mode 100644 themes/default/images/icon_cdr_local_cancelled_b.png create mode 100644 themes/default/images/icon_cdr_local_failed_b.png create mode 100644 themes/default/images/icon_cdr_outbound_answered_b.png create mode 100644 themes/default/images/icon_cdr_outbound_cancelled_b.png create mode 100644 themes/default/images/icon_cdr_outbound_failed_b.png diff --git a/app/xml_cdr/app_config.php b/app/xml_cdr/app_config.php index 2619f2c8e7..c46dac1d53 100644 --- a/app/xml_cdr/app_config.php +++ b/app/xml_cdr/app_config.php @@ -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'; diff --git a/app/xml_cdr/v_xml_cdr_import.php b/app/xml_cdr/v_xml_cdr_import.php index a7f04ce3f6..ade8cc2b01 100644 --- a/app/xml_cdr/v_xml_cdr_import.php +++ b/app/xml_cdr/v_xml_cdr_import.php @@ -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); } diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php index 98ecf69911..72445a5129 100644 --- a/app/xml_cdr/xml_cdr.php +++ b/app/xml_cdr/xml_cdr.php @@ -110,6 +110,7 @@ echo " \n"; echo " \n"; echo " \n"; + echo " \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 "\n"; + $image_name = "icon_cdr_" . $row['direction'] . "_" . $call_result; + if($row['leg'] == 'b'){ + $image_name .= '_b'; + } + $image_name .= ".png"; + echo "\n"; } } else { echo " "; } diff --git a/app/xml_cdr/xml_cdr_inc.php b/app/xml_cdr/xml_cdr_inc.php index ea4eeedc3d..f185306970 100644 --- a/app/xml_cdr/xml_cdr_inc.php +++ b/app/xml_cdr/xml_cdr_inc.php @@ -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") { diff --git a/app/xml_cdr/xml_cdr_statistics.php b/app/xml_cdr/xml_cdr_statistics.php index 1c291eac4a..860a8e52e1 100644 --- a/app/xml_cdr/xml_cdr_statistics.php +++ b/app/xml_cdr/xml_cdr_statistics.php @@ -50,7 +50,11 @@ else { echo " \n"; echo " \n"; if (permission_exists('xml_cdr_search_advanced')) { - echo " \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 " \n"; } if (permission_exists('xml_cdr_all')) { if ($_GET['showall'] != 'true') { diff --git a/themes/default/images/icon_cdr_inbound_answered_b.png b/themes/default/images/icon_cdr_inbound_answered_b.png new file mode 100644 index 0000000000000000000000000000000000000000..78df84406a235cdc46933843bdf84b1d813e93ad GIT binary patch literal 290 zcmV+-0p0$IP)%P*R)U@8Kptrl(E%sm9KCMl8W6pnfeqlMnnbV76EFoL!S)iY zEzcME%NxiV*p+KEHNCPE3DyG_;0|=r>%D3)VzN$GOQ6rctr}EJ^4y|V9R*0RCE$QB zhX16DMz6Q(3KDD!`~Zg+!zA#iLC>&vU%MwO^Hqu0=ye5jz%dQvd6qd^VqxWy)n_{T oj$XUTfDF_!bl`y1-1&d7Kc$;m&boS8p8x;=07*qoM6N<$f~FjLwg3PC literal 0 HcmV?d00001 diff --git a/themes/default/images/icon_cdr_inbound_cancelled_b.png b/themes/default/images/icon_cdr_inbound_cancelled_b.png new file mode 100644 index 0000000000000000000000000000000000000000..e8d0f2a2dd4dcec30f9a29eefb929206660c9cc4 GIT binary patch literal 298 zcmV+_0oDGAP)T?KPZd}l*d53nK)i`mitsXpjP)=I{P+pzs^Je+W0KvrxIv@E}b1U7%>^zd%-E96kV7;5ac%1kV~Y^sP4&fM=O61_0`QR`(rH1HW-#m{jI` wiJ4W1Rv&TePu=UqfB~qY?;rrXwev5q2U;#zM2e;<^8f$<07*qoM6N<$fpCrDYS1kQD4SLbO3#va>6eLMD(lNO~5wH&7bZ9zh$}4Jn*2bQ(7~ zK)~_9_w)}E(b+S1)WbdSB8bkOb&}|8UFwSh!Lxj1RdVv}B2%BIej99pQ3+lOf=RB>0z-P!YeN_oE+-3MmkR+3k yECM0xj1Qw^e*FhR@+8Jh3I4O9vsJ18e{}(KV_S;;PTtx80000Ue{A1A79)6G-(n$p(oxP--?BK^r*Doj}v)G-^yh z0FSu$^a+V5a%Mq2EP-c16gm4OQKT;QML|$qIk*81X4FQJkDG!5{0;n?@ck*`VWlc*^HYK{BK2(s?^_K{Q-=tRq8Y@;v@h7002ovPDHLkV1mymciR8} literal 0 HcmV?d00001 diff --git a/themes/default/images/icon_cdr_local_failed_b.png b/themes/default/images/icon_cdr_local_failed_b.png new file mode 100644 index 0000000000000000000000000000000000000000..a42295e3d23a8bc802a6a024d402f289f9f82ba1 GIT binary patch literal 242 zcmV%;tJOBUy literal 0 HcmV?d00001 diff --git a/themes/default/images/icon_cdr_outbound_answered_b.png b/themes/default/images/icon_cdr_outbound_answered_b.png new file mode 100644 index 0000000000000000000000000000000000000000..c00c666d0038d00d82d0d903d0a680748886394a GIT binary patch literal 269 zcmV+o0rLKdP)@IQ0PFx$0VS{zyTa;(8bRS8u+jp zJ$lf*yr@9{MvZpBfIFS9r!$6NPZiLHI-X&%GK!Ttn)ENYSPk=7Vh5Z9Gk>K!7_(eo TiB4~X00000NkvXXu0mjf`oe1! literal 0 HcmV?d00001 diff --git a/themes/default/images/icon_cdr_outbound_cancelled_b.png b/themes/default/images/icon_cdr_outbound_cancelled_b.png new file mode 100644 index 0000000000000000000000000000000000000000..976207dc9d0fa851f3126f92b9c52374ede6e11a GIT binary patch literal 271 zcmV+q0r38bP)#eO(?+*Fz{ebyz{|~e{^%Z-@mWK zii}1z;YV4K9LUlYU;!L}0@$VQa|DQWVns5b1WrKizI&tErxQ4tEWo|1Rt9`4fR_;> z)t0&$)dpbWkKptP256>7bo+~CEwweO!`wkgMzsa5flxQWZw;(S3DmCL#tU8iyr6*( z8`Yx+&C81#1YnG62MoB=`Fc8I2=-I~ZK&fJwj!eysiR5%f{WEKk0o}%IWY5Ax&wNW VTVst3L#hA(002ovPDHLkV1nAMY=!^; literal 0 HcmV?d00001 diff --git a/themes/default/images/icon_cdr_outbound_failed_b.png b/themes/default/images/icon_cdr_outbound_failed_b.png new file mode 100644 index 0000000000000000000000000000000000000000..b0640c6a862dcac6ac9cd4dd606ebee18e505a90 GIT binary patch literal 204 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`lRaG=Ln`Jhos`SlV8G)duibP0l+XkK D!xm6f literal 0 HcmV?d00001