Portions created by the Initial Developer are Copyright (C) 2018 - 2023 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //includes files require_once dirname(__DIR__, 2) . "/resources/require.php"; require_once "resources/check_auth.php"; require_once "resources/paging.php"; //check permissions if (permission_exists('call_recording_view')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //set additional variables $search = $_GET["search"] ?? ''; $show = $_GET["show"] ?? ''; //get the http post data if (!empty($_POST['call_recordings']) && is_array($_POST['call_recordings'])) { $action = $_POST['action']; $search = $_POST['search']; $call_recordings = $_POST['call_recordings']; } //process the http post data by action if (!empty($action) && is_array($call_recordings) && @sizeof($call_recordings) != 0) { switch ($action) { case 'delete': if (permission_exists('call_recording_delete')) { $obj = new call_recordings; $obj->delete($call_recordings); } break; } //redirect the user header('Location: call_recordings.php'.($search != '' ? '?search='.urlencode($search) : null)); exit; } //get order and order by $order_by = $_GET["order_by"] ?? ''; $order = $_GET["order"] ?? ''; //add the search string if (!empty($search)) { $search = strtolower($_GET["search"]); } //set the time zone if (!empty($_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(*) "; //$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 some of the paging values $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; $page = $_GET['page'] ?? ''; if (empty($page)) { $page = 0; $_GET['page'] = 0; } $offset = $rows_per_page * $page; //get the list $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, r.destination_number, "; $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 ($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 (!empty($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.destination_number) 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 ?? null, 'all'); unset($sql, $parameters); //count the results $result_count = is_array($call_recordings) ? sizeof($call_recordings) : 0; //limit the number of results if (!empty($_SESSION['cdr']['limit']['numeric']) && $_SESSION['cdr']['limit']['numeric'] > 0) { $num_rows = $_SESSION['cdr']['limit']['numeric']; } //prepare to page the results $param = "&search=".urlencode($search); if ($show == "all" && permission_exists('call_recording_all')) { $param .= "&show=all"; } list($paging_controls_mini, $rows_per_page) = paging($num_rows ?? null, $param, $rows_per_page, true, $result_count); //top list($paging_controls, $rows_per_page) = paging($num_rows ?? null, $param, $rows_per_page, false, $result_count); //bottom //create token $object = new token; $token = $object->create($_SERVER['PHP_SELF']); //include the header $document['title'] = $text['title-call_recordings']; require_once "resources/header.php"; //show the content echo "
\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');"]); } if (permission_exists('call_recording_delete') && $call_recordings) { 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 "\n"; echo "
\n"; echo "
\n"; echo "
\n"; if (permission_exists('call_recording_delete') && $call_recordings) { echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]); } echo $text['title_description-call_recordings']."\n"; echo "

\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $col_count = 8; if ($show == "all" && permission_exists('call_recording_all')) { $col_count++; } if (permission_exists('call_recording_delete')) { echo " \n"; $col_count++; } if ($show == "all" && permission_exists('call_recording_all')) { echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, $param, "class='shrink'"); } echo th_order_by('caller_id_name', $text['label-caller_id_name'], $order_by, $order, null, "class='hide-sm-dn shrink'"); echo th_order_by('caller_id_number', $text['label-caller_id_number'], $order_by, $order, null, "class='pct-10'"); echo th_order_by('caller_destination', $text['label-caller_destination'], $order_by, $order, null, "class='hide-sm-dn shrink'"); echo th_order_by('destination_number', $text['label-destination_number'], $order_by, $order, null, "class='hide-sm-dn shrink'"); echo th_order_by('call_recording_name', $text['label-call_recording_name'], $order_by, $order, null, "class='pct-40 hide-sm-dn'"); if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) { echo "\n"; $col_count++; } echo th_order_by('call_recording_length', $text['label-call_recording_length'], $order_by, $order, null, "class='right hide-sm-dn shrink'"); echo th_order_by('call_recording_date', $text['label-call_recording_date'], $order_by, $order, null, "class='center'"); echo th_order_by('call_direction', $text['label-call_direction'], $order_by, $order, null, "class='hide-sm-dn shrink'"); if (permission_exists('xml_cdr_details')) { echo " \n"; } echo "\n"; if (is_array($call_recordings) && @sizeof($call_recordings) != 0) { $x = 0; foreach ($call_recordings as $row) { //playback progress bar if (permission_exists('call_recording_play')) { echo "".(permission_exists('xml_cdr_details') ? "" : null)."\n"; echo "\n"; // dummy row to maintain alternating background color } if (permission_exists('call_recording_play')) { $list_row_url = "javascript:recording_play('".escape($row['call_recording_uuid'])."');"; } echo "\n"; if (permission_exists('call_recording_delete')) { echo " \n"; } if ($show == "all" && permission_exists('call_recording_all')) { echo " \n"; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) { echo " \n"; } echo " \n"; echo " \n"; echo " \n"; if (permission_exists('xml_cdr_details')) { echo " \n"; } echo "\n"; $x++; } unset($call_recordings); } echo "
\n"; echo " \n"; echo " ".$text['label-recording']." 
\n"; echo " \n"; echo " \n"; echo " ".escape($row['domain_name'])."".escape($row['caller_id_name'])."".escape($row['caller_id_number'])."".escape($row['caller_destination'])."".escape($row['destination_number'])."".escape($row['call_recording_name'])."".($row['call_recording_length'] <= 59 ? '0:' : null).escape(str_pad($row['call_recording_length'], 2, '0', STR_PAD_LEFT))."".escape($row['call_recording_date_formatted'])." ".escape($row['call_recording_time_formatted'])."".($row['call_direction'] != '' ? escape($text['label-'.$row['call_direction']]) : null)."\n"; echo button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'link'=>PROJECT_PATH.'/app/xml_cdr/xml_cdr_details.php?id='.urlencode($row['call_recording_uuid'])]); echo "
\n"; echo "
\n"; echo "
".$paging_controls."
\n"; echo "\n"; echo "
\n"; //include the footer require_once "resources/footer.php"; ?>