Add comprehensive queue management to browser phone shortcode
Features Added: - Queue display showing all assigned queues for the current user - Real-time queue statistics (waiting calls, capacity) - Visual indicators for queues with waiting calls (green border, pulse animation) - Queue selection with click interaction - Accept next call from selected queue functionality - Auto-refresh of queue data every 30 seconds - Mobile-responsive queue interface Backend Changes: - New ajax_get_agent_queues() handler to fetch user's assigned queues - Enhanced ajax_get_waiting_calls() to return structured data - Proper permission checking for twp_access_agent_queue capability Frontend Enhancements: - Interactive queue list with selection states - Queue controls panel showing selected queue info - Refresh button for manual queue updates - Visual feedback for queues with active calls - Mobile-optimized layout for smaller screens UI/UX Improvements: - Queues with waiting calls highlighted with green accent - Pulsing indicator for active queues - Auto-selection of first queue with calls - Responsive design for mobile devices - Dark mode support for queue elements 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3973,7 +3973,47 @@ class TWP_Admin {
|
||||
ORDER BY c.position ASC
|
||||
", $user_id));
|
||||
|
||||
wp_send_json_success($waiting_calls);
|
||||
wp_send_json_success(array(
|
||||
'count' => count($waiting_calls),
|
||||
'calls' => $waiting_calls
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX handler for getting agent's assigned queues
|
||||
*/
|
||||
public function ajax_get_agent_queues() {
|
||||
// Check for either admin or frontend nonce
|
||||
if (!$this->verify_ajax_nonce()) {
|
||||
wp_send_json_error('Invalid nonce');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!current_user_can('manage_options') && !current_user_can('twp_access_agent_queue')) {
|
||||
wp_send_json_error('Unauthorized - Agent queue access required');
|
||||
return;
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
$user_id = get_current_user_id();
|
||||
$queues_table = $wpdb->prefix . 'twp_call_queues';
|
||||
$groups_table = $wpdb->prefix . 'twp_group_members';
|
||||
$calls_table = $wpdb->prefix . 'twp_queued_calls';
|
||||
|
||||
// Get queues where user is a member of the assigned agent group
|
||||
$user_queues = $wpdb->get_results($wpdb->prepare("
|
||||
SELECT DISTINCT q.*,
|
||||
COUNT(c.id) as waiting_count,
|
||||
COALESCE(SUM(CASE WHEN c.status = 'waiting' THEN 1 ELSE 0 END), 0) as current_waiting
|
||||
FROM $queues_table q
|
||||
LEFT JOIN $groups_table gm ON gm.group_id = q.agent_group_id
|
||||
LEFT JOIN $calls_table c ON c.queue_id = q.id AND c.status = 'waiting'
|
||||
WHERE gm.user_id = %d AND gm.is_active = 1
|
||||
GROUP BY q.id
|
||||
ORDER BY q.queue_name ASC
|
||||
", $user_id));
|
||||
|
||||
wp_send_json_success($user_queues);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user