testing progress
This commit is contained in:
@@ -3729,6 +3729,55 @@ class TWP_Admin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AJAX handler for accepting next call from a queue
|
||||||
|
*/
|
||||||
|
public function ajax_accept_next_queue_call() {
|
||||||
|
check_ajax_referer('twp_ajax_nonce', 'nonce');
|
||||||
|
|
||||||
|
$queue_id = intval($_POST['queue_id']);
|
||||||
|
$user_id = get_current_user_id();
|
||||||
|
|
||||||
|
global $wpdb;
|
||||||
|
$calls_table = $wpdb->prefix . 'twp_queued_calls';
|
||||||
|
$groups_table = $wpdb->prefix . 'twp_group_members';
|
||||||
|
$queues_table = $wpdb->prefix . 'twp_call_queues';
|
||||||
|
|
||||||
|
// Verify user is a member of this queue's agent group
|
||||||
|
$is_member = $wpdb->get_var($wpdb->prepare("
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM $groups_table gm
|
||||||
|
JOIN $queues_table q ON gm.group_id = q.agent_group_id
|
||||||
|
WHERE gm.user_id = %d AND q.id = %d
|
||||||
|
", $user_id, $queue_id));
|
||||||
|
|
||||||
|
if (!$is_member) {
|
||||||
|
wp_send_json_error('You are not authorized to accept calls from this queue');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the next waiting call from this queue (lowest position number)
|
||||||
|
$next_call = $wpdb->get_row($wpdb->prepare("
|
||||||
|
SELECT * FROM $calls_table
|
||||||
|
WHERE queue_id = %d AND status = 'waiting'
|
||||||
|
ORDER BY position ASC
|
||||||
|
LIMIT 1
|
||||||
|
", $queue_id));
|
||||||
|
|
||||||
|
if (!$next_call) {
|
||||||
|
wp_send_json_error('No calls waiting in this queue');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = TWP_Agent_Manager::accept_queued_call($next_call->id, $user_id);
|
||||||
|
|
||||||
|
if ($result['success']) {
|
||||||
|
wp_send_json_success($result);
|
||||||
|
} else {
|
||||||
|
wp_send_json_error($result['error']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AJAX handler for getting waiting calls
|
* AJAX handler for getting waiting calls
|
||||||
*/
|
*/
|
||||||
@@ -5685,7 +5734,7 @@ class TWP_Admin {
|
|||||||
$button.prop('disabled', true).text('Accepting...');
|
$button.prop('disabled', true).text('Accepting...');
|
||||||
|
|
||||||
$.post(ajaxurl, {
|
$.post(ajaxurl, {
|
||||||
action: 'twp_accept_call',
|
action: 'twp_accept_next_queue_call',
|
||||||
queue_id: queueId,
|
queue_id: queueId,
|
||||||
nonce: '<?php echo wp_create_nonce('twp_ajax_nonce'); ?>'
|
nonce: '<?php echo wp_create_nonce('twp_ajax_nonce'); ?>'
|
||||||
}, function(response) {
|
}, function(response) {
|
||||||
|
@@ -122,6 +122,7 @@ class TWP_Core {
|
|||||||
|
|
||||||
// Agent queue management AJAX
|
// Agent queue management AJAX
|
||||||
$this->loader->add_action('wp_ajax_twp_accept_call', $plugin_admin, 'ajax_accept_call');
|
$this->loader->add_action('wp_ajax_twp_accept_call', $plugin_admin, 'ajax_accept_call');
|
||||||
|
$this->loader->add_action('wp_ajax_twp_accept_next_queue_call', $plugin_admin, 'ajax_accept_next_queue_call');
|
||||||
$this->loader->add_action('wp_ajax_twp_get_waiting_calls', $plugin_admin, 'ajax_get_waiting_calls');
|
$this->loader->add_action('wp_ajax_twp_get_waiting_calls', $plugin_admin, 'ajax_get_waiting_calls');
|
||||||
$this->loader->add_action('wp_ajax_twp_set_agent_status', $plugin_admin, 'ajax_set_agent_status');
|
$this->loader->add_action('wp_ajax_twp_set_agent_status', $plugin_admin, 'ajax_set_agent_status');
|
||||||
$this->loader->add_action('wp_ajax_twp_get_call_details', $plugin_admin, 'ajax_get_call_details');
|
$this->loader->add_action('wp_ajax_twp_get_call_details', $plugin_admin, 'ajax_get_call_details');
|
||||||
|
Reference in New Issue
Block a user