diff --git a/app/call_center_active/v_call_center_active_inc.php b/app/call_center_active/v_call_center_active_inc.php index 940e083f7f..8332f8ada0 100644 --- a/app/call_center_active/v_call_center_active_inc.php +++ b/app/call_center_active/v_call_center_active_inc.php @@ -22,6 +22,7 @@ Contributor(s): Mark J Crane + James Rose */ include "root.php"; require_once "includes/require.php"; @@ -86,6 +87,165 @@ else { echo "\n"; } else { + + //get the agent list + + //show the title + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Agents
\n"; + echo " List all the agents.
\n"; + echo "
\n"; + echo "
\n"; + + //send the event socket command and get the response + //callcenter_config queue list tiers [queue_name] | + $switch_cmd = 'callcenter_config queue list tiers '.$queue_name; + $event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); + $result = str_to_named_array($event_socket_str, '|'); + + //prepare the result for array_multisort + $x = 0; + 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 + array_multisort($tier_result, SORT_ASC); + + //send the event socket command and get the response + //callcenter_config queue list agents [queue_name] [status] | + $switch_cmd = 'callcenter_config queue list agents '.$queue_name; + $event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); + $agent_result = str_to_named_array($event_socket_str, '|'); + + //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"; + echo "\n"; + echo "\n"; + echo "\n"; + 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']; + + foreach ($agent_result as $agent_row) { + if ($tier_row['agent'] == $agent_row['name']) { + $name = $agent_row['name']; + $name = str_replace('@'.$_SESSION['domain_name'], '', $name); + //$system = $agent_row['system']; + $a_uuid = $agent_row['uuid']; + //$type = $agent_row['type']; + $contact = $agent_row['contact']; + $a_exten = preg_replace("/user\//", "", $contact); + $a_exten = preg_replace("/@.*/", "", $a_exten); + $a_exten = preg_replace("/{.*}/", "", $a_exten); + $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_offered_call_seconds = time() - $last_offered_call; + $last_offered_call_length_hour = floor($last_offered_call_seconds/3600); + $last_offered_call_length_min = floor($last_offered_call_seconds/60 - ($last_offered_call_length_hour * 60)); + $last_offered_call_length_sec = $last_offered_call_seconds - (($last_offered_call_length_hour * 3600) + ($last_offered_call_length_min * 60)); + $last_offered_call_length_min = sprintf("%02d", $last_offered_call_length_min); + $last_offered_call_length_sec = sprintf("%02d", $last_offered_call_length_sec); + $last_offered_call_length = $last_offered_call_length_hour.':'.$last_offered_call_length_min.':'.$last_offered_call_length_sec; + + $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; + + 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 (if_group("admin") || if_group("superadmin")) { + + echo ""; + } + } + } + echo "\n"; + + if ($c==0) { $c=1; } else { $c=0; } + } + echo "
NameExtensionStatusStateOffered CallStatus ChangeMissedAnsweredTier StateTier LevelTier PositionOptions
".$name."".$a_exten."".$status."".$state."".$last_offered_call_length."".$last_status_change_length."".$no_answer_count."".$calls_answered."".$tier_state."".$tier_level."".$tier_position.""; + + //need to check state to so only waiting gets call, and trying/answer gets eavesdrop + if ($tier_state == "Offering" || $tier_state == "Active Inbound") { + $orig_command="{origination_caller_id_name=eavesdrop,origination_caller_id_number=".$a_exten."}user/".$_SESSION['user']['extension'][0]['user']."@".$_SESSION['domain_name']." %26eavesdrop(".$a_uuid.")"; + + //debug + //echo $orig_command; + //echo " log_cmd \n"; + echo " eavesdrop \n"; + + $xfer_command = $a_uuid." -bleg ".$_SESSION['user']['extension'][0]['user']." XML ".$_SESSION['domain_name']; + //$xfer_command = $a_uuid." ".$_SESSION['user']['extension'][0]['user']." XML default"; + $xfer_command = urlencode($xfer_command); + echo " transfer \n"; + } + else { + $orig_call="{origination_caller_id_name=c2c-".urlencode($name).",origination_caller_id_number=".$a_exten."}user/".$_SESSION['user']['extension'][0]['user']."@".$_SESSION['domain_name']." %26bridge(user/".$a_exten."@".$_SESSION['domain_name'].")"; + + echo " Click to Call \n"; + } + echo "
\n\n"; + echo "
"; + + //add vertical spacing + echo "
\n"; + echo "
\n"; + echo "
\n"; + + //get the queue list //send the event socket command and get the response //callcenter_config queue list members [queue_name] @@ -186,138 +346,14 @@ else { } //end if uuid_exists } echo "\n"; + echo "
"; + echo "Total Waiting is {$q_waiting}. Total Trying is {$q_trying}. Total Answered is {$q_answered}.\n"; //add vertical spacing echo "
\n"; echo "
\n"; echo "
\n"; - //get the agent list - //show the title - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
Agents
\n"; - echo " List all the agents.
\n"; - echo "
\n"; - echo "
\n"; - - //send the event socket command and get the response - //callcenter_config queue list tiers [queue_name] | - $switch_cmd = 'callcenter_config queue list tiers '.$queue_name; - $event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); - $result = str_to_named_array($event_socket_str, '|'); - - //prepare the result for array_multisort - $x = 0; - 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 - array_multisort($tier_result, SORT_ASC); - - //send the event socket command and get the response - //callcenter_config queue list agents [queue_name] [status] | - $switch_cmd = 'callcenter_config queue list agents '.$queue_name; - $event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); - $agent_result = str_to_named_array($event_socket_str, '|'); - - //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"; - echo "\n"; - echo "\n"; - 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']; - - foreach ($agent_result as $agent_row) { - if ($tier_row['agent'] == $agent_row['name']) { - $name = $agent_row['name']; - $name = str_replace('@'.$_SESSION['domain_name'], '', $name); - //$system = $agent_row['system']; - //$uuid = $agent_row['uuid']; - //$type = $agent_row['type']; - $contact = $agent_row['contact']; - $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_offered_call_seconds = time() - $last_offered_call; - $last_offered_call_length_hour = floor($last_offered_call_seconds/3600); - $last_offered_call_length_min = floor($last_offered_call_seconds/60 - ($last_offered_call_length_hour * 60)); - $last_offered_call_length_sec = $last_offered_call_seconds - (($last_offered_call_length_hour * 3600) + ($last_offered_call_length_min * 60)); - $last_offered_call_length_min = sprintf("%02d", $last_offered_call_length_min); - $last_offered_call_length_sec = sprintf("%02d", $last_offered_call_length_sec); - $last_offered_call_length = $last_offered_call_length_hour.':'.$last_offered_call_length_min.':'.$last_offered_call_length_sec; - - $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; - - echo "\n"; - 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 ($c==0) { $c=1; } else { $c=0; } - } - echo "
NameContactStatusStateOffered CallStatus ChangeMissedAnsweredTier StateTier LevelTier Position
".$name."".$contact."".$status."".$state."".$last_offered_call_length."".$last_status_change_length."".$no_answer_count."".$calls_answered."".$tier_state."".$tier_level."".$tier_position."
\n\n"; - echo "
"; - echo "Total Waiting is {$q_waiting}. Total Trying is {$q_trying}. Total Answered is {$q_answered}.\n"; - - //add vertical spacing - echo "
\n"; - echo "
\n"; - echo "
\n"; } ?> diff --git a/app/call_center_active/v_call_center_exec.php b/app/call_center_active/v_call_center_exec.php index 8ee480ce68..aa7e48a4ba 100644 --- a/app/call_center_active/v_call_center_exec.php +++ b/app/call_center_active/v_call_center_exec.php @@ -1,96 +1,100 @@ -0) { - $switch_cmd = trim($_GET["cmd"]); - $action = trim(check_str($_GET["action"])); - $data = trim(check_str($_GET["data"])); - $username = trim(check_str($_GET["username"])); - } - -//authorized commands - if (stristr($switch_cmd, 'user_status') == true) { - //authorized; - } elseif (stristr($switch_cmd, 'callcenter_config') == true) { - //authorized; - } elseif (stristr($switch_cmd, 'eavesdrop') == true) { - //authorized; - } else { - //not found. this command is not authorized - echo "access denied"; - exit; - } - -//set the username - if (if_group("admin") || if_group("superadmin")) { - //use the username that was provided - } - else { - $username = $_SESSION['username']; - } - -//get to php variables - if (count($_GET)>0) { - if ($action == "user_status") { - $user_status = $data; - $sql = "update v_users set "; - $sql .= "user_status = '".trim($user_status, "'")."' "; - $sql .= "where domain_uuid = '$domain_uuid' "; - $sql .= "and username = '".$username."' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - } - - //fs cmd - if (strlen($switch_cmd) > 0) { - //setup the event socket connection - $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); - //ensure the connection exists - if ($fp) { - //send the command - $switch_result = event_socket_request($fp, 'api '.$switch_cmd); - //set the user state - $cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting"; - $response = event_socket_request($fp, $cmd); - } - } - } - -?> +0) { + $switch_cmd = trim($_GET["cmd"]); + $action = trim(check_str($_GET["action"])); + $data = trim(check_str($_GET["data"])); + $username = trim(check_str($_GET["username"])); + } + +//authorized commands + if (stristr($switch_cmd, 'user_status') == true) { + //authorized; + } elseif (stristr($switch_cmd, 'callcenter_config') == true) { + //authorized; + } elseif (stristr($switch_cmd, 'eavesdrop') == true) { + //authorized; + } elseif (stristr($switch_cmd, 'bridge') == true) { + //authorized; + } elseif (stristr($switch_cmd, 'uuid_transfer') == true) { + //authorized; + } else { + //not found. this command is not authorized + echo "access denied"; + exit; + } + +//set the username + if (if_group("admin") || if_group("superadmin")) { + //use the username that was provided + } + else { + $username = $_SESSION['username']; + } + +//get to php variables + if (count($_GET)>0) { + if ($action == "user_status") { + $user_status = $data; + $sql = "update v_users set "; + $sql .= "user_status = '".trim($user_status, "'")."' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and username = '".$username."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + } + + //fs cmd + if (strlen($switch_cmd) > 0) { + //setup the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + //ensure the connection exists + if ($fp) { + //send the command + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + //set the user state + $cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting"; + $response = event_socket_request($fp, $cmd); + } + } + } + +?>