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 "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('call_center_tier_add') || permission_exists('call_center_tier_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //set tier uuid $call_center_tier_uuid = check_str($_REQUEST["id"]); //get http post variables and set them to php variables if (count($_POST)>0) { $agent_name = check_str($_POST["agent_name"]); $queue_name = check_str($_POST["queue_name"]); $tier_level = check_str($_POST["tier_level"]); $tier_position = check_str($_POST["tier_position"]); } if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $msg = ''; $call_center_tier_uuid = check_str($_POST["call_center_tier_uuid"]); //check for all required data //if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid
\n"; } //if (strlen($agent_name) == 0) { $msg .= $text['message-required'].$text['label-agent_name']."
\n"; } //if (strlen($queue_name) == 0) { $msg .= $text['message-required'].$text['label-queue_name']."
\n"; } //if (strlen($tier_level) == 0) { $msg .= $text['message-required'].$text['label-tier_level']."
\n"; } //if (strlen($tier_position) == 0) { $msg .= $text['message-required'].$text['label-tier_position']."
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } //add the agent //setup the event socket connection $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); //add the agent using event socket if ($fp) { //get the domain using the $domain_uuid $tmp_domain = $_SESSION['domains'][$domain_uuid]['domain_name']; //syntax //callcenter_config tier add [queue_name] [agent_name] [level] [position] //callcenter_config tier set state [queue_name] [agent_name] [state] //callcenter_config tier set level [queue_name] [agent_name] [level] //callcenter_config tier set position [queue_name] [agent_name] [position] //add the agent $cmd = "api callcenter_config tier add ".$queue_name."@".$tmp_domain." ".$agent_name."@".$tmp_domain." ".$tier_level." ".$tier_position; $response = event_socket_request($fp, $cmd); usleep(200); //agent set level $cmd = "api callcenter_config tier set level ".$queue_name."@".$tmp_domain." ".$agent_name."@".$tmp_domain." ".$tier_level; $response = event_socket_request($fp, $cmd); usleep(200); //agent set position $cmd = "api callcenter_config tier set position ".$queue_name."@".$tmp_domain." ".$agent_name."@".$tmp_domain." ".$tier_position; $response = event_socket_request($fp, $cmd); usleep(200); } //update the database $sql = "update v_call_center_tiers set "; $sql .= "domain_uuid = '$domain_uuid', "; $sql .= "agent_name = '$agent_name', "; $sql .= "queue_name = '$queue_name', "; $sql .= "tier_level = '$tier_level', "; $sql .= "tier_position = '$tier_position' "; $sql .= "where call_center_tier_uuid = '$call_center_tier_uuid'"; $db->exec(check_sql($sql)); unset($sql); //syncrhonize configuration save_call_center_xml(); remove_config_from_cache('configuration:callcenter.conf'); //look up queue uuid by queue name (ugh) $sql = "select call_center_queue_uuid from v_call_center_queues where queue_name = '".$queue_name."'"; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $queue_uuid = $row["call_center_queue_uuid"]; break; } unset($prep_statement); message::add($text['message-update']); header("Location: call_center_queue_edit.php?id=".$queue_uuid); return; } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if (count($_GET)>0 && $_POST["persistformvar"] != "true") { $sql = "select * from v_call_center_tiers "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and call_center_tier_uuid = '$call_center_tier_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $agent_name = $row["agent_name"]; $queue_name = $row["queue_name"]; $tier_level = $row["tier_level"]; $tier_position = $row["tier_position"]; break; //limit to 1 row } unset ($prep_statement); } //show the header require_once "resources/header.php"; $document['title'] = $text['title-call_center_tier_edit']; //show the content 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"; 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 ""; echo "
".$text['header-call_center_tier_edit'].""; echo " "; echo " \n"; echo "
\n"; echo $text['description-call_center_tiers']."

\n"; echo "
\n"; echo " ".$text['label-agent_name']."\n"; echo "\n"; //---- Begin Select List -------------------- $sql = "SELECT * FROM v_users "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and user_enabled = 'true' "; $sql .= "order by username asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); echo ""; unset($sql, $result); //---- End Select List -------------------- echo "
\n"; echo $text['description-agent']."\n"; echo "
\n"; echo " ".$text['label-queue_name']."\n"; echo "\n"; //---- Begin Select List -------------------- $sql = "SELECT * FROM v_call_center_queues "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "order by queue_name asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); echo ""; unset($sql, $result); //---- End Select List -------------------- echo "
\n"; echo $text['description-options']."\n"; echo "
\n"; echo " ".$text['label-tier_level']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-tier_level']."\n"; echo "
\n"; echo " ".$text['label-tier_position']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-tier_position']."\n"; echo "
\n"; echo " \n"; echo "
"; echo " \n"; echo "
"; echo "
"; require_once "resources/footer.php"; ?>