Portions created by the Initial Developer are Copyright (C) 2008-2021 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane James Rose */ //includes include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (permission_exists('call_center_active_view')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //get the queue uuid and set it as a variable $queue_uuid = $_GET['queue_name']; //get the queues from the database if (!is_array($_SESSION['queues'])) { $sql = "select * from v_call_center_queues "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "order by queue_name asc "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $database = new database; $_SESSION['queues'] = $database->select($sql, $parameters, 'all'); } //get the queue name foreach ($_SESSION['queues'] as $row) { if ($row['call_center_queue_uuid'] == $queue_uuid) { $queue_name = $row['queue_name']; $queue_extension = $row['queue_extension']; } } //convert the string to a named array function str_to_named_array($tmp_str, $tmp_delimiter) { $tmp_array = explode ("\n", $tmp_str); $result = array(); if (trim(strtoupper($tmp_array[0])) != "+OK") { $tmp_field_name_array = explode ($tmp_delimiter, $tmp_array[0]); $x = 0; if (isset($tmp_array)) foreach ($tmp_array as $row) { if ($x > 0) { $tmp_field_value_array = explode ($tmp_delimiter, $tmp_array[$x]); $y = 0; if (isset($tmp_field_value_array)) foreach ($tmp_field_value_array as $tmp_value) { $tmp_name = $tmp_field_name_array[$y]; if (trim(strtoupper($tmp_value)) != "+OK") { $result[$x][$tmp_name] = $tmp_value; } $y++; } } $x++; } unset($row); } return $result; } //create an event socket connection $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); //get the call center queue, agent and tiers list if (!$fp) { $msg = "
Connection to Event Socket failed.
"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Message
$msg
\n"; echo "
\n"; } else { //get the agent list //show the title echo "".$text['header-agents']."
\n"; echo $text['description-agents']."

\n"; //send the event socket command and get the response //callcenter_config queue list tiers [queue_name] | $switch_command = 'callcenter_config queue list tiers '.$queue_extension."@".$_SESSION["domain_name"]; $event_socket_str = trim(event_socket_request($fp, 'api '.$switch_command)); $result = str_to_named_array($event_socket_str, '|'); //prepare the result for array_multisort $x = 0; if (is_array($result)) { foreach ($result as $row) { $tier_result[$x]['level'] = $row['level']; $tier_result[$x]['position'] = $row['position']; $tier_result[$x]['agent'] = $row['agent']; $tier_result[$x]['state'] = trim($row['state']); $tier_result[$x]['queue'] = $row['queue']; $x++; } } //sort the array //SORT_ASC, SORT_DESC, SORT_REGULAR, SORT_NUMERIC, SORT_STRING if (isset($tier_result)) { array_multisort($tier_result, SORT_ASC); } //send the event socket command and get the response //callcenter_config queue list agents [queue_name] [status] | $switch_command = 'callcenter_config queue list agents '.$queue_extension."@".$_SESSION["domain_name"]; $event_socket_str = trim(event_socket_request($fp, 'api '.$switch_command)); $agent_result = str_to_named_array($event_socket_str, '|'); //get the agents from the database if (!is_array($_SESSION['agents'])) { $sql = "select * from v_call_center_agents "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "order by agent_name asc "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $database = new database; $_SESSION['agents'] = $database->select($sql, $parameters, 'all'); } //list the agents echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (permission_exists('call_center_active_options')) { echo "\n"; } echo "\n"; if (isset($tier_result)) { foreach ($tier_result as $tier_row) { //$queue = $tier_row['queue']; //$queue = str_replace('@'.$_SESSION['domain_name'], '', $queue); $agent = $tier_row['agent']; //$agent = str_replace('@'.$_SESSION['domain_name'], '', $agent); $tier_state = $tier_row['state']; $tier_level = $tier_row['level']; $tier_position = $tier_row['position']; if (isset($agent_result)) { foreach ($agent_result as $agent_row) { if ($tier_row['agent'] == $agent_row['name']) { $agent_uuid = $agent_row['name']; //get the agent name $agent_name = ''; if (is_array($_SESSION['agents'])) { foreach ($_SESSION['agents'] as $agent) { if ($agent['call_center_agent_uuid'] == $agent_uuid) { $agent_name = $agent['agent_name']; } } } //$system = $agent_row['system']; if (is_uuid($agent_row['uuid'])) { $agent_uuid = $agent_row['uuid']; } //$type = $agent_row['type']; $contact = $agent_row['contact']; $agent_extension = preg_replace("/user\//", "", $contact); $agent_extension = preg_replace("/@.*/", "", $agent_extension); $agent_extension = preg_replace("/{.*}/", "", $agent_extension); $status = $agent_row['status']; $state = $agent_row['state']; $max_no_answer = $agent_row['max_no_answer']; $wrap_up_time = $agent_row['wrap_up_time']; $reject_delay_time = $agent_row['reject_delay_time']; $busy_delay_time = $agent_row['busy_delay_time']; $last_bridge_start = $agent_row['last_bridge_start']; $last_bridge_end = $agent_row['last_bridge_end']; //$last_offered_call = $agent_row['last_offered_call']; $last_status_change = $agent_row['last_status_change']; $no_answer_count = $agent_row['no_answer_count']; $calls_answered = $agent_row['calls_answered']; $talk_time = $agent_row['talk_time']; $ready_time = $agent_row['ready_time']; $last_status_change_seconds = time() - $last_status_change; $last_status_change_length_hour = floor($last_status_change_seconds/3600); $last_status_change_length_min = floor($last_status_change_seconds/60 - ($last_status_change_length_hour * 60)); $last_status_change_length_sec = $last_status_change_seconds - (($last_status_change_length_hour * 3600) + ($last_status_change_length_min * 60)); $last_status_change_length_min = sprintf("%02d", $last_status_change_length_min); $last_status_change_length_sec = sprintf("%02d", $last_status_change_length_sec); $last_status_change_length = $last_status_change_length_hour.':'.$last_status_change_length_min.':'.$last_status_change_length_sec; if (permission_exists('call_center_agent_edit')) { $list_row_url = "../call_centers/call_center_agent_edit.php?id=".$agent_uuid; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (permission_exists('call_center_active_options')) { echo ""; } echo "\n"; } //if } //foreach } //if } //foreach } //if echo "
".$text['label-name']."".$text['label-extension']."".$text['label-status']."".$text['label-state']."".$text['label-status_change']."".$text['label-missed']."".$text['label-answered']."".$text['label-tier_state']."".$text['label-tier_level']."".$text['label-tier_position']."".$text['label-options']."
"; if (permission_exists('call_center_agent_edit')) { echo "".escape($agent_name).""; } else { echo escape($agent_name); } echo "".escape($agent_extension)."".escape($status)."".escape($state)."".escape($last_status_change_length)."".escape($no_answer_count)."".escape($calls_answered)."".escape($tier_state)."".escape($tier_level)."".escape($tier_position)."
\n\n"; //add vertical spacing echo "


"; //get the queue list //send the event socket command and get the response //callcenter_config queue list members [queue_name] if (is_uuid($queue_uuid)) { $switch_command = 'callcenter_config queue list members '.$queue_extension."@".$_SESSION["domain_name"]; $event_socket_str = trim(event_socket_request($fp, 'api '.$switch_command)); $result = str_to_named_array($event_socket_str, '|'); if (!is_array($result)) { unset($result); } } //show the title $q_waiting=0; $q_trying=0; $q_answered=0; echo "
\n"; echo "
".$text['label-queue'].": ".ucfirst(escape($queue_name))."
\n"; echo "
\n"; if (isset($result)) { foreach ($result as $row) { $state = $row['state']; $q_trying += ($state == "Trying") ? 1 : 0; $q_waiting += ($state == "Waiting") ? 1 : 0; $q_answered += ($state == "Answered") ? 1 : 0; } } echo " ".$text['label-waiting'].": ".$q_waiting."   "; echo " ".$text['label-trying'].": ".$q_trying."    "; echo " ".$text['label-answered'].": ".$q_answered.""; echo "
\n"; echo "
\n"; echo "
\n"; echo $text['description-queue']."\n"; echo "

\n"; echo "\n"; echo "\n"; echo "\n"; //echo "\n"; echo "\n"; echo "\n"; echo "\n"; if ((if_group("admin") || if_group("superadmin"))) { echo "\n"; } echo "\n"; echo "\n"; if (is_array($result)) { foreach ($result as $row) { $queue = $row['queue']; $system = $row['system']; $uuid = $row['uuid']; $session_uuid = $row['session_uuid']; $caller_number = $row['cid_number']; $caller_name = $row['cid_name']; $system_epoch = $row['system_epoch']; $joined_epoch = $row['joined_epoch']; $rejoined_epoch = $row['rejoined_epoch']; $bridge_epoch = $row['bridge_epoch']; $abandoned_epoch = $row['abandoned_epoch']; $base_score = $row['base_score']; $skill_score = $row['skill_score']; $serving_agent = $row['serving_agent']; $serving_system = $row['serving_system']; $state = $row['state']; $joined_seconds = time() - $joined_epoch; $joined_length_hour = floor($joined_seconds/3600); $joined_length_min = floor($joined_seconds/60 - ($joined_length_hour * 60)); $joined_length_sec = $joined_seconds - (($joined_length_hour * 3600) + ($joined_length_min * 60)); $joined_length_min = sprintf("%02d", $joined_length_min); $joined_length_sec = sprintf("%02d", $joined_length_sec); $joined_length = $joined_length_hour.':'.$joined_length_min.':'.$joined_length_sec; //get the serving agent name $serving_agent_name = ''; if (is_array($_SESSION['agents'])) { foreach ($_SESSION['agents'] as $agent) { if ($agent['call_center_agent_uuid'] == $serving_agent) { $serving_agent_name = $agent['agent_name']; } } } echo "\n"; echo "\n"; //echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (if_group("admin") || if_group("superadmin")) { echo ""; } echo "\n"; echo "\n"; } } echo "
".$text['label-time']."".$text['label-system']."".$text['label-name']."".$text['label-number']."".$text['label-status']."".$text['label-options']."".$text['label-agent']."
".escape($joined_length)."".escape($system_length)."".escape($caller_name)." ".escape($caller_number)." ".escape($state).""; if ($state != "Abandoned") { $orig_command="{origination_caller_id_name=eavesdrop,origination_caller_id_number=".escape($q_caller_number)."}user/".escape($_SESSION['user']['extension'][0]['user'])."@".escape($_SESSION['domain_name'])." %26eavesdrop(".escape($session_uuid).")"; echo button::create(['type'=>'button','class'=>'link','label'=>$text['label-eavesdrop'],'onclick'=>"if (confirm('".$text['message-confirm']."')) { send_command('call_center_exec.php?command=eavesdrop&caller_id_number=".urlencode($caller_number)."&uuid=".urlencode($session_uuid)."'); } else { this.blur(); return false; }"]); } else { echo " "; } echo "".escape($serving_agent_name)." 
\n"; } ?>