diff --git a/app/xml_cdr/app_config.php b/app/xml_cdr/app_config.php index 4c4e3d8110..d9d6a623ac 100644 --- a/app/xml_cdr/app_config.php +++ b/app/xml_cdr/app_config.php @@ -84,6 +84,10 @@ $apps[$x]['permissions'][$y]['name'] = "caller_destination"; $apps[$x]['permissions'][$y]['groups'][] = "admin"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = "xml_cdr_archive"; + $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; //default settings $y=0; @@ -150,7 +154,63 @@ $apps[$x]['default_settings'][$y]['default_setting_value'] = "true"; $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true"; $apps[$x]['default_settings'][$y]['default_setting_description'] = ""; - + $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "f39db4b4-86bc-4d5d-9580-0f17c7934fe8"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "cdr"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "archive_database"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "boolean"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = "false"; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = "Enable Dedicated CDR Database Access"; + $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "c655308c-476c-4f60-ac12-6aaf2b79c344"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "cdr"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "archive_database_driver"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "text"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = "pgsql"; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = "Archive Database Driver"; + $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "eec7b6d7-6955-4ae2-8c6c-b853b3016200"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "cdr"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "archive_database_host"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "text"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = ""; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = "IP/Hostname of Archive Database"; + $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "73a1ad24-82d0-492a-86bb-36376a87348e"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "cdr"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "archive_database_password"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "text"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = ""; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = "Archive Database Password"; + $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "a05be23e-b1cf-4c0b-9ded-e6f06a7a7946"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "cdr"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "archive_database_port"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "text"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = "5432"; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = "Archive Database Port"; + $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "e92612b1-ed97-40a7-a641-78c8a79ff774"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "cdr"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "archive_database_username"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "text"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = ""; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = "Archive Database Username"; + $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "38c507f5-fce2-40de-99d5-5aa4e8d718de"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "cdr"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "archive_database_name"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "text"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = "fusionpbx"; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = "Archive Database Name"; + //schema details $y=0; $apps[$x]['db'][$y]['table']['name'] = "v_xml_cdr"; diff --git a/app/xml_cdr/app_languages.php b/app/xml_cdr/app_languages.php index 7aff7b19d3..4945c5a986 100644 --- a/app/xml_cdr/app_languages.php +++ b/app/xml_cdr/app_languages.php @@ -61,6 +61,26 @@ $text['title']['ru-ru'] = "Детализация Вызовов"; $text['title']['sv-se'] = "Detaljerad Samtalsinformation"; $text['title']['uk-ua'] = "Параметри облікового запису"; +$text['title-archive']['en-us'] = "Call Detail Records Archive"; +$text['title-archive']['ar-eg'] = ""; +$text['title-archive']['de-at'] = "Meine Gespräche Archiv"; //copied from de-de +$text['title-archive']['de-ch'] = "Meine Gespräche Archiv"; //copied from de-de +$text['title-archive']['de-de'] = "Meine Gespräche Archiv"; +$text['title-archive']['es-cl'] = "Registro de Detalle de Llamadas Archivo"; +$text['title-archive']['es-mx'] = "Registro de Detalle de Llamadas Archivo"; //copied from es-cl +$text['title-archive']['fr-ca'] = "Historique détaillé des appels Archiver"; //copied from fr-fr +$text['title-archive']['fr-fr'] = "Historique détaillé des appels Archiver"; +$text['title-archive']['he-il'] = ""; +$text['title-archive']['it-it'] = "Cartellini di Chiamata Archivio"; +$text['title-archive']['nl-nl'] = ""; +$text['title-archive']['pl-pl'] = "Wykaz rozmów Archiwum"; +$text['title-archive']['pt-br'] = "Configurações da Conta Archiwum"; +$text['title-archive']['pt-pt'] = "Registo de Chamadas Arquivo"; +$text['title-archive']['ro-ro'] = ""; +$text['title-archive']['ru-ru'] = "Детализация Вызовов архив"; +$text['title-archive']['sv-se'] = "Detaljerad Samtalsinformation archív"; +$text['title-archive']['uk-ua'] = "Параметри облікового запису архів"; + $text['table-time']['en-us'] = "Time"; $text['table-time']['ar-eg'] = ""; $text['table-time']['de-at'] = "Zeit"; //copied from de-de @@ -2421,6 +2441,26 @@ $text['description-mos']['ru-ru'] = "Средний оценочный пока $text['description-mos']['sv-se'] = "Genomsnittlig bedömning poäng"; $text['description-mos']['uk-ua'] = "Середнє число думок"; +$text['button-archive']['en-us'] = "Archive"; +$text['button-archive']['ar-eg'] = ""; +$text['button-archive']['de-at'] = "Archiv"; //copied from de-de +$text['button-archive']['de-ch'] = "Archiv"; //copied from de-de +$text['button-archive']['de-de'] = "Archiv"; +$text['button-archive']['es-cl'] = "Archivo"; +$text['button-archive']['es-mx'] = "Archivo"; //copied from es-cl +$text['button-archive']['fr-ca'] = "Archiver"; //copied from fr-fr +$text['button-archive']['fr-fr'] = "Archiver"; +$text['button-archive']['he-il'] = ""; +$text['button-archive']['it-it'] = "Archivio"; +$text['button-archive']['nl-nl'] = ""; +$text['button-archive']['pl-pl'] = "Archiwum"; +$text['button-archive']['pt-br'] = "Archiwum"; +$text['button-archive']['pt-pt'] = "Arquivo"; +$text['button-archive']['ro-ro'] = ""; +$text['button-archive']['ru-ru'] = "архив"; +$text['button-archive']['sv-se'] = "archív"; +$text['button-archive']['uk-ua'] = "архів"; + $text['button-update']['en-us'] = "Update"; $text['button-update']['ar-eg'] = ""; $text['button-update']['de-at'] = "Aktualisieren"; //copied from de-de diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php index bf0e5a641c..a453f8697f 100644 --- a/app/xml_cdr/xml_cdr.php +++ b/app/xml_cdr/xml_cdr.php @@ -145,6 +145,12 @@ echo " \n"; } echo " \n"; + if (permission_exists('xml_cdr_archive')) { + if ($_REQUEST['show'] == 'all') { + $query_string = "show=all"; + } + echo " \n"; + } echo " \n"; echo " \n"; echo " "; diff --git a/app/xml_cdr/xml_cdr_archive.php b/app/xml_cdr/xml_cdr_archive.php new file mode 100644 index 0000000000..e6f849b17b --- /dev/null +++ b/app/xml_cdr/xml_cdr_archive.php @@ -0,0 +1,731 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2017 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane + Luis Daniel Lucio Quiroz +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + require_once "resources/check_auth.php"; + +//check permisions + if (permission_exists('xml_cdr_view')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//additional includes + require_once "resources/header.php"; + require_once "resources/paging.php"; + +//xml cdr include + $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; + $archive_request = 'true'; + require_once "xml_cdr_inc.php"; + +//javascript function: send_cmd + echo "\n"; + +//javascript to toggle export select box + echo ""; + +//page title and description + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
".$text['title-archive']."


\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + if (is_array($_SESSION['cdr']['field'])) { + foreach ($_SESSION['cdr']['field'] as $field) { + $array = explode(",", $field); + $field_name = $array[count($array) - 1]; + if (isset($_REQUEST[$field_name])) { + echo " \n"; + } + } + } + if (isset($order_by)) { + echo " \n"; + echo " \n"; + } + if (permission_exists('xml_cdr_all') && $_REQUEST['show'] == 'all') { + echo " \n"; + } + echo " \n"; + echo " \n"; + echo " "; + echo " \n"; + if ($result_count == $rows_per_page && $paging_controls_mini != '') { + echo " \n"; + } + echo " \n"; + echo "
\n"; + if (permission_exists('xml_cdr_all')) { + if ($_REQUEST['show'] != 'alll') { + echo " \n"; + } + } +// if (permission_exists('xml_cdr_search_advanced')) { +// if ($_REQUEST['show'] == 'all') { +// $query_string = "show=all"; +// } +// echo " \n"; +// } + + if ($_GET['call_result'] != 'missed') { + echo " \n"; + } +// echo " \n"; + echo " \n"; + echo " "; + echo " "; + echo " \n"; + echo " ".$paging_controls_mini."
\n"; + echo "
\n"; + echo "
\n"; + + echo $text['description']." \n"; + echo $text['description2']." \n"; + echo $text['description-3']." \n"; + echo $text['description-4']." \n"; + + echo "

\n"; + + echo "
\n"; + + //basic search of call detail records + if (permission_exists('xml_cdr_search')) { + + echo "
\n"; + + echo "\n"; + echo "\n"; + echo ""; + echo ""; + echo ""; + + // show hangup clause filter to super/admin + echo ""; + + echo ""; + echo "
\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-direction']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-status']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + + echo "
\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-source']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-destination']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + + echo "
\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-start_range']."\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-cid-name']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + + echo "
\n"; + + echo "\n"; + echo " \n"; + if (permission_exists('hangup_cause')) { + echo " \n"; + echo " \n"; + echo " \n"; + } + if (permission_exists('caller_destination')) { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + echo "
\n"; + echo " ".$text['label-hangup_cause']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-caller_destination']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + + echo "
"; + + echo "\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
"; + echo $text['description_search']; + echo ""; + if (permission_exists('xml_cdr_all') && $_REQUEST['show'] == 'all') { + echo "\n"; + } + echo "\n"; + echo "\n"; + + echo "
"; + + echo "
"; + echo "

"; + } + +//mod paging parameters for inclusion in column sort heading links + $param = substr($param, 1); //remove leading '&' + $param = substr($param, 0, strrpos($param, '&order_by=')); //remove trailing order by + +//show the results + $col_count = 8; + //echo "
\n"; + echo "\n"; + echo "\n"; + //if (permission_exists('xml_cdr_delete') && $result_count > 0) { + // echo ""; + // $col_count++; + //} + //column headings + echo "\n"; + if ($_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) { + echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, null, null, $param); + $col_count++; + } + echo th_order_by('caller_id_name', $text['label-cid-name'], $order_by, $order, null, null, $param); + echo th_order_by('caller_id_number', $text['label-source'], $order_by, $order, null, null, $param); + if (permission_exists('caller_destination')) { + echo th_order_by('caller_destination', $text['label-caller_destination'], $order_by, $order, null, null, $param); + } + echo th_order_by('destination_number', $text['label-destination'], $order_by, $order, null, null, $param); + if (permission_exists('recording_play') || permission_exists('recording_download')) { + echo "\n"; + $col_count++; + } + if (is_array($_SESSION['cdr']['field'])) { + foreach ($_SESSION['cdr']['field'] as $field) { + $array = explode(",", $field); + $field_name = $array[count($array) - 1]; + $field_label = ucwords(str_replace("_", " ", $field_name)); + $field_label = str_replace("Sip", "SIP", $field_label); + if ($field_name != "destination_number") { + echo th_order_by($field_name, $field_label, $order_by, $order, null, "style='text-align: right;'", $param); + } + } + } + echo th_order_by('start_stamp', $text['label-start'], $order_by, $order, null, "style='text-align: center;'", $param); + echo th_order_by('tta', $text['label-tta'], $order_by, $order, null, "style='text-align: right;'", $param, $text['description-tta']); + echo th_order_by('duration', $text['label-duration'], $order_by, $order, null, "style='text-align: center;'", $param); + if (file_exists($_SERVER["PROJECT_ROOT"]."/app/billing/app_config.php")){ + echo "\n"; + $col_count++; + } + if (permission_exists('xml_cdr_pdd')) { + echo th_order_by('pdd_ms', $text['label-pdd'], $order_by, $order, null, "style='text-align: right;'", $param, $text['description-pdd']); + $col_count++; + } + if (permission_exists('xml_cdr_mos')) { + echo th_order_by('rtp_audio_in_mos', $text['label-mos'], $order_by, $order, null, "style='text-align: center;'", $param, $text['description-mos']); + $col_count++; + } + if (permission_exists('hangup_cause')) { + echo th_order_by('hangup_cause', $text['label-hangup_cause'], $order_by, $order, null, null, $param); + } + else { + echo "\n"; + } +/* if (if_group("admin") || if_group("superadmin") || if_group("cdr")) { + echo "\n"; + $col_count++; + } +*/ echo "\n"; + + if (file_exists($_SERVER["PROJECT_ROOT"]."/app/billing/app_config.php")){ + require_once "app/billing/resources/functions/rating.php"; + require_once "resources/classes/database.php"; + $database = new database; + } + + if ($result_count > 0) { + //determine if theme images exist + $theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/"; + $theme_cdr_images_exist = ( + file_exists($theme_image_path."icon_cdr_inbound_answered.png") && + file_exists($theme_image_path."icon_cdr_inbound_voicemail.png") && + file_exists($theme_image_path."icon_cdr_inbound_cancelled.png") && + file_exists($theme_image_path."icon_cdr_inbound_failed.png") && + file_exists($theme_image_path."icon_cdr_outbound_answered.png") && + file_exists($theme_image_path."icon_cdr_outbound_cancelled.png") && + file_exists($theme_image_path."icon_cdr_outbound_failed.png") && + file_exists($theme_image_path."icon_cdr_local_answered.png") && + file_exists($theme_image_path."icon_cdr_local_voicemail.png") && + file_exists($theme_image_path."icon_cdr_local_cancelled.png") && + file_exists($theme_image_path."icon_cdr_local_failed.png") + ) ? true : false; + + foreach($result as $index => $row) { + //get the date and time + $tmp_year = date("Y", strtotime($row['start_stamp'])); + $tmp_month = date("M", strtotime($row['start_stamp'])); + $tmp_day = date("d", strtotime($row['start_stamp'])); + $tmp_start_epoch = ($_SESSION['domain']['time_format']['text'] == '12h') ? date("j M Y g:i:sa", $row['start_epoch']) : date("j M Y H:i:s", $row['start_epoch']); + + //get the hangup cause + $hangup_cause = $row['hangup_cause']; + $hangup_cause = str_replace("_", " ", $hangup_cause); + $hangup_cause = strtolower($hangup_cause); + $hangup_cause = ucwords($hangup_cause); + + //if call cancelled, show the ring time, not the bill time. + $seconds = ($row['hangup_cause']=="ORIGINATOR_CANCEL") ? $row['duration'] : round(($row['billmsec'] / 1000), 0, PHP_ROUND_HALF_UP); + + //determine recording properties + if (permission_exists('recording_play') || permission_exists('recording_download')) { + $record_path = $row['record_path']; + $record_name = $row['record_name']; + //$record_name = strtolower(pathinfo($tmp_name, PATHINFO_BASENAME)); + $record_extension = pathinfo($record_name, PATHINFO_EXTENSION); + switch ($record_extension) { + case "wav" : $record_type = "audio/wav"; break; + case "mp3" : $record_type = "audio/mpeg"; break; + case "ogg" : $record_type = "audio/ogg"; break; + } + } + + //recording playback + if (permission_exists('recording_play') && $record_path != '') { + echo "\n"; + } + + // if ($row['raw_data_exists'] && permission_exists('xml_cdr_details')) { + // $tr_link = "href='xml_cdr_details.php?uuid=".$row['uuid'].(($_REQUEST['show']) ? "&show=all" : null)."'"; + // } + // else { + // $tr_link = null; + // } + // echo "\n"; +/* if (permission_exists('xml_cdr_delete')) { + echo " "; + $xml_ids[] = 'checkbox_'.$row['uuid']; + } +*/ //determine call result and appropriate icon + echo "\n"; + //domain name + if ($_REQUEST['show'] == "all" && permission_exists('xml_cdr_all')) { + echo " \n"; + } + //caller id name + echo " \n"; + //source + echo " \n"; + //caller destination + if (permission_exists('caller_destination')) { + echo " \n"; + } + //destination + echo " \n"; + //recording + if (permission_exists('recording_play') || permission_exists('recording_download')) { + if ($record_path != '' && file_exists($record_path.'/'.$record_name)) { + echo " \n"; + } + else { + echo " \n"; + } + } + //dynamic cdr fields + if (is_array($_SESSION['cdr']['field'])) { + foreach ($_SESSION['cdr']['field'] as $field) { + $array = explode(",", $field); + $field_name = $array[count($array) - 1]; + if ($field_name != "destination_number") { + echo " \n"; + } + } + } + //start + echo " \n"; + //tta (time to answer) + echo " \n"; + //duration + echo " \n"; + //billing + if (file_exists($_SERVER["PROJECT_ROOT"]."/app/billing/app_config.php")){ + + $database->table = "v_xml_cdr"; + $accountcode = (strlen($row["accountcode"])?$row["accountcode"]:$_SESSION[domain_name]); + $database->sql = "SELECT currency FROM v_billings WHERE type_value='$accountcode'"; + $database->result = $database->execute(); + $billing_currency = (strlen($database->result[0]['currency'])?$database->result[0]['currency']:'USD'); + $billing_currency = (strlen($database->result[0]['currency'])?$database->result[0]['currency']: + (strlen($_SESSION['billing']['currency']['text'])?$_SESSION['billing']['currency']['text']:'USD') + ); + unset($database->sql); + unset($database->result); + + $sell_price = strlen($row['call_sell'])?$row['call_sell']:0; + $lcr_direction = (strlen($row['direction'])?$row['direction']:"outbound"); + + $xml_string = trim($row["xml"]); + $json_string = trim($row["json"]); + if (strlen($xml_string) > 0) { + $format = "xml"; + } + if (strlen($json_string) > 0) { + $format = "json"; + } + try { + if ($format == 'json') { + $array = json_decode($json_string,true); + } + if ($format == 'xml') { + $array = json_decode(json_encode((array)simplexml_load_string($xml_string)),true); + } + } + catch(Exception $e) { + echo $e->getMessage(); + } + + $n = (($lcr_direction == "inbound")? + check_str(urldecode($array["caller_profile"]["caller_id_number"])): + check_str(urldecode($array["variables"]["lcr_query_digits"])) + ); + + $database->table = "v_lcr"; + $database->sql = "SELECT currency FROM v_lcr WHERE v_lcr.carrier_uuid IS NULL AND v_lcr.enabled='true' AND v_lcr.lcr_direction='$lcr_direction' AND v_lcr.digits IN (".number_series($n).") ORDER BY digits DESC, rate ASC, date_start DESC LIMIT 1"; + $database->result = $database->execute(); + // print "
"; print $database->sql . ":";print "[".$database->result[0]['currency']."]"; print_r($array); print "
"; + + $lcr_currency = ((is_string($database->result[0]['currency']) && strlen($database->result[0]['currency']))?$database->result[0]['currency']: + (strlen($_SESSION['billing']['currency']['text'])?$_SESSION['billing']['currency']['text']:'USD') + ); //billed currency + unset($database->sql); + unset($database->result); + if ($sell_price){ + $price = currency_convert($sell_price, $billing_currency, $lcr_currency); + } + else { + $price = 0; + } + echo " \n"; + unset ($sell_price, $price); + } + //pdd (post dial delay) + if (permission_exists("xml_cdr_pdd")) { + echo " \n"; + } + //mos (mean opinion score) + if (permission_exists("xml_cdr_mos")) { + if(strlen($row['rtp_audio_in_mos']) > 0){ + $title = " title='".$text['label-mos_score-'.round($row['rtp_audio_in_mos'])]."'"; + $value = $row['rtp_audio_in_mos']; + } + echo " \n"; + } + //hangup cause/call result + if (permission_exists('hangup_cause')) { + echo " \n"; + } + else { + echo " \n"; + } + //control icons + if (permission_exists('xml_cdr_details')) { + echo " \n"; + } + echo "\n"; + $c = ($c) ? 0 : 1; + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "
 ".$text['label-recording']."".$text['label-price']."".$text['label-status'].""; + if (permission_exists('xml_cdr_delete') && $result_count > 0) { + echo "".$v_link_label_delete.""; + } + echo "
\n"; + if ($theme_cdr_images_exist) { + if ($row['direction'] == 'inbound' || $row['direction'] == 'local') { + if ($row['answer_stamp'] != '' && $row['bridge_uuid'] != '') { $call_result = 'answered'; } + else if ($row['answer_stamp'] != '' && $row['bridge_uuid'] == '') { $call_result = 'voicemail'; } + else if ($row['answer_stamp'] == '' && $row['bridge_uuid'] == '' && $row['sip_hangup_disposition'] != 'send_refuse') { $call_result = 'cancelled'; } + else { $call_result = 'failed'; } + } + else if ($row['direction'] == 'outbound') { + if ($row['answer_stamp'] != '' && $row['bridge_uuid'] != '') { $call_result = 'answered'; } + else if ($row['answer_stamp'] == '' && $row['bridge_uuid'] != '') { $call_result = 'cancelled'; } + else { $call_result = 'failed'; } + } + if (strlen($row['direction']) > 0) { + $image_name = "icon_cdr_" . $row['direction'] . "_" . $call_result; + if($row['leg'] == 'b'){ + $image_name .= '_b'; + } + $image_name .= ".png"; + echo "\n"; + } + } + else { echo " "; } + echo ""; + echo $row['domain_name'].' '; + echo " ".$row['caller_id_name']."  ".$row[$field_name] ."".$tmp_start_epoch."".(($row['tta'] > 0) ? $row['tta']."s" : " ")."".gmdate("G:i:s", $seconds)."".number_format($price,6)." $billing_currency".number_format($row['pdd_ms']/1000,2)."s$value".$hangup_cause."".ucwords($call_result)."
"; + echo "
"; + echo "

"; + if ($result_count == $rows_per_page) { + echo $paging_controls; + } + echo "

"; + + // check or uncheck all checkboxes + if (sizeof($xml_ids) > 0) { + echo "\n"; + } + + //store last search/sort query parameters in session + $_SESSION['xml_cdr']['last_query'] = $_SERVER["QUERY_STRING"]; + +//show the footer + require_once "resources/footer.php"; + +?> diff --git a/app/xml_cdr/xml_cdr_export.php b/app/xml_cdr/xml_cdr_export.php index 099af9477c..9b7e361dcd 100644 --- a/app/xml_cdr/xml_cdr_export.php +++ b/app/xml_cdr/xml_cdr_export.php @@ -40,6 +40,9 @@ else { //additional includes $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; + if ($_REQUEST['archive_request'] == 'true') { + $archive_request = 'true'; + } require_once "xml_cdr_inc.php"; //get the format @@ -286,4 +289,4 @@ else { } -?> \ No newline at end of file +?> diff --git a/app/xml_cdr/xml_cdr_inc.php b/app/xml_cdr/xml_cdr_inc.php index 75fc5ac829..35d3ac88aa 100644 --- a/app/xml_cdr/xml_cdr_inc.php +++ b/app/xml_cdr/xml_cdr_inc.php @@ -422,9 +422,25 @@ } $sql= str_replace(" ", " ", $sql); $sql= str_replace("where and", "where", $sql); - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + //$prep_statement = $db->prepare(check_sql($sql)); + //$prep_statement->execute(); + //$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $database = new database; + if ($archive_request == 'true') { + if ($_SESSION['cdr']['archive_database']['boolean'] == 'true') { + $database->driver = $_SESSION['cdr']['archive_database_driver']['text']; + $database->host = $_SESSION['cdr']['archive_database_host']['text']; + $database->type = $_SESSION['cdr']['archive_database_type']['text']; + $database->port = $_SESSION['cdr']['archive_database_port']['text']; + $database->db_name = $_SESSION['cdr']['archive_database_name']['text']; + $database->username = $_SESSION['cdr']['archive_database_username']['text']; + $database->password = $_SESSION['cdr']['archive_database_password']['text']; + } + } + $database->select($sql); + $result = $database->result; + $result_count = count($result); + unset($database); $result_count = count($result); unset ($prep_statement, $sql);