diff --git a/app/xml_cdr/app_languages.php b/app/xml_cdr/app_languages.php index 3a04c52f8c..2432becda1 100644 --- a/app/xml_cdr/app_languages.php +++ b/app/xml_cdr/app_languages.php @@ -60,6 +60,26 @@ $text['title']['ru-ru'] = "Детализация Вызовов"; $text['title']['sv-se'] = "Detaljerad Samtalsinformation"; $text['title']['uk-ua'] = "Параметри облікового запису"; +$text['title-call_detail_records']['en-us'] = "Call Detail Records"; +$text['title-call_detail_records']['ar-eg'] = ""; +$text['title-call_detail_records']['de-at'] = "Meine Gespräche"; //copied from de-de +$text['title-call_detail_records']['de-ch'] = "Meine Gespräche"; //copied from de-de +$text['title-call_detail_records']['de-de'] = "Meine Gespräche"; +$text['title-call_detail_records']['es-cl'] = "Registro de Detalle de Llamadas"; +$text['title-call_detail_records']['es-mx'] = "Registro de Detalle de Llamadas"; //copied from es-cl +$text['title-call_detail_records']['fr-ca'] = "Historique détaillé des appels"; //copied from fr-fr +$text['title-call_detail_records']['fr-fr'] = "Historique détaillé des appels"; +$text['title-call_detail_records']['he-il'] = ""; +$text['title-call_detail_records']['it-it'] = "Cartellini di Chiamata"; +$text['title-call_detail_records']['nl-nl'] = ""; +$text['title-call_detail_records']['pl-pl'] = "Wykaz rozmów"; +$text['title-call_detail_records']['pt-br'] = "Configurações da Conta"; +$text['title-call_detail_records']['pt-pt'] = "Registo de Chamadas"; +$text['title-call_detail_records']['ro-ro'] = ""; +$text['title-call_detail_records']['ru-ru'] = "Детализация Вызовов"; +$text['title-call_detail_records']['sv-se'] = "Detaljerad Samtalsinformation"; +$text['title-call_detail_records']['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 @@ -2340,6 +2360,26 @@ $text['label-seconds']['ru-ru'] = "Sec"; $text['label-seconds']['sv-se'] = "Sec"; $text['label-seconds']['uk-ua'] = "Sec"; +$text['label-format']['en-us'] = "Format"; +$text['label-format']['ar-eg'] = "Format"; +$text['label-format']['de-at'] = "Format"; +$text['label-format']['de-ch'] = "Format"; +$text['label-format']['de-de'] = "Format"; +$text['label-format']['es-cl'] = "Format"; +$text['label-format']['es-mx'] = "Format"; +$text['label-format']['fr-ca'] = "Format"; +$text['label-format']['fr-fr'] = "Format"; +$text['label-format']['he-il'] = "Format"; +$text['label-format']['it-it'] = "Format"; +$text['label-format']['nl-nl'] = "Format"; +$text['label-format']['pl-pl'] = "Format"; +$text['label-format']['pt-br'] = "Format"; +$text['label-format']['pt-pt'] = "Format"; +$text['label-format']['ro-ro'] = "Format"; +$text['label-format']['ru-ru'] = "Format"; +$text['label-format']['sv-se'] = "Format"; +$text['label-format']['uk-ua'] = "Format"; + $text['description_search']['en-us'] = "Note: Destination and Caller ID (CID) Name fields support the use of an asterisk ('*') as a wildcard character."; $text['description_search']['ar-eg'] = ""; $text['description_search']['de-at'] = "Info: Ziel und Anruferkennung (CID) Namesfelder unterstützen die Verwendung von Stern ('*') als Wildcard Zeichen."; //copied from de-de diff --git a/app/xml_cdr/resources/classes/xml_cdr.php b/app/xml_cdr/resources/classes/xml_cdr.php index 74e0912a91..2adae85fe1 100644 --- a/app/xml_cdr/resources/classes/xml_cdr.php +++ b/app/xml_cdr/resources/classes/xml_cdr.php @@ -50,6 +50,16 @@ if (!class_exists('xml_cdr')) { public $include_internal; public $extensions; + /** + * delete method + */ + private $app_name; + private $app_uuid; + private $permission_prefix; + private $list_page; + private $table; + private $uuid_prefix; + /** * Called when the object is created */ @@ -61,6 +71,14 @@ if (!class_exists('xml_cdr')) { $database->connect(); $this->db = $database->db; } + + //assign private variables (for delete method) + $this->app_name = 'xml_cdr'; + $this->app_uuid = '4a085c51-7635-ff03-f67b-86e834422848'; + $this->permission_prefix = 'xml_cdr_'; + $this->list_page = 'xml_cdr.php'; + $this->table = 'xml_cdr'; + $this->uuid_prefix = 'xml_cdr_'; } /** @@ -1104,6 +1122,82 @@ if (!class_exists('xml_cdr')) { } } //end download method + /** + * delete records + */ + public function delete($records) { + if (permission_exists($this->permission_prefix.'delete')) { + + //add multi-lingual support + $language = new text; + $text = $language->get(); + + //validate the token + $token = new token; + if (!$token->validate($_SERVER['PHP_SELF'])) { + message::add($text['message-invalid_token'],'negative'); + header('Location: '.$this->list_page); + exit; + } + + //delete multiple records + if (is_array($records) && @sizeof($records) != 0) { + $records_deleted = 0; + + //loop through records + foreach($records as $x => $record) { + if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { + + //get the call recordings + $sql = "select * from v_call_recordings "; + $sql .= "where call_recording_uuid = :xml_cdr_uuid "; + $parameters['xml_cdr_uuid'] = $record['uuid']; + $database = new database; + $row = $database->select($sql, $parameters, 'row'); + unset($sql, $parameters); + + //delete the call recording (file) + $call_recording_path = realpath($row['call_recording_path']); + $call_recording_name = $row['call_recording_name']; + if (file_exists($call_recording_path.'/'.$call_recording_name)) { + @unlink($call_recording_path.'/'.$call_recording_name); + } + + //build the delete array + $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid']; + $array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid']; + $array['call_recordings'][$x]['call_recording_uuid'] = $record['uuid']; + + //increment counter + $records_deleted++; + } + } + + //delete the checked rows + if (is_array($array) && @sizeof($array) != 0) { + + //grant temporary permissions + $p = new permissions; + $p->add('call_recording_delete', 'temp'); + + //execute delete + $database = new database; + $database->app_name = $this->app_name; + $database->app_uuid = $this->app_uuid; + $database->delete($array); + unset($array); + + //revoke temporary permissions + $p->delete('call_recording_delete', 'temp'); + + //set message + message::add($text['message-delete'].": ".$records_deleted); + } + unset($records); + } + } + } + } //end the class } /* diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php index aa5e90a559..7e123f56a2 100644 --- a/app/xml_cdr/xml_cdr.php +++ b/app/xml_cdr/xml_cdr.php @@ -29,6 +29,7 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; + require_once "resources/paging.php"; //check permisions if (permission_exists('xml_cdr_view')) { @@ -43,9 +44,30 @@ $language = new text; $text = $language->get(); +//get posted data + if (is_array($_POST['xml_cdrs'])) { + $action = $_POST['action']; + $xml_cdrs = $_POST['xml_cdrs']; + } + +//delete the cdr + if (permission_exists('xml_cdr_delete')) { + if ($action == 'delete' && is_array($xml_cdrs) && @sizeof($xml_cdrs) != 0) { + //delete + $obj = new xml_cdr; + $obj->delete($xml_cdrs); + //redirect + header('Location: xml_cdr.php'); + exit; + } + } + +//create token + $object = new token; + $token = $object->create($_SERVER['PHP_SELF']); + //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; @@ -72,16 +94,15 @@ echo " function toggle_select(select_id) {"; echo " $('#'+select_id).fadeToggle(fade_speed, function() {"; echo " document.getElementById(select_id).selectedIndex = 0;"; + echo " document.getElementById(select_id).focus();"; echo " });"; echo " }"; echo ""; //page title and description - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
".$text['title']."


\n"; - echo "
\n"; + echo "
\n"; + echo " ".$text['title-call_detail_records']."\n"; + echo " \n"; echo " \n"; echo " \n"; echo " \n"; @@ -124,42 +145,36 @@ echo " \n"; echo " \n"; } - if (permission_exists('xml_cdr_all') && $_REQUEST['show'] == 'all') { - echo " \n"; + if (permission_exists('bridge_delete')) { + echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]); } - echo " \n"; - echo " \n"; - echo " "; - echo " \n"; - echo " \n"; - echo "
\n"; if (permission_exists('xml_cdr_all')) { - if ($_REQUEST['show'] != 'alll') { - echo " \n"; + if ($_REQUEST['show'] == 'all') { + echo " \n"; + } + else { + echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?show=all']); } } if ($_GET['call_result'] != 'missed') { - echo " \n"; + echo button::create(['type'=>'button','label'=>$text['button-missed'],'icon'=>'phone-slash','link'=>'?call_result=missed']); } - echo " \n"; + echo button::create(['type'=>'button','label'=>$text['button-statistics'],'icon'=>'chart-area','link'=>'xml_cdr_statistics.php']); if (permission_exists('xml_cdr_archive')) { - if ($_REQUEST['show'] == 'all') { - $query_string = "show=all"; - } - echo " \n"; + echo button::create(['type'=>'button','label'=>$text['button-archive'],'icon'=>'archive','link'=>'xml_cdr_archive.php'.($_REQUEST['show'] == 'all' ? '?show=all' : null)]); + } + echo button::create(['type'=>'button','label'=>$text['button-export'],'icon'=>'file-export','onclick'=>"toggle_select('export_format'); this.blur();"]); + echo ""; + echo button::create(['type'=>'button','label'=>$text['button-refresh'],'icon'=>'sync-alt','link'=>'xml_cdr.php']); + if ($paging_controls_mini != '') { + echo "".$paging_controls_mini.""; } - echo " \n"; - echo " \n"; - echo " \n"; - echo " ".$paging_controls_mini."
\n"; echo " \n"; - echo "
\n"; + echo "\n"; echo $text['description']." \n"; echo $text['description2']." \n"; @@ -167,7 +182,6 @@ echo $text['description-4']." \n"; echo "

\n"; - //basic search of call detail records if (permission_exists('xml_cdr_search')) { echo "
\n"; @@ -243,7 +257,7 @@ echo "
\n"; echo " ".$text['label-caller_id']."\n"; echo "
\n"; - echo "
\n"; + echo "
\n"; echo " \n"; echo " \n"; echo "
\n"; @@ -254,7 +268,7 @@ echo "
\n"; echo " ".$text['label-start_range']."\n"; echo "
\n"; - echo "
\n"; + echo "
\n"; echo " \n"; echo " \n"; echo "
\n"; @@ -265,7 +279,7 @@ echo "
\n"; echo " ".$text['label-duration']." (".$text['label-seconds'].")\n"; echo "
\n"; - echo "
\n"; + echo "
\n"; echo " \n"; echo " \n"; echo "
\n"; @@ -296,7 +310,7 @@ echo "
\n"; echo " ".$text['label-tta']." (".$text['label-seconds'].")\n"; echo "
\n"; - echo "
\n"; + echo "
\n"; echo " \n"; echo " \n"; echo "
\n"; @@ -371,7 +385,7 @@ echo "
\n"; echo " ".$text['label-order']."\n"; echo "
\n"; - echo "
\n"; + echo "
\n"; echo " \n"; } if (permission_exists('xml_cdr_search_advanced')) { - if ($_REQUEST['show'] == 'all') { - $query_string = "show=all"; - } - echo " \n"; + echo button::create(['type'=>'button','label'=>$text['button-advanced_search'],'icon'=>'bolt','link'=>"xml_cdr_search.php".($_REQUEST['show'] == 'all' ? '?show=all' : null),'style'=>'margin-right: 15px;']); } - echo " \n"; - echo " \n"; + echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button', 'link'=>'xml_cdr.php']); + echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','name'=>'submit']); echo "
\n"; echo "
".$text['description_search']."
\n"; @@ -461,11 +473,15 @@ //show the results $col_count = 0; - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo "\n"; if (permission_exists('xml_cdr_delete') && $result_count > 0) { - echo ""; + echo " \n"; $col_count++; } @@ -483,7 +499,7 @@ $col_count++; } if (permission_exists('xml_cdr_caller_id_name')) { - echo "\n"; + echo "\n"; $col_count++; } if (permission_exists('xml_cdr_caller_id_number')) { @@ -491,7 +507,7 @@ $col_count++; } if (permission_exists('xml_cdr_caller_destination')) { - echo "\n"; + echo "\n"; $col_count++; } if (permission_exists('xml_cdr_destination')) { @@ -499,7 +515,7 @@ $col_count++; } if (permission_exists('xml_cdr_recording') && (permission_exists('recording_play') || permission_exists('recording_download'))) { - echo "\n"; + echo "\n"; $col_count++; } if (permission_exists('xml_cdr_custom_fields')) { @@ -510,34 +526,34 @@ $field_label = ucwords(str_replace("_", " ", $field_name)); $field_label = str_replace("Sip", "SIP", $field_label); if ($field_name != "destination_number") { - echo "\n"; + echo "\n"; $col_count++; } } } } if (permission_exists('xml_cdr_start')) { - echo "\n"; + echo "\n"; $col_count++; } if (permission_exists('xml_cdr_tta')) { - echo "\n"; + echo "\n"; $col_count++; } if (permission_exists('xml_cdr_duration')) { - echo "\n"; + echo "\n"; $col_count++; } if (permission_exists('xml_cdr_pdd')) { - echo "\n"; + echo "\n"; $col_count++; } if (permission_exists('xml_cdr_mos')) { - echo "\n"; + echo "\n"; $col_count++; } if (permission_exists('xml_cdr_hangup_cause')) { - echo "\n"; + echo "\n"; $col_count++; } else { @@ -545,16 +561,13 @@ $col_count++; } if (permission_exists('xml_cdr_details')) { - echo "\n"; + echo "\n"; } echo "\n"; //show results if (is_array($result)) { + //determine if theme images exist $theme_image_path = $_SERVER["DOCUMENT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/images/"; $theme_cdr_images_exist = ( @@ -572,12 +585,13 @@ ) ? true : false; //loop through the results + $x = 0; 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']); + $tmp_start_epoch = ($_SESSION['domain']['time_format']['text'] == '12h') ? escape(date("j M Y", $row['start_epoch']))." ".escape(date("g:i:sa", $row['start_epoch']))."" : escape(date("j M Y", $row['start_epoch']))." ".escape(date("H:i:s", $row['start_epoch'])).""; //get the hangup cause $hangup_cause = $row['hangup_cause']; @@ -606,27 +620,23 @@ //recording playback if (permission_exists('recording_play') && $record_path != '') { - $content .= "\n"; + $content .= "\n"; + $content .= "\n"; // dummy table row to maintain alternating background color } - if (permission_exists('xml_cdr_details')) { - $tr_link = "href='xml_cdr_details.php?id=".urlencode($row['xml_cdr_uuid']).(($_REQUEST['show']) ? "&show=all" : null)."'"; + $list_row_url = "xml_cdr_details.php?id=".urlencode($row['xml_cdr_uuid']).($_REQUEST['show'] ? "&show=all" : null); } - else { - $tr_link = null; - } - $content .= "\n"; + $content .= "\n"; if (permission_exists('xml_cdr_delete')) { - $content .= " "; - $xml_ids[] = 'checkbox_'.$row['xml_cdr_uuid']; + $content .= " \n"; } //determine call result and appropriate icon if (permission_exists('xml_cdr_direction')) { - $content .= "\n"; } //domain name if (permission_exists('xml_cdr_all') && $_REQUEST['show'] == "all") { - $content .= " \n"; } //caller id name if (permission_exists('xml_cdr_caller_id_name')) { - $content .= " \n"; + $content .= " \n"; } //source if (permission_exists('xml_cdr_caller_id_number')) { - $content .= " \n"; + $content .= "\n"; } else { - $content .= " \n"; + $content .= " \n"; } } //custom cdr fields @@ -769,26 +775,26 @@ $array = explode(",", $field); $field_name = $array[count($array) - 1]; if ($field_name != "destination_number") { - $content .= " \n"; + $content .= " \n"; } } } } //start if (permission_exists('xml_cdr_start')) { - $content .= " \n"; + $content .= " \n"; } //tta (time to answer) if (permission_exists('xml_cdr_tta')) { - $content .= " \n"; + $content .= " \n"; } //duration if (permission_exists('xml_cdr_duration')) { - $content .= " \n"; + $content .= " \n"; } //pdd (post dial delay) if (permission_exists("xml_cdr_pdd")) { - $content .= " \n"; + $content .= " \n"; } //mos (mean opinion score) if (permission_exists("xml_cdr_mos")) { @@ -796,24 +802,19 @@ $title = " title='".$text['label-mos_score-'.round($row['rtp_audio_in_mos'])]."'"; $value = $row['rtp_audio_in_mos']; } - $content .= " \n"; + $content .= " \n"; } //hangup cause/call result if (permission_exists('xml_cdr_hangup_cause')) { - $content .= " \n"; + $content .= " \n"; } else { - $content .= " \n"; + $content .= " \n"; } - //control icons + //action icon if (permission_exists('xml_cdr_details')) { - $content .= " \n"; } $content .= "\n"; @@ -827,30 +828,18 @@ } unset($content); - //toggle the color - $c = $c ? 0 : 1; - } //foreach - } //if + $x++; + } + } unset($sql, $result, $row_count); -//paging controls - echo "\n"; - echo "
\n"; + echo " \n"; + echo " ".$text['label-caller_id_name']."".$text['label-caller_id_name']."".$text['label-caller_destination']."".$text['label-caller_destination']."".$text['label-recording']."".$text['label-recording']."".$field_label."".$field_label."".$text['label-start']."".$text['label-start']."".$text['label-tta']."".$text['label-tta']."".$text['label-duration']."".$text['label-duration']."".$text['label-pdd']."".$text['label-pdd']."".$text['label-mos']."".$text['label-mos']."".$text['label-hangup_cause']."".$text['label-hangup_cause'].""; - if (permission_exists('xml_cdr_delete') && $result_count > 0) { - echo "".$v_link_label_delete.""; - } - echo " 
\n"; + $content .= " \n"; + $content .= " \n"; + $content .= " \n"; + $content .= "\n"; if ($theme_cdr_images_exist) { if ($row['direction'] == 'inbound' || $row['direction'] == 'local') { if ($row['answer_stamp'] != '' && $row['bridge_uuid'] != '') { $call_result = 'answered'; } @@ -653,23 +663,23 @@ } //extension if (permission_exists('xml_cdr_extension')) { - $content .= " "; + $content .= " "; $content .= $row['extension'].' '; $content .= " "; + $content .= " "; $content .= $row['domain_name'].' '; $content .= " ".escape(substr($row['caller_id_name'], 0, 20))." ".escape($row['caller_id_name'])."   ".escape($row[$field_name])."".escape($row[$field_name])."".escape($tmp_start_epoch)."".$tmp_start_epoch."".(($row['tta'] > 0) ? $row['tta']."s" : " ")."".(($row['tta'] > 0) ? $row['tta']."s" : " ")."".gmdate("G:i:s", $seconds)."".gmdate("G:i:s", $seconds)."".number_format(escape($row['pdd_ms'])/1000,2)."s".number_format(escape($row['pdd_ms'])/1000,2)."s$value".$value."".escape($hangup_cause)."".escape($hangup_cause)."".ucwords(escape($call_result))."".ucwords(escape($call_result)).""; + $content .= button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'link'=>$list_row_url]); $content .= "
"; - echo ""; - echo "

"; - echo $paging_controls; - echo "

"; + echo "\n"; + echo "
\n"; + echo "
".$paging_controls."
\n"; -// check or uncheck all checkboxes - if (is_array($xml_ids) && sizeof($xml_ids) > 0) { - echo "\n"; - } + echo "\n"; + + echo "\n"; //store last search/sort query parameters in session $_SESSION['xml_cdr']['last_query'] = $_SERVER["QUERY_STRING"]; @@ -858,4 +847,4 @@ //show the footer require_once "resources/footer.php"; -?> +?> \ 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 81c550f712..d152700ebd 100644 --- a/app/xml_cdr/xml_cdr_inc.php +++ b/app/xml_cdr/xml_cdr_inc.php @@ -511,7 +511,6 @@ //end where if (strlen($order_by) > 0) { $sql .= order_by($order_by, $order); - //$sql .= " order by $order_by $order "; } if ($_REQUEST['export_format'] != "csv" && $_REQUEST['export_format'] != "pdf") { if ($rows_per_page == 0) { @@ -542,12 +541,7 @@ unset($database, $sql, $parameters); //return the paging - list($paging_controls_mini, $rows_per_page, $offset) = paging($num_rows, $param, $rows_per_page, true, $result_count); //top - list($paging_controls, $rows_per_page, $offset) = paging($num_rows, $param, $rows_per_page, false, $result_count); //bottom + list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true, $result_count); //top + list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page, false, $result_count); //bottom -//set the row style - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; - -?> +?> \ No newline at end of file