Added many input variable declarations to admin.php for PHP8
Added agent_ingroup_availability API function git-svn-id: svn://192.168.202.10@4014 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2026-05-19
|
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2026-08-22
|
||||||
|
|
||||||
This document describes the functions of an API(Application Programming
|
This document describes the functions of an API(Application Programming
|
||||||
Interface) for all functions NOT directly relating to the VICIDIAL Agent screen.
|
Interface) for all functions NOT directly relating to the VICIDIAL Agent screen.
|
||||||
@@ -22,6 +22,7 @@ add_lead - adds a new lead to the vicidial_list table with several fields and op
|
|||||||
update_lead - updates lead information in vicidial_list and associated custom table
|
update_lead - updates lead information in vicidial_list and associated custom table
|
||||||
batch_update_lead - updates multiple leads in vicidial_list with single set of field values (limited field options)
|
batch_update_lead - updates multiple leads in vicidial_list with single set of field values (limited field options)
|
||||||
agent_ingroup_info - shows in-group and outbound auto-dial info for logged-in agent
|
agent_ingroup_info - shows in-group and outbound auto-dial info for logged-in agent
|
||||||
|
agent_ingroup_availability - shows a total count of agents available to take calls in selected ingroups
|
||||||
recording_lookup - looks up recordings based upon user and date or lead_id
|
recording_lookup - looks up recordings based upon user and date or lead_id
|
||||||
did_log_export - exports all calls inbound to a DID for one day
|
did_log_export - exports all calls inbound to a DID for one day
|
||||||
agent_stats_export - exports agent statistics for set time period
|
agent_stats_export - exports agent statistics for set time period
|
||||||
@@ -235,6 +236,7 @@ Changes:
|
|||||||
260123-1020 - pause_sec fix in agent_stats_export
|
260123-1020 - pause_sec fix in agent_stats_export
|
||||||
260506-1525 - small fix for campaign changes
|
260506-1525 - small fix for campaign changes
|
||||||
260519-1647 - Code updates for PHP8 compatibility, and json output format
|
260519-1647 - Code updates for PHP8 compatibility, and json output format
|
||||||
|
260822-0841 - Added agent_ingroup_availability function
|
||||||
|
|
||||||
|
|
||||||
API Functions use the 'function' variable
|
API Functions use the 'function' variable
|
||||||
@@ -388,6 +390,58 @@ ERROR: agent_ingroup_info INVALID USER ID - 1255|6666
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
agent_ingroup_availability - shows a total count of agents available to take calls in selected ingroups,
|
||||||
|
and also a per-ingroup count of the agents currently available to take calls
|
||||||
|
|
||||||
|
NOTE: api user for this function must have user_level set to 8 or higher and "View Reports" enabled
|
||||||
|
|
||||||
|
REQUIRED FIELDS-
|
||||||
|
source - description of what originated the API call (maximum 20 characters)
|
||||||
|
in_groups - comma-delimited list of ingroups to return counts on
|
||||||
|
queue_groups - comma-delimited list of queue_groups to query for ingroups to return counts on
|
||||||
|
* Either in_groups or queue_groups are required. Both can be used, but only one of the two is required
|
||||||
|
|
||||||
|
OPTIONAL FIELDS-
|
||||||
|
display_field - By default the ingroup breakdown will use the group_id from the vicidial_inbound_groups table as the key values
|
||||||
|
If you set "display_field" to another column in the vicidial_inbound_groups table, the value from that column will
|
||||||
|
be used instead, if there is a value. If there is no value (or the column doesn't exist) the group_id will be used by default.
|
||||||
|
stage - Set to "json" to return data in JSON format, otherwise the results will be comma-delimited
|
||||||
|
summary_name - When returning results in JSON format, you can set this value to define a key name for the value of total agents available. Default is "availableCount"
|
||||||
|
ingroup_set_name - When returning results in JSON format, you can set this value to define a key name for the array containing the ingroup count breakdown. Default is "states"
|
||||||
|
|
||||||
|
Example URL strings for API calls:
|
||||||
|
http://server/vicidial/non_agent_api.php?user=6666&pass=1234&source=test&function=agent_ingroup_availability&in_groups=INGROUP1,INGROUP2,INGROUP3
|
||||||
|
http://server/vicidial/non_agent_api.php?user=6666&pass=1234&source=test&function=agent_ingroup_availability&queue_groups=QUEUEGRP1,QUEUEGRP2&display_field=custom_five&stage=JSON&ingroup_set_name=INGROUPS
|
||||||
|
|
||||||
|
|
||||||
|
Example responses:
|
||||||
|
ERROR: agent_ingroup_availability USER DOES NOT HAVE PERMISSION TO GET AGENT INFO - 6666|0
|
||||||
|
ERROR: NO INGROUPS DEFINED
|
||||||
|
ERROR: NO INGROUPS FOUND
|
||||||
|
|
||||||
|
Successful responses:
|
||||||
|
|
||||||
|
Successful CSV response:
|
||||||
|
GROUP,AVAILABLE COUNT
|
||||||
|
AGENTS,5
|
||||||
|
INGROUP1,5
|
||||||
|
INGROUP2,2
|
||||||
|
INGROUP3,0
|
||||||
|
|
||||||
|
Successful JSON response, using "INGROUPS" as the ingroup_set_name:
|
||||||
|
{"availableCount": 5,
|
||||||
|
"INGROUPS": {
|
||||||
|
"INGROUP1": 5,
|
||||||
|
"INGROUP2": 3,
|
||||||
|
"INGROUP3": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
agent_campaigns - looks up allowed campaigns/in-groups for a specific user
|
agent_campaigns - looks up allowed campaigns/in-groups for a specific user
|
||||||
|
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ $query_date_T = preg_replace('/[^\:0-9]/', '', $query_date_T);
|
|||||||
$file_download = preg_replace('/[^0-9]/', '', $file_download);
|
$file_download = preg_replace('/[^0-9]/', '', $file_download);
|
||||||
$lower_limit = preg_replace('/[^0-9]/', '', $lower_limit);
|
$lower_limit = preg_replace('/[^0-9]/', '', $lower_limit);
|
||||||
$upper_limit = preg_replace('/[^0-9]/', '', $upper_limit);
|
$upper_limit = preg_replace('/[^0-9]/', '', $upper_limit);
|
||||||
|
$rpt_output_type = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$rpt_output_type);
|
||||||
|
|
||||||
# Variables filtered further down in the code
|
# Variables filtered further down in the code
|
||||||
# $server_ip
|
# $server_ip
|
||||||
@@ -460,10 +461,12 @@ while($status_row=mysqli_fetch_row($status_rslt))
|
|||||||
$agent_status_SQL=preg_replace('/,\s$/', '', $agent_status_SQL);
|
$agent_status_SQL=preg_replace('/,\s$/', '', $agent_status_SQL);
|
||||||
if (strlen($agent_status_SQL)>0) {$agent_status_SQL="and status in ($agent_status_SQL)";}
|
if (strlen($agent_status_SQL)>0) {$agent_status_SQL="and status in ($agent_status_SQL)";}
|
||||||
$status_rpt_string=", statuses: ".implode(', ', $agent_status);
|
$status_rpt_string=", statuses: ".implode(', ', $agent_status);
|
||||||
|
$status_rpt_string = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$status_rpt_string);
|
||||||
|
|
||||||
$agent_statusQS='';
|
$agent_statusQS='';
|
||||||
for ($i=0; $i<count($agent_status); $i++)
|
for ($i=0; $i<count($agent_status); $i++)
|
||||||
{
|
{
|
||||||
|
$agent_status[$i] = preg_replace("/\<|\>|\'|\"|\\\\|;/","",$agent_status[$i]);
|
||||||
$agent_statusQS.="&agent_status[]=".$agent_status[$i];
|
$agent_statusQS.="&agent_status[]=".$agent_status[$i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,11 @@
|
|||||||
# 220518-2210 - Small fix for encrypted auth
|
# 220518-2210 - Small fix for encrypted auth
|
||||||
# 220922-1027 - Added BLANK action for first agent screen page load
|
# 220922-1027 - Added BLANK action for first agent screen page load
|
||||||
# 260303-0714 - Code updates for PHP8 compatibility
|
# 260303-0714 - Code updates for PHP8 compatibility
|
||||||
|
# 260823-1411 - input filtering fix
|
||||||
#
|
#
|
||||||
|
|
||||||
$admin_version = '2.14-14';
|
$admin_version = '2.14-15';
|
||||||
$build = '260303-0714';
|
$build = '260823-1411';
|
||||||
$php_script = 'agc_agent_manager_chat_interface.php';
|
$php_script = 'agc_agent_manager_chat_interface.php';
|
||||||
|
|
||||||
$sh="managerchats";
|
$sh="managerchats";
|
||||||
@@ -84,13 +85,13 @@ if ($non_latin < 1)
|
|||||||
{
|
{
|
||||||
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
|
$user=preg_replace("/[^-_0-9a-zA-Z]/","",$user);
|
||||||
$pass=preg_replace("/[^-\.\+\/\=_0-9a-zA-Z]/","",$pass);
|
$pass=preg_replace("/[^-\.\+\/\=_0-9a-zA-Z]/","",$pass);
|
||||||
$manager_chat_id = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$user);
|
$manager_chat_id = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$manager_chat_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$user = preg_replace('/[^-_0-9\p{L}]/u','',$user);
|
$user = preg_replace('/[^-_0-9\p{L}]/u','',$user);
|
||||||
$pass = preg_replace('/[^-\.\+\/\=_0-9\p{L}]/u','',$pass);
|
$pass = preg_replace('/[^-\.\+\/\=_0-9\p{L}]/u','',$pass);
|
||||||
$manager_chat_id = preg_replace("/[^- \_\.0-9\p{L}]/u","",$user);
|
$manager_chat_id = preg_replace("/[^- \_\.0-9\p{L}]/u","",$manager_chat_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$manager_chat_refresh_seconds=1;
|
$manager_chat_refresh_seconds=1;
|
||||||
|
|||||||
+2081
-336
File diff suppressed because one or more lines are too long
@@ -230,10 +230,11 @@
|
|||||||
# 260506-1525 - small fix for campaign changes
|
# 260506-1525 - small fix for campaign changes
|
||||||
# 260519-1647 - Code updates for PHP8 compatibility, and json output format
|
# 260519-1647 - Code updates for PHP8 compatibility, and json output format
|
||||||
# 260611-2256 - Fix for input variable filtering
|
# 260611-2256 - Fix for input variable filtering
|
||||||
|
# 260822-0841 - Added agent_ingroup_availability function
|
||||||
#
|
#
|
||||||
|
|
||||||
$version = '2.14-205';
|
$version = '2.14-206';
|
||||||
$build = '260611-2256';
|
$build = '260822-0841';
|
||||||
$php_script='non_agent_api.php';
|
$php_script='non_agent_api.php';
|
||||||
$api_url_log = 0;
|
$api_url_log = 0;
|
||||||
$camp_lead_order_random=1;
|
$camp_lead_order_random=1;
|
||||||
@@ -615,6 +616,9 @@ if (isset($_GET["user_groups"])) {$user_groups=$_GET["user_groups"];}
|
|||||||
if (isset($_GET["in_groups"])) {$in_groups=$_GET["in_groups"];}
|
if (isset($_GET["in_groups"])) {$in_groups=$_GET["in_groups"];}
|
||||||
elseif (isset($_POST["in_groups"])) {$in_groups=$_POST["in_groups"];}
|
elseif (isset($_POST["in_groups"])) {$in_groups=$_POST["in_groups"];}
|
||||||
else {$in_groups="";}
|
else {$in_groups="";}
|
||||||
|
if (isset($_GET["queue_groups"])) {$queue_groups=$_GET["queue_groups"];}
|
||||||
|
elseif (isset($_POST["queue_groups"])) {$queue_groups=$_POST["queue_groups"];}
|
||||||
|
else {$queue_groups="";}
|
||||||
if (isset($_GET["did_ids"])) {$did_ids=$_GET["did_ids"];}
|
if (isset($_GET["did_ids"])) {$did_ids=$_GET["did_ids"];}
|
||||||
elseif (isset($_POST["did_ids"])) {$did_ids=$_POST["did_ids"];}
|
elseif (isset($_POST["did_ids"])) {$did_ids=$_POST["did_ids"];}
|
||||||
else {$did_ids="";}
|
else {$did_ids="";}
|
||||||
@@ -1017,6 +1021,15 @@ if (isset($_GET["webform_three"])) {$webform_three=$_GET["webform_three"];}
|
|||||||
if (isset($_GET["forcephonecode"])) {$forcephonecode=$_GET["forcephonecode"];}
|
if (isset($_GET["forcephonecode"])) {$forcephonecode=$_GET["forcephonecode"];}
|
||||||
elseif (isset($_POST["forcephonecode"])) {$forcephonecode=$_POST["forcephonecode"];}
|
elseif (isset($_POST["forcephonecode"])) {$forcephonecode=$_POST["forcephonecode"];}
|
||||||
else {$forcephonecode="";}
|
else {$forcephonecode="";}
|
||||||
|
if (isset($_GET["display_field"])) {$display_field=$_GET["display_field"];}
|
||||||
|
elseif (isset($_POST["display_field"])) {$display_field=$_POST["display_field"];}
|
||||||
|
else {$display_field="";}
|
||||||
|
if (isset($_GET["summary_name"])) {$summary_name=$_GET["summary_name"];}
|
||||||
|
elseif (isset($_POST["summary_name"])) {$summary_name=$_POST["summary_name"];}
|
||||||
|
else {$summary_name="";}
|
||||||
|
if (isset($_GET["ingroup_set_name"])) {$ingroup_set_name=$_GET["ingroup_set_name"];}
|
||||||
|
elseif (isset($_POST["ingroup_set_name"])) {$ingroup_set_name=$_POST["ingroup_set_name"];}
|
||||||
|
else {$ingroup_set_name="";}
|
||||||
if (isset($_GET["DBX"])) {$DBX=$_GET["DBX"];}
|
if (isset($_GET["DBX"])) {$DBX=$_GET["DBX"];}
|
||||||
elseif (isset($_POST["DBX"])) {$DBX=$_POST["DBX"];}
|
elseif (isset($_POST["DBX"])) {$DBX=$_POST["DBX"];}
|
||||||
|
|
||||||
@@ -1278,6 +1291,7 @@ if ($non_latin < 1)
|
|||||||
$caller_id_name = preg_replace('/[^- \+\_0-9a-zA-Z]/','',$caller_id_name);
|
$caller_id_name = preg_replace('/[^- \+\_0-9a-zA-Z]/','',$caller_id_name);
|
||||||
$user_groups = preg_replace('/[^-\|\,\_0-9a-zA-Z]/','',$user_groups); #JCJ
|
$user_groups = preg_replace('/[^-\|\,\_0-9a-zA-Z]/','',$user_groups); #JCJ
|
||||||
$in_groups = preg_replace('/[^-\|\,\_0-9a-zA-Z]/','',$in_groups); #JCJ
|
$in_groups = preg_replace('/[^-\|\,\_0-9a-zA-Z]/','',$in_groups); #JCJ
|
||||||
|
$queue_groups = preg_replace('/[^-\|\,\_0-9a-zA-Z]/','',$queue_groups); #JCJ
|
||||||
$group = preg_replace('/[^-\|\_0-9a-zA-Z]/','',$group);
|
$group = preg_replace('/[^-\|\_0-9a-zA-Z]/','',$group);
|
||||||
$call_id = preg_replace('/[^0-9a-zA-Z]/','',$call_id);
|
$call_id = preg_replace('/[^0-9a-zA-Z]/','',$call_id);
|
||||||
$expiration_date = preg_replace('/[^-_0-9a-zA-Z]/','',$expiration_date);
|
$expiration_date = preg_replace('/[^-_0-9a-zA-Z]/','',$expiration_date);
|
||||||
@@ -1341,6 +1355,9 @@ if ($non_latin < 1)
|
|||||||
$preset_name = preg_replace('/[^- \_0-9a-zA-Z]/','',$preset_name);
|
$preset_name = preg_replace('/[^- \_0-9a-zA-Z]/','',$preset_name);
|
||||||
$dial_status_add=preg_replace('/[^-_0-9a-zA-Z]/','',$dial_status_add);
|
$dial_status_add=preg_replace('/[^-_0-9a-zA-Z]/','',$dial_status_add);
|
||||||
$dial_status_remove=preg_replace('/[^-_0-9a-zA-Z]/','',$dial_status_remove);
|
$dial_status_remove=preg_replace('/[^-_0-9a-zA-Z]/','',$dial_status_remove);
|
||||||
|
$display_field = preg_replace('/[^_0-9a-zA-Z]/','',$display_field);
|
||||||
|
$summary_name = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$summary_name);
|
||||||
|
$ingroup_set_name = preg_replace('/[^- \_\.0-9a-zA-Z]/','',$ingroup_set_name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1437,6 +1454,7 @@ else
|
|||||||
$caller_id_name = preg_replace('/[^- \+\_0-9\p{L}]/u','',$caller_id_name);
|
$caller_id_name = preg_replace('/[^- \+\_0-9\p{L}]/u','',$caller_id_name);
|
||||||
$user_groups = preg_replace('/[^-\|\,\_0-9\p{L}]/u','',$user_groups); #JCJ
|
$user_groups = preg_replace('/[^-\|\,\_0-9\p{L}]/u','',$user_groups); #JCJ
|
||||||
$in_groups = preg_replace('/[^-\|\,\_0-9\p{L}]/u','',$in_groups); #JCJ
|
$in_groups = preg_replace('/[^-\|\,\_0-9\p{L}]/u','',$in_groups); #JCJ
|
||||||
|
$queue_groups = preg_replace('/[^-\|\,\_0-9\p{L}]/u','',$queue_groups); #JCJ
|
||||||
$group = preg_replace('/[^-\|\_0-9\p{L}]/u','',$group);
|
$group = preg_replace('/[^-\|\_0-9\p{L}]/u','',$group);
|
||||||
$call_id = preg_replace('/[^0-9\p{L}]/u','',$call_id);
|
$call_id = preg_replace('/[^0-9\p{L}]/u','',$call_id);
|
||||||
$expiration_date = preg_replace('/[^-_0-9\p{L}]/u','',$expiration_date);
|
$expiration_date = preg_replace('/[^-_0-9\p{L}]/u','',$expiration_date);
|
||||||
@@ -1500,6 +1518,9 @@ else
|
|||||||
$preset_name = preg_replace('/[^- \_0-9\p{L}]/u','',$preset_name);
|
$preset_name = preg_replace('/[^- \_0-9\p{L}]/u','',$preset_name);
|
||||||
$dial_status_add=preg_replace('/[^-_0-9\p{L}]/u','',$dial_status_add);
|
$dial_status_add=preg_replace('/[^-_0-9\p{L}]/u','',$dial_status_add);
|
||||||
$dial_status_remove=preg_replace('/[^-_0-9\p{L}]/u','',$dial_status_remove);
|
$dial_status_remove=preg_replace('/[^-_0-9\p{L}]/u','',$dial_status_remove);
|
||||||
|
$display_field = preg_replace('/[^_0-9\p{L}]/u','',$display_field);
|
||||||
|
$summary_name = preg_replace('/[^- \_\.0-9\p{L}]/u','',$summary_name);
|
||||||
|
$ingroup_set_name = preg_replace('/[^- \_\.0-9\p{L}]/u','',$ingroup_set_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($stage=="json") {$header="YES";}
|
if ($stage=="json") {$header="YES";}
|
||||||
@@ -11322,7 +11343,167 @@ if ($function == 'copy_did')
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
### agent_ingroup_availability -
|
||||||
|
################################################################################
|
||||||
|
if ($function == 'agent_ingroup_availability')
|
||||||
|
{
|
||||||
|
if(strlen($source)<2)
|
||||||
|
{
|
||||||
|
$result = 'ERROR';
|
||||||
|
$result_reason = "Invalid Source";
|
||||||
|
echo "$result: $result_reason: |$source|\n";
|
||||||
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( (!preg_match("/ $function /",$api_allowed_functions)) and (!preg_match("/ALL_FUNCTIONS/",$api_allowed_functions)) )
|
||||||
|
{
|
||||||
|
$result = 'ERROR';
|
||||||
|
$result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION";
|
||||||
|
echo "$result: $result_reason: |$user|$function|\n";
|
||||||
|
$data = "$allowed_user";
|
||||||
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
$stmt="SELECT count(*) from vicidial_users where user='$user' and vdc_agent_api_access='1' and view_reports='1' and user_level >= 8 and active='Y';";
|
||||||
|
$rslt=mysql_to_mysqli($stmt, $link);
|
||||||
|
$row=mysqli_fetch_row($rslt);
|
||||||
|
$allowed_user=$row[0];
|
||||||
|
if ($allowed_user < 1)
|
||||||
|
{
|
||||||
|
$result = 'ERROR';
|
||||||
|
$result_reason = "agent_ingroup_availability USER DOES NOT HAVE PERMISSION TO GET AGENT INFO";
|
||||||
|
$data = "$allowed_user";
|
||||||
|
echo "$result: $result_reason: |$user|$data\n";
|
||||||
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$all_ingroups=array();
|
||||||
|
if (strlen($in_groups) > 0)
|
||||||
|
{
|
||||||
|
$all_ingroups=explode(",", $in_groups);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($queue_groups) > 0)
|
||||||
|
{
|
||||||
|
$queue_group_array=explode(",", $queue_groups);
|
||||||
|
|
||||||
|
$qg_stmt="select included_inbound_groups from vicidial_queue_groups where queue_group in ('".implode("','", $queue_group_array)."') ";
|
||||||
|
$qg_rslt=mysql_to_mysqli($qg_stmt, $link);
|
||||||
|
while ($qg_row=mysqli_fetch_row($qg_rslt))
|
||||||
|
{
|
||||||
|
$iigs=trim($qg_row[0]);
|
||||||
|
$iigs=preg_replace('/ -\s?$/', "", $iigs);
|
||||||
|
$inc_inb_groups=explode(" ", $iigs);
|
||||||
|
|
||||||
|
$all_ingroups=array_merge($all_ingroups, $inc_inb_groups);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# print_r($all_ingroups); die;
|
||||||
|
|
||||||
|
$ingroups_to_check=array_unique($all_ingroups);
|
||||||
|
if (count($ingroups_to_check)==0)
|
||||||
|
{
|
||||||
|
$result = 'ERROR';
|
||||||
|
$result_reason = "NO INGROUPS DEFINED";
|
||||||
|
echo "$result: $result_reason: |$user|$function|\n";
|
||||||
|
$data = "$allowed_user";
|
||||||
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$column_name="group_id";
|
||||||
|
if (strlen($display_field) > 0)
|
||||||
|
{
|
||||||
|
$column_stmt="show columns from vicidial_inbound_groups like '$display_field'";
|
||||||
|
$column_rslt=mysql_to_mysqli($column_stmt, $link);
|
||||||
|
if (mysqli_num_rows($column_rslt)>0)
|
||||||
|
{
|
||||||
|
$column_name=$display_field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# print_r($ingroups_to_check);
|
||||||
|
$ingroup_stmt="select group_id, $column_name from vicidial_inbound_groups where group_id in ('".implode("','", $ingroups_to_check)."')";
|
||||||
|
$ingroup_rslt=mysql_to_mysqli($ingroup_stmt, $link);
|
||||||
|
|
||||||
|
# print "$ingroup_stmt<BR>";
|
||||||
|
|
||||||
|
$availability_array=array(); $existing_ingroups=array(); $custom_display_array=array();
|
||||||
|
while ($ingroup_row=mysqli_fetch_array($ingroup_rslt))
|
||||||
|
{
|
||||||
|
$existing_ingroups[]=$ingroup_row[0];
|
||||||
|
$key=(strlen($ingroup_row[1])>0 ? $ingroup_row[1] : $ingroup_row[0]);
|
||||||
|
$custom_display_array["$ingroup_row[0]"]=$key;
|
||||||
|
$availability_array["$key"]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($existing_ingroups)==0)
|
||||||
|
{
|
||||||
|
$result = 'ERROR';
|
||||||
|
$result_reason = "NO INGROUPS FOUND";
|
||||||
|
echo "$result: $result_reason: |$user|$function|\n";
|
||||||
|
$data = "$allowed_user";
|
||||||
|
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($campaigns) > 0)
|
||||||
|
{
|
||||||
|
$campaign_id_array=explode(",", $campaigns);
|
||||||
|
$campaignSQL=" and campaign_id in ('".implode("','", $campaign_id_array)."') ";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$vla_stmt="select user, status, closer_campaigns From vicidial_live_agents where status in ('READY', 'CLOSER') $campaignSQL";
|
||||||
|
$vla_rslt=mysql_to_mysqli($vla_stmt, $link);
|
||||||
|
$user_counts=array();
|
||||||
|
while ($vla_row=mysqli_fetch_array($vla_rslt))
|
||||||
|
{
|
||||||
|
$closer_campaigns=$vla_row["closer_campaigns"];
|
||||||
|
$vla_user=$vla_row["user"];
|
||||||
|
$closer_campaigns=preg_replace('/- $/', "", $closer_campaigns);
|
||||||
|
$closer_campaigns_array=explode(" ", $closer_campaigns);
|
||||||
|
|
||||||
|
$matching_arrays=array_values(array_intersect($closer_campaigns_array, $existing_ingroups));
|
||||||
|
for ($i=0; $i<count($matching_arrays); $i++)
|
||||||
|
{
|
||||||
|
$key=$custom_display_array["$matching_arrays[$i]"];
|
||||||
|
$availability_array["$key"]++;
|
||||||
|
$user_counts["$vla_user"]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$user_count=count($user_counts);
|
||||||
|
ksort($availability_array);
|
||||||
|
|
||||||
|
if (!isset($summary_name) || strlen($summary_name)==0) {$summary_name="availableCount";}
|
||||||
|
if (!isset($ingroup_set_name) || strlen($ingroup_set_name)==0) {$ingroup_set_name="states";}
|
||||||
|
if (preg_match('/^JSON$/i', $stage))
|
||||||
|
{
|
||||||
|
echo "{\"$summary_name\": $user_count,\n";
|
||||||
|
echo "\"$ingroup_set_name\": {\n";
|
||||||
|
$state_str="";
|
||||||
|
foreach ($availability_array as $key => $value)
|
||||||
|
{
|
||||||
|
$state_str.="\"$key\": $value,\n";
|
||||||
|
}
|
||||||
|
$state_str=preg_replace('/,\n$/', "\n", $state_str);
|
||||||
|
echo "$state_str}\n}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "GROUP,AVAILABLE COUNT\n";
|
||||||
|
echo "AGENTS,$user_count\n";
|
||||||
|
foreach ($availability_array as $key => $value)
|
||||||
|
{
|
||||||
|
echo "$key,$value\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user