Database class integration.

This commit is contained in:
Nate 2019-07-02 10:56:36 -06:00
parent f7742bef81
commit d50170269e
11 changed files with 346 additions and 389 deletions

View File

@ -49,11 +49,11 @@
//get the queues from the database //get the queues from the database
if (!is_array($_SESSION['queues'])) { if (!is_array($_SESSION['queues'])) {
$sql = "select * from v_call_center_queues "; $sql = "select * from v_call_center_queues ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by queue_name ASC "; $sql .= "order by queue_name asc ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute(); $database = new database;
$_SESSION['queues'] = $prep_statement->fetchAll(PDO::FETCH_NAMED); $_SESSION['queues'] = $database->select($sql, $parameters, 'all');
} }
//get the queue name //get the queue name
@ -150,11 +150,11 @@
//get the agents from the database //get the agents from the database
if (!is_array($_SESSION['agents'])) { if (!is_array($_SESSION['agents'])) {
$sql = "select * from v_call_center_agents "; $sql = "select * from v_call_center_agents ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by agent_name ASC "; $sql .= "order by agent_name asc ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute(); $database = new database;
$_SESSION['agents'] = $prep_statement->fetchAll(PDO::FETCH_NAMED); $_SESSION['agents'] = $database->select($sql, $parameters, 'all');
} }
//list the agents //list the agents

View File

@ -50,21 +50,6 @@
$order_by = $_GET["order_by"]; $order_by = $_GET["order_by"];
$order = $_GET["order"]; $order = $_GET["order"];
//validate order by
if (strlen($order_by) > 0) {
$order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', $order_by);
}
//validate the order
switch ($order) {
case 'asc':
break;
case 'desc':
break;
default:
$order = '';
}
//show the content //show the content
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n"; echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
@ -82,7 +67,6 @@
//get the call center queue count //get the call center queue count
$sql = "select count(*) from v_call_center_queues "; $sql = "select count(*) from v_call_center_queues ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
if (strlen($order_by) > 0) { $sql .= "order by $order_by $order "; }
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database; $database = new database;
$num_rows = $database->select($sql, $parameters, 'column'); $num_rows = $database->select($sql, $parameters, 'column');
@ -98,12 +82,10 @@
//get the call center queues //get the call center queues
$sql = "select * from v_call_center_queues "; $sql = "select * from v_call_center_queues ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
if (strlen($order_by) > 0) { $sql .= "order by $order_by $order "; } $sql .= order_by($order_by, $order);
$sql .= " limit :rows_per_page offset :offset "; $sql .= limit_offset($rows_per_page, $offset);
$database = new database; $database = new database;
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['rows_per_page'] = $rows_per_page;
$parameters['offset'] = $offset;
$call_center_queues = $database->select($sql, $parameters, 'all'); $call_center_queues = $database->select($sql, $parameters, 'all');
$c = 0; $c = 0;

View File

@ -51,21 +51,6 @@
$order_by = $_GET["order_by"]; $order_by = $_GET["order_by"];
$order = $_GET["order"]; $order = $_GET["order"];
//validate order by
if (strlen($order_by) > 0) {
$order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', $order_by);
}
//validate the order
switch ($order) {
case 'asc':
break;
case 'desc':
break;
default:
$order = '';
}
//setup the event socket connection //setup the event socket connection
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
@ -81,12 +66,15 @@
if ($fp) { if ($fp) {
//set the user_status //set the user_status
$sql = "update v_users set "; $sql = "update v_users set ";
$sql .= "user_status = '".$row['agent_status']."' "; $sql .= "user_status = :user_status ";
$sql .= "where domain_uuid = '".$domain_uuid."' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and username = '".$row['agent_name']."' "; $sql .= "and username = :username ";
//echo $sql."\n"; $parameters['user_status'] = $row['agent_status'];
//$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
//$prep_statement->execute(); $parameters['username'] = $row['agent_name'];
//$database = new database;
//$database->execute($sql, $parameters);
//unset($sql, $parameters);
//set the agent status to available and assign the agent to the queue with the tier //set the agent status to available and assign the agent to the queue with the tier
if ($row['agent_status'] == 'Available') { if ($row['agent_status'] == 'Available') {
@ -124,18 +112,21 @@
$sql = "select * from v_call_center_queues "; $sql = "select * from v_call_center_queues ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by queue_name asc "; $sql .= "order by queue_name asc ";
$database = new database;
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$call_center_queues = $database->select($sql, $parameters, 'all'); $call_center_queues = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//get the agents from the database //get the agents from the database
$sql = "select * from v_call_center_agents "; $sql = "select * from v_call_center_agents ";
$sql .= "where user_uuid = :user_uuid "; $sql .= "where user_uuid = :user_uuid ";
$sql .= "and domain_uuid = :domain_uuid "; $sql .= "and domain_uuid = :domain_uuid ";
//$sql .= "ORDER BY agent_name ASC "; //$sql .= "ORDER BY agent_name ASC ";
$database = new database;
$parameters['user_uuid'] = $_SESSION['user_uuid']; $parameters['user_uuid'] = $_SESSION['user_uuid'];
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$agent = $database->select($sql, $parameters, 'all'); $agent = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//echo "<pre>\n"; //echo "<pre>\n";
//print_r($agent); //print_r($agent);
//echo "</pre>\n"; //echo "</pre>\n";

View File

@ -30,10 +30,7 @@
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
//check the permissions //check the permissions
if (permission_exists('call_center_agent_delete')) { if (!permission_exists('call_center_agent_delete')) {
//access granted
}
else {
echo "access denied"; echo "access denied";
exit; exit;
} }
@ -43,47 +40,50 @@
$text = $language->get(); $text = $language->get();
//get the primary key //get the primary key
if (isset($_GET["id"]) && is_uuid($_GET["id"])) { if (is_uuid($_GET["id"])) {
$id = check_str($_GET["id"]); $agent_uuid = $_GET["id"];
}
else { //delete the agent from the freeswitch
exit; //setup the event socket connection
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
//delete the agent over event socket
if ($fp) {
$cmd = "api callcenter_config agent del ".$agent_uuid;
$response = event_socket_request($fp, $cmd);
}
//delete the agent from db
//tiers table
$sql = "delete from v_call_center_tiers ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and agent_name = :agent_name ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['agent_name'] = $agent_uuid;
$database = new database;
$database->execute($sql, $parameters);
unset($sql, $parameters);
//agents table
$array['call_center_agents'][0]['call_center_agent_uuid'] = $agent_uuid;
$array['call_center_agents'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$database->app_name = 'call_centers';
$database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
$database->delete($array);
$response = $database->message;
unset($array);
//synchronize configuration
save_call_center_xml();
remove_config_from_cache('configuration:callcenter.conf');
//set message
message::add($text['message-delete']);
} }
//delete the agent from the freeswitch
//setup the event socket connection
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
//delete the agent over event socket
if ($fp) {
$cmd = "api callcenter_config agent del ".$id;
$response = event_socket_request($fp, $cmd);
}
//delete the agent from db
if (strlen($id)>0) {
//tiers table
$sql = "delete from v_call_center_tiers ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and agent_name = '$agent_name' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($sql);
//agents table
$sql = "delete from v_call_center_agents ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and call_center_agent_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($sql);
}
//synchronize configuration
save_call_center_xml();
remove_config_from_cache('configuration:callcenter.conf');
//redirect the browser //redirect the browser
message::add($text['message-delete']);
header("Location: call_center_agents.php"); header("Location: call_center_agents.php");
return; return;

View File

@ -47,34 +47,31 @@
if ($_GET["check"] == 'duplicate') { if ($_GET["check"] == 'duplicate') {
//agent id //agent id
if ($_GET["agent_id"] != '') { if ($_GET["agent_id"] != '') {
$sql = "select "; $sql = "select agent_name ";
$sql .= "agent_name "; $sql .= "from v_call_center_agents ";
$sql .= "from "; $sql .= "where agent_id = :agent_id ";
$sql .= "v_call_center_agents "; $sql .= "and domain_uuid = :domain_uuid ";
$sql .= "where "; if (is_uuid($_GET["agent_uuid"])) {
$sql .= "agent_id = '".check_str($_GET["agent_id"])."' "; $sql .= " and call_center_agent_uuid <> :call_center_agent_uuid ";
$sql .= "and domain_uuid = '".$domain_uuid."' "; $parameters['call_center_agent_uuid'] = $_GET["agent_uuid"];
if ($_GET["agent_uuid"] != '') {
$sql .= " and call_center_agent_uuid <> '".check_str($_GET["agent_uuid"])."' ";
} }
$prep_statement = $db->prepare($sql); $parameters['agent_id'] = $_GET["agent_id"];
if ($prep_statement) { $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute(); $database = new database;
$row = $prep_statement->fetch(PDO::FETCH_ASSOC); $row = $database->select($sql, $parameters, 'row');
if ($row['agent_name'] != '') { if (is_array($row) && sizeof($row) != 0 && $row['agent_name'] != '') {
echo $text['message-duplicate_agent_id'].((if_group("superadmin")) ? ": ".$row["agent_name"] : null); echo $text['message-duplicate_agent_id'].(if_group("superadmin") ? ": ".$row["agent_name"] : null);
}
} }
unset($prep_statement); unset($sql, $parameters);
} }
exit; exit;
} }
//action add or update //action add or update
if (isset($_REQUEST["id"])) { if (is_uuid($_REQUEST["id"])) {
$action = "update"; $action = "update";
$call_center_agent_uuid = check_str($_REQUEST["id"]); $call_center_agent_uuid = $_REQUEST["id"];
} }
else { else {
$action = "add"; $action = "add";
@ -82,21 +79,21 @@
//get http post variables and set them to php variables //get http post variables and set them to php variables
if (is_array($_POST)) { if (is_array($_POST)) {
$call_center_agent_uuid = check_str($_POST["call_center_agent_uuid"]); $call_center_agent_uuid = $_POST["call_center_agent_uuid"];
$user_uuid = check_str($_POST["user_uuid"]); $user_uuid = $_POST["user_uuid"];
$agent_name = check_str($_POST["agent_name"]); $agent_name = $_POST["agent_name"];
$agent_type = check_str($_POST["agent_type"]); $agent_type = $_POST["agent_type"];
$agent_call_timeout = check_str($_POST["agent_call_timeout"]); $agent_call_timeout = $_POST["agent_call_timeout"];
$agent_id = check_str($_POST["agent_id"]); $agent_id = $_POST["agent_id"];
$agent_password = check_str($_POST["agent_password"]); $agent_password = $_POST["agent_password"];
$agent_status = check_str($_POST["agent_status"]); $agent_status = $_POST["agent_status"];
$agent_contact = check_str($_POST["agent_contact"]); $agent_contact = $_POST["agent_contact"];
$agent_no_answer_delay_time = check_str($_POST["agent_no_answer_delay_time"]); $agent_no_answer_delay_time = $_POST["agent_no_answer_delay_time"];
$agent_max_no_answer = check_str($_POST["agent_max_no_answer"]); $agent_max_no_answer = $_POST["agent_max_no_answer"];
$agent_wrap_up_time = check_str($_POST["agent_wrap_up_time"]); $agent_wrap_up_time = $_POST["agent_wrap_up_time"];
$agent_reject_delay_time = check_str($_POST["agent_reject_delay_time"]); $agent_reject_delay_time = $_POST["agent_reject_delay_time"];
$agent_busy_delay_time = check_str($_POST["agent_busy_delay_time"]); $agent_busy_delay_time = $_POST["agent_busy_delay_time"];
//$agent_logout = check_str($_POST["agent_logout"]); //$agent_logout = $_POST["agent_logout"];
} }
//process the user data and save it to the database //process the user data and save it to the database
@ -104,7 +101,7 @@
//get the uuid from the POST //get the uuid from the POST
if ($action == "update") { if ($action == "update") {
$call_center_agent_uuid = check_str($_POST["call_center_agent_uuid"]); $call_center_agent_uuid = $_POST["call_center_agent_uuid"];
} }
//check for all required data //check for all required data
@ -214,8 +211,8 @@
} }
//get the users array //get the users array
$sql = "SELECT * FROM v_users "; $sql = "select * from v_users ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "where domain_uuid = :domain_uuid'".$_SESSION['domain_uuid']."' ";
$sql .= "order by username asc "; $sql .= "order by username asc ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
@ -264,14 +261,15 @@
//pre-populate the form //pre-populate the form
if (is_array($_GET) && $_POST["persistformvar"] != "true") { if (is_array($_GET) && $_POST["persistformvar"] != "true") {
$call_center_agent_uuid = check_str($_GET["id"]); $call_center_agent_uuid = $_GET["id"];
$sql = "select * from v_call_center_agents "; $sql = "select * from v_call_center_agents ";
$sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and call_center_agent_uuid = '$call_center_agent_uuid' "; $sql .= "and call_center_agent_uuid = :call_center_agent_uuid ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute(); $parameters['call_center_agent_uuid'] = $call_center_agent_uuid;
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $database = new database;
foreach ($result as &$row) { $row = $database->select($sql, $parameters, 'row');
if (is_array($row) && sizeof($row) != 0) {
$call_center_agent_uuid = $row["call_center_agent_uuid"]; $call_center_agent_uuid = $row["call_center_agent_uuid"];
$user_uuid = $row["user_uuid"]; $user_uuid = $row["user_uuid"];
$agent_name = $row["agent_name"]; $agent_name = $row["agent_name"];
@ -288,7 +286,7 @@
$agent_busy_delay_time = $row["agent_busy_delay_time"]; $agent_busy_delay_time = $row["agent_busy_delay_time"];
//$agent_logout = $row["agent_logout"]; //$agent_logout = $row["agent_logout"];
} }
unset ($prep_statement); unset($sql, $parameters);
} }
//set default values //set default values
@ -310,14 +308,14 @@
} }
//get the list of users for this domain //get the list of users for this domain
$sql = "SELECT * FROM v_users "; $sql = "select * from v_users ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and user_enabled = 'true' "; $sql .= "and user_enabled = 'true' ";
$sql .= "order by username asc "; $sql .= "order by username asc ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute(); $database = new database;
$users = $prep_statement->fetchAll(PDO::FETCH_NAMED); $users = $database->select($sql, $parameters, 'all');
unset($sql); unset($sql, $parameters);
//javascript to check for duplicates //javascript to check for duplicates
?> ?>

View File

@ -50,8 +50,8 @@
//get the agents from the database //get the agents from the database
$sql = "select * from v_call_center_tiers "; $sql = "select * from v_call_center_tiers ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$database = new database;
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$tiers = $database->select($sql, $parameters, 'all'); $tiers = $database->select($sql, $parameters, 'all');
if (count($tiers) == 0) { if (count($tiers) == 0) {
$per_queue_login = true; $per_queue_login = true;
@ -59,6 +59,7 @@
else { else {
$per_queue_login = false; $per_queue_login = false;
} }
unset($sql, $parameters);
//setup the event socket connection //setup the event socket connection
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
@ -77,15 +78,21 @@
if ($fp) { if ($fp) {
//set the user_status //set the user_status
if (!isset($row['queue_name'])) { if (!isset($row['queue_name'])) {
$sql = "update v_users set "; $array['users'][0]['user_uuid'] = $row['user_uuid'];
$sql .= "user_status = :row['agent_status'] "; $array['users'][0]['user_status'] = $row['agent_status'];
$sql .= "where domain_uuid = :domain_uuid "; $array['users'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$sql .= "and user_uuid = :row['user_uuid'] ";
$parameters['agent_uuid'] = $row['agent_uuid']; $p = new permissions;
$parameters['agent_status'] = $row['agent_status']; $p->add('user_edit', 'temp');
$database = new database; $database = new database;
$database->select($sql, $parameters); $database->app_name = 'call_centers';
unset($parameters); $database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
$database->save($array);
$response = $database->message;
unset($array);
$p->delete('user_edit', 'temp');
} }
//validate the agent status //validate the agent status
@ -153,11 +160,12 @@
//get the agents from the database //get the agents from the database
$sql = "select agent_name from v_call_center_agents "; $sql = "select agent_name from v_call_center_agents ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and call_center_agent_uuid = :row['agent_uuid'] "; $sql .= "and call_center_agent_uuid = :call_center_agent_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['call_center_agent_uuid'] = $row['agent_uuid'];
$database = new database; $database = new database;
$parameters['agent_uuid'] = $row['agent_uuid'];
$agent_name = $database->select($sql, $parameters, 'all'); $agent_name = $database->select($sql, $parameters, 'all');
unset($parameters); unset($sql, $parameters);
if ($row['agent_status'] == 'Available') { if ($row['agent_status'] == 'Available') {
$answer_state = 'confirmed'; $answer_state = 'confirmed';
@ -187,8 +195,10 @@
$sql = "select * from v_call_center_agents "; $sql = "select * from v_call_center_agents ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by agent_name asc "; $sql .= "order by agent_name asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database; $database = new database;
$agents = $database->select($sql, $parameters, 'all'); $agents = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//get the agent list from event socket //get the agent list from event socket
$switch_cmd = 'callcenter_config agent list'; $switch_cmd = 'callcenter_config agent list';
@ -204,8 +214,10 @@
$sql = "select * from v_call_center_queues "; $sql = "select * from v_call_center_queues ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by queue_name asc "; $sql .= "order by queue_name asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database; $database = new database;
$call_center_queues = $database->select($sql, $parameters, 'all'); $call_center_queues = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//add the status to the call_center_queues array //add the status to the call_center_queues array
$x = 0; $x = 0;

View File

@ -48,24 +48,9 @@
require_once "resources/paging.php"; require_once "resources/paging.php";
//get http values and set them to php variables //get http values and set them to php variables
$order_by = $_GET["order_by"]; $order_by = $_GET["order_by"] != '' ? $_GET["order_by"] : 'agent_name';
$order = $_GET["order"]; $order = $_GET["order"];
//validate order by
if (strlen($order_by) > 0) {
$order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', $order_by);
}
//validate the order
switch ($order) {
case 'asc':
break;
case 'desc':
break;
default:
$order = '';
}
//show content //show content
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n"; echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
@ -82,20 +67,12 @@
echo "</tr>\n"; echo "</tr>\n";
echo "</tr></table>\n"; echo "</tr></table>\n";
$sql = "select * from v_call_center_agents "; $sql = "select count(*) from v_call_center_agents ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
if (strlen($order_by) == 0) {
$order_by = 'agent_name';
$order = 'asc';
}
else {
$sql .= "order by $order_by $order ";
}
$database = new database;
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['rows_per_page'] = $rows_per_page; $database = new database;
$parameters['offset'] = $offset; $num_rows = $database->select($sql, $parameters, 'column');
$result = $database->select($sql, $parameters, 'all'); unset($sql, $parameters);
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = ""; $param = "";
@ -106,18 +83,12 @@
$sql = "select * from v_call_center_agents "; $sql = "select * from v_call_center_agents ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
if (strlen($order_by) == 0) { $sql .= order_by($order_by, $order);
$order_by = 'agent_name'; $sql .= limit_offset($rows_per_page, $offset);
$order = 'asc'; $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
else {
$sql .= "order by $order_by $order ";
}
$sql .= " limit :rows_per_page offset :offset ";
$database = new database; $database = new database;
$parameters['rows_per_page'] = $rows_per_page;
$parameters['offset'] = $offset;
$result = $database->select($sql, $parameters, 'all'); $result = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
$c = 0; $c = 0;
$row_style["0"] = "row_style0"; $row_style["0"] = "row_style0";
@ -164,15 +135,16 @@
$bridge_statement = explode('/', $row['agent_contact']); $bridge_statement = explode('/', $row['agent_contact']);
if ($bridge_statement[0] == 'sofia' && $bridge_statement[1] == 'gateway' && is_uuid($bridge_statement[2])) { if ($bridge_statement[0] == 'sofia' && $bridge_statement[1] == 'gateway' && is_uuid($bridge_statement[2])) {
// retrieve gateway name from db // retrieve gateway name from db
$sql = "select gateway from v_gateways where gateway_uuid = '".$bridge_statement[2]."' "; $sql = "select gateway from v_gateways ";
$prep_statement = $db->prepare(check_sql($sql)); $sql .= "where gateway_uuid = :gateway_uuid ";
$prep_statement->execute(); $parameters['gateway_uuid'] = $bridge_statement[2];
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $database = new database;
$result = $database->select($sql, $parameters, 'all');
if (count($result) > 0) { if (count($result) > 0) {
$gateway_name = $result[0]['gateway']; $gateway_name = $result[0]['gateway'];
$agent_contact = str_replace($bridge_statement[2], $gateway_name, $agent_contact); $agent_contact = str_replace($bridge_statement[2], $gateway_name, $agent_contact);
} }
unset ($prep_statement, $sql, $bridge_statement); unset($sql, $parameters, $bridge_statement);
} }
echo " <td valign='top' class='".$row_style[$c]."'>".$agent_contact."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$agent_contact."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['agent_max_no_answer'])."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['agent_max_no_answer'])."&nbsp;</td>\n";
@ -193,7 +165,7 @@
echo "</tr>\n"; echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; } if ($c==0) { $c=1; } else { $c=0; }
} //end foreach } //end foreach
unset($sql, $result, $row_count); unset($result);
} //end if results } //end if results
echo "<tr>\n"; echo "<tr>\n";

View File

@ -42,52 +42,58 @@
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//get the id
if (count($_GET) > 0) {
$id = check_str($_GET["id"]);
}
//delete the data //delete the data
if (strlen($id) > 0) { if (is_uuid($_GET["id"])) {
$call_center_queue_uuid = $_GET["id"];
//get the dialplan uuid //get the dialplan uuid
$sql = "select * from v_call_center_queues "; $sql = "select * from v_call_center_queues ";
$sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and call_center_queue_uuid = '$id' "; $sql .= "and call_center_queue_uuid = :call_center_queue_uuid ";
$prep_statement = $db->prepare($sql); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute(); $parameters['call_center_queue_uuid'] = $call_center_queue_uuid;
while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) { $database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row) && sizeof($row) != 0) {
$queue_name = $row['queue_name']; $queue_name = $row['queue_name'];
$dialplan_uuid = $row['dialplan_uuid']; $dialplan_uuid = $row['dialplan_uuid'];
} }
unset($sql, $parameters, $row);
//delete the tier from the database //delete the tier from the database
$sql = "delete from v_call_center_tiers "; $array['call_center_tiers'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$sql .= "where domain_uuid = '$domain_uuid' "; $array['call_center_tiers'][0]['call_center_queue_uuid'] = $call_center_queue_uuid;
$sql .= "and (call_center_queue_uuid = '$id' or queue_name = '".$queue_name."@".$_SESSION['domain_name']."') "; $array['call_center_tiers'][1]['domain_uuid'] = $_SESSION['domain_uuid'];
$db->query($sql); $array['call_center_tiers'][1]['queue_name'] = $queue_name."@".$_SESSION['domain_name'];
unset($sql);
//delete the call center queue //delete the call center queue
$sql = "delete from v_call_center_queues "; $array['call_center_queues'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$sql .= "where domain_uuid = '$domain_uuid' "; $array['call_center_queues'][0]['call_center_queue_uuid'] = $call_center_queue_uuid;
$sql .= "and call_center_queue_uuid = '$id' ";
$db->query($sql);
unset($sql);
//delete the dialplan entry //delete the dialplan entry
$sql = "delete from v_dialplans "; $array['dialplans'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$sql .= "where domain_uuid = '$domain_uuid' "; $array['dialplans'][0]['dialplan_uuid'] = $dialplan_uuid;
$sql .= "and dialplan_uuid = '$dialplan_uuid' ";
$db->query($sql);
unset($sql);
//delete the dialplan details //delete the dialplan details
$sql = "delete from v_dialplan_details "; $array['dialplan_details'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$sql .= "where domain_uuid = '$domain_uuid' "; $array['dialplan_details'][0]['dialplan_uuid'] = $dialplan_uuid;
$sql .= "and dialplan_uuid = '$dialplan_uuid' ";
$db->query($sql); //execute
unset($sql); $p = new permissions;
$p->add('call_center_tier_delete', 'temp');
$p->add('dialplan_delete', 'temp');
$p->add('dialplan_detail_delete', 'temp');
$database = new database;
$database->app_name = 'call_centers';
$database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
$database->delete($array);
$response = $database->message;
unset($array);
$p->delete('call_center_tier_delete', 'temp');
$p->delete('dialplan_delete', 'temp');
$p->delete('dialplan_detail_delete', 'temp');
//clear the cache //clear the cache
$cache = new cache; $cache = new cache;
@ -100,10 +106,12 @@
//apply settings reminder //apply settings reminder
$_SESSION["reload_xml"] = true; $_SESSION["reload_xml"] = true;
//set message
message::add($text['message-delete']);
} }
//redirect the browser //redirect the browser
message::add($text['message-delete']);
header("Location: call_center_queues.php"); header("Location: call_center_queues.php");
return; return;

View File

@ -44,9 +44,9 @@
$text = $language->get(); $text = $language->get();
//action add or update //action add or update
if (isset($_REQUEST["id"])) { if (is_uuid($_REQUEST["id"])) {
$action = "update"; $action = "update";
$call_center_queue_uuid = check_str($_REQUEST["id"]); $call_center_queue_uuid = $_REQUEST["id"];
} }
else { else {
$action = "add"; $action = "add";
@ -55,15 +55,13 @@
//get total call center queues count from the database, check limit, if defined //get total call center queues count from the database, check limit, if defined
if ($action == 'add') { if ($action == 'add') {
if ($_SESSION['limit']['call_center_queues']['numeric'] != '') { if ($_SESSION['limit']['call_center_queues']['numeric'] != '') {
$sql = "select count(*) as num_rows from v_call_center_queues "; $sql = "select count(*) from v_call_center_queues ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "where domain_uuid = :domain_uuid ";
$prep_statement = $db->prepare($sql); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
if ($prep_statement) { $database = new database;
$prep_statement->execute(); $total_call_center_queues = $database->select($sql, $parameters, 'column');
$row = $prep_statement->fetch(PDO::FETCH_ASSOC); unset($sql, $parameters);
$total_call_center_queues = $row['num_rows'];
}
unset($prep_statement, $row);
if ($total_call_center_queues >= $_SESSION['limit']['call_center_queues']['numeric']) { if ($total_call_center_queues >= $_SESSION['limit']['call_center_queues']['numeric']) {
message::add($text['message-maximum_queues'].' '.$_SESSION['limit']['call_center_queues']['numeric'], 'negative'); message::add($text['message-maximum_queues'].' '.$_SESSION['limit']['call_center_queues']['numeric'], 'negative');
header('Location: call_center_queues.php'); header('Location: call_center_queues.php');
@ -75,30 +73,30 @@
//get http post variables and set them to php variables //get http post variables and set them to php variables
if (is_array($_POST)) { if (is_array($_POST)) {
//get the post variables a run a security chack on them //get the post variables a run a security chack on them
//$domain_uuid = check_str($_POST["domain_uuid"]); //$domain_uuid = $_POST["domain_uuid"];
$dialplan_uuid = check_str($_POST["dialplan_uuid"]); $dialplan_uuid = $_POST["dialplan_uuid"];
$queue_name = check_str($_POST["queue_name"]); $queue_name = $_POST["queue_name"];
$queue_extension = check_str($_POST["queue_extension"]); $queue_extension = $_POST["queue_extension"];
$queue_greeting = check_str($_POST["queue_greeting"]); $queue_greeting = $_POST["queue_greeting"];
$queue_strategy = check_str($_POST["queue_strategy"]); $queue_strategy = $_POST["queue_strategy"];
$queue_moh_sound = check_str($_POST["queue_moh_sound"]); $queue_moh_sound = $_POST["queue_moh_sound"];
$queue_record_template = check_str($_POST["queue_record_template"]); $queue_record_template = $_POST["queue_record_template"];
$queue_time_base_score = check_str($_POST["queue_time_base_score"]); $queue_time_base_score = $_POST["queue_time_base_score"];
$queue_max_wait_time = check_str($_POST["queue_max_wait_time"]); $queue_max_wait_time = $_POST["queue_max_wait_time"];
$queue_max_wait_time_with_no_agent = check_str($_POST["queue_max_wait_time_with_no_agent"]); $queue_max_wait_time_with_no_agent = $_POST["queue_max_wait_time_with_no_agent"];
$queue_max_wait_time_with_no_agent_time_reached = check_str($_POST["queue_max_wait_time_with_no_agent_time_reached"]); $queue_max_wait_time_with_no_agent_time_reached = $_POST["queue_max_wait_time_with_no_agent_time_reached"];
$queue_tier_rules_apply = check_str($_POST["queue_tier_rules_apply"]); $queue_tier_rules_apply = $_POST["queue_tier_rules_apply"];
$queue_tier_rule_wait_second = check_str($_POST["queue_tier_rule_wait_second"]); $queue_tier_rule_wait_second = $_POST["queue_tier_rule_wait_second"];
$queue_tier_rule_wait_multiply_level = check_str($_POST["queue_tier_rule_wait_multiply_level"]); $queue_tier_rule_wait_multiply_level = $_POST["queue_tier_rule_wait_multiply_level"];
$queue_tier_rule_no_agent_no_wait = check_str($_POST["queue_tier_rule_no_agent_no_wait"]); $queue_tier_rule_no_agent_no_wait = $_POST["queue_tier_rule_no_agent_no_wait"];
$queue_timeout_action = check_str($_POST["queue_timeout_action"]); $queue_timeout_action = $_POST["queue_timeout_action"];
$queue_discard_abandoned_after = check_str($_POST["queue_discard_abandoned_after"]); $queue_discard_abandoned_after = $_POST["queue_discard_abandoned_after"];
$queue_abandoned_resume_allowed = check_str($_POST["queue_abandoned_resume_allowed"]); $queue_abandoned_resume_allowed = $_POST["queue_abandoned_resume_allowed"];
$queue_cid_prefix = check_str($_POST["queue_cid_prefix"]); $queue_cid_prefix = $_POST["queue_cid_prefix"];
$queue_announce_sound = check_str($_POST["queue_announce_sound"]); $queue_announce_sound = $_POST["queue_announce_sound"];
$queue_announce_frequency = check_str($_POST["queue_announce_frequency"]); $queue_announce_frequency = $_POST["queue_announce_frequency"];
$queue_cc_exit_keys = check_str($_POST["queue_cc_exit_keys"]); $queue_cc_exit_keys = $_POST["queue_cc_exit_keys"];
$queue_description = check_str($_POST["queue_description"]); $queue_description = $_POST["queue_description"];
//remove invalid characters //remove invalid characters
$queue_cid_prefix = str_replace(":", "-", $queue_cid_prefix); $queue_cid_prefix = str_replace(":", "-", $queue_cid_prefix);
@ -111,23 +109,25 @@
//delete the tier (agent from the queue) //delete the tier (agent from the queue)
if ($_REQUEST["a"] == "delete" && strlen($_REQUEST["id"]) > 0 && permission_exists("call_center_tier_delete")) { if ($_REQUEST["a"] == "delete" && strlen($_REQUEST["id"]) > 0 && permission_exists("call_center_tier_delete")) {
//set the variables //set the variables
$call_center_queue_uuid = check_str($_REQUEST["id"]); $call_center_queue_uuid = $_REQUEST["id"];
$call_center_tier_uuid = check_str($_REQUEST["call_center_tier_uuid"]); $call_center_tier_uuid = $_REQUEST["call_center_tier_uuid"];
//get the agent details //get the agent details
$sql = "select agent_name, queue_name, call_center_agent_uuid, call_center_queue_uuid "; $sql = "select agent_name, queue_name, call_center_agent_uuid, call_center_queue_uuid ";
$sql .= "from v_call_center_tiers "; $sql .= "from v_call_center_tiers ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and call_center_tier_uuid = '".$call_center_tier_uuid."' "; $sql .= "and call_center_tier_uuid = :call_center_tier_uuid ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute(); $parameters['call_center_tier_uuid'] = $call_center_tier_uuid;
$tiers = $prep_statement->fetchAll(PDO::FETCH_NAMED); $database = new database;
if (is_array($tiers)) { $tiers = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
if (is_array($tiers) && sizeof($tiers) != 0) {
foreach ($tiers as &$row) { foreach ($tiers as &$row) {
$call_center_agent_uuid = $row["call_center_agent_uuid"]; $call_center_agent_uuid = $row["call_center_agent_uuid"];
$call_center_queue_uuid = $row["call_center_queue_uuid"]; $call_center_queue_uuid = $row["call_center_queue_uuid"];
} }
} }
unset ($prep_statement);
//delete the agent from freeswitch //delete the agent from freeswitch
//setup the event socket connection //setup the event socket connection
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
@ -139,10 +139,19 @@
} }
//delete the tier from the database //delete the tier from the database
if (strlen($call_center_tier_uuid) > 0) { if (strlen($call_center_tier_uuid) > 0) {
$sql = "delete from v_call_center_tiers where domain_uuid = '".$_SESSION['domain_uuid']."' and call_center_tier_uuid = '".$call_center_tier_uuid."'"; $array['call_center_tiers'][0]['call_center_tier_uuid'] = $call_center_tier_uuid;
$prep_statement = $db->prepare(check_sql($sql)); $array['call_center_tiers'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute();
unset($sql); $p = new permissions;
$p->add('call_center_tier_delete', 'temp');
$database = new database;
$database->app_name = 'call_centers';
$database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
$database->delete($array);
unset($array);
$p->delete('call_center_tier_delete', 'temp');
} }
} }
@ -151,7 +160,7 @@
//get the uuid from the POST //get the uuid from the POST
if ($action == "update") { if ($action == "update") {
$call_center_queue_uuid = check_str($_POST["call_center_queue_uuid"]); $call_center_queue_uuid = $_POST["call_center_queue_uuid"];
} }
//check for all required data //check for all required data
@ -313,9 +322,9 @@
remove_config_from_cache('configuration:callcenter.conf'); remove_config_from_cache('configuration:callcenter.conf');
//add agent/tier to queue //add agent/tier to queue
$agent_name = check_str($_POST["agent_name"]); $agent_name = $_POST["agent_name"];
$tier_level = check_str($_POST["tier_level"]); $tier_level = $_POST["tier_level"];
$tier_position = check_str($_POST["tier_position"]); $tier_position = $_POST["tier_position"];
if ($agent_name != '') { if ($agent_name != '') {
//setup the event socket connection //setup the event socket connection
@ -362,11 +371,14 @@
if (is_array($_GET) && is_uuid($_GET["id"]) && $_POST["persistformvar"] != "true") { if (is_array($_GET) && is_uuid($_GET["id"]) && $_POST["persistformvar"] != "true") {
$call_center_queue_uuid = $_GET["id"]; $call_center_queue_uuid = $_GET["id"];
$sql = "select * from v_call_center_queues "; $sql = "select * from v_call_center_queues ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and call_center_queue_uuid = '$call_center_queue_uuid' "; $sql .= "and call_center_queue_uuid = :call_center_queue_uuid ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute(); $parameters['call_center_queue_uuid'] = $call_center_queue_uuid;
$call_center_queues = $prep_statement->fetchAll(PDO::FETCH_NAMED); $database = new database;
$call_center_queues = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
if (is_array($call_center_queues)) { if (is_array($call_center_queues)) {
foreach ($call_center_queues as &$row) { foreach ($call_center_queues as &$row) {
$queue_name = $row["queue_name"]; $queue_name = $row["queue_name"];
@ -395,19 +407,20 @@
$queue_description = $row["queue_description"]; $queue_description = $row["queue_description"];
} }
} }
unset ($prep_statement);
} }
//get the tiers //get the tiers
$sql = "select t.call_center_tier_uuid, t.call_center_agent_uuid, t.call_center_queue_uuid, t.tier_level, t.tier_position, a.agent_name "; $sql = "select t.call_center_tier_uuid, t.call_center_agent_uuid, t.call_center_queue_uuid, t.tier_level, t.tier_position, a.agent_name ";
$sql .= "from v_call_center_tiers as t, v_call_center_agents as a "; $sql .= "from v_call_center_tiers as t, v_call_center_agents as a ";
$sql .= "where t.call_center_queue_uuid = '".$call_center_queue_uuid."' "; $sql .= "where t.call_center_queue_uuid = :call_center_queue_uuid ";
$sql .= "and t.call_center_agent_uuid = a.call_center_agent_uuid "; $sql .= "and t.call_center_agent_uuid = a.call_center_agent_uuid ";
$sql .= "and t.domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "and t.domain_uuid = :domain_uuid ";
$sql .= "order by tier_level asc, tier_position asc, a.agent_name asc"; $sql .= "order by tier_level asc, tier_position asc, a.agent_name asc";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute(); $parameters['call_center_queue_uuid'] = $call_center_queue_uuid;
$tiers = $prep_statement->fetchAll(PDO::FETCH_NAMED); $database = new database;
$tiers = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//add an empty row to the tiers array //add an empty row to the tiers array
if (count($tiers) == 0) { if (count($tiers) == 0) {
@ -430,13 +443,14 @@
//get the agents //get the agents
$sql = "select call_center_agent_uuid, agent_name from v_call_center_agents "; $sql = "select call_center_agent_uuid, agent_name from v_call_center_agents ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by agent_name asc"; $sql .= "order by agent_name asc";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute(); $database = new database;
$agents = $prep_statement->fetchAll(PDO::FETCH_NAMED); $agents = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//get the sounds //get the sounds
$sounds = new sounds; $sounds = new sounds;
$sounds = $sounds->get(); $sounds = $sounds->get();
@ -674,7 +688,7 @@
$assigned_agents[] = $field['agent_name']; $assigned_agents[] = $field['agent_name'];
$x++; $x++;
} }
unset ($prep_statement, $sql, $tiers); unset ($tiers);
echo " </table>\n"; echo " </table>\n";
echo " <br>\n"; echo " <br>\n";
echo " ".$text['description-tiers']."\n"; echo " ".$text['description-tiers']."\n";

View File

@ -48,24 +48,9 @@
require_once "resources/paging.php"; require_once "resources/paging.php";
//get http variables and set as php variables //get http variables and set as php variables
$order_by = $_GET["order_by"]; $order_by = $_GET["order_by"] != '' ? $_GET["order_by"] : 'queue_name';
$order = $_GET["order"]; $order = $_GET["order"];
//validate order by
if (strlen($order_by) > 0) {
$order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', $order_by);
}
//validate the order
switch ($order) {
case 'asc':
break;
case 'desc':
break;
default:
$order = '';
}
//show the content //show the content
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n"; echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
@ -85,24 +70,15 @@
echo "</tr></table>\n"; echo "</tr></table>\n";
//get total call center queues count from the database //get total call center queues count from the database
$sql = "select count(*) as num_rows from v_call_center_queues where domain_uuid = :domain_uuid "; $sql = "select count(*) from v_call_center_queues ";
$database = new database; $sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$row = $database->select($sql, $parameters, 'all');
$total_call_center_queues = $row['num_rows'];
//prepare to page the results (reuse $sql from above)
if (strlen($order_by) == 0) {
$order_by = 'queue_name';
$order = 'asc';
}
else {
$sql .= "order by $order_by $order ";
}
$database = new database; $database = new database;
$result = $database->select($sql, $parameters, 'all'); $total_call_center_queues = $database->select($sql, $parameters, 'column');
$num_rows = $database->select($sql, $parameters, 'column'); unset($sql, $parameters);
//prepare to page the results
$num_rows = $total_call_center_queues;
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = ""; $param = "";
$page = $_GET['page']; $page = $_GET['page'];
@ -112,18 +88,12 @@
$sql = "select * from v_call_center_queues "; $sql = "select * from v_call_center_queues ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
if (strlen($order_by) == 0) { $sql .= order_by($order_by, $order);
$order_by = 'queue_name'; $sql .= limit_offset($rows_per_page, $offset);
$order = 'asc'; $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
else {
$sql .= "order by $order_by $order ";
}
$sql .= " limit :rows_per_page offset :offset ";
$database = new database; $database = new database;
$parameters['rows_per_page'] = $rows_per_page;
$parameters['offset'] = $offset;
$result = $database->select($sql, $parameters, 'all'); $result = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
$c = 0; $c = 0;
$row_style["0"] = "row_style0"; $row_style["0"] = "row_style0";

View File

@ -39,20 +39,20 @@ else {
$text = $language->get(); $text = $language->get();
//set tier uuid //set tier uuid
$call_center_tier_uuid = check_str($_REQUEST["id"]); $call_center_tier_uuid = $_REQUEST["id"];
//get http post variables and set them to php variables //get http post variables and set them to php variables
if (count($_POST)>0) { if (count($_POST)>0) {
$agent_name = check_str($_POST["agent_name"]); $agent_name = $_POST["agent_name"];
$queue_name = check_str($_POST["queue_name"]); $queue_name = $_POST["queue_name"];
$tier_level = check_str($_POST["tier_level"]); $tier_level = $_POST["tier_level"];
$tier_position = check_str($_POST["tier_position"]); $tier_position = $_POST["tier_position"];
} }
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$msg = ''; $msg = '';
$call_center_tier_uuid = check_str($_POST["call_center_tier_uuid"]); $call_center_tier_uuid = $_POST["call_center_tier_uuid"];
//check for all required data //check for all required data
//if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid<br>\n"; } //if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid<br>\n"; }
@ -100,30 +100,35 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
} }
//update the database //update the database
$sql = "update v_call_center_tiers set "; $array['call_center_tiers'][0]['call_center_tier_uuid'] = $call_center_tier_uuid;
$sql .= "domain_uuid = '$domain_uuid', "; $array['call_center_tiers'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
$sql .= "agent_name = '$agent_name', "; $array['call_center_tiers'][0]['agent_name'] = $agent_name;
$sql .= "queue_name = '$queue_name', "; $array['call_center_tiers'][0]['queue_name'] = $queue_name;
$sql .= "tier_level = '$tier_level', "; $array['call_center_tiers'][0]['tier_level'] = $tier_level;
$sql .= "tier_position = '$tier_position' "; $array['call_center_tiers'][0]['tier_position'] = $tier_position;
$sql .= "where call_center_tier_uuid = '$call_center_tier_uuid'"; $database = new database;
$db->exec(check_sql($sql)); $database->app_name = 'call_centers';
unset($sql); $database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370';
$database->save($array);
unset($array);
//syncrhonize configuration //syncrhonize configuration
save_call_center_xml(); save_call_center_xml();
remove_config_from_cache('configuration:callcenter.conf'); remove_config_from_cache('configuration:callcenter.conf');
//look up queue uuid by queue name (ugh) //look up queue uuid by queue name (ugh)
$sql = "select call_center_queue_uuid from v_call_center_queues where queue_name = '".$queue_name."'"; $sql = "select call_center_queue_uuid from v_call_center_queues ";
$prep_statement = $db->prepare(check_sql($sql)); $sql .= "where queue_name = :queue_name ";
$prep_statement->execute(); $parameters['queue_name'] = $queue_name;
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $database = new database;
foreach ($result as &$row) { $result = $database->select($sql, $parameters, 'all');
$queue_uuid = $row["call_center_queue_uuid"]; if (is_array($result) && sizeof($result) != 0) {
break; foreach ($result as &$row) {
$queue_uuid = $row["call_center_queue_uuid"];
break;
}
} }
unset($prep_statement); unset($sql, $parameters, $result, $row);
message::add($text['message-update']); message::add($text['message-update']);
header("Location: call_center_queue_edit.php?id=".$queue_uuid); header("Location: call_center_queue_edit.php?id=".$queue_uuid);
@ -134,19 +139,22 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//pre-populate the form //pre-populate the form
if (count($_GET)>0 && $_POST["persistformvar"] != "true") { if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
$sql = "select * from v_call_center_tiers "; $sql = "select * from v_call_center_tiers ";
$sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and call_center_tier_uuid = '$call_center_tier_uuid' "; $sql .= "and call_center_tier_uuid = :call_center_tier_uuid ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute(); $parameters['call_center_tier_uuid'] = $call_center_tier_uuid;
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $database = new database;
foreach ($result as &$row) { $result = $database->select($sql, $parameters, 'all');
$agent_name = $row["agent_name"]; if (is_array($result) && sizeof($result) != 0) {
$queue_name = $row["queue_name"]; foreach ($result as &$row) {
$tier_level = $row["tier_level"]; $agent_name = $row["agent_name"];
$tier_position = $row["tier_position"]; $queue_name = $row["queue_name"];
break; //limit to 1 row $tier_level = $row["tier_level"];
$tier_position = $row["tier_position"];
break; //limit to 1 row
}
} }
unset ($prep_statement); unset($sql, $parameters, $result, $row);
} }
@ -177,16 +185,17 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
//---- Begin Select List -------------------- //---- Begin Select List --------------------
$sql = "SELECT * FROM v_users "; $sql = "select * from v_users ";
$sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and user_enabled = 'true' "; $sql .= "and user_enabled = 'true' ";
$sql .= "order by username asc "; $sql .= "order by username asc ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute(); $database = new database;
$result = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
echo "<select id=\"agent_name\" name=\"agent_name\" class='formfld'>\n"; echo "<select id=\"agent_name\" name=\"agent_name\" class='formfld'>\n";
echo "<option value=\"\"></option>\n"; echo "<option value=\"\"></option>\n";
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
//$catcount = count($result); //$catcount = count($result);
foreach($result as $field) { foreach($result as $field) {
if ($field[username] == $agent_name) { if ($field[username] == $agent_name) {
@ -212,15 +221,16 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
//---- Begin Select List -------------------- //---- Begin Select List --------------------
$sql = "SELECT * FROM v_call_center_queues "; $sql = "select * from v_call_center_queues ";
$sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by queue_name asc "; $sql .= "order by queue_name asc ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute(); $database = new database;
$result = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
echo "<select id=\"queue_name\" name=\"queue_name\" class='formfld'>\n"; echo "<select id=\"queue_name\" name=\"queue_name\" class='formfld'>\n";
echo "<option value=\"\"></option>\n"; echo "<option value=\"\"></option>\n";
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
//$catcount = count($result); //$catcount = count($result);
foreach($result as $field) { foreach($result as $field) {
if ($field[queue_name] == $queue_name) { if ($field[queue_name] == $queue_name) {