Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ require_once "root.php"; require_once "includes/require.php"; require_once "includes/checkauth.php"; if (permission_exists('call_center_agents_edit')) { //access granted } else { echo "access denied"; exit; } require_once "includes/header.php"; require_once "includes/paging.php"; //setup the event socket connection $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); //get the http post values and set them as php variables if (count($_POST)>0) { //include the dnd php class include "includes/classes/do_not_disturb.php"; foreach($_POST['agents'] as $row) { if (strlen($row['status']) > 0) { //agent set status if ($fp) { //set the user_status $sql = "update v_users set "; $sql .= "user_status = '".$row['status']."' "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and username = '".$row['name']."' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); //set the call center status if ($row['status'] == "Do Not Disturb") { //set the default dnd action $dnd_action = "add"; //set the call center status to Logged Out $cmd = "api callcenter_config agent set status ".$row['name']."@".$_SESSION['domains'][$domain_uuid]['domain_name']." 'Logged Out'"; } else { $cmd = "api callcenter_config agent set status ".$row['name']."@".$_SESSION['domains'][$domain_uuid]['domain_name']." '".$row['status']."'"; } //echo $cmd."
\n"; $response = event_socket_request($fp, $cmd); usleep(200); } //loop through the list of assigned extensions foreach ($_SESSION['user']['extension'] as &$sub_row) { $extension = $sub_row["user"]; //hunt_group information used to determine if this is an add or an update $sql = "select * from v_hunt_groups "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and hunt_group_extension = '$extension' "; $prep_statement_2 = $db->prepare(check_sql($sql)); $prep_statement_2->execute(); $result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED); foreach ($result2 as &$row2) { if ($row2["hunt_group_type"] == 'dnd') { $dnd_action = "update"; $dnd_uuid = $row2["hunt_group_uuid"]; } } unset ($prep_statement_2, $result2, $row2); //add or update dnd $dnd = new do_not_disturb; //$dnd->debug = false; $dnd->domain_uuid = $domain_uuid; $dnd->dnd_uuid = $dnd_uuid; $dnd->domain_name = $_SESSION['domain_name']; $dnd->extension = $extension; if ($row['status'] == "Do Not Disturb") { $dnd->dnd_enabled = "true"; if ($dnd_action == "add") { $dnd->dnd_add(); } if ($dnd_action == "update") { $dnd->dnd_update(); } } else { //for other status disable dnd if ($dnd_action == "update") { $dnd->dnd_enabled = "false"; $dnd->dnd_update(); } } unset($dnd); } unset ($prep_statement); } } } //get the agent list from event socket $switch_cmd = 'callcenter_config agent list'; $event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); $agent_array = csv_to_named_array($event_socket_str, '|'); //set the status on the user_array by using the extension as the key foreach ($agent_array as $row) { if (count($_SESSION['domains']) == 1) { //get the extension status from the call center agent list preg_match('/user\/(\d{2,7})/', $row['contact'], $matches); $extension = $matches[1]; $user_array[$extension]['username'] = $tmp[0]; if ($user_array[$extension]['user_status'] != "Do Not Disturb") { $user_array[$extension]['user_status'] = $row['status']; } } else { $tmp = explode('@',$row["name"]); if ($tmp[1] == $_SESSION['domain_name']) { //get the extension status from the call center agent list preg_match('/user\/(\d{2,7})/', $row['contact'], $matches); $extension = $matches[1]; $user_array[$extension]['username'] = $tmp[0]; if ($user_array[$extension]['user_status'] != "Do Not Disturb") { $user_array[$extension]['user_status'] = $row['status']; } } } } //show the content echo "
"; echo "\n"; echo "\n"; echo " "; echo ""; echo "
\n"; echo "
"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Call Center Agent Status\n"; echo " \n"; echo " \n"; echo "
\n"; echo "List all the call center agents with the option to change the status of one or more agents.

\n"; echo "
\n"; $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $x = 0; foreach($agent_array as $row) { $tmp = explode('@',$row["name"]); $agent_name = $tmp[0]; if ($tmp[1] == $_SESSION['domain_name']) { echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; } if ($c==0) { $c=1; } else { $c=0; } $x++; } //end foreach unset($sql, $result, $row_count); echo "\n"; echo "\n"; echo "\n"; echo "
AgentStatusOptions
".$row['name']." ".$row['status']." "; 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 "
 $paging_controls\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
"; echo "
"; echo "

"; echo "

"; echo "
"; echo "
"; echo "\n"; echo "

"; //show the footer require_once "includes/footer.php"; ?>