From d4e3d9a7b53c23d756dbdc6e20d10cd6af4fa1b7 Mon Sep 17 00:00:00 2001 From: Nate Jones Date: Wed, 6 Aug 2014 05:21:13 +0000 Subject: [PATCH] Extension Summary: New report - displays per extension call count and usage statistics within a given date range. --- app/xml_cdr/app_config.php | 18 ++ app/xml_cdr/app_languages.php | 81 ++++++++ app/xml_cdr/xml_cdr_extension_summary.php | 242 ++++++++++++++++++++++ app/xml_cdr/xml_cdr_statistics.php | 1 + 4 files changed, 342 insertions(+) create mode 100644 app/xml_cdr/xml_cdr_extension_summary.php diff --git a/app/xml_cdr/app_config.php b/app/xml_cdr/app_config.php index 7632355399..eaf10d8403 100644 --- a/app/xml_cdr/app_config.php +++ b/app/xml_cdr/app_config.php @@ -58,6 +58,24 @@ $apps[$x]['menu'][$y]['groups'][] = "user"; $apps[$x]['menu'][$y]['groups'][] = "admin"; $apps[$x]['menu'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['menu'][$y]['title']['en-us'] = "Extension Summary"; + $apps[$x]['menu'][$y]['title']['es-cl'] = "Extension Summary"; + $apps[$x]['menu'][$y]['title']['es-mx'] = ""; + $apps[$x]['menu'][$y]['title']['de-de'] = ""; + $apps[$x]['menu'][$y]['title']['de-ch'] = ""; + $apps[$x]['menu'][$y]['title']['de-at'] = ""; + $apps[$x]['menu'][$y]['title']['fr-fr'] = "Extension Summary"; + $apps[$x]['menu'][$y]['title']['fr-ca'] = ""; + $apps[$x]['menu'][$y]['title']['fr-ch'] = ""; + $apps[$x]['menu'][$y]['title']['pt-pt'] = "Extension Summary"; + $apps[$x]['menu'][$y]['title']['pt-br'] = ""; + $apps[$x]['menu'][$y]['uuid'] = "4e45a3c1-6db5-417f-9abb-1d30a4fd0bf2"; + $apps[$x]['menu'][$y]['parent_uuid'] = "0438b504-8613-7887-c420-c837ffb20cb1"; + $apps[$x]['menu'][$y]['category'] = "internal"; + $apps[$x]['menu'][$y]['path'] = "/app/xml_cdr/xml_cdr_extension_summary.php"; + $apps[$x]['menu'][$y]['groups'][] = "admin"; + $apps[$x]['menu'][$y]['groups'][] = "superadmin"; //permission details $y = 0; diff --git a/app/xml_cdr/app_languages.php b/app/xml_cdr/app_languages.php index 8e17a24825..5de3a171bc 100644 --- a/app/xml_cdr/app_languages.php +++ b/app/xml_cdr/app_languages.php @@ -425,4 +425,85 @@ $text['table-days']['pt-pt'] = "Dias"; $text['table-days']['fr-fr'] = "Jours"; + $text['button-extension_summary']['en-us'] = "Extension Summary"; + $text['button-extension_summary']['es-cl'] = "Resumen Extensión"; + $text['button-extension_summary']['pt-pt'] = "Resumo Extensão"; + $text['button-extension_summary']['fr-fr'] = "Résumé d'Extension"; + + //xml_cdr_extension_summary + $text['description-extension_summary']['en-us'] = "Default View: Last 7 Days"; + $text['description-extension_summary']['es-cl'] = "Vista predeterminada: Últimos 7 días"; + $text['description-extension_summary']['pt-pt'] = "Exibição padrão: nos últimos 7 dias"; + $text['description-extension_summary']['fr-fr'] = "Vue par défaut: Les 7 derniers jours"; + + $text['title-extension_summary']['en-us'] = "Extension Summary"; + $text['title-extension_summary']['es-cl'] = "Resumen Extensión"; + $text['title-extension_summary']['pt-pt'] = "Resumo Extensão"; + $text['title-extension_summary']['fr-fr'] = "Résumé d'Extension"; + + $text['label-start_date_time']['en-us'] = "Start Date/Time"; + $text['label-start_date_time']['es-cl'] = "Fecha/Hora de Comienzo"; + $text['label-start_date_time']['pt-pt'] = "Data/Hora de Início"; + $text['label-start_date_time']['fr-fr'] = "Date de Début/Heure"; + + $text['label-end_date_time']['en-us'] = "End Date/Time"; + $text['label-end_date_time']['es-cl'] = "Fecha/Hora"; + $text['label-end_date_time']['pt-pt'] = "Data/Hora Final"; + $text['label-end_date_time']['fr-fr'] = "Fin Date/Heure"; + + $text['label-include_internal']['en-us'] = "Include Internal"; + $text['label-include_internal']['es-cl'] = "Incluya Interna"; + $text['label-include_internal']['pt-pt'] = "Incluir Interno"; + $text['label-include_internal']['fr-fr'] = "Inclure Interne"; + + $text['button-update']['en-us'] = "Update"; + $text['button-update']['es-cl'] = "Actualización"; + $text['button-update']['pt-pt'] = "Atualizar"; + $text['button-update']['fr-fr'] = "Mise à jour"; + + $text['label-extension']['en-us'] = "Extension"; + $text['label-extension']['es-cl'] = "Extensión"; + $text['label-extension']['pt-pt'] = "Extensão"; + $text['label-extension']['fr-fr'] = "Extension"; + + $text['label-number_alias']['en-us'] = "Number Alias"; + $text['label-number_alias']['es-cl'] = "Número Alias"; + $text['label-number_alias']['pt-pt'] = "Número Alias"; + $text['label-number_alias']['fr-fr'] = "Nombre Alias"; + + $text['label-username']['en-us'] = "Username"; + $text['label-username']['es-cl'] = "Nombre de usuario"; + $text['label-username']['pt-pt'] = "Nome de Utilizador"; + $text['label-username']['fr-fr'] = "Nom d'Utilisateur"; + + $text['label-inbound_calls']['en-us'] = "Inbound Calls"; + $text['label-inbound_calls']['es-cl'] = "Las Llamadas Entrantes"; + $text['label-inbound_calls']['pt-pt'] = "Chamadas de Entrada"; + $text['label-inbound_calls']['fr-fr'] = "Les Appels Entrants"; + + $text['label-outbound_calls']['en-us'] = "Outbound Calls"; + $text['label-outbound_calls']['es-cl'] = "Llamadas Salientes"; + $text['label-outbound_calls']['pt-pt'] = "Chamadas de Saída"; + $text['label-outbound_calls']['fr-fr'] = "Appels Sortants"; + + $text['label-inbound_duration']['en-us'] = "Inbound Duration"; + $text['label-inbound_duration']['es-cl'] = "Duración Inbound"; + $text['label-inbound_duration']['pt-pt'] = "Inbound Duração"; + $text['label-inbound_duration']['fr-fr'] = "Inbound Durée"; + + $text['label-outbound_duration']['en-us'] = "Outbound Duration"; + $text['label-outbound_duration']['es-cl'] = "Duración de Salida"; + $text['label-outbound_duration']['pt-pt'] = "Outbound Duração"; + $text['label-outbound_duration']['fr-fr'] = "Sortant Durée"; + + $text['option-true']['en-us'] = "True"; + $text['option-true']['es-cl'] = "Verdadero"; + $text['option-true']['pt-pt'] = "Sim"; + $text['option-true']['fr-fr'] = "Oui"; + + $text['option-false']['en-us'] = "False"; + $text['option-false']['es-cl'] = "Falso"; + $text['option-false']['pt-pt'] = "Não"; + $text['option-false']['fr-fr'] = "Non"; + ?> diff --git a/app/xml_cdr/xml_cdr_extension_summary.php b/app/xml_cdr/xml_cdr_extension_summary.php new file mode 100644 index 0000000000..c3fddc3c2b --- /dev/null +++ b/app/xml_cdr/xml_cdr_extension_summary.php @@ -0,0 +1,242 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2014 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; + +if (permission_exists('xml_cdr_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//add multi-lingual support + require_once "app_languages.php"; + foreach($text as $key => $value) { + $text[$key] = $value[$_SESSION['domain']['language']['code']]; + } + +//additional includes + require_once "resources/header.php"; + +// retrieve submitted data + $start_stamp_begin = check_str($_REQUEST['start_stamp_begin']); + $start_stamp_end = check_str($_REQUEST['start_stamp_end']); + $include_internal = check_str($_REQUEST['include_internal']); + +//page title and description + echo "
"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['title-extension_summary']."

\n"; + echo " ".$text['description-extension_summary']."
\n"; + echo "
 
\n"; + echo "
\n"; + + if (permission_exists('xml_cdr_search')) { + echo "
\n"; + + echo "\n"; + echo " \n"; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
\n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-start_date_time']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + + echo "
\n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-end_date_time']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + + echo "
\n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-include_internal']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + + echo "
"; + + echo " \n"; + echo " \n"; + + echo "
"; + + echo "
"; + echo "

"; + } + +// get current extension info + $sql = "select "; + $sql .= "extension_uuid, "; + $sql .= "extension, "; + $sql .= "number_alias "; + $sql .= "from "; + $sql .= "v_extensions "; + $sql .= "where "; + $sql .= "enabled = 'true' "; + $sql .= "and domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "order by "; + $sql .= "extension asc"; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + if ($result_count > 0) { + foreach($result as $row) { + $extensions[$row['extension']]['extension_uuid'] = $row['extension_uuid']; + $extensions[$row['extension']]['number_alias'] = $row['number_alias']; + } + } + unset ($sql, $prep_statement, $result, $row_count); + // create list of extensions for query below + foreach ($extensions as $extension => $blah) { + $ext_array[] = $extension; + } + $ext_list = implode("','", $ext_array); + +// calculate the summary data + $sql = "select "; + $sql .= "caller_id_number, "; + $sql .= "destination_number, "; + $sql .= "billsec "; + $sql .= "from "; + $sql .= "v_xml_cdr "; + $sql .= "where "; + $sql .= "domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and ( "; + $sql .= " caller_id_number in ('".$ext_list."') or "; + $sql .= " destination_number in ('".$ext_list."') "; + $sql .= ") "; + if (!$include_internal) { + $sql .= " and ( direction = 'inbound' or direction = 'outbound' ) "; + } + if (strlen($start_stamp_begin) == 0 && strlen($start_stamp_end) == 0) { + $sql .= "and start_stamp >= '".date('Y-m-d H:i:s.000', strtotime("-1 week"))."' "; // show last 7 days if no range specified + } + else if (strlen($start_stamp_begin) > 0 && strlen($start_stamp_end) > 0) { $sql .= " and start_stamp BETWEEN '".$start_stamp_begin.":00.000' AND '".$start_stamp_end.":59.999'"; } + else { + if (strlen($start_stamp_begin) > 0) { $sql .= " and start_stamp >= '".$start_stamp_begin.":00.000'"; } + if (strlen($start_stamp_end) > 0) { $sql .= " and start_stamp <= '".$start_stamp_end.":59.999'"; } + } + //echo $sql."

"; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + if ($result_count > 0) { + foreach($result as $row) { + if (in_array($row['caller_id_number'], $ext_array)) { + $summary[$row['caller_id_number']]['outbound']['count']++; + $summary[$row['caller_id_number']]['outbound']['seconds'] += $row['billsec']; + } + if (in_array($row['destination_number'], $ext_array)) { + $summary[$row['destination_number']]['inbound']['count']++; + $summary[$row['destination_number']]['inbound']['seconds'] += $row['billsec']; + } + } //end foreach + } //end if results + unset ($sql, $prep_statement, $result, $row_count); + +//show the results + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + foreach ($extensions as $extension => $ext) { + $seconds['inbound'] = $summary[$extension]['inbound']['seconds']; + $seconds['outbound'] = $summary[$extension]['outbound']['seconds']; + $tr_link = "xhref='xml_cdr.php?'"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + $c = ($c==0) ? 1 : 0; + } + + echo "
".$text['label-extension']."".$text['label-number_alias']."".$text['label-inbound_calls']."".$text['label-inbound_duration']."".$text['label-outbound_calls']."".$text['label-outbound_duration']."
".$extension."".$ext['number_alias']."  ".(($summary[$extension]['inbound']['count'] != '') ? $summary[$extension]['inbound']['count'] : "0")."".(($seconds['inbound'] != '') ? gmdate("G:i:s", $seconds['inbound']) : '0:00:00')." ".(($summary[$extension]['outbound']['count'] != '') ? $summary[$extension]['outbound']['count'] : "0")."".(($seconds['outbound'] != '') ? gmdate("G:i:s", $seconds['outbound']) : '0:00:00')."
"; + echo "
"; + echo "

"; + echo "

"; + +//show the footer + require_once "resources/footer.php"; + +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_statistics.php b/app/xml_cdr/xml_cdr_statistics.php index aa06f11dbd..41b0a41055 100644 --- a/app/xml_cdr/xml_cdr_statistics.php +++ b/app/xml_cdr/xml_cdr_statistics.php @@ -51,6 +51,7 @@ else { echo " ".$text['label-call-statistics']."\n"; echo " \n"; echo " \n"; + echo " \n"; echo " \n"; echo " \n"; echo "\n";