diff --git a/app/call_recordings/call_recordings.php b/app/call_recordings/call_recordings.php index e5c6419b06..137f350144 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 - 2019 the Initial Developer. All Rights Reserved. Contributor(s): @@ -27,9 +27,9 @@ //includes require_once "root.php"; require_once "resources/require.php"; + require_once "resources/check_auth.php"; //check permissions - require_once "resources/check_auth.php"; if (permission_exists('call_recording_view')) { //access granted } @@ -42,258 +42,166 @@ $language = new text; $text = $language->get(); -//get the action - if (strlen($_REQUEST["search"]) == 0 && is_array($_POST["call_recordings"])) { - $call_recordings = $_POST["call_recordings"]; - foreach($call_recordings as $row) { - if ($row['action'] === 'download') { - $action = 'download'; +//get the http post data + if (is_array($_POST['call_recordings'])) { + $action = $_POST['action']; + $search = $_POST['search']; + $call_recordings = $_POST['call_recordings']; + } + +//process the http post data by action + if ($action != '' && is_array($call_recordings) && @sizeof($call_recordings) != 0) { + switch ($action) { + case 'copy': + if (permission_exists('call_recording_add')) { + $obj = new call_recordings; + $obj->copy($call_recordings); + } break; - } - if ($row['action'] === 'delete') { - $action = 'delete'; + case 'toggle': + if (permission_exists('call_recording_edit')) { + $obj = new call_recordings; + $obj->toggle($call_recordings); + } + break; + case 'delete': + if (permission_exists('call_recording_delete')) { + $obj = new call_recordings; + $obj->delete($call_recordings); + } break; - } } + + header('Location: call_recordings.php'.($search != '' ? '?search='.urlencode($search) : null)); + exit; } -//download recordings - if (permission_exists('call_recording_download_add')) { - if ($action == "download") { - //download - $obj = new call_recording_downloads; - $obj->save($call_recordings); - //direct the user to the downloads - header("Location: ".PROJECT_PATH."/app/call_recording_downloads/call_recording_downloads.php"); - } - } +//get order and order by + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; -//delete the recordings - if (permission_exists('call_recording_delete')) { - if ($action === "delete") { - //set the array - $call_recordings = $_POST["call_recordings"]; - //download - $obj = new call_recordings; - $obj->delete($call_recordings); - //delete message - message::add($text['message-delete']); - //redirect - header('Location: call_recordings.php'); - exit; - } - } - -//additional includes - require_once "resources/header.php"; - require_once "resources/paging.php"; - -//get variables used to control the order - $order_by = $_REQUEST["order_by"] != '' ? $_REQUEST["order_by"] : 'call_recording_date'; - $order = $_REQUEST["order"] != '' ? $_REQUEST["order"] : 'desc'; - - //add the search term - $search = strtolower($_REQUEST["search"]); - if (strlen($search) > 0) { - $sql_search = "and ("; - $sql_search .= "lower(call_recording_name) like :search "; - $sql_search .= "or lower(call_recording_path) like :search "; - $sql_search .= "or cast(call_recording_date as text) like :search "; - $sql_search .= "or lower(call_direction) like :search "; - $sql_search .= "or lower(call_recording_description) like :search "; +//add the search string + if (isset($_GET["search"])) { + $search = strtolower($_GET["search"]); + $sql_search = " ("; + $sql_search .= " lower(call_recording_name) like :search "; + $sql_search .= " or lower(call_recording_path) like :search "; + $sql_search .= " or lower(call_recording_description) like :search "; $sql_search .= ") "; $parameters['search'] = '%'.$search.'%'; } -//prepare to page the results +//get the count $sql = "select count(call_recording_uuid) from v_call_recordings "; - $sql .= "where domain_uuid = :domain_uuid "; - $sql .= $sql_search; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + if (isset($sql_search)) { + $sql .= "where ".$sql_search; + } $database = new database; $num_rows = $database->select($sql, $parameters, 'column'); - unset($sql); - -//prepare to page the results - $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; - $param = ""; - if (isset($_GET['page'])) { - $page = $_REQUEST['page']; - if (strlen($page) == 0) { $page = 0; $_REQUEST['page'] = 0; } - list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); - $offset = $rows_per_page * $page; - } //get the list - $sql = "select * from v_call_recordings "; - $sql .= "where domain_uuid = :domain_uuid "; - $sql .= $sql_search; - $sql .= order_by($order_by, $order); + $sql = str_replace('count(call_recording_uuid)', '*', $sql); + $sql .= order_by($order_by, $order, 'call_recording_name', 'asc'); $sql .= limit_offset($rows_per_page, $offset); $database = new database; - $result = $database->select($sql, $parameters, 'all'); + $call_recordings = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); -//alternate the row style - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; +//create token + $object = new token; + $token = $object->create($_SERVER['PHP_SELF']); -//define the checkbox_toggle function - echo "\n"; +//include the header + require_once "resources/header.php"; //show the content - echo "
\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
".$text['title-call_recordings']." (".$num_rows.")\n"; - if (permission_exists('call_recording_download_add')) { - echo " \n"; - echo "       "; + echo "
\n"; + echo "
".$text['title-call_recordings']." (".$num_rows.")
\n"; + echo "
\n"; + if (permission_exists('call_recording_add')) { + echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'link'=>'call_recording_edit.php']); } - echo " \n"; - echo " \n"; - echo "
\n"; - echo " ".$text['title_description-call_recording']."

\n"; - echo "
\n"; + if (permission_exists('call_recording_delete') && $call_recordings) { + 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 ""; + echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]); + echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'call_recordings.php','style'=>($search == '' ? 'display: none;' : null)]); + if ($paging_controls_mini != '') { + echo "".$paging_controls_mini."\n"; + } + echo "
\n"; + echo " \n"; + echo "
\n"; + echo "\n"; - //echo "\n"; - echo "\n"; + echo $text['description-call_recordings']."\n"; + echo "

\n"; - echo "\n"; - echo "\n"; - echo " \n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; - echo " \n"; - echo "
\n"; + echo "\n"; + if (permission_exists('call_recording_add') || permission_exists('call_recording_edit') || permission_exists('call_recording_delete')) { + echo " \n"; + } echo th_order_by('call_recording_name', $text['label-call_recording_name'], $order_by, $order); - echo "\n"; - //echo th_order_by('call_recording_path', $text['label-play'], $order_by, $order); echo th_order_by('call_recording_length', $text['label-call_recording_length'], $order_by, $order); echo th_order_by('call_recording_date', $text['label-call_recording_date'], $order_by, $order); echo th_order_by('call_direction', $text['label-call_direction'], $order_by, $order); - echo th_order_by('call_recording_description', $text['label-call_recording_description'], $order_by, $order); - //echo th_order_by('call_recording_base64', $text['label-call_recording_base64'], $order_by, $order); - echo " \n"; + if (permission_exists('call_recording_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + echo " \n"; } - else { - echo " \n"; - } - echo " \n"; - echo "\n"; + echo "\n"; - if (is_array($result)) { + if (is_array($call_recordings) && @sizeof($call_recordings) != 0) { $x = 0; - foreach($result as $row) { - //if (permission_exists('call_recording_play') && $recording_file_path != '') { - // echo "\n"; - //} + foreach ($call_recordings as $row) { if (permission_exists('call_recording_edit')) { - $tr_link = "href='call_recording_edit.php?id=".$row['call_recording_uuid']."'"; + $list_row_url = "call_recording_edit.php?id=".urlencode($row['call_recording_uuid']); } - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - //echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - //echo " \n"; - echo " \n"; + if (permission_exists('call_recording_add') || permission_exists('call_recording_edit') || permission_exists('call_recording_delete')) { + echo " \n"; } + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + if (permission_exists('call_recording_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { + echo " \n"; + } echo "\n"; $x++; - if ($c==0) { $c=1; } else { $c=0; } - } //end foreach - unset($result); - } //end if results + } + unset($call_recordings); + } - echo "\n"; - echo "\n"; - echo "\n"; - echo "
\n"; + echo " \n"; + echo " ".$text['label-recording'].""; - if (permission_exists('call_recording_add')) { - echo " $v_link_label_add"; + echo " ".$text['label-call_recording_description']." 
".escape($row['call_recording_name'])." \n"; - //echo " ".$text['label-download']." ".$v_link_label_download."\n"; - //echo " ".($row['call_recording_length'] <= 59 ? '0:' : null).escape($row['call_recording_length'])." ".escape($row['call_recording_date'])." ".($row['call_direction'] != '' ? escape($text['label-'.$row['call_direction']]) : null)." ".escape($row['call_recording_description'])." ".escape($row['call_recording_base64'])." "; - if (permission_exists('xml_cdr_details')) { - echo " $v_link_label_view"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; if (permission_exists('call_recording_edit')) { - echo "\n"; + else { + echo " ".escape($row['call_recording_name']); } echo " ".escape($row['call_recording_length'])."".escape($row['call_recording_date'])."".escape($row['call_direction'])."".escape($row['call_recording_description'])."\n"; + echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]); + echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
  "; - if (permission_exists('call_recording_add')) { - echo "$v_link_label_add"; - } - else { - echo " "; - } - echo "
\n"; - echo "
"; + echo "\n"; + echo "
\n"; + echo "
".$paging_controls."
\n"; + echo "\n"; echo "\n"; - if (strlen($paging_controls) > 0) { - echo "
"; - echo $paging_controls."\n"; - } - - echo "

"; - //include the footer require_once "resources/footer.php";