diff --git a/app/xml_cdr/app_config.php b/app/xml_cdr/app_config.php index b130e477ef..29a1acb1eb 100644 --- a/app/xml_cdr/app_config.php +++ b/app/xml_cdr/app_config.php @@ -197,6 +197,9 @@ $apps[$x]['permissions'][$y]['name'] = "xml_cdr_lose_race"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $y++; + $apps[$x]['permissions'][$y]['name'] = "xml_cdr_enterprise_leg"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; $apps[$x]['permissions'][$y]['name'] = "xml_cdr_cc_agent_leg"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $y++; @@ -537,6 +540,12 @@ $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(1)"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "The leg of the call a or b."; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = "originating_leg_uuid"; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Originating Leg UUID. Used to identify legs of an enterprise ring group - and exclude them "; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = "pdd_ms"; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "numeric"; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "numeric"; diff --git a/app/xml_cdr/resources/classes/xml_cdr.php b/app/xml_cdr/resources/classes/xml_cdr.php index 904f920290..20a6d6fa25 100644 --- a/app/xml_cdr/resources/classes/xml_cdr.php +++ b/app/xml_cdr/resources/classes/xml_cdr.php @@ -145,6 +145,7 @@ if (!class_exists('xml_cdr')) { $this->fields[] = "record_path"; $this->fields[] = "record_name"; $this->fields[] = "leg"; + $this->fields[] = "originating_leg_uuid"; $this->fields[] = "pdd_ms"; $this->fields[] = "rtp_audio_in_mos"; $this->fields[] = "last_app"; @@ -316,7 +317,7 @@ if (!class_exists('xml_cdr')) { //set missed calls $missed_call = 'false'; - if (strlen($xml->variables->answer_stamp) == 0) { + if (strlen($xml->variables->originating_leg_uuid) == 0 && $xml->variables->call_direction != 'outbound' && strlen($xml->variables->answer_stamp) == 0) { $missed_call = 'true'; } if ($xml->variables->missed_call == 'true') { @@ -404,6 +405,9 @@ if (!class_exists('xml_cdr')) { //store the call leg $this->array[$key]['leg'] = $leg; + //store the originating leg uuid + $this->array[$key]['originating_leg_uuid'] = urldecode($xml->variables->originating_leg_uuid); + //store post dial delay, in milliseconds $this->array[$key]['pdd_ms'] = urldecode($xml->variables->progress_mediamsec) + urldecode($xml->variables->progressmsec); @@ -430,7 +434,7 @@ if (!class_exists('xml_cdr')) { if (strlen($domain_name) == 0) { $presence_id = urldecode($xml->variables->presence_id); if (strlen($presence_id) > 0) { - $presence_array = explode($presence_id); + $presence_array = explode($presence_id, '%40'); $domain_name = $presence_array[1]; } } @@ -1210,7 +1214,7 @@ if (!class_exists('xml_cdr')) { // If the range starts with an '-' we start from the beginning // If not, we forward the file pointer // And make sure to get the end byte if spesified - if ($range0 == '-') { + if ($range == '-') { // The n-number of the last bytes is requested $c_start = $size - substr($range, 1); } diff --git a/app/xml_cdr/v_xml_cdr_import.php b/app/xml_cdr/v_xml_cdr_import.php index d8a3198aef..bfbd1026c7 100644 --- a/app/xml_cdr/v_xml_cdr_import.php +++ b/app/xml_cdr/v_xml_cdr_import.php @@ -265,6 +265,9 @@ //store the call leg $database->fields['leg'] = $leg; + + //store the originating leg + $database->fields['originating_leg_uuid'] = urldecode($xml->variables->originating_leg_uuid); //store post dial delay, in milliseconds $database->fields['pdd_ms'] = urldecode($xml->variables->progress_mediamsec) + urldecode($xml->variables->progressmsec); @@ -292,7 +295,7 @@ if (strlen($domain_name) == 0) { $presence_id = urldecode($xml->variables->presence_id); if (strlen($presence_id) > 0) { - $presence_array = explode($presence_id); + $presence_array = explode($presence_id, '%40'); $domain_name = $presence_array[1]; } } diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php index 5cd4e71c94..8288e5b3d0 100644 --- a/app/xml_cdr/xml_cdr.php +++ b/app/xml_cdr/xml_cdr.php @@ -824,13 +824,6 @@ $content .= "\n"; - if (!permission_exists('xml_cdr_lose_race') && $row['hangup_cause'] == 'LOSE_RACE') { - $content = ''; - } - //show agent originated legs only to those with the permission - if (!permission_exists('xml_cdr_cc_agent_leg') && $row['cc_side'] == "agent") { - $content = ''; - } //show the leg b only to those with the permission if ($row['leg'] == 'a') { echo $content; diff --git a/app/xml_cdr/xml_cdr_inc.php b/app/xml_cdr/xml_cdr_inc.php index df1653fbb1..01b5a42f34 100644 --- a/app/xml_cdr/xml_cdr_inc.php +++ b/app/xml_cdr/xml_cdr_inc.php @@ -413,10 +413,13 @@ $sql .= "and billsec like :billsec "; $parameters['billsec'] = '%'.$billsec.'%'; } - if (strlen($hangup_cause) > 0) { + if (strlen($hangup_cause) > 0 && $hangup_cause != 'LOSE_RACE') { $sql .= "and hangup_cause like :hangup_cause "; $parameters['hangup_cause'] = '%'.$hangup_cause.'%'; } + elseif (!permission_exists('xml_cdr_lose_race')) { + $sql .= "and hangup_cause != 'LOSE_RACE' "; + } if (strlen($call_result) > 0) { switch ($call_result) { case 'answered': @@ -491,6 +494,10 @@ $sql .= "and leg = :leg "; $parameters['leg'] = $leg; } + //exclude enterprise ring group legs + if (!permission_exists('xml_cdr_enterprise_leg')) { + $sql .= "and originating_leg_uuid IS NULL "; + } if (is_numeric($tta_min)) { $sql .= "and (c.answer_epoch - c.start_epoch) >= :tta_min "; $parameters['tta_min'] = $tta_min; @@ -507,6 +514,10 @@ $sql .= "and (c.record_path is null or c.record_name is null) "; } } + //show agent originated legs only to those with the permission + if (!permission_exists('xml_cdr_cc_agent_leg')) { + $sql .= "and cc_side != 'agent' "; + } //end where if (strlen($order_by) > 0) { $sql .= order_by($order_by, $order); diff --git a/app/xml_cdr/xml_cdr_statistics_inc.php b/app/xml_cdr/xml_cdr_statistics_inc.php index 574440d413..4b1c9d9b04 100644 --- a/app/xml_cdr/xml_cdr_statistics_inc.php +++ b/app/xml_cdr/xml_cdr_statistics_inc.php @@ -153,7 +153,7 @@ $parameters['domain_uuid'] = $_SESSION['domain_uuid']; } if ($missed == true) { - $sql_where_ands[] = "billsec = '0'"; + $sql_where_ands[] = "missed_call = true "; } if (strlen($start_epoch) > 0 && strlen($stop_epoch) > 0) { $sql_where_ands[] = "start_epoch between :start_epoch and :stop_epoch"; @@ -284,6 +284,11 @@ if (!permission_exists('xml_cdr_lose_race')) { $sql_where_ands[] = "hangup_cause != 'LOSE_RACE'"; } + //Exclude enterprise ring group legs + if (!permission_exists('xml_cdr_enterprise_leg')) { + $sql_where_ands[] .= "originating_leg_uuid IS NULL"; + } + //if not admin or superadmin, only show own calls if (!permission_exists('xml_cdr_domain')) { @@ -349,7 +354,7 @@ //get the call volume between a start end end time in seconds function get_call_volume_between($start, $end, $where, $parameters) { - $sql = "select count(*) as count, sum(billsec) as seconds from v_xml_cdr "; + $sql = "select count(*) as count, sum(billsec) as seconds, sum(answer_stamp - start_stamp) as tta from v_xml_cdr "; $sql .= $where." "; $sql .= "start_epoch between :start and :end "; $parameters['start'] = $start; @@ -360,6 +365,7 @@ return array( 'volume' => $row['count'], 'seconds' => $row['seconds'], + 'tta' => $row['tta'], ); } return false; @@ -379,14 +385,13 @@ $stats[$i]['volume'] = $stat_range ? $stat_range['volume'] : 0; $stats[$i]['seconds'] = $stat_range ? $stat_range['seconds'] : 0; $stats[$i]['minutes'] = $stats[$i]['seconds'] / 60; - $stats[$i]['avg_sec'] = $stats[$i]['volume'] == 0 ? 0 : $stats[$i]['seconds'] / $stats[$i]['volume']; if ($missed) { //we select only missed calls at first place - no reasons to select it again $stats[$i]['missed'] = $stats[$i]['volume']; } else { - $where = $sql_where."billsec = '0' and "; + $where = $sql_where."missed_call = true and "; $stat_range = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where, $parameters); $stats[$i]['missed'] = $stat_range ? $stat_range['volume'] : 0; } @@ -403,6 +408,9 @@ //answer / seizure ratio $stats[$i]['asr'] = $stats[$i]['volume'] == 0 ? 0 : ($success_volume / $stats[$i]['volume'] * 100); + //average time to answer + $stats[$i]['avg_tta'] = $stats[$i]['volume'] == 0 ? 0 : round($stat_range['tta'] / $success_volume); + //average length of call $stats[$i]['aloc'] = $success_volume == 0 ? 0 : $stats[$i]['minutes'] / $success_volume; }