Fax Server: Implement Read/Unread Toggle.
This commit is contained in:
+84
-27
@@ -17,7 +17,7 @@
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2018-2023
|
||||
Portions created by the Initial Developer are Copyright (C) 2018-2024
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
@@ -60,6 +60,18 @@
|
||||
//process the http post data by action
|
||||
if (!empty($action) && !empty($fax_files) && is_array($fax_files) && @sizeof($fax_files) != 0) {
|
||||
switch ($action) {
|
||||
case 'toggle':
|
||||
if (permission_exists('fax_file_edit')) {
|
||||
$fax = new fax;
|
||||
$fax->domain_uuid = $_SESSION['domain_uuid'];
|
||||
$fax_files_toggled = $fax->fax_file_toggle($fax_files);
|
||||
unset($fax, $fax_files);
|
||||
|
||||
if ($fax_files_toggled != 0) {
|
||||
message::add($text['message-toggle'].': '.$fax_files_toggled);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
if (permission_exists('fax_file_delete')) {
|
||||
$obj = new fax;
|
||||
@@ -70,7 +82,7 @@
|
||||
break;
|
||||
}
|
||||
|
||||
header('Location: fax_files.php?orderby='.$order_by.'&order='.$order.'&id='.$fax_uuid.'&box='.$box);
|
||||
header('Location: fax_files.php?order_by='.$order_by.'&order='.$order.'&id='.$fax_uuid.'&box='.$box);
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -125,7 +137,7 @@
|
||||
$fax_extension = preg_replace('/[^0-9]/', '', $_GET['ext']);
|
||||
$fax_filename = preg_replace('/[\/\\\&\%\#]/', '', $_GET['filename']);
|
||||
|
||||
//check if the file is in the inbox or sent directory.
|
||||
//check if the file is in the inbox or sent directory
|
||||
if ($_GET['type'] == "fax_inbox") {
|
||||
if (file_exists($fax_dir.'/'.$fax_extension.'/inbox/'.$fax_filename)) {
|
||||
$download_filename = $fax_dir.'/'.$fax_extension.'/inbox/'.$fax_filename;
|
||||
@@ -137,6 +149,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
//mark fax file as read if in inbox
|
||||
if ($_GET['type'] == "fax_inbox" && !empty($_GET['fax_file_uuid']) && is_uuid($_GET['fax_file_uuid'])) {
|
||||
$fax_files[0] = ['checked'=>'true','uuid'=>$_GET['fax_file_uuid']];
|
||||
$fax = new fax;
|
||||
$fax->domain_uuid = $_SESSION['domain_uuid'];
|
||||
$fax->fax_uuid = $_GET['id'] ?? '';
|
||||
$fax->order_by = $_GET['order_by'] ?? '';
|
||||
$fax->order = $_GET['order'] ?? '';
|
||||
$fax->box = $_GET['box'] ?? '';
|
||||
$fax->fax_file_toggle($fax_files);
|
||||
unset($fax, $fax_files);
|
||||
}
|
||||
|
||||
//add the headers and stream the file
|
||||
if (!empty($download_filename)) {
|
||||
$fd = fopen($download_filename, "rb");
|
||||
@@ -249,7 +274,8 @@
|
||||
$sql .= "fax_destination, fax_file_type, fax_file_path, fax_caller_id_name, \n";
|
||||
$sql .= "fax_caller_id_number, fax_epoch, fax_base64, fax_date, \n";
|
||||
$sql .= "to_char(timezone(:time_zone, fax_date), 'DD Mon YYYY') as fax_date_formatted, \n";
|
||||
$sql .= "to_char(timezone(:time_zone, fax_date), '".$time_format."') as fax_time_formatted \n";
|
||||
$sql .= "to_char(timezone(:time_zone, fax_date), '".$time_format."') as fax_time_formatted, \n";
|
||||
$sql .= "to_char(timezone(:time_zone, read_date), 'YYYY-MM-DD') as read_date_formatted \n";
|
||||
$sql .= "from v_fax_files \n";
|
||||
$sql .= "where fax_uuid = :fax_uuid \n";
|
||||
$sql .= "and domain_uuid = :domain_uuid \n";
|
||||
@@ -291,8 +317,13 @@
|
||||
echo " </div>\n";
|
||||
echo " <div class='actions'>\n";
|
||||
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'fax.php']);
|
||||
$margin_left = false;
|
||||
if (permission_exists('fax_file_edit') && $_REQUEST['box'] == 'inbox' && $fax_files) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'id'=>'btn_toggle','name'=>'btn_toggle','collapse'=>'hide-xs','style'=>'display: none; margin-left: 15px;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
|
||||
$margin_left = true;
|
||||
}
|
||||
if (permission_exists('fax_file_delete') && $fax_files) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','style'=>'margin-left: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
|
||||
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 ? 'margin-left: 15px;' : null),'onclick'=>"modal_open('modal-delete','btn_delete');"]);
|
||||
}
|
||||
if ($paging_controls_mini != '') {
|
||||
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
|
||||
@@ -301,6 +332,9 @@
|
||||
echo " <div style='clear: both;'></div>\n";
|
||||
echo "</div>\n";
|
||||
|
||||
if (permission_exists('fax_file_edit') && $_REQUEST['box'] == 'inbox' && $fax_files) {
|
||||
echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]);
|
||||
}
|
||||
if (permission_exists('fax_file_delete') && $fax_files) {
|
||||
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');"])]);
|
||||
}
|
||||
@@ -312,9 +346,9 @@
|
||||
|
||||
echo "<table class='list'>\n";
|
||||
echo "<tr class='list-header'>\n";
|
||||
if (permission_exists('fax_file_delete')) {
|
||||
if (permission_exists('fax_file_delete') || permission_exists('fax_file_edit')) {
|
||||
echo " <th class='checkbox'>\n";
|
||||
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".(empty($fax_files) ? "style='visibility: hidden;'" : null).">\n";
|
||||
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(empty($fax_files) ? "style='visibility: hidden;'" : null).">\n";
|
||||
echo " </th>\n";
|
||||
}
|
||||
echo th_order_by('fax_caller_id_name', $text['label-fax_caller_id_name'], $order_by, $order, "&id=".$fax_uuid."&box=".$_GET['box']."&page=".$page);
|
||||
@@ -414,44 +448,51 @@
|
||||
if (file_exists($dir_fax_temp.'/'.$file_name.'.tif')) { @unlink($dir_fax_temp.'/'.$file_name.'.tif'); }
|
||||
}
|
||||
|
||||
if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) {
|
||||
$list_row_url = "fax_files.php?id=".urlencode($fax_uuid)."&a=download&type=fax_inbox&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file);
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) {
|
||||
$list_row_url = "fax_files.php?id=".urlencode($fax_uuid)."&a=download&type=fax_sent&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file);
|
||||
//set fax as bold if unread and normal font weight if read
|
||||
$bold = $_REQUEST['box'] == 'inbox' && empty($row['read_date_formatted']) ? 'font-weight: bold;' : null;
|
||||
|
||||
$list_row_url = null;
|
||||
if (permission_exists('fax_inbox_view') || permission_exists('fax_sent_view')) {
|
||||
$list_row_url = "fax_files.php?id=".urlencode($fax_uuid);
|
||||
$list_row_url .= "&fax_file_uuid=".urlencode($row['fax_file_uuid']);
|
||||
$list_row_url .= "&a=download";
|
||||
$list_row_url .= "&type=fax_".urlencode($_REQUEST['box']);
|
||||
$list_row_url .= "&t=bin";
|
||||
$list_row_url .= "&order_by=".urlencode($_REQUEST['order_by']);
|
||||
$list_row_url .= "&order=".urlencode($_REQUEST['order']);
|
||||
$list_row_url .= "&box=".urlencode($_REQUEST['box']);
|
||||
$list_row_url .= "&ext=".urlencode($fax_extension);
|
||||
$list_row_url .= "&".$token['name']."=".$token['hash'];
|
||||
$list_row_url .= "&filename=".urlencode($file);
|
||||
}
|
||||
|
||||
echo "<tr class='list-row' href='".$list_row_url."'>\n";
|
||||
if (permission_exists('fax_file_delete')) {
|
||||
if (permission_exists('fax_file_delete') || permission_exists['fax_file_edit']) {
|
||||
echo " <td class='checkbox'>\n";
|
||||
echo " <input type='checkbox' name='fax_files[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
|
||||
echo " <input type='checkbox' name='fax_files[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; } checkbox_on_change(this);\">\n";
|
||||
echo " <input type='hidden' name='fax_files[$x][uuid]' value='".escape($row['fax_file_uuid'])."' />\n";
|
||||
echo " </td>\n";
|
||||
}
|
||||
echo " <td>".escape($row['fax_caller_id_name'])." </td>\n";
|
||||
echo " <td>".escape(format_phone($row['fax_caller_id_number']))." </td>\n";
|
||||
echo " <td style='".$bold."'>".escape($row['fax_caller_id_name'])." </td>\n";
|
||||
echo " <td style='".$bold."'>".escape(format_phone($row['fax_caller_id_number']))." </td>\n";
|
||||
if ($_REQUEST['box'] == 'sent') {
|
||||
echo " <td>".escape(format_phone($row['fax_destination']))." </td>\n";
|
||||
}
|
||||
if (permission_exists('fax_download_view')) {
|
||||
echo " <td><a href='".$list_row_url."'>".$file_name."</a></td>\n";
|
||||
echo " <td style='".$bold."'><a href='".$list_row_url."'>".$file_name."</a></td>\n";
|
||||
}
|
||||
echo " <td class='no-link'>\n";
|
||||
echo " <td class='no-link' style='".$bold."'>\n";
|
||||
if ($_REQUEST['box'] == 'inbox') {
|
||||
$dir_fax = $dir_fax_inbox;
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent') {
|
||||
$dir_fax = $dir_fax_sent;
|
||||
}
|
||||
if (file_exists($dir_fax.'/'.$file_name.".pdf")) {
|
||||
if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) {
|
||||
echo " <a href=\"fax_files.php?id=".urlencode($fax_uuid)."&a=download&type=fax_inbox&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file_name).".pdf\">PDF</a>\n";
|
||||
}
|
||||
if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) {
|
||||
echo " <a href=\"fax_files.php?id=".urlencode($fax_uuid)."&a=download&type=fax_sent&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file_name).".pdf\">PDF</a>\n";
|
||||
}
|
||||
if ((permission_exists('fax_inbox_view') || permission_exists('fax_sent_view')) && file_exists($dir_fax.'/'.$file_name.".pdf")) {
|
||||
echo " <a href=\"".substr($list_row_url, 0, -4).".pdf\">PDF</a>\n";
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo " <td>".$row['fax_date_formatted']." ".$row['fax_time_formatted']." </td>\n";
|
||||
echo " <td style='".$bold."'>".$row['fax_date_formatted']." ".$row['fax_time_formatted']." </td>\n";
|
||||
echo "</tr>\n";
|
||||
$x++;
|
||||
}
|
||||
@@ -463,7 +504,23 @@
|
||||
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
//unbold new fax rows when clicked/downloaded
|
||||
if ($_REQUEST['box'] == 'inbox') {
|
||||
echo "<script>\n";
|
||||
echo " $(document).ready(function() {\n";
|
||||
echo " $('.list-row').each(function(i,e) {\n";
|
||||
echo " $(e).children('td:not(.checkbox)').on('click',function() {\n";
|
||||
echo " $(this).closest('tr').children('td').css('font-weight','normal');\n";
|
||||
echo " });\n";
|
||||
echo " $(e).children('td').children('button').on('click',function() {\n";
|
||||
echo " $(this).closest('tr').children('td').css('font-weight','normal');\n";
|
||||
echo " });\n";
|
||||
echo " });\n";
|
||||
echo " });\n";
|
||||
echo "</script>\n";
|
||||
}
|
||||
|
||||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
?>
|
||||
?>
|
||||
Reference in New Issue
Block a user