Merge pull request #1296 from moteus/fax_queue

Fax queue web monitor
This commit is contained in:
FusionPBX
2015-12-09 16:25:29 -08:00
9 changed files with 494 additions and 1 deletions

View File

@@ -146,6 +146,13 @@
$apps[$x]['permissions'][$y]['name'] = 'fax_file_delete';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'fax_active_view';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$apps[$x]['permissions'][$y]['groups'][] = 'admin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'fax_active_all';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
//schema details
$y = 0; //table array index

View File

@@ -330,6 +330,17 @@ $text['label-log']['de-at'] = "Log";
$text['label-log']['ro'] = "Log";
$text['label-log']['he'] = "";
$text['label-active']['en-us'] = "Active";
$text['label-active']['es-cl'] = "";
$text['label-active']['pt-pt'] = "";
$text['label-active']['fr-fr'] = "";
$text['label-active']['pt-br'] = "";
$text['label-active']['pl'] = "";
$text['label-active']['sv-se'] = "";
$text['label-active']['de-at'] = "";
$text['label-active']['ro'] = "";
$text['label-active']['he'] = "";
$text['label-location']['en-us'] = "Location";
$text['label-location']['es-cl'] = "Localización";
$text['label-location']['pt-pt'] = "Localização";
@@ -2068,4 +2079,38 @@ $text['button-add']['de-at'] = "Hinzufügen";
$text['button-add']['ro'] = "Adaugă";
$text['button-add']['he'] = "הוספה";
$text['button-show_all']['en-us'] = "Show All";
$text['button-show_all']['es-cl'] = "Mostrar Todos";
$text['button-show_all']['pt-pt'] = "Mostrar Todos";
$text['button-show_all']['fr-fr'] = "Montrer Tout";
$text['button-show_all']['pt-br'] = "Mostrar Todos";
$text['button-show_all']['pl'] = "Pokaż Wszystkie";
$text['button-show_all']['uk'] = "Показати всі";
$text['button-show_all']['de-at'] = "Alle anzeigen";
$text['button-show_all']['he'] = "";
$text['fax-active_title']['en-us'] = "Fax queue";
$text['fax-active_description']['en-us'] = "Current status of fax queue";
$text['fax-active_title_fax_server']['en-us'] = "Fax";
$text['fax-active_title_enabled']['en-us'] = "Enabled";
$text['fax-active_title_status']['en-us'] = "Status";
$text['fax-active_title_next_time']['en-us'] = "Next time";
$text['fax-active_title_files']['en-us'] = "Files";
$text['fax-active_title_uri']['en-us'] = "URI";
$text['fax-active_status_wait']['en-us'] = "Wait";
$text['fax-active_status_execute']['en-us'] = "Execute";
$text['fax-active_status_success']['en-us'] = "Success";
$text['fax-active_status_fail']['en-us'] = "Fail";
?>

View File

@@ -170,6 +170,9 @@ else {
if (permission_exists('fax_log_view')) {
echo " <a href='fax_logs.php?id=".$row['fax_uuid']."'>".$text['label-log']."</a>";
}
if (permission_exists('fax_active_view')) {
echo " <a href='fax_active.php?id=".$row['fax_uuid']."'>".$text['label-active']."</a>";
}
echo " </td>\n";
echo " <td valign='top' class='row_stylebg' width='35%'>".$row['fax_description']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>";

136
app/fax/fax_active.php Normal file
View File

@@ -0,0 +1,136 @@
<?php
/*
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>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
if (permission_exists('fax_active_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//get the HTTP values and set as variables
$show = trim($_REQUEST["show"]);
if ($show != "all") { $show = ''; }
//
$fax_uuid = false;
if(isset($_REQUEST['id'])) {
$fax_uuid = check_str($_REQUEST["id"]);
}
//show the header
$document['title'] = $text['title'];
require_once "resources/header.php";
//ajax for refresh
?>
<script type="text/javascript">
//define refresh function, initial start
var refresh = 1500;
var source_url = 'fax_active_inc.php?';
var timer_id;
<?php
if ($show == 'all') {
echo "source_url = source_url + '&show=all';";
}
if ($fax_uuid) {
echo "source_url = source_url + '&id=" . $fax_uuid . "';";
}
if (isset($_REQUEST["debug"])) {
echo "source_url = source_url + '&debug';";
}
?>
var ajax_get = function () {
$.ajax({
url: source_url, success: function(response){
$("#ajax_reponse").html(response);
}
});
timer_id = setTimeout(ajax_get, refresh);
};
refresh_start();
//refresh controls
function refresh_stop() {
clearTimeout(timer_id);
document.getElementById('refresh_state').innerHTML = "<img src='resources/images/refresh_paused.png' style='width: 16px; height: 16px; border: none; margin-top: 1px; cursor: pointer;' onclick='refresh_start();' alt=\"<?php echo $text['label-refresh_enable']?>\" title=\"<?php echo $text['label-refresh_enable']?>\">";
}
function refresh_start() {
if (document.getElementById('refresh_state')) { document.getElementById('refresh_state').innerHTML = "<img src='resources/images/refresh_active.gif' style='width: 16px; height: 16px; border: none; margin-top: 3px; cursor: pointer;' alt=\"<?php echo $text['label-refresh_pause']?>\" title=\"<?php echo $text['label-refresh_pause']?>\">"; }
ajax_get();
}
//call controls
function hangup(uuid) {
if (confirm("<?php echo $text['confirm-hangup']?>")) {
send_cmd('fax_active_exec.php?cmd=delete&id='+uuid);
}
}
function send_cmd(url) {
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET",url,false);
xmlhttp.send(null);
document.getElementById('cmd_reponse').innerHTML=xmlhttp.responseText;
}
</script>
<?php
echo "<div id='ajax_reponse'></div>\n";
echo "<div id='time_stamp' style='visibility:hidden'>".date('Y-m-d-s')."</div>\n";
echo "<br><br><br>";
require_once "resources/footer.php";
/*
// deprecated functions for this page
function get_park_cmd(uuid, context) {
cmd = \"uuid_transfer \"+uuid+\" -bleg *6000 xml \"+context;
return escape(cmd);
}
function get_record_cmd(uuid, prefix, name) {
cmd = \"uuid_record \"+uuid+\" start ".$_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/archive/".date("Y")."/".date("M")."/".date("d")."/\"+uuid+\".wav\";
return escape(cmd);
}
*/
?>

View File

@@ -0,0 +1,74 @@
<?php
/* $Id$ */
/*
v_exec.php
Copyright (C) 2008 Mark J Crane
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
if (permission_exists('fax_active_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//authorized referrer
if(stristr($_SERVER["HTTP_REFERER"], '/fax_active.php') === false) {
echo " access denied";
exit;
}
//http get variables set to php variables
if (count($_GET)>0) {
$cmd = trim(check_str($_GET['cmd']));
$fax_uuid = trim(check_str($_GET['id']));
}
//authorized commands
if ($cmd == 'delete') {
//authorized;
} else {
//not found. this command is not authorized
echo "access denied";
exit;
}
//Command
if ($cmd == 'delete') {
if($fax_uuid){
$sql = <<<HERE
delete from v_fax_tasks
where fax_task_uuid='$fax_uuid'
HERE;
$result = $db->exec($sql);
// if($result === false){
// var_dump($db->errorInfo());
// }
}
}
?>

222
app/fax/fax_active_inc.php Normal file
View File

@@ -0,0 +1,222 @@
<?php
/*
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>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
if (permission_exists('fax_active_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
if ((!permission_exists('fax_active_all')) && ($show == 'all')) {
echo "access denied";
exit;
}
$fax_uuid = false;
if(isset($_REQUEST['id'])) {
$fax_uuid = check_str($_REQUEST["id"]);
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//get the HTTP values and set as variables
$show = trim($_REQUEST["show"]);
if ($show != "all") { $show = ''; }
//include theme config for button images
include_once("themes/".$_SESSION['domain']['template']['name']."/config.php");
$where = 'where (1 = 1)';
if($show !== 'all'){
$where .= 'and (t3.domain_name = \'' . check_str($_SESSION['domain_name']) . '\')';
}
else if($fax_uuid){
if(!permission_exists('fax_active_all')){
$where .= 'and (t3.domain_name = \'' . check_str($_SESSION['domain_name']) . '\')';
}
$where .= 'and (t1.fax_uuid =\'' . check_str($fax_uuid) . '\')';
}
$sql = <<<HERE
select
t1.fax_task_uuid as uuid,
t1.fax_uuid as fax_uuid,
t3.domain_name,
t3.domain_uuid,
t1.task_next_time as next_time,
t1.task_interrupted as interrupted,
t1.task_status as status,
t1.task_uri as uri,
t1.task_dial_string as dial_string,
t1.task_dtmf as dtmf,
t1.task_fax_file as fax_file,
t1.task_wav_file as wav_file,
t1.task_reply_address as reply_address,
t1.task_no_answer_counter as no_answer_counter,
t1.task_no_answer_retry_counter as no_answer_retry_counter,
t1.task_retry_counter as retry_counter,
t2.fax_send_greeting as greeting,
t2.fax_name as fax_server_name
from v_fax_tasks t1
inner join v_fax t2 on t2.fax_uuid = t1.fax_uuid
inner join v_domains t3 on t2.domain_uuid = t3.domain_uuid
$where
order by domain_name, fax_server_name, next_time
HERE;
$result = false;
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
if($prep_statement->execute()) {
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
}
}
unset($prep_statement, $sql, $where);
//if the connnection is available then run it and return the results
if ($result === false) {
var_dump($db->errorInfo());
$msg = "<div align='center'>".$text['message-fail']."<br /></div>";
echo "<div align='center'>\n";
echo "<table width='40%'>\n";
echo "<tr>\n";
echo "<th align='left'>".$text['label-message']."</th>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='row_style1'><strong>$msg</strong></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</div>\n";
}
else {
//define js function call var
$onhover_pause_refresh = " onmouseover='refresh_stop();' onmouseout='refresh_start();'";
//show buttons
echo "<table cellpadding='0' cellspacing='0' border='0' align='right'>";
echo " <tr>";
echo " <td valign='middle' nowrap='nowrap' style='padding-right: 15px' id='refresh_state'>";
echo " <img src='resources/images/refresh_active.gif' style='width: 16px; height: 16px; border: none; margin-top: 3px; cursor: pointer;' onclick='refresh_stop();' alt=\"".$text['label-refresh_pause']."\" title=\"".$text['label-refresh_pause']."\">";
echo " </td>";
echo " <td valign='top' nowrap='nowrap'>";
if (permission_exists('fax_active_all')) {
if ($show == "all") {
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"document.location='fax_active.php';\" value='".$text['button-back']."' ".$onhover_pause_refresh.">\n";
}
else {
echo " <input type='button' class='btn' name='' alt='".$text['button-show_all']."' onclick=\"document.location='fax_active.php?show=all';\" value='".$text['button-show_all']."' ".$onhover_pause_refresh.">\n";
}
}
echo " </td>";
echo " </tr>";
echo "</table>";
// show title
echo "<b>".$text['fax-active_title']."</b>";
echo "<br><br>\n";
echo $text['fax-active_description']."\n";
echo "<br><br>\n";
//set the alternating color for each row
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
//show the results
echo "<div id='cmd_reponse'></div>\n";
//show headers
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<th>" . $text['fax-active_title_fax_server'] . "</th>\n";
echo "<th>" . $text['fax-active_title_enabled'] . "</th>\n";
echo "<th>" . $text['fax-active_title_status'] . "</th>\n";
echo "<th>" . $text['fax-active_title_next_time'] . "</th>\n";
echo "<th>" . $text['fax-active_title_files'] . "</th>\n";
echo "<th>" . $text['fax-active_title_uri'] . "</th>\n";
echo "<td class='list_control_icon'></td>\n";
echo "</tr>\n";
foreach ($result as &$row) {
$fax_uri = $row['uri'];
$domain_name = $row['domain_name'];
$task_enabled = ($row['interrupted'] == 'true') ? 'Disable': 'Enable';
$task_status = $text['fax-active_status_wait'];
$task_next_time = $row['next_time'];
if($row['status'] > 0){
if($row['status'] <= 3){
$task_status = $text['fax-active_status_execute'];
}
else if($row['status'] == 10){
$task_status = $text['fax-active_status_success'];
}
else{
$task_status = $text['fax-active_status_fail'];
}
}
$fax_server = $row['fax_server_name'];
if ($show == 'all') {
$fax_server .= '@' . $domain_name;
}
$task_files = '';
if(!empty($row['fax_file'])){
$task_files .= '&nbsp;' . basename($row['fax_file']);
}
if(!empty($row['wav_file'])){
$task_files .= '<br/>&nbsp;' . basename($row['wav_file']);
} else if(!empty($row['greeting'])){
$task_files .= '<br/>&nbsp;' . basename($row['greeting']);
}
echo "<tr>\n";
echo "<td valign='top' class='".$row_style[$c]."'>" . $fax_server . "&nbsp;</td>\n";
echo "<td valign='top' class='".$row_style[$c]."'>" . $task_enabled . "&nbsp;</td>\n";
echo "<td valign='top' class='".$row_style[$c]."'>" . $task_status . "&nbsp;</td>\n";
echo "<td valign='top' class='".$row_style[$c]."'>" . $task_next_time . "&nbsp;</td>\n";
echo "<td valign='top' class='".$row_style[$c]."'>" . $task_files . "&nbsp;</td>\n";
echo "<td valign='top' class='".$row_style[$c]."'>" . $fax_uri . "&nbsp;</td>\n";
echo "<td class='list_control_icons' style='width: 25px; text-align: left;'><a href='javascript:void(0);' alt='".$text['label-hangup']."' onclick=\"hangup(escape('".$row['uuid']."'));\">".$v_link_label_delete."</a></td>\n";
echo "</tr>\n";
$c = ($c) ? 0 : 1;
}
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
}
?>

View File

@@ -706,6 +706,7 @@ function fax_split_dtmf(&$fax_number, &$fax_dtmf){
foreach ($fax_numbers as $fax_number) {
$dial_string = $common_dial_string;
fax_split_dtmf($fax_number, $fax_dtmf);
//prepare the fax command
@@ -767,7 +768,12 @@ function fax_split_dtmf(&$fax_number, &$fax_dtmf){
if (!$included) {
//redirect the browser
$_SESSION["message"] = $response;
header("Location: fax_files.php?id=".$fax_uuid."&box=sent");
if (permission_exists('fax_active_view')) {
header("Location: fax_active.php?id=".$fax_uuid);
}
else {
header("Location: fax_files.php?id=".$fax_uuid."&box=sent");
}
exit;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 B