Add call_center queue_login options: dynamic or static (default)
This commit is contained in:
parent
cb5fbc68b1
commit
edb0180bcf
|
|
@ -189,6 +189,14 @@
|
||||||
$apps[$x]['default_settings'][$y]['default_setting_value'] = "1500";
|
$apps[$x]['default_settings'][$y]['default_setting_value'] = "1500";
|
||||||
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
|
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
|
||||||
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Set the refresh rate in seconds (<=120) or milliseconds (>=500).";
|
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Set the refresh rate in seconds (<=120) or milliseconds (>=500).";
|
||||||
|
$y++;
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "ca34cbc0-e071-432e-afd6-b587aa52bd85";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_category'] = "call_center";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "queue_login";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_name'] = "text";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_value'] = "static";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
|
||||||
|
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Agent queue login options: dynamic, static";
|
||||||
|
|
||||||
//cache details
|
//cache details
|
||||||
$apps[$x]['cache']['key'] = "dialplan.\${domain_name}";
|
$apps[$x]['cache']['key'] = "dialplan.\${domain_name}";
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||||
$database = new database;
|
$database = new database;
|
||||||
$tiers = $database->select($sql, $parameters, 'all');
|
$tiers = $database->select($sql, $parameters, 'all');
|
||||||
if (empty($tiers)) {
|
if (!empty($_SESSION['call_center']['queue_login']['text']) && $_SESSION['call_center']['queue_login']['text'] == 'dynamic') {
|
||||||
$per_queue_login = true;
|
$per_queue_login = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -358,6 +358,7 @@
|
||||||
echo " <th class='pct-20 hide-sm-dn'> </th>\n";
|
echo " <th class='pct-20 hide-sm-dn'> </th>\n";
|
||||||
if ($per_queue_login) {
|
if ($per_queue_login) {
|
||||||
echo " <th class='pct-40'>".$text['label-options']."</th>\n";
|
echo " <th class='pct-40'>".$text['label-options']."</th>\n";
|
||||||
|
echo " <th class='pct-40' style='width=50%;'> </th>\n";
|
||||||
}
|
}
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
|
|
||||||
|
|
@ -366,7 +367,7 @@
|
||||||
foreach ($agents as $row) {
|
foreach ($agents as $row) {
|
||||||
$onclick = "onclick=\"cycle('agents[".$x."][agent_status]');\"";
|
$onclick = "onclick=\"cycle('agents[".$x."][agent_status]');\"";
|
||||||
$html = "<tr class='list-row'>\n";
|
$html = "<tr class='list-row'>\n";
|
||||||
$html .= " <td ".$onclick.">".escape($row['agent_name'])." </td>\n";
|
$html .= " <td style='vertical-align: top;' ".$onclick.">".escape($row['agent_name'])." </td>\n";
|
||||||
|
|
||||||
if (!$per_queue_login) {
|
if (!$per_queue_login) {
|
||||||
$html .= " <td class='no-wrap'>";
|
$html .= " <td class='no-wrap'>";
|
||||||
|
|
@ -381,7 +382,7 @@
|
||||||
$html .= " <td ".$onclick." class='hide-sm-dn'> </td>\n";
|
$html .= " <td ".$onclick." class='hide-sm-dn'> </td>\n";
|
||||||
|
|
||||||
if ($per_queue_login) {
|
if ($per_queue_login) {
|
||||||
$html .= " <td class='description'>";
|
$html .= " <td class='description' style='width: 30%;'>";
|
||||||
if (!empty($row['queues'])) {
|
if (!empty($row['queues'])) {
|
||||||
$html .= " <table class='list' >\n";
|
$html .= " <table class='list' >\n";
|
||||||
$html .= " <tr>\n";
|
$html .= " <tr>\n";
|
||||||
|
|
@ -410,7 +411,8 @@
|
||||||
$html .= " <input type='hidden' name='agents[".$x."][queue_uuid]' value='".escape($queue['call_center_queue_uuid'])."'>\n";
|
$html .= " <input type='hidden' name='agents[".$x."][queue_uuid]' value='".escape($queue['call_center_queue_uuid'])."'>\n";
|
||||||
$html .= " <input type='hidden' name='agents[".$x."][agent_uuid]' value='".escape($row['call_center_agent_uuid'])."'>\n";
|
$html .= " <input type='hidden' name='agents[".$x."][agent_uuid]' value='".escape($row['call_center_agent_uuid'])."'>\n";
|
||||||
$html .= " <label style='margin: 0; cursor: pointer; margin-right: 10px;'><input type='radio' name='agents[".$x."][agent_status]' value='Available' ".($queue['queue_status'] == 'Available' ? "checked='checked'" : null)."> ".$text['option-available']."</label> \n";
|
$html .= " <label style='margin: 0; cursor: pointer; margin-right: 10px;'><input type='radio' name='agents[".$x."][agent_status]' value='Available' ".($queue['queue_status'] == 'Available' ? "checked='checked'" : null)."> ".$text['option-available']."</label> \n";
|
||||||
$html .= " <label style='margin: 0; cursor: pointer;'><input type='radio' name='agents[".$x."][agent_status]' value='Logged Out' ".($queue['queue_status'] == 'Logged Out' ? "checked='checked'" : null)."> ".$text['option-logged_out']."</label>\n";
|
$html .= " <label style='margin: 0; cursor: pointer; margin-right: 10px;'><input type='radio' name='agents[".$x."][agent_status]' value='Logged Out' ".($queue['queue_status'] == 'Logged Out' ? "checked='checked'" : null)."> ".$text['option-logged_out']."</label>\n";
|
||||||
|
//$html .= " <label style='margin: 0; cursor: pointer;'><input type='radio' name='agents[".$x."][agent_status]' value='On Break' ".($queue['queue_status'] == 'On Break' ? "checked='checked'" : null)."> ".$text['option-on_break']."</label>\n";
|
||||||
$html .= " </td>\n";
|
$html .= " </td>\n";
|
||||||
$html .= " </tr>\n";
|
$html .= " </tr>\n";
|
||||||
}
|
}
|
||||||
|
|
@ -418,6 +420,7 @@
|
||||||
$html .= " </table>\n";
|
$html .= " </table>\n";
|
||||||
}
|
}
|
||||||
$html .= " </td>\n";
|
$html .= " </td>\n";
|
||||||
|
$html .= " <td> </td>\n";
|
||||||
}
|
}
|
||||||
$html .= "</tr>\n";
|
$html .= "</tr>\n";
|
||||||
if (count($_SESSION['domains']) > 1) {
|
if (count($_SESSION['domains']) > 1) {
|
||||||
|
|
|
||||||
|
|
@ -127,15 +127,6 @@
|
||||||
$event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd));
|
$event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd));
|
||||||
$call_center_tiers = csv_to_named_array($event_socket_str, '|');
|
$call_center_tiers = csv_to_named_array($event_socket_str, '|');
|
||||||
|
|
||||||
//get the call center queues from the database
|
|
||||||
$sql = "select * from v_call_center_queues ";
|
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
|
||||||
$sql .= "order by queue_extension asc ";
|
|
||||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
|
||||||
$call_center_queues = $database->select($sql, $parameters, 'all');
|
|
||||||
$num_rows = !is_array($call_center_queues) ? 0 : @sizeof($call_center_queues);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
|
|
||||||
//get the agents from the database
|
//get the agents from the database
|
||||||
$sql = "select * from v_call_center_agents ";
|
$sql = "select * from v_call_center_agents ";
|
||||||
$sql .= "where user_uuid = :user_uuid ";
|
$sql .= "where user_uuid = :user_uuid ";
|
||||||
|
|
@ -148,6 +139,22 @@
|
||||||
}
|
}
|
||||||
unset($sql, $parameters);
|
unset($sql, $parameters);
|
||||||
|
|
||||||
|
//get the call center queues from the database
|
||||||
|
if (!empty($_SESSION['call_center']['queue_login']['text']) && $_SESSION['call_center']['queue_login']['text'] == 'dynamic') {
|
||||||
|
$sql = "select * from v_call_center_queues ";
|
||||||
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
|
$sql .= "and call_center_queue_uuid in ( ";
|
||||||
|
$sql .= " select call_center_queue_uuid from v_call_center_tiers ";
|
||||||
|
$sql .= " where call_center_agent_uuid = :call_center_agent_uuid ";
|
||||||
|
$sql .= ") ";
|
||||||
|
$parameters['call_center_agent_uuid'] = $agent['call_center_agent_uuid'];
|
||||||
|
$sql .= "order by queue_extension asc ";
|
||||||
|
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||||
|
$call_center_queues = $database->select($sql, $parameters, 'all');
|
||||||
|
$num_rows = !is_array($call_center_queues) ? 0 : @sizeof($call_center_queues);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
//get the agent details from event socket
|
//get the agent details from event socket
|
||||||
$switch_cmd = 'callcenter_config agent list '.$agent['call_center_agent_uuid'];
|
$switch_cmd = 'callcenter_config agent list '.$agent['call_center_agent_uuid'];
|
||||||
$event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd));
|
$event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd));
|
||||||
|
|
@ -158,14 +165,16 @@
|
||||||
|
|
||||||
//update the queue status
|
//update the queue status
|
||||||
$x = 0;
|
$x = 0;
|
||||||
foreach ($call_center_queues as $queue) {
|
if (is_array($call_center_queues)) {
|
||||||
$call_center_queues[$x]['queue_status'] = 'Logged Out';
|
foreach ($call_center_queues as $queue) {
|
||||||
foreach ($call_center_tiers as $tier) {
|
$call_center_queues[$x]['queue_status'] = 'Logged Out';
|
||||||
if ($queue['queue_extension'] .'@'. $_SESSION['user']['domain_name'] == $tier['queue'] && $agent['call_center_agent_uuid'] == $tier['agent']) {
|
foreach ($call_center_tiers as $tier) {
|
||||||
$call_center_queues[$x]['queue_status'] = $agent['agent_status'];
|
if ($queue['queue_extension'] .'@'. $_SESSION['user']['domain_name'] == $tier['queue'] && $agent['call_center_agent_uuid'] == $tier['agent']) {
|
||||||
|
$call_center_queues[$x]['queue_status'] = $agent['agent_status'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$x++;
|
||||||
}
|
}
|
||||||
$x++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//includes the header
|
//includes the header
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
-- xml_handler.lua
|
-- xml_handler.lua
|
||||||
-- Part of FusionPBX
|
-- Part of FusionPBX
|
||||||
-- Copyright (C) 2015-2022 Mark J Crane <markjcrane@fusionpbx.com>
|
-- Copyright (C) 2015-2023 Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
-- All rights reserved.
|
-- All rights reserved.
|
||||||
--
|
--
|
||||||
-- Redistribution and use in source and binary forms, with or without
|
-- Redistribution and use in source and binary forms, with or without
|
||||||
|
|
@ -25,11 +25,29 @@
|
||||||
-- POSSIBILITY OF SUCH DAMAGE.
|
-- POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
--include functions
|
--include functions
|
||||||
require "resources.functions.format_ringback"
|
require "resources.functions.format_ringback"
|
||||||
|
|
||||||
--include xml library
|
--include xml library
|
||||||
local Xml = require "resources.functions.xml";
|
local Xml = require "resources.functions.xml";
|
||||||
|
|
||||||
|
--connect to the database
|
||||||
|
local Database = require "resources.functions.database";
|
||||||
|
dbh = Database.new('system');
|
||||||
|
|
||||||
|
--include settings library
|
||||||
|
local Settings = require "resources.functions.lazy_settings"
|
||||||
|
|
||||||
|
--create the settings object
|
||||||
|
local settings = Settings.new(dbh, domain_name, domain_uuid);
|
||||||
|
|
||||||
|
--check queue
|
||||||
|
queue_login = settings:get('call_center', 'queue_login', 'text');
|
||||||
|
if (queue_login ~= nil and queue_login == 'dynamic') then
|
||||||
|
per_queue_login = true;
|
||||||
|
else
|
||||||
|
per_queue_login = false;
|
||||||
|
end
|
||||||
|
|
||||||
--get the cache
|
--get the cache
|
||||||
local cache = require "resources.functions.cache"
|
local cache = require "resources.functions.cache"
|
||||||
hostname = trim(api:execute("switchname", ""));
|
hostname = trim(api:execute("switchname", ""));
|
||||||
|
|
@ -43,10 +61,6 @@
|
||||||
freeswitch.consoleLog("warning", "[xml_handler] " .. cc_cache_key .. " can not be get from the cache: " .. tostring(err) .. "\n");
|
freeswitch.consoleLog("warning", "[xml_handler] " .. cc_cache_key .. " can not be get from the cache: " .. tostring(err) .. "\n");
|
||||||
end
|
end
|
||||||
|
|
||||||
--connect to the database
|
|
||||||
local Database = require "resources.functions.database";
|
|
||||||
dbh = Database.new('system');
|
|
||||||
|
|
||||||
--exits the script if we didn't connect properly
|
--exits the script if we didn't connect properly
|
||||||
assert(dbh:connected());
|
assert(dbh:connected());
|
||||||
|
|
||||||
|
|
@ -278,35 +292,37 @@
|
||||||
xml:append([[ </agents>]]);
|
xml:append([[ </agents>]]);
|
||||||
|
|
||||||
--get the tiers
|
--get the tiers
|
||||||
sql = "select t.domain_uuid, d.domain_name, t.call_center_agent_uuid, t.call_center_queue_uuid, q.queue_extension, t.tier_level, t.tier_position ";
|
if (not per_queue_login) then
|
||||||
sql = sql .. "from v_call_center_tiers as t, v_domains as d, v_call_center_queues as q ";
|
sql = "select t.domain_uuid, d.domain_name, t.call_center_agent_uuid, t.call_center_queue_uuid, q.queue_extension, t.tier_level, t.tier_position ";
|
||||||
sql = sql .. "where d.domain_uuid = t.domain_uuid ";
|
sql = sql .. "from v_call_center_tiers as t, v_domains as d, v_call_center_queues as q ";
|
||||||
sql = sql .. "and t.call_center_queue_uuid = q.call_center_queue_uuid; ";
|
sql = sql .. "where d.domain_uuid = t.domain_uuid ";
|
||||||
if (debug["sql"]) then
|
sql = sql .. "and t.call_center_queue_uuid = q.call_center_queue_uuid; ";
|
||||||
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
|
if (debug["sql"]) then
|
||||||
|
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
|
||||||
|
end
|
||||||
|
xml:append([[ <tiers>]]);
|
||||||
|
dbh:query(sql, function(row)
|
||||||
|
--get the values from the database and set as variables
|
||||||
|
domain_uuid = row.domain_uuid;
|
||||||
|
domain_name = row.domain_name;
|
||||||
|
agent_uuid = row.call_center_agent_uuid;
|
||||||
|
queue_uuid = row.call_center_queue_uuid;
|
||||||
|
queue_extension = row.queue_extension;
|
||||||
|
tier_level = row.tier_level;
|
||||||
|
tier_position = row.tier_position;
|
||||||
|
--build the xml
|
||||||
|
xml:append([[ <tier ]]);
|
||||||
|
xml:append([[ agent="]] .. xml.sanitize(agent_uuid) .. [[" ]]);
|
||||||
|
xml:append([[ queue="]] .. xml.sanitize(queue_extension) .. [[@]] .. xml.sanitize(domain_name) .. [[" ]]);
|
||||||
|
xml:append([[ domain_name="]] .. xml.sanitize(domain_name) .. [[" ]]);
|
||||||
|
--xml:append([[ agent_name="]] .. xml.sanitize(agent_name) .. [[" ]]);
|
||||||
|
--xml:append([[ queue_name="]] .. xml.sanitize(queue_name) .. [[" ]]);
|
||||||
|
xml:append([[ level="]] .. xml.sanitize(tier_level) .. [[" ]]);
|
||||||
|
xml:append([[ position="]] .. xml.sanitize(tier_position) .. [[" ]]);
|
||||||
|
xml:append([[ />]]);
|
||||||
|
end)
|
||||||
|
xml:append([[ </tiers>]]);
|
||||||
end
|
end
|
||||||
xml:append([[ <tiers>]]);
|
|
||||||
dbh:query(sql, function(row)
|
|
||||||
--get the values from the database and set as variables
|
|
||||||
domain_uuid = row.domain_uuid;
|
|
||||||
domain_name = row.domain_name;
|
|
||||||
agent_uuid = row.call_center_agent_uuid;
|
|
||||||
queue_uuid = row.call_center_queue_uuid;
|
|
||||||
queue_extension = row.queue_extension;
|
|
||||||
tier_level = row.tier_level;
|
|
||||||
tier_position = row.tier_position;
|
|
||||||
--build the xml
|
|
||||||
xml:append([[ <tier ]]);
|
|
||||||
xml:append([[ agent="]] .. xml.sanitize(agent_uuid) .. [[" ]]);
|
|
||||||
xml:append([[ queue="]] .. xml.sanitize(queue_extension) .. [[@]] .. xml.sanitize(domain_name) .. [[" ]]);
|
|
||||||
xml:append([[ domain_name="]] .. xml.sanitize(domain_name) .. [[" ]]);
|
|
||||||
--xml:append([[ agent_name="]] .. xml.sanitize(agent_name) .. [[" ]]);
|
|
||||||
--xml:append([[ queue_name="]] .. xml.sanitize(queue_name) .. [[" ]]);
|
|
||||||
xml:append([[ level="]] .. xml.sanitize(tier_level) .. [[" ]]);
|
|
||||||
xml:append([[ position="]] .. xml.sanitize(tier_position) .. [[" ]]);
|
|
||||||
xml:append([[ />]]);
|
|
||||||
end)
|
|
||||||
xml:append([[ </tiers>]]);
|
|
||||||
|
|
||||||
--close the extension tag if it was left open
|
--close the extension tag if it was left open
|
||||||
xml:append([[ </configuration>]]);
|
xml:append([[ </configuration>]]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue