From 832549a32e660f3a74e4eb7c04d656e8c7af8a4b Mon Sep 17 00:00:00 2001 From: Andrew Querol Date: Fri, 30 Jul 2021 00:47:09 -0500 Subject: [PATCH] Fix dashboard widget for agent status management (#5993) * Fix dashboard widget for agent status management This needed to be updated for the ext@domain call center naming change. * Add support for On-Break and remove user_status and agent_status syncing --- .../call_center_agent_dashboard.php | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/app/call_centers/call_center_agent_dashboard.php b/app/call_centers/call_center_agent_dashboard.php index 95b24cb3d4..c0a1ab3871 100644 --- a/app/call_centers/call_center_agent_dashboard.php +++ b/app/call_centers/call_center_agent_dashboard.php @@ -54,35 +54,32 @@ if (count($_POST) > 0) { foreach ($_POST['agents'] as $row) { if (strlen($row['agent_status']) > 0) { - //agent set status if ($fp) { - //set the user_status - $sql = "update v_users set "; - $sql .= "user_status = :user_status "; - $sql .= "where domain_uuid = :domain_uuid "; - $sql .= "and username = :username "; - $parameters['user_status'] = $row['agent_status']; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $parameters['username'] = $row['agent_name']; + // update the database + $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 = new database; + $database->app_name = 'call_centers_dashboard'; + $database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370'; + $database->save($array); + //set the call center status + $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') { - //set the call center status - //$cmd = "api callcenter_config agent set status ".$row['agent_name']."@".$_SESSION['domain_name']." '".$row['agent_status']."'"; - //$response = event_socket_request($fp, $cmd); - //assign the agent to the queue - $cmd = "api callcenter_config tier add ".$row['queue_name']."@".$_SESSION['domain_name']." ".$row['agent_name']."@".$_SESSION['domain_name']." 1 1"; + $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_name']."@".$_SESSION['domain_name']." ".$row['agent_name']."@".$_SESSION['domain_name']; + $cmd = "api callcenter_config tier del ".$row['queue_extension']."@".$_SESSION['domain_name']." ".$row['id']; $response = event_socket_request($fp, $cmd); } - usleep(200); unset($parameters); } @@ -105,7 +102,7 @@ //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_name asc "; + $sql .= "order by queue_extension asc "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $database = new database; $call_center_queues = $database->select($sql, $parameters, 'all'); @@ -115,11 +112,14 @@ //get the agents from the database $sql = "select * from v_call_center_agents "; $sql .= "where user_uuid = :user_uuid "; - $sql .= "and domain_uuid = :domain_uuid "; + $sql .= "and domain_uuid = :domain_uuid"; $parameters['user_uuid'] = $_SESSION['user_uuid']; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $database = new database; - $agent = $database->select($sql, $parameters, 'all'); + $agents = $database->select($sql, $parameters, 'all'); + if (count($agents) > 0) { + $agent = $agents[0]; + } unset($sql, $parameters); //update the queue status @@ -127,11 +127,8 @@ foreach ($call_center_queues as $queue) { $call_center_queues[$x]['queue_status'] = 'Logged Out'; foreach ($call_center_tiers as $tier) { - if ( - $queue['queue_name'] .'@'. $_SESSION['domain_name'] == $tier['queue'] - && $agent['agent_name'] .'@'. $_SESSION['domain_name'] == $tier['agent'] - ) { - $call_center_queues[$x]['queue_status'] = 'Available'; + 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++; @@ -194,11 +191,12 @@ // } // echo " \n"; echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; echo " \n"; echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; echo " \n"; echo "\n"; $x++;