\n";
diff --git a/app/fax/fax_send.php b/app/fax/fax_send.php
index b016ba0bfd..35b17e5a2b 100644
--- a/app/fax/fax_send.php
+++ b/app/fax/fax_send.php
@@ -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;
}
diff --git a/app/fax/resources/images/refresh_active.gif b/app/fax/resources/images/refresh_active.gif
new file mode 100644
index 0000000000..305457831c
Binary files /dev/null and b/app/fax/resources/images/refresh_active.gif differ
diff --git a/app/fax/resources/images/refresh_paused.png b/app/fax/resources/images/refresh_paused.png
new file mode 100644
index 0000000000..38937ec1f2
Binary files /dev/null and b/app/fax/resources/images/refresh_paused.png differ
diff --git a/app/xml_cdr/app_languages.php b/app/xml_cdr/app_languages.php
index 1e57575810..4041b12921 100644
--- a/app/xml_cdr/app_languages.php
+++ b/app/xml_cdr/app_languages.php
@@ -1373,4 +1373,4 @@ $text['button-advanced_search']['uk'] = "";
$text['button-advanced_search']['de-at'] = "Erweiterte Suche";
$text['button-advanced_search']['he'] = "חיפוש מתקדם";
-?>
\ No newline at end of file
+?>
diff --git a/resources/install/scripts/app/failure_handler/index.lua b/resources/install/scripts/app/failure_handler/index.lua
index 72410b3ddf..31883bd231 100644
--- a/resources/install/scripts/app/failure_handler/index.lua
+++ b/resources/install/scripts/app/failure_handler/index.lua
@@ -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
diff --git a/resources/install/scripts/app/fax/app_languages.lua b/resources/install/scripts/app/fax/app_languages.lua
new file mode 100644
index 0000000000..7983512b77
--- /dev/null
+++ b/resources/install/scripts/app/fax/app_languages.lua
@@ -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
\ No newline at end of file
diff --git a/resources/install/scripts/app/fax/resources/scripts/queue/next.lua b/resources/install/scripts/app/fax/resources/scripts/queue/next.lua
index 4780867a1d..874171cca7 100644
--- a/resources/install/scripts/app/fax/resources/scripts/queue/next.lua
+++ b/resources/install/scripts/app/fax/resources/scripts/queue/next.lua
@@ -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
diff --git a/resources/install/scripts/app/fax/resources/scripts/queue/retry.lua b/resources/install/scripts/app/fax/resources/scripts/queue/retry.lua
index 1d634ea725..3cc20dbf43 100644
--- a/resources/install/scripts/app/fax/resources/scripts/queue/retry.lua
+++ b/resources/install/scripts/app/fax/resources/scripts/queue/retry.lua
@@ -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
diff --git a/resources/install/scripts/app/fax/resources/scripts/queue/tasks.lua b/resources/install/scripts/app/fax/resources/scripts/queue/tasks.lua
index e6ba83835f..6e78bffccb 100644
--- a/resources/install/scripts/app/fax/resources/scripts/queue/tasks.lua
+++ b/resources/install/scripts/app/fax/resources/scripts/queue/tasks.lua
@@ -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;
}
diff --git a/resources/install/scripts/app/fax/resources/templates/en/us/outbound/fail/body.tpl b/resources/install/scripts/app/fax/resources/templates/en/us/outbound/fail/body.tpl
new file mode 100644
index 0000000000..0a74af6208
--- /dev/null
+++ b/resources/install/scripts/app/fax/resources/templates/en/us/outbound/fail/body.tpl
@@ -0,0 +1,51 @@
+
+
+
\ No newline at end of file
diff --git a/resources/install/scripts/app/fax/resources/templates/en/us/outbound/fail/subject.tpl b/resources/install/scripts/app/fax/resources/templates/en/us/outbound/fail/subject.tpl
new file mode 100644
index 0000000000..0b4efa53ac
--- /dev/null
+++ b/resources/install/scripts/app/fax/resources/templates/en/us/outbound/fail/subject.tpl
@@ -0,0 +1 @@
+Fax to: ${destination_number} FAILED
\ No newline at end of file
diff --git a/resources/install/scripts/app/fax/resources/templates/en/us/outbound/success/body.tpl b/resources/install/scripts/app/fax/resources/templates/en/us/outbound/success/body.tpl
new file mode 100644
index 0000000000..073e4c6db6
--- /dev/null
+++ b/resources/install/scripts/app/fax/resources/templates/en/us/outbound/success/body.tpl
@@ -0,0 +1,51 @@
+
+
+
+
+ Send fax successfully
+
+
+
+
+
+
+
+ To
+
+
+ ${destination_number}
+
+
+
+
+ Pages
+
+
+ ${document_transferred_pages}
+
+
+
+
+ Message
+
+
+ ${message}
+
+
+
+
+ Options
+
+
+ ${fax_options}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/resources/install/scripts/app/fax/resources/templates/en/us/outbound/success/subject.tpl b/resources/install/scripts/app/fax/resources/templates/en/us/outbound/success/subject.tpl
new file mode 100644
index 0000000000..a1e835ddd1
--- /dev/null
+++ b/resources/install/scripts/app/fax/resources/templates/en/us/outbound/success/subject.tpl
@@ -0,0 +1 @@
+Fax to: ${destination_number} sent
\ No newline at end of file
diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua b/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua
index 325a2685e5..88ec1808ca 100644
--- a/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua
+++ b/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua
@@ -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, [[ ]]);
end
+ if (string.len(forward_user_not_registered_enabled) > 0) then
+ table.insert(xml, [[ ]]);
+ end
+ if (string.len(forward_user_not_registered_destination) > 0) then
+ table.insert(xml, [[ ]]);
+ end
+
if (string.len(do_not_disturb) > 0) then
table.insert(xml, [[ ]]);
end
diff --git a/resources/install/scripts/resources/functions/file_exists.lua b/resources/install/scripts/resources/functions/file_exists.lua
index 76a31c5126..aece58bd5f 100644
--- a/resources/install/scripts/resources/functions/file_exists.lua
+++ b/resources/install/scripts/resources/functions/file_exists.lua
@@ -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
\ No newline at end of file