fusionpbx/app/call_recordings/call_recordings.php

226 lines
10 KiB
PHP
Raw Normal View History

2017-09-14 20:08:16 +02:00
<?php
2017-09-14 20:32:18 +02:00
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
2019-12-19 17:26:40 +01:00
Portions created by the Initial Developer are Copyright (C) 2018 - 2019
2017-09-14 20:32:18 +02:00
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
2017-09-14 20:08:16 +02:00
//includes
require_once "root.php";
require_once "resources/require.php";
2019-12-19 17:26:40 +01:00
require_once "resources/check_auth.php";
2017-09-14 20:08:16 +02:00
//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();
2019-12-19 17:26:40 +01:00
//get the http post data
if (is_array($_POST['call_recordings'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$call_recordings = $_POST['call_recordings'];
2017-09-30 08:16:26 +02:00
}
2017-09-14 20:08:16 +02:00
2019-12-19 17:26:40 +01:00
//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;
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;
2017-09-30 08:16:26 +02:00
}
2017-09-14 20:08:16 +02:00
2019-12-19 17:26:40 +01:00
header('Location: call_recordings.php'.($search != '' ? '?search='.urlencode($search) : null));
exit;
2017-09-14 20:08:16 +02:00
}
2019-12-19 17:26:40 +01:00
//get order and order by
$order_by = $_GET["order_by"];
$order = $_GET["order"];
//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 ";
2017-09-30 08:16:26 +02:00
$sql_search .= ") ";
2019-07-04 17:01:28 +02:00
$parameters['search'] = '%'.$search.'%';
2017-09-30 08:16:26 +02:00
}
2019-12-19 17:26:40 +01:00
//get the count
2019-07-04 17:01:28 +02:00
$sql = "select count(call_recording_uuid) from v_call_recordings ";
2019-12-19 17:26:40 +01:00
if (isset($sql_search)) {
$sql .= "where ".$sql_search;
}
2019-05-30 05:00:05 +02:00
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
2017-09-14 20:08:16 +02:00
//get the list
2019-12-19 17:26:40 +01:00
$sql = str_replace('count(call_recording_uuid)', '*', $sql);
$sql .= order_by($order_by, $order, 'call_recording_name', 'asc');
2019-07-04 17:01:28 +02:00
$sql .= limit_offset($rows_per_page, $offset);
2019-05-30 05:00:05 +02:00
$database = new database;
2019-12-19 17:26:40 +01:00
$call_recordings = $database->select($sql, $parameters, 'all');
2019-07-04 17:01:28 +02:00
unset($sql, $parameters);
2017-09-14 20:08:16 +02:00
2019-12-19 17:26:40 +01:00
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
2017-09-14 20:08:16 +02:00
2019-12-19 17:26:40 +01:00
//include the header
require_once "resources/header.php";
2017-09-14 20:08:16 +02:00
//show the content
2019-12-19 17:26:40 +01:00
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-call_recordings']." (".$num_rows.")</b></div>\n";
echo " <div class='actions'>\n";
if (permission_exists('call_recording_delete') && $call_recordings) {
2019-12-19 20:04:16 +01:00
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'collapse'=>'hide-xs','onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
2019-12-19 17:26:40 +01:00
}
echo "<form id='form_search' class='inline' method='get'>\n";
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
2019-12-19 20:04:16 +01:00
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null),'collapse'=>'hide-xs']);
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),'collapse'=>'hide-xs']);
2019-12-19 17:26:40 +01:00
if ($paging_controls_mini != '') {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
2019-12-19 18:48:39 +01:00
echo $text['title_description-call_recordings']."\n";
2019-12-19 17:26:40 +01:00
echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
2019-12-19 18:48:39 +01:00
$col_count = 4;
if (permission_exists('call_recording_delete')) {
2019-12-19 17:26:40 +01:00
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($call_recordings ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
2019-12-19 18:48:39 +01:00
$col_count++;
}
echo th_order_by('call_recording_name', $text['label-call_recording_name'], $order_by, $order, null, "class='pct-40'");
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
2019-12-19 20:04:16 +01:00
echo "<th class='shrink center'>".$text['label-recording']."</th>\n";
2019-12-19 18:48:39 +01:00
$col_count++;
2017-10-05 21:15:36 +02:00
}
2019-12-19 20:04:16 +01:00
echo th_order_by('call_recording_length', $text['label-call_recording_length'], $order_by, $order, null, "class='right'");
2017-09-14 20:08:16 +02:00
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);
2019-12-19 18:48:39 +01:00
if (permission_exists('xml_cdr_details')) {
2019-12-19 17:26:40 +01:00
echo " <td class='action-button'>&nbsp;</td>\n";
2017-09-14 20:08:16 +02:00
}
2019-12-19 17:26:40 +01:00
echo "</tr>\n";
2017-09-30 08:16:26 +02:00
2019-12-19 17:26:40 +01:00
if (is_array($call_recordings) && @sizeof($call_recordings) != 0) {
2017-09-14 20:08:16 +02:00
$x = 0;
2019-12-19 17:26:40 +01:00
foreach ($call_recordings as $row) {
2019-12-19 18:48:39 +01:00
//playback progress bar
if (permission_exists('call_recording_play')) {
echo "<tr class='list-row' id='recording_progress_bar_".escape($row['call_recording_uuid'])."' style='display: none;'><td class='playback_progress_bar_background' style='padding: 0; border: none;' colspan='".$col_count."'><span class='playback_progress_bar' id='recording_progress_".escape($row['call_recording_uuid'])."'></span></td>".(permission_exists('xml_cdr_details') ? "<td class='action-button' style='border-bottom: none !important;'></td>" : null)."</tr>\n";
echo "<tr class='list-row' style='display: none;'><td></td></tr>\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'])."');";
2017-10-15 23:56:06 +02:00
}
2019-12-19 18:48:39 +01:00
echo "<tr class='list-row' href=\"".$list_row_url."\">\n";
if (permission_exists('call_recording_delete')) {
2019-12-19 17:26:40 +01:00
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='call_recordings[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='call_recordings[$x][uuid]' value='".escape($row['call_recording_uuid'])."' />\n";
echo " </td>\n";
2017-09-14 20:08:16 +02:00
}
2019-12-19 20:04:16 +01:00
echo " <td class='overflow'>".escape($row['call_recording_name'])."</td>\n";
2019-12-19 18:48:39 +01:00
if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) {
echo " <td class='middle button center no-link no-wrap'>";
if (file_exists($row['call_recording_path'].'/'.$row['call_recording_name'])) {
if (permission_exists('call_recording_play')) {
$recording_file_ext = pathinfo($row['call_recording_name'], PATHINFO_EXTENSION);
switch ($recording_file_ext) {
case "wav" : $recording_type = "audio/wav"; break;
case "mp3" : $recording_type = "audio/mpeg"; break;
case "ogg" : $recording_type = "audio/ogg"; break;
}
echo "<audio id='recording_audio_".escape($row['call_recording_uuid'])."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".escape($row['call_recording_uuid'])."')\" onended=\"recording_reset('".escape($row['call_recording_uuid'])."');\" src='download.php?id=".urlencode($row['call_recording_uuid'])."' type='".$recording_type."'></audio>";
echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.escape($row['call_recording_uuid']),'onclick'=>"recording_play('".escape($row['call_recording_uuid'])."')"]);
}
if (permission_exists('call_recording_download')) {
2019-12-19 20:04:16 +01:00
echo button::create(['type'=>'button','title'=>$text['label-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'link'=>'download.php?id='.urlencode($row['call_recording_uuid']).'&binary']);
2019-12-19 18:48:39 +01:00
}
}
echo " </td>\n";
}
2019-12-19 20:04:16 +01:00
echo " <td class='right'>".($row['call_recording_length'] <= 59 ? '0:' : null).escape(str_pad($row['call_recording_length'], 2, '0', STR_PAD_LEFT))."</td>\n";
2019-12-19 18:48:39 +01:00
$call_recording_date = explode(' ', $row['call_recording_date']);
echo " <td class='no-wrap'>".escape($call_recording_date['0'])." <span class='hide-sm-dn'>".escape($call_recording_date[1])."</span></td>\n";
echo " <td>".($row['call_direction'] != '' ? escape($text['label-'.$row['call_direction']]) : null)."</td>\n";
if (permission_exists('xml_cdr_details')) {
2019-12-19 17:26:40 +01:00
echo " <td class='action-button'>\n";
2019-12-19 18:48:39 +01:00
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'])]);
2019-12-19 17:26:40 +01:00
echo " </td>\n";
}
2017-09-14 20:08:16 +02:00
echo "</tr>\n";
$x++;
2019-12-19 17:26:40 +01:00
}
unset($call_recordings);
}
2019-12-19 17:26:40 +01:00
echo "</table>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
2017-09-14 20:08:16 +02:00
//include the footer
require_once "resources/footer.php";
2019-12-19 18:48:39 +01:00
?>