diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/callcenter.conf.lua b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/callcenter.conf.lua index 73463563ef..9806d6a76d 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/callcenter.conf.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/callcenter.conf.lua @@ -44,6 +44,7 @@ --get the variables dsn = trim(api:execute("global_getvar", "dsn")); + dsn_callcenter = trim(api:execute("global_getvar", "dsn_callcenter")); --start the xml array local xml = {} @@ -52,8 +53,12 @@ table.insert(xml, [[
]]); table.insert(xml, [[ ]]); table.insert(xml, [[ ]]); - if (string.len(dsn) > 0) then - table.insert(xml, [[ ]]); + if (dsn_callcenter) then + table.insert(xml, [[ ]]); + else + if (string.len(dsn) > 0) then + table.insert(xml, [[ ]]); + end end --table.insert(xml, [[ ]]); table.insert(xml, [[ ]]); @@ -156,136 +161,136 @@ table.insert(xml, [[ ]]); --get the agents - table.insert(xml, [[ ]]); - sql = "select * from v_call_center_agents as a, v_domains as d "; - sql = sql .. "where d.domain_uuid = a.domain_uuid; "; - if (debug["sql"]) then - freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n"); - end - x = 0; - 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_name = row.agent_name; - agent_type = row.agent_type; - agent_call_timeout = row.agent_call_timeout; - agent_contact = row.agent_contact; - agent_status = row.agent_status; - agent_no_answer_delay_time = row.agent_no_answer_delay_time; - agent_max_no_answer = row.agent_max_no_answer; - agent_wrap_up_time = row.agent_wrap_up_time; - agent_reject_delay_time = row.agent_reject_delay_time; - agent_busy_delay_time = row.agent_busy_delay_time; + table.insert(xml, [[ ]]); + sql = "select * from v_call_center_agents as a, v_domains as d "; + sql = sql .. "where d.domain_uuid = a.domain_uuid; "; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n"); + end + x = 0; + 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_name = row.agent_name; + agent_type = row.agent_type; + agent_call_timeout = row.agent_call_timeout; + agent_contact = row.agent_contact; + agent_status = row.agent_status; + agent_no_answer_delay_time = row.agent_no_answer_delay_time; + agent_max_no_answer = row.agent_max_no_answer; + agent_wrap_up_time = row.agent_wrap_up_time; + agent_reject_delay_time = row.agent_reject_delay_time; + agent_busy_delay_time = row.agent_busy_delay_time; - --get and then set the complete agent_contact with the call_timeout and when necessary confirm - --confirm = "group_confirm_file=custom/press_1_to_accept_this_call.wav,group_confirm_key=1"; - --if you change this variable also change app/call_center/call_center_agent_edit.php - confirm = "group_confirm_file=custom/press_1_to_accept_this_call.wav,group_confirm_key=1,group_confirm_read_timeout=2000,leg_timeout="..agent_call_timeout; - if (string.find(agent_contact, '}') == nil) then + --get and then set the complete agent_contact with the call_timeout and when necessary confirm + --confirm = "group_confirm_file=custom/press_1_to_accept_this_call.wav,group_confirm_key=1"; + --if you change this variable also change app/call_center/call_center_agent_edit.php + confirm = "group_confirm_file=custom/press_1_to_accept_this_call.wav,group_confirm_key=1,group_confirm_read_timeout=2000,leg_timeout="..agent_call_timeout; + if (string.find(agent_contact, '}') == nil) then + --not found + if (string.find(agent_contact, 'sofia/gateway') == nil) then + --add the call_timeout + agent_contact = "{call_timeout="..agent_call_timeout.."}"..agent_contact; + else + --add the call_timeout and confirm + tmp_pos = string.find(agent_contact, "}"); + tmp_first = string.sub(agent_contact, 0, tmp_pos); + tmp_last = string.sub(agent_contact, tmp_pos); + agent_contact = tmp_first..',call_timeout='..agent_call_timeout..tmp_last; + agent_contact = "{"..confirm..",call_timeout="..agent_call_timeout.."}"..agent_contact; + end + else + --found + if (string.find(agent_contact, 'sofia/gateway') == nil) then --not found - if (string.find(agent_contact, 'sofia/gateway') == nil) then - --add the call_timeout - agent_contact = "{call_timeout="..agent_call_timeout.."}"..agent_contact; + if (string.find(agent_contact, 'call_timeout') == nil) then + --add the call_timeout + pos = string.find(agent_contact, "}"); + first = string.sub(agent_contact, 0, pos); + last = string.sub(agent_contact, tmp_pos); + agent_contact = first..[[,call_timeout=]]..agent_call_timeout..last; else - --add the call_timeout and confirm - tmp_pos = string.find(agent_contact, "}"); - tmp_first = string.sub(agent_contact, 0, tmp_pos); - tmp_last = string.sub(agent_contact, tmp_pos); - agent_contact = tmp_first..',call_timeout='..agent_call_timeout..tmp_last; - agent_contact = "{"..confirm..",call_timeout="..agent_call_timeout.."}"..agent_contact; + --the string has the call timeout + agent_contact = agent_contact; end else --found - if (string.find(agent_contact, 'sofia/gateway') == nil) then - --not found - if (string.find(agent_contact, 'call_timeout') == nil) then - --add the call_timeout - pos = string.find(agent_contact, "}"); - first = string.sub(agent_contact, 0, pos); - last = string.sub(agent_contact, tmp_pos); - agent_contact = first..[[,call_timeout=]]..agent_call_timeout..last; - else - --the string has the call timeout - agent_contact = agent_contact; - end + pos = string.find(agent_contact, "}"); + first = string.sub(agent_contact, 0, pos); + last = string.sub(agent_contact, pos); + if (stristr(agent_contact, 'call_timeout') == FALSE) then + --add the call_timeout and confirm + agent_contact = first..','..confirm..',call_timeout='..agent_call_timeout..last; else - --found - pos = string.find(agent_contact, "}"); - first = string.sub(agent_contact, 0, pos); - last = string.sub(agent_contact, pos); - if (stristr(agent_contact, 'call_timeout') == FALSE) then - --add the call_timeout and confirm - agent_contact = first..','..confirm..',call_timeout='..agent_call_timeout..last; - else - --add confirm - agent_contact = tmp_first..','..confirm..tmp_last; - end + --add confirm + agent_contact = tmp_first..','..confirm..tmp_last; end end + end - --build the xml string - table.insert(xml, [[ ]]); - end) - table.insert(xml, [[ ]]); + --build the xml string + table.insert(xml, [[ ]]); + end) + table.insert(xml, [[ ]]); --get the tiers - sql = "select * from v_call_center_tiers as t, v_domains as d "; - sql = sql .. "where d.domain_uuid = t.domain_uuid; "; - if (debug["sql"]) then - freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n"); - end - table.insert(xml, [[ ]]); - 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_name = row.agent_name; - queue_name = row.queue_name; - tier_level = row.tier_level; - tier_position = row.tier_position; - --build the xml - table.insert(xml, [[ ]]); - end) - table.insert(xml, [[ ]]); + sql = "select * from v_call_center_tiers as t, v_domains as d "; + sql = sql .. "where d.domain_uuid = t.domain_uuid; "; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n"); + end + table.insert(xml, [[ ]]); + 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_name = row.agent_name; + queue_name = row.queue_name; + tier_level = row.tier_level; + tier_position = row.tier_position; + --build the xml + table.insert(xml, [[ ]]); + end) + table.insert(xml, [[ ]]); --close the extension tag if it was left open - table.insert(xml, [[ ]]); - table.insert(xml, [[
]]); - table.insert(xml, [[]]); - XML_STRING = table.concat(xml, "\n"); - if (debug["xml_string"]) then - freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n"); - end + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[]]); + XML_STRING = table.concat(xml, "\n"); + if (debug["xml_string"]) then + freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n"); + end --close the database connection - dbh:release(); - --freeswitch.consoleLog("notice", "[xml_handler]"..api:execute("eval ${dsn}")); + dbh:release(); + --freeswitch.consoleLog("notice", "[xml_handler]"..api:execute("eval ${dsn}")); --set the cache result = trim(api:execute("memcache", "set configuration:callcenter.conf:" .. hostname .." '"..XML_STRING:gsub("'", "'").."' ".."expire['callcenter.conf']"));