Merge pull request #2 from fusionpbx/master

test2
This commit is contained in:
blackc2004
2015-12-10 08:17:05 -08:00
28 changed files with 946 additions and 44 deletions

View File

@@ -122,6 +122,17 @@ $text['label-no_answer']['sv-se'] = "Inget Svar ";
$text['label-no_answer']['uk'] = "Без відповіді";
$text['label-no_answer']['de-at'] = "Keine Antwort";
$text['label-not_registered']['en-us'] = "Not Registered";
$text['label-not_registered']['es-cl'] = "";
$text['label-not_registered']['pt-pt'] = "";
$text['label-not_registered']['fr-fr'] = "";
$text['label-not_registered']['it-it'] = "";
$text['label-not_registered']['pt-br'] = "";
$text['label-not_registered']['pl'] = "";
$text['label-not_registered']['sv-se'] = "";
$text['label-not_registered']['uk'] = "";
$text['label-not_registered']['de-at'] = "";
$text['label-ignore-busy']['en-us'] = "Ignore Busy";
$text['label-ignore-busy']['es-cl'] = "";
$text['label-ignore-busy']['pt-pt'] = "";
@@ -335,6 +346,17 @@ $text['description-no_answer']['sv-se'] = "Om aktiverad, så tar den överhand f
$text['description-no_answer']['uk'] = "";
$text['description-no_answer']['de-at'] = "Falls aktiv, wird der Wert 'Mailbox eingeschaltet' in der Nebenstelle überschrieben";
$text['description-not_registered']['en-us'] = "If endpoint is not reachable, forward to this destination before going to voicemail.";
$text['description-not_registered']['es-cl'] = "";
$text['description-not_registered']['pt-pt'] = "";
$text['description-not_registered']['fr-fr'] = "";
$text['description-not_registered']['it-it'] = "";
$text['description-not_registered']['pt-br'] = "";
$text['description-not_registered']['pl'] = "";
$text['description-not_registered']['sv-se'] = "";
$text['description-not_registered']['uk'] = "";
$text['description-not_registered']['de-at'] = "";
$text['description-cid-number-prefix']['en-us'] = "Set the caller ID number prefix.";
$text['description-cid-number-prefix']['es-cl'] = "Configure el prefijo de número de caller ID.";
$text['description-cid-number-prefix']['pt-pt'] = "Defina o número do Chamador";
@@ -493,4 +515,4 @@ $text['button-back']['sv-se'] = "Tillbaka ";
$text['button-back']['uk'] = "Назад";
$text['button-back']['de-at'] = "Zurück";
?>
?>

View File

@@ -102,6 +102,8 @@ else {
$forward_busy_enabled = $row["forward_busy_enabled"];
$forward_no_answer_destination = $row["forward_no_answer_destination"];
$forward_no_answer_enabled = $row["forward_no_answer_enabled"];
$forward_user_not_registered_destination = $row["forward_user_not_registered_destination"];
$forward_user_not_registered_enabled = $row["forward_user_not_registered_enabled"];
$follow_me_uuid = $row["follow_me_uuid"];
$forward_caller_id_uuid = $row["forward_caller_id_uuid"];
break; //limit to 1 row
@@ -122,6 +124,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$forward_busy_destination = check_str($_POST["forward_busy_destination"]);
$forward_no_answer_enabled = check_str($_POST["forward_no_answer_enabled"]);
$forward_no_answer_destination = check_str($_POST["forward_no_answer_destination"]);
$forward_user_not_registered_destination = check_str($_POST["forward_user_not_registered_destination"]);
$forward_user_not_registered_enabled = check_str($_POST["forward_user_not_registered_enabled"]);
$forward_caller_id_uuid = check_str($_POST["forward_caller_id_uuid"]);
$cid_name_prefix = check_str($_POST["cid_name_prefix"]);
$cid_number_prefix = check_str($_POST["cid_number_prefix"]);
@@ -371,6 +375,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$sql .= "forward_busy_enabled = '".$forward_busy_enabled."', ";
$sql .= "forward_no_answer_destination = '".$forward_no_answer_destination."', ";
$sql .= "forward_no_answer_enabled = '".$forward_no_answer_enabled."', ";
$sql .= "forward_user_not_registered_destination = '".$forward_user_not_registered_destination."', ";
$sql .= "forward_user_not_registered_enabled = '".$forward_user_not_registered_enabled."', ";
$sql .= "forward_caller_id_uuid = ".(($forward_caller_id_uuid != '') ? "'".$forward_caller_id_uuid."' " : "null ");
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "and extension_uuid = '".$extension_uuid."'";
@@ -596,6 +602,24 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "</td>\n";
echo "</tr>\n";
//CJB
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-not_registered']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
$on_click = "document.getElementById('dnd_disabled').checked=true;";
$on_click .= "document.getElementById('forward_user_not_registered_destination').focus();";
echo " <label for='forward_user_not_registered_disabled'><input type='radio' name='forward_user_not_registered_enabled' id='forward_user_not_registered_disabled' onclick=\"\" value='false' ".(($forward_user_not_registered_enabled == "false" || $forward_user_not_registered_enabled == "") ? "checked='checked'" : null)." /> ".$text['label-disabled']."</label> \n";
echo " <label for='forward_user_not_registered_enabled'><input type='radio' name='forward_user_not_registered_enabled' id='forward_user_not_registered_enabled' onclick=\"$on_click\" value='true' ".(($forward_user_not_registered_enabled == "true") ? "checked='checked'" : null)."/> ".$text['label-enabled']."</label> \n";
unset($on_click);
echo "&nbsp;&nbsp;&nbsp;";
echo " <input class='formfld' type='text' name='forward_user_not_registered_destination' id='forward_user_not_registered_destination' maxlength='255' placeholder=\"".$text['label-destination']."\" value=\"".$forward_user_not_registered_destination."\">\n";
echo " <br />".$text['description-not_registered'].".\n";
echo "</td>\n";
echo "</tr>\n";
//CJB
echo "<tr><td colspan='2'><br /></td></tr>\n";
echo "<tr>\n";
@@ -833,4 +857,4 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//include the footer
require_once "resources/footer.php";
?>
?>

View File

@@ -99,7 +99,11 @@ else {
//prepare to page the results
$rows_per_page = 150;
$param = "";
if ($_GET['showall'] && permission_exists('device_all')) {
$param = "&showall=true";
} else {
$param = "";
}
$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);
@@ -271,4 +275,4 @@ else {
//include the footer
require_once "resources/footer.php";
?>
?>

View File

@@ -12,6 +12,8 @@
<action application="set" data="forward_busy_destination=${user_data ${destination_number}@${domain_name} var forward_busy_destination}"/>
<action application="set" data="forward_no_answer_enabled=${user_data ${destination_number}@${domain_name} var forward_no_answer_enabled}"/>
<action application="set" data="forward_no_answer_destination=${user_data ${destination_number}@${domain_name} var forward_no_answer_destination}"/>
<action application="set" data="forward_user_not_registered_enabled=${user_data ${destination_number}@${domain_name} var forward_user_not_registered_enabled}"/>
<action application="set" data="forward_user_not_registered_destination=${user_data ${destination_number}@${domain_name} var forward_user_not_registered_destination}"/>
<action application="set" data="do_not_disturb=${user_data ${destination_number}@${domain_name} var do_not_disturb}"/>
<action application="set" data="call_timeout=${user_data ${destination_number}@${domain_name} var call_timeout}"/>
<action application="set" data="missed_call_app=${user_data ${destination_number}@${domain_name} var missed_call_app}"/>
@@ -19,4 +21,4 @@
<action application="set" data="call_screen_enabled=${user_data ${destination_number}@${domain_name} var call_screen_enabled}" inline="true"/>
</condition>
</extension>
</context>
</context>

View File

@@ -366,6 +366,14 @@
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "forward_user_not_registered_destination";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "forward_user_not_registered_enabled";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "follow_me_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";

View File

@@ -382,6 +382,13 @@
if (strlen($row['forward_no_answer_destination']) > 0) {
$xml .= " <variable name=\"forward_no_answer_destination\" value=\"" . $row['forward_no_answer_destination'] . "\"/>\n";
}
if (strlen($row['forward_user_not_registered_enabled']) > 0) {
$xml .= " <variable name=\"forward_user_not_registered_enabled\" value=\"" . $row['forward_user_not_registered_enabled'] . "\"/>\n";
}
if (strlen($row['forward_user_not_registered_destination']) > 0) {
$xml .= " <variable name=\"forward_user_not_registered_destination\" value=\"" . $row['forward_user_not_registered_destination'] . "\"/>\n";
}
if (strlen($row['do_not_disturb']) > 0) {
$xml .= " <variable name=\"do_not_disturb\" value=\"" . $row['do_not_disturb'] . "\"/>\n";
}

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

@@ -686,7 +686,108 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo " ".$text['label-fax_send_greeting']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='fax_send_greeting' maxlength='255' value=\"$fax_send_greeting\">\n";
if (permission_exists('fax_extension_add') || permission_exists('fax_extension_edit')) {
echo "<script>\n";
echo "var Objs;\n";
echo "\n";
echo "function changeToInput(obj){\n";
echo " tb=document.createElement('INPUT');\n";
echo " tb.type='text';\n";
echo " tb.name=obj.name;\n";
echo " tb.setAttribute('class', 'formfld');\n";
echo " tb.setAttribute('style', 'width: 350px;');\n";
echo " tb.value=obj.options[obj.selectedIndex].value;\n";
echo " tbb=document.createElement('INPUT');\n";
echo " tbb.setAttribute('class', 'btn');\n";
echo " tbb.setAttribute('style', 'margin-left: 4px;');\n";
echo " tbb.type='button';\n";
echo " tbb.value=$('<div />').html('&#9665;').text();\n";
echo " tbb.objs=[obj,tb,tbb];\n";
echo " tbb.onclick=function(){ Replace(this.objs); }\n";
echo " obj.parentNode.insertBefore(tb,obj);\n";
echo " obj.parentNode.insertBefore(tbb,obj);\n";
echo " obj.parentNode.removeChild(obj);\n";
echo "}\n";
echo "\n";
echo "function Replace(obj){\n";
echo " obj[2].parentNode.insertBefore(obj[0],obj[2]);\n";
echo " obj[0].parentNode.removeChild(obj[1]);\n";
echo " obj[0].parentNode.removeChild(obj[2]);\n";
echo "}\n";
echo "</script>\n";
echo "\n";
}
echo " <select name='fax_send_greeting' class='formfld' ".((permission_exists('fax_extension_add') || permission_exists('fax_extension_edit')) ? "onchange='changeToInput(this);'" : null).">\n";
echo " <option></option>\n";
//recordings
if($dh = opendir($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/")) {
$tmp_selected = false;
$files = Array();
echo "<optgroup label='Recordings'>\n";
while ($file = readdir($dh)) {
if ($file != "." && $file != ".." && $file[0] != '.') {
if (!is_dir($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$file)) {
$selected = ($fax_send_greeting == $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$file && strlen($fax_send_greeting) > 0) ? true : false;
echo " <option value='".$_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$file."' ".(($selected) ? "selected='selected'" : null).">".$file."</option>\n";
if ($selected) { $tmp_selected = true; }
}
}
}
closedir($dh);
echo "</optgroup>\n";
}
//phrases
$sql = "select * from v_phrases where domain_uuid = '".$domain_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
if (count($result) > 0) {
echo "<optgroup label='Phrases'>\n";
foreach ($result as &$row) {
$selected = ($fax_send_greeting == "phrase:".$row["phrase_name"].".".$domain_uuid) ? true : false;
echo " <option value='phrase:".$row["phrase_name"].".".$domain_uuid."' ".(($selected) ? "selected='selected'" : null).">".$row["phrase_name"]."</option>\n";
if ($selected) { $tmp_selected = true; }
}
unset ($prep_statement);
echo "</optgroup>\n";
}
//sounds
$dir_path = $_SESSION['switch']['sounds']['dir'];
recur_sounds_dir($_SESSION['switch']['sounds']['dir']);
if (count($dir_array) > 0) {
echo "<optgroup label='Sounds'>\n";
foreach ($dir_array as $key => $value) {
if (strlen($value) > 0) {
if (substr($fax_send_greeting, 0, 71) == "\$\${sounds_dir}/\${default_language}/\${default_dialect}/\${default_voice}/") {
$fax_send_greeting = substr($fax_send_greeting, 71);
}
$selected = ($fax_send_greeting == $key) ? true : false;
echo " <option value='".$key."' ".(($selected) ? "selected='selected'" : null).">".$key."</option>\n";
if ($selected) { $tmp_selected = true; }
}
}
echo "</optgroup>\n";
}
//select
if (strlen($fax_send_greeting) > 0) {
if (permission_exists('conference_center_add') || permission_exists('conference_center_edit')) {
if (!$tmp_selected) {
echo "<optgroup label='selected'>\n";
if (file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$fax_send_greeting)) {
echo " <option value='".$_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$fax_send_greeting."' selected='selected'>".$ivr_menu_greet_long."</option>\n";
}
else if (substr($fax_send_greeting, -3) == "wav" || substr($fax_send_greeting, -3) == "mp3") {
echo " <option value='".$fax_send_greeting."' selected='selected'>".$fax_send_greeting."</option>\n";
}
else {
echo " <option value='".$fax_send_greeting."' selected='selected'>".$fax_send_greeting."</option>\n";
}
echo "</optgroup>\n";
}
unset($tmp_selected);
}
}
echo " </select>\n";
echo "<br />\n";
echo " ".$text['description-fax_send_greeting']."\n";
echo "</td>\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

View File

@@ -1373,4 +1373,4 @@ $text['button-advanced_search']['uk'] = "";
$text['button-advanced_search']['de-at'] = "Erweiterte Suche";
$text['button-advanced_search']['he'] = "חיפוש מתקדם";
?>
?>

View File

@@ -188,8 +188,25 @@
end
elseif (originate_disposition == "USER_NOT_REGISTERED") then
--handle USER_NOT_REGISTERED
forward_user_not_registered_enabled = session:getVariable("forward_user_not_registered_enabled");
if (forward_user_not_registered_enabled == "true") then
forward_user_not_registered_destination = session:getVariable("forward_user_not_registered_destination");
if (forward_user_not_registered_destination == nil) then
freeswitch.consoleLog("NOTICE", "[failure_handler] forwarding user not registered to hangup\n");
session:hangup("NO_ANSWER");
else
freeswitch.consoleLog("NOTICE", "[failure_handler] forwarding user not registerd to: " .. forward_user_not_registered_destination .. "\n");
session:transfer(forward_user_not_registered_destination, "XML", context);
end
else
--send missed call notification
missed();
end
--send missed call notification
missed();
--missed();
--handle USER_NOT_REGISTERED
if (debug["info"] ) then

View File

@@ -0,0 +1,9 @@
text = text or {};
text['message-send_success'] = {}
text['message-send_success']['en-us'] = "We are happy to report the fax was sent successfully. It has been attached for your records."
text['message-send_fail'] = {}
text['message-send_fail']['en-us'] = "We are sorry the fax failed to go through. It has been attached. Please check the number, and if it was correct you might consider emailing it instead."
return text

View File

@@ -1,6 +1,7 @@
require "resources.functions.config"
require "resources.functions.sleep"
require "resources.functions.file_exists"
local log = require "resources.functions.log".next_fax_task
local Tasks = require "app.fax.resources.scripts.queue.tasks"
local Esl = require "resources.functions.esl"
@@ -13,17 +14,27 @@ local FAX_OPTIONS = {
"fax_use_ecm=false,fax_enable_t38=false,fax_enable_t38_request=false,fax_disable_v17=false";
}
local function task_send_mail(task)
local function task_send_mail(task, err)
local number_dialed = task.uri:match("/([^/]-)%s*$")
Tasks.send_mail_task(task, {
"Fax to: " .. number_dialed .. " FAILED",
table.concat{
"We are sorry the fax failed to go through. ",
"It has been attached. Please check the number " .. number_dialed .. ", ",
"and if it was correct you might consider emailing it instead.",
}}
)
local Text = require "resources.functions.text"
local text = Text.new("app.fax.app_languages")
local env = {
destination_number = number_dialed:match("^([^@]*)");
hangup_cause = err;
message = text['message-send_fail'];
}
local body = Tasks.build_template(task, 'outbound/fail/body', env)
local subject = Tasks.build_template(task, 'outbound/fail/subject', env)
if not subject then
log.warning("Can not find template for email")
subject = "Fax to: " .. number_dialed .. " FAILED"
end
Tasks.send_mail_task(task, {subject, body}, nil, file_exists(task.fax_file))
end
local function next_task()
@@ -56,7 +67,7 @@ local function next_task()
Tasks.wait_task(task, false, info)
if task.status ~= 0 then
Tasks.remove_task(task)
task_send_mail(task)
task_send_mail(task, tostring(info))
end
log.noticef('Can not originate to `%s` cause: %s: %s ', task.uri, tostring(status), tostring(info))
else

View File

@@ -1,8 +1,7 @@
-- include libraries
require "resources.functions.config";
require "resources.functions.explode";
require "resources.functions.split";
require "resources.functions.count";
require "resources.functions.file_exists";
local log = require "resources.functions.log".fax_retry
local Database = require "resources.functions.database"
@@ -28,6 +27,10 @@
local dbh = Database.new('system')
-- Global environment
default_language = env:getHeader("default_language")
default_dialect = env:getHeader("default_dialect")
-- Channel/FusionPBX variables
local uuid = env:getHeader("uuid")
local fax_queue_task_session = env:getHeader('fax_queue_task_session')
@@ -312,18 +315,32 @@
--Success
log.infof("RETRY STATS SUCCESS: GATEWAY[%s]", fax_options);
Tasks.remove_task(task)
local Text = require "resources.functions.text"
local text = Text.new("app.fax.app_languages")
local env = {
fax_options = fax_options;
destination_number = number_dialed:match("^([^@]*)");
document_transferred_pages = fax_document_transferred_pages;
document_total_pages = fax_document_total_pages;
message = text['message-send_success'];
}
local body = Tasks.build_template(task, 'outbound/success/body', env)
local subject = Tasks.build_template(task, 'outbound/success/subject', env)
if not subject then
log.warning("Can not find template for email")
subject = "Fax to: " .. number_dialed .. " SENT"
end
Tasks.send_mail_task(task, {subject, body}, uuid, file_exists(fax_file))
if keep_local == "false" then
os.remove(fax_file);
end
Tasks.remove_task(task)
Tasks.send_mail_task(task, {
"Fax to: " .. number_dialed .. " SENT",
table.concat{
"We are happy to report the fax was sent successfully.",
"It has been attached for your records.",
}}, uuid
)
end
if fax_success ~= "1" then
@@ -345,14 +362,32 @@
Tasks.wait_task(task, answered, hangup_cause_q850)
if task.status ~= 0 then
Tasks.remove_task(task)
Tasks.send_mail_task(task, {
"Fax to: " .. number_dialed .. " FAILED",
table.concat{
"We are sorry the fax failed to go through. ",
"It has been attached. Please check the number "..number_dialed..", ",
"and if it was correct you might consider emailing it instead.",
}}, uuid
)
local Text = require "resources.functions.text"
local text = Text.new("app.fax.app_languages")
local env = {
fax_options = fax_options;
destination_number = number_dialed:match("^([^@]*)");
document_transferred_pages = fax_document_transferred_pages;
document_total_pages = fax_document_total_pages;
hangup_cause = hangup_cause;
hangup_cause_q850 = hangup_cause_q850;
fax_result_code = fax_result_code;
fax_result_text = fax_result_text;
message = text['message-send_fail'];
}
local body = Tasks.build_template(task, 'outbound/fail/body', env)
local subject = Tasks.build_template(task, 'outbound/fail/subject', env)
if not subject then
log.warning("Can not find template for email")
subject = "Fax to: " .. number_dialed .. " FAILED"
end
Tasks.send_mail_task(task, {subject, body}, uuid, file_exists(fax_file))
end
end
end

View File

@@ -203,8 +203,6 @@ local function wait_task(task, answered, q850)
task.uuid
)
print(sql)
local ok, err = db:query( sql )
if not ok then return nil, err end
@@ -245,7 +243,7 @@ local function cleanup_tasks()
db:query(remove_finished_tasks_sql)
end
local function send_mail_task(task, message, call_uuid)
local function send_mail_task(task, message, call_uuid, file)
if not task.reply_address or #task.reply_address == 0 then
return
end
@@ -257,7 +255,61 @@ local function send_mail_task(task, message, call_uuid)
["X-FusionPBX-Email-Type"] = 'email2fax';
}
return send_mail(mail_x_headers, task.reply_address, message)
return send_mail(mail_x_headers, task.reply_address, message, file)
end
local function read_file(name, mode)
local f, err, code = io.open(name, mode or 'rb')
if not f then return nil, err, code end
local data = f:read("*all")
f:close()
return data
end
local function read_template(app, name, lang)
local default_language_path = 'en/us'
local full_path_tpl = scripts_dir .. '/app/' .. app .. '/resources/templates/{lang}/' .. name .. '.tpl'
local path
if lang then
path = file_exists((full_path_tpl:gsub('{lang}', lang)))
end
if (not path) and (lang ~= default_language_path) then
path = file_exists((full_path_tpl:gsub('{lang}', default_language_path)))
end
if path then
return read_file(path)
end
end
local function build_template(task, templ, env)
local lang
if default_language and default_dialect then
lang = (default_language .. '/' .. default_dialect):lower()
else
local settings = Settings.new(get_db(), task.domain_name, task.domain_uuid)
lang = settings:get('domain', 'language', 'code')
if lang then lang = lang:gsub('%-', '/'):lower() end
end
local body = read_template('fax', templ, lang)
body = body:gsub("[^\\](${.-})", function(name)
name = name:sub(3, -2)
if type(env) == 'table' then
return env[name] or ''
end
if type(env) == 'function' then
return env(name) or ''
end
end)
return body
end
return {
@@ -274,4 +326,5 @@ return {
release_task = release_task;
cleanup_tasks = cleanup_tasks;
send_mail_task = send_mail_task;
build_template = build_template;
}

View File

@@ -0,0 +1,51 @@
<html>
<table width="400" border="0" cellspacing="0" cellpadding="0" align="center"
style="border: 1px solid #cbcfd5;-moz-border-radius: 4px;
-webkit-border-radius: 4px; border-radius: 4px;">
<tr>
<td valign="middle" align="center" bgcolor="#ff7174" style="background-color: #ff7174;
color: #000; font-family: Arial; font-size: 14px; padding: 7px;-moz-border-radius: 4px;
-webkit-border-radius: 4px; border-radius: 4px;">
<strong>Send fax fail</strong>
</td>
</tr>
<tr>
<td valign="top" style="padding: 15px;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="color: #333; font-family: Arial; font-size: 12px; padding-bottom: 11px;">
<strong>To</strong>
</td>
<td style="color: #666; font-family: Arial; font-size: 12px; padding-bottom: 11px;">
${destination_number}
</td>
</tr>
<tr>
<td style="color: #333; font-family: Arial; font-size: 12px; padding-bottom: 11px;">
<strong>Pages</strong>
</td>
<td style="color: #666; font-family: Arial; font-size: 12px; padding-bottom: 11px;">
${document_transferred_pages}/${document_total_pages}
</td>
</tr>
<tr>
<td style="color: #333; font-family: Arial; font-size: 12px; padding-bottom: 11px;">
<strong>Message</strong>
</td>
<td style="color: #666; font-family: Arial; font-size: 12px; padding-bottom: 11px;">
${message}
</td>
</tr>
<tr>
<td style="color: #333; font-family: Arial; font-size: 12px; padding-bottom: 11px;">
<strong>Error</strong>
</td>
<td style="color: #666; font-family: Arial; font-size: 12px; padding-bottom: 11px;">
${hangup_cause}/${fax_result_code}/${fax_result_text}
</td>
</tr>
</table>
</td>
</tr>
</table>
</html>

View File

@@ -0,0 +1 @@
Fax to: ${destination_number} FAILED

View File

@@ -0,0 +1,51 @@
<html>
<table width="400" border="0" cellspacing="0" cellpadding="0" align="center"
style="border: 1px solid #cbcfd5;-moz-border-radius: 4px;
-webkit-border-radius: 4px; border-radius: 4px;">
<tr>
<td valign="middle" align="center" bgcolor="#e5e9f0" style="background-color: #e5e9f0;
color: #000; font-family: Arial; font-size: 14px; padding: 7px;-moz-border-radius: 4px;
-webkit-border-radius: 4px; border-radius: 4px;">
<strong>Send fax successfully</strong>
</td>
</tr>
<tr>
<td valign="top" style="padding: 15px;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="color: #333; font-family: Arial; font-size: 12px; padding-bottom: 11px;">
<strong>To</strong>
</td>
<td style="color: #666; font-family: Arial; font-size: 12px; padding-bottom: 11px;">
${destination_number}
</td>
</tr>
<tr>
<td style="color: #333; font-family: Arial; font-size: 12px; padding-bottom: 11px;">
<strong>Pages</strong>
</td>
<td style="color: #666; font-family: Arial; font-size: 12px; padding-bottom: 11px;">
${document_transferred_pages}
</td>
</tr>
<tr>
<td style="color: #333; font-family: Arial; font-size: 12px; padding-bottom: 11px;">
<strong>Message</strong>
</td>
<td style="color: #666; font-family: Arial; font-size: 12px; padding-bottom: 11px;">
${message}
</td>
</tr>
<tr>
<td style="color: #333; font-family: Arial; font-size: 12px; padding-bottom: 11px;">
<strong>Options</strong>
</td>
<td style="color: #666; font-family: Arial; font-size: 12px; padding-bottom: 11px;">
${fax_options}
</td>
</tr>
</table>
</td>
</tr>
</table>
</html>

View File

@@ -0,0 +1 @@
Fax to: ${destination_number} sent

View File

@@ -251,6 +251,9 @@
forward_busy_destination = row.forward_busy_destination;
forward_no_answer_enabled = row.forward_no_answer_enabled;
forward_no_answer_destination = row.forward_no_answer_destination;
forward_user_not_registered_enabled = row.forward_user_not_registered_enabled;
forward_user_not_registered_destination = row.forward_user_not_registered_destination;
do_not_disturb = row.do_not_disturb;
--set the dial_string
@@ -477,6 +480,13 @@
if (string.len(forward_no_answer_destination) > 0) then
table.insert(xml, [[ <variable name="forward_no_answer_destination" value="]] .. forward_no_answer_destination .. [["/>]]);
end
if (string.len(forward_user_not_registered_enabled) > 0) then
table.insert(xml, [[ <variable name="forward_user_not_registered_enabled" value="]] .. forward_user_not_registered_enabled .. [["/>]]);
end
if (string.len(forward_user_not_registered_destination) > 0) then
table.insert(xml, [[ <variable name="forward_user_not_registered_destination" value="]] .. forward_user_not_registered_destination .. [["/>]]);
end
if (string.len(do_not_disturb) > 0) then
table.insert(xml, [[ <variable name="do_not_disturb" value="]] .. do_not_disturb .. [["/>]]);
end

View File

@@ -1,6 +1,8 @@
--check if a file exists
function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
local f = io.open(name, "r")
if not f then return end
f:close()
return name
end