diff --git a/app/call_centers/call_center_agent_edit.php b/app/call_centers/call_center_agent_edit.php index 318a28ed4a..190d8988e9 100644 --- a/app/call_centers/call_center_agent_edit.php +++ b/app/call_centers/call_center_agent_edit.php @@ -42,36 +42,14 @@ $language = new text; $text = $language->get(); +//connect to the database + $database = new database; + //set the defaults $agent_id = ''; $agent_name = ''; $agent_password = ''; -//check for duplicates - if (!empty($_GET["check"]) && $_GET["check"] == 'duplicate') { - //agent id - if (!empty($_GET["agent_id"])) { - $sql = "select agent_name "; - $sql .= "from v_call_center_agents "; - $sql .= "where agent_id = :agent_id "; - $sql .= "and domain_uuid = :domain_uuid "; - if (!empty($_GET["agent_uuid"]) && is_uuid($_GET["agent_uuid"])) { - $sql .= " and call_center_agent_uuid <> :call_center_agent_uuid "; - $parameters['call_center_agent_uuid'] = $_GET["agent_uuid"]; - } - $parameters['agent_id'] = $_GET["agent_id"]; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $database = new database; - $row = $database->select($sql, $parameters, 'row'); - if (!empty($row) && !empty($row['agent_name'])) { - echo $text['message-duplicate_agent_id'].(if_group("superadmin") ? ": ".$row["agent_name"] : null); - } - unset($sql, $parameters); - } - - exit; - } - //action add or update if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) { $action = "update"; @@ -81,6 +59,14 @@ $action = "add"; } +//get the users array + $sql = "select * from v_users "; + $sql .= "where domain_uuid = :domain_uuid "; + $sql .= "order by username asc "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $users = $database->select($sql, $parameters, 'all'); + unset($sql, $parameters); + //get http post variables and set them to php variables if (!empty($_POST)) { $call_center_agent_uuid = $_POST["call_center_agent_uuid"] ?? null; @@ -151,15 +137,6 @@ $call_center_agent_uuid = uuid(); } - //get the users array - $sql = "select * from v_users "; - $sql .= "where domain_uuid = :domain_uuid "; - $sql .= "order by username asc "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $database = new database; - $users = $database->select($sql, $parameters, 'all'); - unset($sql, $parameters); - //change the contact string to loopback - Not recommended added for backwards comptability causes multiple problems if ($_SESSION['call_center']['agent_contact_method']['text'] == 'loopback') { $agent_contact = str_replace("user/", "loopback/", $agent_contact); @@ -193,11 +170,9 @@ } //save to the data - $database = new database; $database->app_name = 'call_center'; $database->app_uuid = '95788e50-9500-079e-2807-fd530b0ea370'; $database->save($array); - //$message = $database->message; //syncrhonize configuration save_call_center_xml(); @@ -295,7 +270,6 @@ $sql .= "and call_center_agent_uuid = :call_center_agent_uuid "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['call_center_agent_uuid'] = $call_center_agent_uuid; - $database = new database; $row = $database->select($sql, $parameters, 'row'); if (!empty($row)) { $call_center_agent_uuid = $row["call_center_agent_uuid"]; @@ -338,47 +312,12 @@ if ($action == "update") { $document['title'] = $text['title-call_center_agent_edit']; } + +//include the header require_once "resources/header.php"; -//get the list of users for this domain - $sql = "select * from v_users "; - $sql .= "where domain_uuid = :domain_uuid "; - $sql .= "and user_enabled = 'true' "; - $sql .= "order by username asc "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $database = new database; - $users = $database->select($sql, $parameters, 'all'); - unset($sql, $parameters); - -//javascript to check for duplicates - ?> - - -\n"; + echo "