Agent Status Dashboard Update

Fixes some problems on the agent status dashboard
This commit is contained in:
FusionPBX 2023-11-15 21:34:53 -07:00 committed by GitHub
parent 5e0c27d592
commit cb5fbc68b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 76 additions and 39 deletions

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2017-2019
Portions created by the Initial Developer are Copyright (C) 2017-2023
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -54,22 +54,43 @@
$fp = event_socket_create();
//get the http post values and set them as php variables
if (count($_POST) > 0) {
if (!empty($_POST['agents'])) {
$x = 0;
foreach ($_POST['agents'] as $row) {
if (!empty($row['agent_status'])) {
//agent set status
if ($fp) {
if ($fp && is_numeric($row['queue_extension']) && is_uuid($row['id'])) {
//santize the agent status
switch ($row['agent_status']) {
case 'Available':
$row['agent_status'] = 'Available';
break;
case 'On Break':
$row['agent_status'] = 'On Break';
break;
case 'Logged Out':
$row['agent_status'] = 'Logged Out';
break;
default:
$row['agent_status'] = 'Logged Out';
}
//update the database
if ($x == 0) {
$array['call_center_agents'][0]['call_center_agent_uuid'] = $row['id'];
$array['call_center_agents'][0]['domain_uuid'] = $_SESSION['user']['domain_uuid'];
$array['call_center_agents'][0]['agent_status'] = $row['agent_status'];
$database->app_name = 'call_centers_dashboard';
$database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
$database->save($array);
$result = $database->save($array);
}
//set the call center status
if ($x == 0) {
$cmd = "api callcenter_config agent set status ".$row['id']." '".$row['agent_status']."'";
$response = event_socket_request($fp, $cmd);
}
//set the agent status to available and assign the agent to the queue with the tier
if ($row['agent_status'] == 'Available') {
//assign the agent to the queue
@ -77,6 +98,13 @@
$response = event_socket_request($fp, $cmd);
}
//set the agent status to available and assign the agent to the queue with the tier
if ($row['agent_status'] == 'On Break') {
//assign the agent to the queue
$cmd = "api callcenter_config tier add ".$row['queue_extension']."@".$_SESSION['domain_name']." ".$row['id']." 1 1";
$response = event_socket_request($fp, $cmd);
}
//un-assign the agent from the queue
if ($row['agent_status'] == 'Logged Out') {
$cmd = "api callcenter_config tier del ".$row['queue_extension']."@".$_SESSION['domain_name']." ".$row['id'];
@ -85,7 +113,8 @@
usleep(200);
unset($parameters);
}
}
$x++;
}
//redirect
@ -114,11 +143,19 @@
$parameters['user_uuid'] = $_SESSION['user_uuid'];
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$agents = $database->select($sql, $parameters, 'all');
if (count($agents) > 0) {
if (!empty($agents)) {
$agent = $agents[0];
}
unset($sql, $parameters);
//get the agent details from event socket
$switch_cmd = 'callcenter_config agent list '.$agent['call_center_agent_uuid'];
$event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd));
$call_center_agent = csv_to_named_array($event_socket_str, '|');
//set the agent status
$agent['agent_status'] = $call_center_agent[1]['status'];
//update the queue status
$x = 0;
foreach ($call_center_queues as $queue) {