mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-02-14 23:25:00 +00:00
Clear the cache when agent is removed from the Queue
- Add checkboxes for removing one or more agents from the call center queue.
This commit is contained in:
@@ -132,6 +132,7 @@
|
||||
$queue_cc_exit_keys = $_POST["queue_cc_exit_keys"] ?? null;
|
||||
$queue_email_address = $_POST["queue_email_address"] ?? null;
|
||||
$queue_description = $_POST["queue_description"];
|
||||
$call_center_tier_delete = $_POST["call_center_tier_delete"] ?? null;
|
||||
|
||||
//set the context for users that do not have the permission
|
||||
if (permission_exists('call_center_queue_context')) {
|
||||
@@ -216,7 +217,7 @@
|
||||
}
|
||||
|
||||
//if the user doesn't have the correct permission then
|
||||
//override domain_uuid and queue_context values
|
||||
//override domain_uuid and queue_context values
|
||||
if ($action == 'update' && is_uuid($call_center_queue_uuid)) {
|
||||
$sql = "select * from v_call_center_queues ";
|
||||
$sql .= "where call_center_queue_uuid = :call_center_queue_uuid ";
|
||||
@@ -481,6 +482,12 @@
|
||||
$p->delete("dialplan_add", "temp");
|
||||
$p->delete("dialplan_edit", "temp");
|
||||
|
||||
//remove checked options
|
||||
if ($action == 'update' && permission_exists('call_center_tier_delete') && !empty($call_center_tier_delete)) {
|
||||
$obj = new call_center;
|
||||
$obj->delete_tiers($call_center_tier_delete);
|
||||
}
|
||||
|
||||
//debug info
|
||||
//echo "<pre>". print_r($message, true) ."</pre>"; exit;
|
||||
|
||||
@@ -1036,7 +1043,12 @@
|
||||
echo " <td class='vtable'>".$text['label-agent_name']."</td>\n";
|
||||
echo " <td class='vtable' style='text-align: center;'>".$text['label-tier_level']."</td>\n";
|
||||
echo " <td class='vtable' style='text-align: center;'>".$text['label-tier_position']."</td>\n";
|
||||
echo " <td></td>\n";
|
||||
if (permission_exists('call_center_tier_delete')) {
|
||||
echo " <td class='vtable edit_delete_checkbox_all' onmouseover=\"swap_display('delete_label_options', 'delete_toggle_options');\" onmouseout=\"swap_display('delete_label_options', 'delete_toggle_options');\">\n";
|
||||
echo " <span id='delete_label_options'>".$text['label-delete']."</span>\n";
|
||||
echo " <span id='delete_toggle_options'><input type='checkbox' id='checkbox_all_options' name='checkbox_all' onclick=\"edit_all_toggle('options');\"></span>\n";
|
||||
echo " </td>\n";
|
||||
}
|
||||
echo " </tr>\n";
|
||||
$x = 0;
|
||||
if (is_array($tiers)) {
|
||||
@@ -1079,11 +1091,17 @@
|
||||
}
|
||||
echo " </select>\n";
|
||||
echo " </td>\n";
|
||||
echo " <td class=''>";
|
||||
if (permission_exists('call_center_tier_delete')) {
|
||||
echo " <a href=\"call_center_queue_edit.php?id=".escape($call_center_queue_uuid)."&call_center_tier_uuid=".escape($field['call_center_tier_uuid'])."&a=delete\" alt=\"".$text['button-delete']."\" onclick=\"return confirm('".$text['confirm-delete']."');\">$v_link_label_delete</a>";
|
||||
if (!empty($field['call_center_agent_uuid']) && is_uuid($field['call_center_agent_uuid'])) {
|
||||
echo "<td class='vtable' style='text-align: center; padding-bottom: 3px;'>";
|
||||
echo " <input type='checkbox' name='call_center_tier_delete[".$x."][checked]' value='true' class='chk_delete checkbox_options' onclick=\"edit_delete_action('options');\">\n";
|
||||
echo " <input type='hidden' name='call_center_tier_delete[".$x."][uuid]' value='".escape($field['call_center_tier_uuid'])."' />\n";
|
||||
}
|
||||
else {
|
||||
echo "<td>";
|
||||
}
|
||||
echo "</td>\n";
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
$assigned_agents[] = $field['agent_name'];
|
||||
$x++;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Copyright (C) 2015 - 2023
|
||||
Copyright (C) 2015 - 2026
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
@@ -409,7 +409,7 @@ class call_center {
|
||||
//clear the cache
|
||||
$cache = new cache;
|
||||
$cache->delete("dialplan:" . $this->domain_name);
|
||||
remove_config_from_cache('configuration:callcenter.conf');
|
||||
$cache->delete('configuration:callcenter.conf');
|
||||
|
||||
//clear the destinations session array
|
||||
if (isset($_SESSION['destinations']['array'])) {
|
||||
@@ -506,7 +506,10 @@ class call_center {
|
||||
|
||||
//synchronize configuration
|
||||
save_call_center_xml();
|
||||
remove_config_from_cache('configuration:callcenter.conf');
|
||||
|
||||
//clear the cache
|
||||
$cache = new cache;
|
||||
$cache->delete('configuration:callcenter.conf');
|
||||
|
||||
//set message
|
||||
message::add($text['message-delete']);
|
||||
@@ -516,6 +519,103 @@ class call_center {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove one or more agents from a call center queue by deleting the tier assignment
|
||||
*
|
||||
* @param array $records A list of records to delete, where each record is an associative array containing a 'uuid'
|
||||
* key.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete_tiers($records) {
|
||||
|
||||
//permission doesn't exist return now
|
||||
if (!permission_exists('call_center_tier_delete')) {
|
||||
return;
|
||||
}
|
||||
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'], 'negative');
|
||||
header('Location: ' . $this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//delete multiple records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//delete the tier to remove the agent from the queue
|
||||
$x = 0;
|
||||
foreach ($records as $record) {
|
||||
//not checked skip this row
|
||||
if (empty($record['checked'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// //not a valid uuid skip this row
|
||||
if (!is_uuid($record['uuid'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//get the agent details
|
||||
$sql = "select t.call_center_agent_uuid, t.call_center_queue_uuid, q.queue_extension ";
|
||||
$sql .= "from v_call_center_tiers as t, v_call_center_queues as q ";
|
||||
$sql .= "where t.domain_uuid = :domain_uuid ";
|
||||
$sql .= "and t.call_center_tier_uuid = :call_center_tier_uuid ";
|
||||
$sql .= "and t.call_center_queue_uuid = q.call_center_queue_uuid; ";
|
||||
$parameters['domain_uuid'] = $this->domain_uuid;
|
||||
$parameters['call_center_tier_uuid'] = $record['uuid'];
|
||||
$tiers = $this->database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
if (!empty($tiers)) {
|
||||
foreach ($tiers as $row) {
|
||||
$call_center_agent_uuid = $row["call_center_agent_uuid"];
|
||||
$call_center_queue_uuid = $row["call_center_queue_uuid"];
|
||||
$queue_extension = $row["queue_extension"];
|
||||
}
|
||||
}
|
||||
|
||||
//delete the agent from freeswitch
|
||||
//setup the event socket connection
|
||||
$esl = event_socket::create();
|
||||
|
||||
//remove the tier to unassign the agent from the queue
|
||||
if ($esl->is_connected()) {
|
||||
//callcenter_config tier del [queue_name] [agent_name]
|
||||
if (is_numeric($queue_extension) && is_uuid($call_center_agent_uuid)) {
|
||||
$cmd = "callcenter_config tier del ".$queue_extension."@".$this->domain_name." ".$call_center_agent_uuid;
|
||||
$response = event_socket::api($cmd);
|
||||
}
|
||||
}
|
||||
|
||||
//build the delete array
|
||||
if (!empty($record['uuid'])) {
|
||||
$array['call_center_tiers'][$x]['domain_uuid'] = $this->domain_uuid;
|
||||
$array['call_center_tiers'][$x]['call_center_tier_uuid'] = $record['uuid'];
|
||||
}
|
||||
|
||||
//increment the $id
|
||||
$x++;
|
||||
}
|
||||
|
||||
//delete the tier from the database
|
||||
if (!empty($array)) {
|
||||
$p = permissions::new();
|
||||
$p->add('call_center_tier_delete', 'temp');
|
||||
|
||||
$this->database->delete($array);
|
||||
unset($array);
|
||||
|
||||
$p->delete('call_center_tier_delete', 'temp');
|
||||
}
|
||||
|
||||
//clear the cache
|
||||
$cache = new cache;
|
||||
$cache->delete('configuration:callcenter.conf');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies one or more records
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user