Fax Server: List view, button, bulk delete via class, etc.

This commit is contained in:
Nate 2020-01-29 11:41:12 -07:00
parent 479a376713
commit 1ceccf698e
8 changed files with 540 additions and 228 deletions

View File

@ -81,7 +81,7 @@ $text['title-inbox']['ru-ru'] = "Входящий";
$text['title-inbox']['sv-se'] = "Inbox";
$text['title-inbox']['uk-ua'] = "";
$text['title-sent_faxes']['en-us'] = "Sent Faxes";
$text['title-sent_faxes']['en-us'] = "Sent";
$text['title-sent_faxes']['ar-eg'] = "";
$text['title-sent_faxes']['de-at'] = "Gesendete Faxe"; //copied from de-de
$text['title-sent_faxes']['de-ch'] = "Gesendete Faxe"; //copied from de-de
@ -2061,7 +2061,7 @@ $text['label-copy']['ru-ru'] = "Copy";
$text['label-copy']['sv-se'] = "Copy";
$text['label-copy']['uk-ua'] = "Copy";
$text['header-sent_faxes']['en-us'] = "Sent Faxes";
$text['header-sent_faxes']['en-us'] = "Sent";
$text['header-sent_faxes']['ar-eg'] = "";
$text['header-sent_faxes']['de-at'] = "Gesendete Faxe"; //copied from de-de
$text['header-sent_faxes']['de-ch'] = "Gesendete Faxe"; //copied from de-de

View File

@ -227,7 +227,7 @@
echo " <a href='fax_files.php?order_by=fax_date&order=desc&id=".urlencode($row['fax_uuid'])."&box=sent'>".$text['label-sent']."</a>&nbsp;&nbsp;";
}
if (permission_exists('fax_log_view')) {
echo " <a href='fax_logs.php?order_by=fax_epoch&order=desc&id=".urlencode($row['fax_uuid'])."'>".$text['label-log']."</a>";
echo " <a href='fax_logs.php?id=".urlencode($row['fax_uuid'])."'>".$text['label-log']."</a>";
}
if (permission_exists('fax_active_view') && isset($_SESSION['fax']['send_mode']['text']) && $_SESSION['fax']['send_mode']['text'] == 'queue') {
echo " <a href='fax_active.php?id=".urlencode($row['fax_uuid'])."'>".$text['label-active']."</a>";

View File

@ -87,6 +87,31 @@
//get the http post values and set them as php variables
if (count($_POST) > 0) {
//process the http post data by submitted action
if ($_POST['action'] != '' && is_uuid($fax_uuid)) {
$array[0]['checked'] = 'true';
$array[0]['uuid'] = $fax_uuid;
switch ($_POST['action']) {
case 'copy':
if (permission_exists('fax_extension_copy')) {
$obj = new fax;
$obj->copy($array);
}
break;
case 'delete':
if (permission_exists('fax_extension_delete')) {
$obj = new fax;
$obj->delete($array);
}
break;
}
header('Location: fax.php');
exit;
}
//set the variables
$fax_name = $_POST["fax_name"];
$fax_extension = $_POST["fax_extension"];
@ -462,7 +487,7 @@
echo " function toggle_advanced(advanced_id) {\n";
echo " $('#'+advanced_id).toggle();\n";
echo " if ($('#'+advanced_id).is(':visible')) {\n";
echo " $('#page').animate({scrollTop: $('#'+advanced_id).offset().top - 80}, 'slow');\n";
echo " $('html, body').animate({scrollTop: $('#'+advanced_id).offset().top - 80}, 'slow');\n";
echo " }\n";
echo " }\n";
echo " function add_sender() {\n";
@ -472,28 +497,36 @@
echo " }\n";
echo "</script>\n";
//fax extension form
echo "<form method='post' name='frm' action=''>\n";
//show the content
echo "<form method='post' name='frm'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-fax_server_settings']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'fax.php']);
$button_margin = 'margin-left: 15px;';
if (permission_exists('fax_extension_copy') && $action == "update") {
echo button::create(['type'=>'submit','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'name'=>'action','value'=>'copy','style'=>$button_margin,'onclick'=>"if (!confirm('".$text['confirm-copy']."')) { this.blur(); return false; }"]);
unset($button_margin);
}
if (permission_exists('fax_extension_delete') && $action == "update") {
echo button::create(['type'=>'submit','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'action','value'=>'delete','style'=>$button_margin,'onclick'=>"if (!confirm('".$text['confirm-delete']."')) { this.blur(); return false; }"]);
unset($button_margin);
}
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>'margin-left: 15px;']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td align='left' width='30%' valign='top' nowrap='nowrap'><b>".$text['header-fax_server_settings']."</b><br><br></td>\n";
echo " <td width='70%' valign='top' align='right'>\n";
echo " <input type='button' class='btn' name='' alt=\"".$text['button-back']."\" onclick=\"window.location='fax.php'\" value=\"".$text['button-back']."\">\n";
if (permission_exists('fax_extension_copy') && $action == "update") {
echo " <input type='button' class='btn' alt=\"".$text['button-copy']."\" onclick=\"if (confirm('".$text['confirm-copy']."')){window.location='fax_copy.php?id=".urlencode($fax_uuid)."';}\" value=\"".$text['button-copy']."\">\n";
}
echo " <input type='submit' class='btn' name='submit' value='".$text['button-save']."'>\n";
echo " </td>\n";
echo " </tr>\n";
if (!permission_exists('fax_extension_delete')) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo "<td width='30%' class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-email']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <input class='formfld' type='email' name='fax_email' maxlength='255' value=\"".escape($fax_email)."\">\n";
echo "<br />\n";
echo " ".$text['description-email']."\n";
@ -504,10 +537,10 @@
else { //admin, superadmin, etc
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-name']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_name' maxlength='30' value=\"".escape($fax_name)."\" required='required'>\n";
echo "<br />\n";
echo "".$text['description-name']."\n";
@ -579,9 +612,9 @@
echo " </td>\n";
echo "</table>\n";
echo " ".$text['description-email']."\n";
echo "<br />\n";
if (permission_exists('fax_extension_advanced') && function_exists("imap_open") && file_exists("fax_files_remote.php")) {
echo "<input type='button' class='btn' value='".$text['button-advanced']."' onclick=\"toggle_advanced('advanced_email_connection');\">\n";
echo "<br /><br />\n";
echo button::create(['type'=>'button','label'=>$text['button-advanced'],'icon'=>'tools','onclick'=>"toggle_advanced('advanced_email_connection');"]);
}
echo "<br />\n";
echo "</td>\n";
@ -661,7 +694,7 @@
}
unset($available_users);
echo " </select>";
echo " <input type=\"submit\" class='btn' value=\"".$text['button-add']."\">\n";
echo button::create(['type'=>'submit','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add']]);
echo " <br>\n";
echo " ".$text['description-user-add']."\n";
echo " <br />\n";
@ -824,7 +857,6 @@
echo " <input type='hidden' name='dialplan_uuid' value='".escape($dialplan_uuid)."'>\n";
}
echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n";
echo " </tr>";
echo "</table>";
@ -834,8 +866,15 @@
echo "<div id='advanced_email_connection' ".(($fax_email_connection_host == '') ? "style='display: none;'" : null).">\n";
echo "<b>".$text['label-advanced_settings']."</b><br><br>";
echo $text['description-advanced_settings']."<br><br>";
echo "<div class='action_bar sub'>\n";
echo " <div class='heading'><b>".$text['label-advanced_settings']."</b></div>\n";
echo " <div class='actions'>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-advanced_settings']."\n";
echo "<br><br>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>";
@ -868,7 +907,7 @@
echo " ".$text['label-email_connection_server']."\n";
echo "</td>\n";
echo "<td class='vtable' style='white-space: nowrap;' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_email_connection_host' maxlength='255' value=\"".escape($fax_email_connection_host)."\">&nbsp;:&nbsp;";
echo " <input class='formfld' type='text' name='fax_email_connection_host' maxlength='255' value=\"".escape($fax_email_connection_host)."\">&nbsp;<strong style='font-size: 15px;'>:</strong>&nbsp;";
echo "<input class='formfld' style='width: 50px; min-width: 50px; max-width: 50px;' type='text' name='fax_email_connection_port' maxlength='5' value=\"$fax_email_connection_port\">\n";
echo "<br />\n";
echo " ".$text['description-email_connection_server']."\n";
@ -1017,15 +1056,10 @@
echo "</table>\n";
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td colspan='3' style='text-align: right;'>";
echo " <br><input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>";
echo " <tr>";
echo "</table>";
echo "<br>";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<br><br>\n";
echo "</div>\n";
}
@ -1034,4 +1068,4 @@
//show the footer
require_once "resources/footer.php";
?>
?>

View File

@ -44,8 +44,33 @@
$text = $language->get();
//get variables used to control the order
$order_by = $_GET["order_by"];
$order = $_GET["order"];
$order_by = $_REQUEST["order_by"];
$order = $_REQUEST["order"];
//get the http post data
if (is_array($_POST['fax_files'])) {
$action = $_POST['action'];
$fax_uuid = $_POST['fax_uuid'];
$box = $_POST['box'];
$fax_files = $_POST['fax_files'];
}
//process the http post data by action
if ($action != '' && is_array($fax_files) && @sizeof($fax_files) != 0) {
switch ($action) {
case 'delete':
if (permission_exists('fax_file_delete')) {
$obj = new fax;
$obj->fax_uuid = $fax_uuid;
$obj->box = $box;
$obj->delete_files($fax_files);
}
break;
}
header('Location: fax_files.php?orderby='.$order_by.'&order='.$order.'&id='.$fax_uuid.'&box='.$box);
exit;
}
//get fax extension
if (is_uuid($_GET["id"])) {
@ -164,7 +189,7 @@
}
//prepare to page the results
$sql = "select count(*) from v_fax_files ";
$sql = "select count(fax_file_uuid) from v_fax_files ";
$sql .= "where fax_uuid = :fax_uuid ";
$sql .= "and domain_uuid = :domain_uuid ";
if ($_REQUEST['box'] == 'inbox') {
@ -181,66 +206,79 @@
//prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = "&id=".$fax_uuid."&box=".$_GET['box']."&order_by=".$_GET['order_by']."&order=".$_GET['order'];
$page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
$page = is_numeric($_GET['page']) ? $_GET['page'] : 0;
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
$offset = $rows_per_page * $page;
//get the list
$sql = str_replace('count(*)', '*', $sql);
$sql = str_replace('count(fax_file_uuid)', '*', $sql);
$sql .= order_by($order_by, $order, 'fax_date', 'desc');
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$fax_files = $database->select($sql, $parameters, 'all');
unset($sql, $parameters, $num_rows);
unset($sql, $parameters);
//include header
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//include the header
if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) {
$document['title'] = $text['title-inbox'].": ".escape($fax_name)." (".escape($fax_extension).")";
$document['title'] = escape($fax_name)." [".escape($fax_extension)."]: ".$text['title-inbox'];
}
if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) {
$document['title'] = $text['title-sent_faxes'].": ".escape($fax_name)." (".escape($fax_extension).")";
$document['title'] = escape($fax_name)." [".escape($fax_extension)."]: ".$text['title-sent_faxes'];
}
require_once "resources/header.php";
//show the header
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td align='left' valign='top'>\n";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'>";
if ($_REQUEST['box'] == 'inbox' && permission_exists('fax_inbox_view')) {
echo " <b>".$text['header-inbox'].": ".escape($fax_name)." (".escape($fax_extension).")</b>\n";
echo "<b>".escape($fax_name)." [".escape($fax_extension)."]: ".$text['header-inbox']." (".$num_rows.")</b>";
}
if ($_REQUEST['box'] == 'sent' && permission_exists('fax_sent_view')) {
echo " <b>".$text['header-sent_faxes'].": ".escape($fax_name)." (".escape($fax_extension).")</b>\n";
echo "<b>".escape($fax_name)." [".escape($fax_extension)."]: ".$text['header-sent_faxes']." (".$num_rows.")</b>";
}
echo " </td>\n";
echo " <td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='fax.php'\" value='".$text['button-back']."'>\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<br>\n";
echo " </div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'style'=>'margin-right: 15px;','link'=>'fax.php']);
if (permission_exists('fax_file_delete') && $fax_files) {
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; }"]);
}
if ($paging_controls_mini != '') {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
//show the table and content
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='fax_uuid' value='".escape($fax_uuid)."'>\n";
echo "<input type='hidden' name='box' value='".escape($_REQUEST['box'])."'>\n";
//show the fax files
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('fax_file_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($fax_files ?: "style='visibility: hidden;'").">\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=".$_GET['page']);
echo th_order_by('fax_caller_id_number', $text['label-fax_caller_id_number'], $order_by, $order, "&id=".$fax_uuid."&box=".$_GET['box']."&page=".$_GET['page']);
if ($_REQUEST['box'] == 'sent') {
echo th_order_by('fax_destination', $text['label-fax_destination'], $order_by, $order, "&id=".$fax_uuid."&box=".$_GET['box']."&page=".$_GET['page']);
}
echo "<th width=''>".$text['table-file']."</th>\n";
echo "<th>".$text['table-file']."</th>\n";
echo "<th width='10%'>".$text['table-view']."</th>\n";
echo th_order_by('fax_date', $text['label-fax_date'], $order_by, $order, "&id=".$fax_uuid."&box=".$_GET['box']."&page=".$_GET['page']);
echo "<td style='width: 25px;' class='list_control_icons'>&nbsp;</td>\n";
echo "</tr>\n";
if (is_array($fax_files) && @sizeof($fax_files) != 0) {
foreach($fax_files as $row) {
$x = 0;
foreach ($fax_files as $row) {
$file = basename($row['fax_file_path']);
if (strtolower(substr($file, -3)) == "tif" || strtolower(substr($file, -3)) == "pdf") {
$file_name = substr($file, 0, (strlen($file) -4));
@ -321,24 +359,27 @@
exec($cmd_tif2pdf);
@unlink($dir_fax_temp.'/'.$file_name."_temp.tif");
}
echo "</td></tr>";
echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['fax_caller_id_name'])."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape(format_phone($row['fax_caller_id_number']))."&nbsp;</td>\n";
if ($_REQUEST['box'] == 'sent') {
echo " <td valign='top' class='".$row_style[$c]."'>".escape(format_phone($row['fax_destination']))."&nbsp;</td>\n";
}
echo " <td class='".$row_style[$c]."' ondblclick=\"\">\n";
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)."\">\n";
$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')) {
echo " <a href=\"fax_files.php?id=".urlencode($fax_uuid)."&a=download&type=fax_sent&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file)."\">\n";
$list_row_url = "fax_files.php?id=".urlencode($fax_uuid)."&a=download&type=fax_sent&t=bin&ext=".urlencode($fax_extension)."&filename=".urlencode($file);
}
echo " $file_name";
echo " </a>";
echo " </td>\n";
echo " <td class='".$row_style[$c]."' ondblclick=''>\n";
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('fax_file_delete')) {
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='hidden' name='fax_files[$x][uuid]' value='".escape($row['fax_file_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td>".escape($row['fax_caller_id_name'])."&nbsp;</td>\n";
echo " <td>".escape(format_phone($row['fax_caller_id_number']))."&nbsp;</td>\n";
if ($_REQUEST['box'] == 'sent') {
echo " <td>".escape(format_phone($row['fax_destination']))."&nbsp;</td>\n";
}
echo " <td><a href='".$list_row_url."'>".$file_name."</a></td>\n";
echo " <td class='no-link'>\n";
if ($_REQUEST['box'] == 'inbox') {
$dir_fax = $dir_fax_inbox;
}
@ -353,32 +394,23 @@
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";
}
}
else {
echo "&nbsp;\n";
}
$fax_date = ($_SESSION['domain']['time_format']['text'] == '12h') ? date("F d Y H:i", $row['fax_epoch']) : date("F d Y H:i", $row['fax_epoch']);
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$fax_date."&nbsp;</td>\n";
echo " <td style='width: 25px;' class='list_control_icons'>";
if (permission_exists('fax_file_delete')) {
echo "<a href='fax_file_delete.php?id=".urlencode($row['fax_file_uuid'])."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
}
echo " </td>\n";
$fax_date = ($_SESSION['domain']['time_format']['text'] == '12h') ? date("F d Y H:i", $row['fax_epoch']) : date("F d Y H:i", $row['fax_epoch']);
echo " <td>".$fax_date."&nbsp;</td>\n";
echo "</tr>\n";
$c = ($c) ? 0 : 1;
$x++;
}
}
unset($fax_files, $row);
//show the paging controls
echo "</table>";
echo "<br /><br />";
unset($fax_files);
echo "</table>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<br /><br />";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
?>
?>

View File

@ -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) 2008-2019
Portions created by the Initial Developer are Copyright (C) 2008-2020
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -50,6 +50,25 @@
$fax_uuid = $_REQUEST["fax_uuid"];
}
//process the http post data by submitted action
if ($_POST['action'] != '' && is_uuid($fax_log_uuid) && is_uuid($fax_uuid)) {
$array[0]['checked'] = 'true';
$array[0]['uuid'] = $fax_log_uuid;
switch ($_POST['action']) {
case 'delete':
if (permission_exists('fax_log_delete')) {
$obj = new fax;
$obj->fax_uuid = $fax_uuid;
$obj->delete_logs($array);
}
break;
}
header('Location: fax_logs.php?id='.urlencode($fax_uuid));
exit;
}
//pre-populate the form
if (is_uuid($fax_log_uuid) && is_uuid($fax_uuid)) {
$sql = "select * from v_fax_logs ";
@ -83,13 +102,27 @@
unset($sql, $parameters, $row);
}
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header
$document['title'] = $text['title-fax_logs'];
require_once "resources/header.php";
//show the content
echo "<table cellpadding='0' cellspacing='0' border='0' align='right'><tr><td><input type='button' class='btn' alt='".$text['button-back']."' onclick=\"document.location='fax_logs.php?id=".urlencode($fax_uuid)."'\" value='".$text['button-back']."'></td></tr></table>";
echo "<b>".$text['title-fax_log']."</b>\n";
echo "<br /><br />\n";
echo "<form method='post' name='frm'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-fax_log']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'fax_logs.php?id='.urlencode($fax_uuid)]);
if (permission_exists('fax_log_delete')) {
echo button::create(['type'=>'submit','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'action','value'=>'delete','style'=>'margin-left: 15px;','onclick'=>"if (!confirm('".$text['confirm-delete']."')) { this.blur(); return false; }"]);
}
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
@ -186,9 +219,13 @@
echo "</table>";
echo "<br /><br />";
echo "<input type='hidden' name='id' value='".escape($fax_log_uuid)."'>\n";
echo "<input type='hidden' name='fax_uuid' value='".escape($fax_uuid)."'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
?>

View File

@ -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) 2008-2019
Portions created by the Initial Developer are Copyright (C) 2008-2020
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -43,38 +43,52 @@
$language = new text;
$text = $language->get();
//get the fax_uuid
$fax_uuid = $_REQUEST["id"];
//get variables used to control the order
$order_by = $_GET["order_by"];
$order = $_GET["order"];
//get the fax_uuid
$fax_uuid = $_GET["id"];
//get the http post data
if (is_array($_POST['fax_logs'])) {
$action = $_POST['action'];
$fax_logs = $_POST['fax_logs'];
}
//additional includes
$document['title'] = $text['title-fax_logs'];
require_once "resources/header.php";
//process the http post data by action
if ($action != '' && is_array($fax_logs) && @sizeof($fax_logs) != 0) {
switch ($action) {
case 'delete':
if (permission_exists('fax_log_delete')) {
$obj = new fax;
$obj->fax_uuid = $fax_uuid;
$obj->delete_logs($fax_logs);
}
break;
}
//show the content
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='50%' align='left' valign='top' nowrap='nowrap'><b>".$text['title-fax_logs']."</b></td>\n";
echo " <td width='50%' align='right'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='fax.php'\" value='".$text['button-back']."'>";
echo " <input type='button' class='btn' name='' alt='".$text['button-refresh']."' onclick=\"document.location.reload();\" value='".$text['button-refresh']."'>\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align='left' valign='top' colspan='2'>\n";
echo " <br>";
echo " ".$text['description-fax_log']."<br /><br />\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
header('Location: fax_logs.php?id='.urlencode($fax_uuid));
exit;
}
//add the search string
$search = strtolower($_GET["search"]);
if (strlen($search) > 0) {
$sql_search = " and (";
$sql_search .= " lower(fax_result_text) like :search ";
$sql_search .= " or lower(fax_file) like :search ";
$sql_search .= " or lower(fax_local_station_id) like :search ";
$sql_search .= " or fax_date::text like :search ";
$sql_search .= ") ";
$parameters['search'] = '%'.$search.'%';
}
//prepare to page the results
$sql = "select count(*) from v_fax_logs ";
$sql = "select count(fax_log_uuid) from v_fax_logs ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and fax_uuid = :fax_uuid ";
$sql .= $sql_search;
$parameters['domain_uuid'] = $domain_uuid;
$parameters['fax_uuid'] = $fax_uuid;
$database = new database;
@ -82,30 +96,67 @@
//prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = "&id=".$fax_uuid."&order_by=".$order_by."&order=".$order;
$param = "&id=".$fax_uuid."&order_by=".$order_by."&order=".$order."&search=".$search;
if (isset($_GET['page'])) {
$page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
$page = is_numeric($_GET['page']) ? $_GET['page'] : 0;
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
$offset = $rows_per_page * $page;
}
//get the list
$sql = str_replace('count(*)', '*', $sql);
$sql = str_replace('count(fax_log_uuid)', '*', $sql);
$sql .= order_by($order_by, $order, 'fax_epoch', 'desc');
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$fax_logs = $database->select($sql, $parameters, 'all');
unset($sql, $parameters, $num_rows);
unset($sql, $parameters);
//set 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']);
//show the fax logs
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
//include the header
$document['title'] = $text['title-fax_logs'];
require_once "resources/header.php";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-fax_logs']." (".$num_rows.")</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'fax.php']);
if (permission_exists('fax_log_delete') && $fax_logs) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'style'=>'margin-left: 15px;','onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
echo button::create(['type'=>'button','label'=>$text['button-refresh'],'icon'=>$_SESSION['theme']['button_icon_refresh'],'style'=>'margin-left: 15px;','link'=>'fax_logs.php']);
echo "<form id='form_search' class='inline' method='get'>\n";
echo "<input type='hidden' name='id' value='".escape($fax_uuid)."'>";
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
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'=>'fax_logs.php?id='.$fax_uuid,'style'=>($search == '' ? 'display: none;' : null)]);
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";
echo $text['description-fax_log']."\n";
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";
if (permission_exists('fax_log_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($fax_logs ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo th_order_by('fax_epoch', $text['label-fax_date'], $order_by, $order, null, null, "&id=".$fax_uuid);
echo th_order_by('fax_success', $text['label-fax_success'], $order_by, $order, null, null, "&id=".$fax_uuid);
echo th_order_by('fax_result_code', $text['label-fax_result_code'], $order_by, $order, null, null, "&id=".$fax_uuid);
echo th_order_by('fax_result_text', $text['label-fax_result_text'], $order_by, $order, null, null, "&id=".$fax_uuid);
@ -122,56 +173,60 @@
//echo th_order_by('fax_retry_limit', $text['label-fax_retry_limit'], $order_by, $order);
//echo th_order_by('fax_retry_sleep', $text['label-fax_retry_sleep'], $order_by, $order);
echo th_order_by('fax_uri', $text['label-fax_destination'], $order_by, $order, null, null, "&id=".$fax_uuid);
echo th_order_by('fax_epoch', $text['label-fax_date'], $order_by, $order, null, null, "&id=".$fax_uuid);
//echo th_order_by('fax_epoch', $text['label-fax_epoch'], $order_by, $order);
echo "<td class='list_control_icons'>";
echo "&nbsp;\n";
echo "</td>\n";
if ($_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (is_array($fax_logs) && @sizeof($fax_logs) != 0) {
foreach($fax_logs as $row) {
//$fax_date = date("j M Y", $row['fax_date'].' 00:00:00');
$fax_date = ($_SESSION['domain']['time_format']['text'] == '12h') ? date("j M Y g:i:sa", $row['fax_epoch']) : date("j M Y H:i:s", $row['fax_epoch']);
$tr_link = "href='fax_log_view.php?id=".$row['fax_log_uuid']."&fax_uuid=".$fax_uuid."'";
echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_success']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_result_code']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_result_text']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".basename($row['fax_file'])."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_ecm_used']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_local_station_id']."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_document_transferred_pages']."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_document_total_pages']."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_image_resolution']."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_image_size']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_bad_rows']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_transfer_rate']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_retry_attempts']."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_retry_limit']."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_retry_sleep']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".basename($row['fax_uri'])."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$fax_date."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['fax_epoch']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>";
echo "<a href='fax_log_view.php?id=".$row['fax_log_uuid']."&fax_uuid=$fax_uuid' alt='".$text['button-view']."'>".$v_link_label_view."</a>";
$x = 0;
foreach ($fax_logs as $row) {
$list_row_url = "fax_log_view.php?id=".urlencode($row['fax_log_uuid'])."&fax_uuid=".$fax_uuid;
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('fax_log_delete')) {
echo "<a href='fax_log_delete.php?id=".$row['fax_log_uuid']."&fax_uuid=".$fax_uuid."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>";
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='fax_logs[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='fax_logs[$x][uuid]' value='".escape($row['fax_log_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td><a href='".$list_row_url."'>".($_SESSION['domain']['time_format']['text'] == '12h' ? date("j M Y g:i:sa", $row['fax_epoch']) : date("j M Y H:i:s", $row['fax_epoch']))."</a>&nbsp;</td>\n";
echo " <td>".$row['fax_success']."&nbsp;</td>\n";
echo " <td>".$row['fax_result_code']."&nbsp;</td>\n";
echo " <td>".$row['fax_result_text']."&nbsp;</td>\n";
echo " <td>".basename($row['fax_file'])."&nbsp;</td>\n";
echo " <td>".$row['fax_ecm_used']."&nbsp;</td>\n";
echo " <td>".$row['fax_local_station_id']."&nbsp;</td>\n";
//echo " <td>".$row['fax_document_transferred_pages']."&nbsp;</td>\n";
//echo " <td>".$row['fax_document_total_pages']."&nbsp;</td>\n";
//echo " <td>".$row['fax_image_resolution']."&nbsp;</td>\n";
//echo " <td>".$row['fax_image_size']."&nbsp;</td>\n";
echo " <td>".$row['fax_bad_rows']."&nbsp;</td>\n";
echo " <td>".$row['fax_transfer_rate']."&nbsp;</td>\n";
echo " <td>".$row['fax_retry_attempts']."&nbsp;</td>\n";
//echo " <td>".$row['fax_retry_limit']."&nbsp;</td>\n";
//echo " <td>".$row['fax_retry_sleep']."&nbsp;</td>\n";
echo " <td>".basename($row['fax_uri'])."&nbsp;</td>\n";
//echo " <td>".$row['fax_epoch']."&nbsp;</td>\n";
if ($_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</td>\n";
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
$x++;
}
}
unset($fax_logs, $row);
unset($fax_logs);
echo "</table>";
echo "<br /><br />";
echo "<div style='text-align: center;'>".$paging_controls."</div>";
echo "<br /><br />";
echo "</table>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='id' value='".escape($fax_uuid)."'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";
?>
?>

View File

@ -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) 2008-2019
Portions created by the Initial Developer are Copyright (C) 2008-2020
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -689,14 +689,14 @@ if (!function_exists('fax_split_dtmf')) {
else {
if (!$included) {
//nothing to send, redirect the browser
message::add($text['message-invalid-fax'], 'negative');
message::add($text['message-invalid-fax'], 'negative', 4000);
header("Location: fax_send.php?id=".$fax_uuid);
exit;
}
}
//preview, if requested
if (($_REQUEST['submit'] != '') && ($_REQUEST['submit'] == $text['button-preview'])) {
if (($_REQUEST['submit'] != '') && ($_REQUEST['submit'] == 'preview')) {
unset($file_type);
if (file_exists($dir_fax_temp.'/'.$fax_instance_uuid.'.pdf')) {
$file_type = 'pdf';
@ -905,29 +905,23 @@ if (!$included) {
echo "</script>";
//fax extension form
echo "<form action='' method='POST' enctype='multipart/form-data' name='frmUpload' onSubmit=''>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo " <td align='left' valign='top' width='30%'>\n";
echo " <span class='title'>".$text['header-new_fax']."</span>\n";
echo " </td>\n";
echo " <td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='fax.php'\" value='".$text['button-back']."'>\n";
echo " <input type='submit' name='submit' class='btn' id='preview' value='".$text['button-preview']."'>\n";
echo " <input name='submit' type='submit' class='btn' id='upload' value='".$text['button-send']."'>\n";
echo " </td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br>\n";
//show the content
echo "<form method='post' name='frm' enctype='multipart/form-data'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-new_fax']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'style'=>'margin-right: 15px;','link'=>'fax.php']);
echo button::create(['type'=>'submit','label'=>$text['button-preview'],'name'=>'submit','value'=>'preview','icon'=>'eye']);
echo button::create(['type'=>'submit','label'=>$text['button-send'],'name'=>'submit','value'=>'send','icon'=>'paper-plane','style'=>'margin-left: 15px;']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-2']." ".(if_group('superadmin') ? $text['description-3'] : null)."\n";
echo "<br /><br />\n";
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>\n";
echo " <tr>\n";
echo " <td colspan='2' align='left'>\n";
echo " ".$text['description-2']." ".((if_group('superadmin')) ? $text['description-3'] : null)." \n";
echo " <br /><br />\n";
echo " </td>\n";
echo " </tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
@ -1068,7 +1062,9 @@ if (!$included) {
echo "<td class='vtable' align='left'>\n";
for ($f = 1; $f <= 3; $f++) {
echo " <span id='fax_file_".$f."' ".(($f > 1) ? "style='display: none;'" : null).">";
echo " <input name='fax_files[]' id='fax_files_".$f."' type='file' class='formfld fileinput' style='margin-right: 3px; ".(($f > 1) ? "margin-top: 3px;" : null)."' onchange=\"".(($f < 3) ? "document.getElementById('fax_file_".($f+1)."').style.display='';" : null)." list_selected_files(".$f.");\" multiple='multiple'><input type='button' class='btn' value='".$text['button-clear']."' onclick=\"reset_file_input('fax_files_".$f."'); document.getElementById('file_list_".$f."').innerHTML='';\"><br />";
echo " <input name='fax_files[]' id='fax_files_".$f."' type='file' class='formfld fileinput' style='margin-right: 3px; ".(($f > 1) ? "margin-top: 3px;" : null)."' onchange=\"".(($f < 3) ? "document.getElementById('fax_file_".($f+1)."').style.display='';" : null)." list_selected_files(".$f.");\" multiple='multiple'>";
echo button::create(['type'=>'button','label'=>$text['button-clear'],'icon'=>$_SESSION['theme']['button_icon_reset'],'onclick'=>"reset_file_input('fax_files_".$f."'); document.getElementById('file_list_".$f."').innerHTML='';"]);
echo "<br />";
echo " <span id='file_list_".$f."'></span>";
echo " </span>\n";
}
@ -1139,22 +1135,17 @@ if (!$included) {
echo "</td>\n";
echo "</tr>\n";
echo " <tr>\n";
echo " <td colspan='2' align='right'>\n";
echo " <br>\n";
echo " <input type='hidden' name='fax_caller_id_name' value='".escape($fax_caller_id_name)."'>\n";
echo " <input type='hidden' name='fax_caller_id_number' value='".escape($fax_caller_id_number)."'>\n";
echo " <input type='hidden' name='fax_extension' value='".escape($fax_extension)."'>\n";
echo " <input type='hidden' name='id' value='".escape($fax_uuid)."'>\n";
echo " <input type='hidden' name='action' value='send'>\n";
echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo " <input type='submit' name='submit' class='btn' id='preview' value='".$text['button-preview']."'>\n";
echo " <input type='submit' name='submit' class='btn' id='upload' value='".$text['button-send']."'>\n";
echo " </td>\n";
echo " </tr>";
echo "</table>";
echo "<br /><br />\n";
echo "<input type='hidden' name='fax_caller_id_name' value='".escape($fax_caller_id_name)."'>\n";
echo "<input type='hidden' name='fax_caller_id_number' value='".escape($fax_caller_id_number)."'>\n";
echo "<input type='hidden' name='fax_extension' value='".escape($fax_extension)."'>\n";
echo "<input type='hidden' name='id' value='".escape($fax_uuid)."'>\n";
echo "<input type='hidden' name='action' value='send'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
echo "<br />\n";
//show the footer
require_once "resources/footer.php";
@ -1184,4 +1175,4 @@ function showgrid($pdf) {
}
*/
?>
?>

View File

@ -39,6 +39,7 @@ if (!class_exists('fax')) {
public $fax_extension;
public $fax_forward_number;
public $destination_number;
public $box;
private $forward_prefix;
/**
@ -61,10 +62,6 @@ if (!class_exists('fax')) {
//assign private variables
$this->app_name = 'fax';
$this->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
$this->permission_prefix = 'fax_extension_';
$this->list_page = 'fax.php';
$this->table = 'fax';
$this->uuid_prefix = 'fax_';
}
@ -212,6 +209,13 @@ if (!class_exists('fax')) {
* delete records
*/
public function delete($records) {
//set private variables
$this->permission_prefix = 'fax_extension_';
$this->list_page = 'fax.php';
$this->table = 'fax';
$this->uuid_prefix = 'fax_';
if (permission_exists($this->permission_prefix.'delete')) {
//add multi-lingual support
@ -305,10 +309,169 @@ if (!class_exists('fax')) {
}
}
public function delete_files($records) {
//set private variables
$this->permission_prefix = 'fax_file_';
$this->list_page = 'fax_files.php?id='.urlencode($this->fax_uuid).'&box='.urlencode($this->box);
$this->table = 'fax_files';
$this->uuid_prefix = 'fax_file_';
if (permission_exists($this->permission_prefix.'delete')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->list_page);
exit;
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//filter out unchecked fax files, build where clause for below
foreach ($records as $x => $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'";
}
}
//get necessary fax file details
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->uuid_prefix."uuid as uuid, fax_mode, fax_file_path, fax_file_type from v_".$this->table." ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
if ($row['fax_mode'] == 'rx') { $fax_files[$row['uuid']]['folder'] = 'inbox'; }
if ($row['fax_mode'] == 'tx') { $fax_files[$row['uuid']]['folder'] = 'sent'; }
$fax_files[$row['uuid']]['path'] = $row['fax_file_path'];
$fax_files[$row['uuid']]['type'] = $row['fax_file_type'];
}
}
unset($sql, $parameters, $rows, $row);
}
//delete fax file(s)
if (is_array($fax_files) && @sizeof($fax_files) != 0) {
foreach ($fax_files as $fax_file_uuid => $fax_file) {
if (substr_count($fax_file['path'], '/temp/') > 0) {
$fax_file['path'] = str_replace('/temp/', '/'.$fax_file['type'].'/', $fax_file['path']);
}
if (file_exists($fax_file['path'])) {
@unlink($fax_file['path']);
}
if ($fax_file['type'] == 'tif') {
$fax_file['path'] = str_replace('.tif', '.pdf', $fax_file['path']);
if (file_exists($fax_file['path'])) {
@unlink($fax_file['path']);
}
}
else if ($fax_file['type'] == 'pdf') {
$fax_file['path'] = str_replace('.pdf', '.tif', $fax_file['path']);
if (file_exists($fax_file['path'])) {
@unlink($fax_file['path']);
}
}
}
}
//build the delete array
$x = 0;
foreach ($fax_files as $fax_file_uuid => $fax_file) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $fax_file_uuid;
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
$x++;
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
//set message
message::add($text['message-delete']);
}
unset($records);
}
}
}
public function delete_logs($records) {
//set private variables
$this->permission_prefix = 'fax_log_';
$this->list_page = 'fax_logs.php?id='.urlencode($this->fax_uuid);
$this->table = 'fax_logs';
$this->uuid_prefix = 'fax_log_';
if (permission_exists($this->permission_prefix.'delete')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->list_page);
exit;
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//filter out unchecked fax logs, build the delete array
foreach ($records as $x => $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
}
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
//set message
message::add($text['message-delete']);
}
unset($records);
}
}
}
/**
* copy records
*/
public function copy($records) {
//set private variables
$this->permission_prefix = 'fax_extension_';
$this->list_page = 'fax.php';
$this->table = 'fax';
$this->uuid_prefix = 'fax_';
if (permission_exists($this->permission_prefix.'copy')) {
//add multi-lingual support