From afa57b26a485192e3905f364bc6917a32850d48f Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Sat, 3 Dec 2022 18:46:58 -0700 Subject: [PATCH] Update call recordings with more details - Use the view_call_recordings view - Add caller id name, number and destination - Add more to the search - Improve responsiveness - Remove count to improve speed --- app/call_recordings/call_recordings.php | 118 ++++++++++++++++-------- 1 file changed, 80 insertions(+), 38 deletions(-) diff --git a/app/call_recordings/call_recordings.php b/app/call_recordings/call_recordings.php index 39bd5c2e3c..66078973df 100644 --- a/app/call_recordings/call_recordings.php +++ b/app/call_recordings/call_recordings.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2018 - 2019 + Portions created by the Initial Developer are Copyright (C) 2018 - 2022 the Initial Developer. All Rights Reserved. Contributor(s): @@ -76,25 +76,34 @@ //add the search string if (isset($_GET["search"])) { $search = strtolower($_GET["search"]); - $sql_search = "and ("; - $sql_search .= " lower(call_recording_name) like :search "; - $sql_search .= " or lower(call_recording_path) like :search "; - $sql_search .= ") "; - $parameters['search'] = '%'.$search.'%'; } +//set the time zone + if (isset($_SESSION['domain']['time_zone']['name'])) { + $time_zone = $_SESSION['domain']['time_zone']['name']; + } + else { + $time_zone = date_default_timezone_get(); + } + $parameters['time_zone'] = $time_zone; + //get the count - $sql = "select count(call_recording_uuid) from v_call_recordings "; - $sql .= "where true "; - if ($_GET['show'] != "all" || !permission_exists('call_recording_all')) { - $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - } - if (isset($sql_search)) { - $sql .= $sql_search; - } - $database = new database; - $num_rows = $database->select($sql, $parameters, 'column'); + //$sql = "select count(*) "; + //$sql .= "from view_call_recordings "; + //$sql .= "where true "; + //if ($_GET['show'] != "all" || !permission_exists('call_recording_all')) { + // $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; + // $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + //} + //if (isset($search)) { + // $sql .= "and ("; + // $sql .= " lower(call_recording_name) like :search "; + // $sql .= " or lower(call_recording_path) like :search "; + // $sql .= ") "; + // $parameters['search'] = '%'.$search.'%'; + //} + //$database = new database; + //$num_rows = $database->select($sql, $parameters, 'column'); //prepare to page the results $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; @@ -109,8 +118,31 @@ $offset = $rows_per_page * $page; //get the list - $sql = str_replace('count(call_recording_uuid)', '*', $sql); - $sql .= order_by($order_by, $order, 'call_recording_date', 'desc'); + $sql = "select r.domain_uuid, d.domain_name, r.call_recording_uuid, r.call_direction, "; + $sql .= "r.call_recording_name, r.call_recording_path, r.call_recording_length, "; + $sql .= "r.caller_id_name, r.caller_id_number, r.caller_destination, "; + $sql .= "to_char(timezone(:time_zone, r.call_recording_date), 'DD Mon YYYY') as call_recording_date_formatted, \n"; + $sql .= "to_char(timezone(:time_zone, r.call_recording_date), 'HH12:MI:SS am') as call_recording_time_formatted \n"; + $sql .= "from view_call_recordings as r, v_domains as d "; + //$sql .= "from v_call_recordings as r, v_domains as d "; + $sql .= "where true "; + if ($_GET['show'] != "all" || !permission_exists('call_recording_all')) { + $sql .= "and (r.domain_uuid = :domain_uuid or r.domain_uuid is null) "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + } + $sql .= "and r.domain_uuid = d.domain_uuid "; + if (isset($search)) { + $sql .= "and ("; + $sql .= " lower(r.call_direction) like :search "; + $sql .= " or lower(r.caller_id_name) like :search "; + $sql .= " or lower(r.caller_id_number) like :search "; + $sql .= " or lower(r.caller_destination) like :search "; + $sql .= " or lower(r.call_recording_name) like :search "; + $sql .= " or lower(r.call_recording_path) like :search "; + $sql .= ") "; + $parameters['search'] = '%'.$search.'%'; + } + $sql .= order_by($order_by, $order, 'r.call_recording_date', 'desc'); $sql .= limit_offset($rows_per_page, $offset); $database = new database; $call_recordings = $database->select($sql, $parameters, 'all'); @@ -126,7 +158,7 @@ //show the content echo "
\n"; - echo "
".$text['title-call_recordings']." (".$num_rows.")
\n"; + echo "
".$text['title-call_recordings']."
\n"; echo "
\n"; if (permission_exists('call_recording_download_add') && $call_recordings) { echo button::create(['type'=>'button','label'=>$text['button-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'collapse'=>'hide-xs','onclick'=>"list_action_set('download'); list_form_submit('form_list');"]); @@ -135,9 +167,17 @@ echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none; margin-left: 15px;','collapse'=>'hide-xs','onclick'=>"modal_open('modal-delete','btn_delete');"]); } echo "