Add comprehensive voicemail integration to browser phone
- Add AJAX endpoint for fetching user voicemails with stats and recent list - Create voicemail display section with counts, transcriptions, and playback - Implement click-to-play functionality for voicemail audio - Add refresh and view-all buttons with admin page integration - Style voicemail section with consistent design and dark mode support - Include visual indicators for recordings and formatted durations - Add mobile responsive design and hover effects 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3770,6 +3770,56 @@ class TWP_Admin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX handler for getting user's recent voicemails
|
||||
*/
|
||||
public function ajax_get_user_voicemails() {
|
||||
check_ajax_referer('twp_ajax_nonce', 'nonce');
|
||||
|
||||
if (!current_user_can('manage_options') && !current_user_can('twp_access_voicemails')) {
|
||||
wp_send_json_error('Unauthorized');
|
||||
return;
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
$table_name = $wpdb->prefix . 'twp_voicemails';
|
||||
|
||||
// Get recent voicemails (last 10)
|
||||
$voicemails = $wpdb->get_results($wpdb->prepare("
|
||||
SELECT id, from_number, duration, transcription, created_at, recording_url
|
||||
FROM $table_name
|
||||
ORDER BY created_at DESC
|
||||
LIMIT %d
|
||||
", 10));
|
||||
|
||||
// Format data for frontend
|
||||
$formatted_voicemails = array();
|
||||
foreach ($voicemails as $vm) {
|
||||
$formatted_voicemails[] = array(
|
||||
'id' => $vm->id,
|
||||
'from_number' => $vm->from_number,
|
||||
'duration' => $vm->duration,
|
||||
'transcription' => $vm->transcription ? substr($vm->transcription, 0, 100) . '...' : 'No transcription',
|
||||
'created_at' => $vm->created_at,
|
||||
'time_ago' => human_time_diff(strtotime($vm->created_at), current_time('timestamp')) . ' ago',
|
||||
'has_recording' => !empty($vm->recording_url)
|
||||
);
|
||||
}
|
||||
|
||||
// Get voicemail counts
|
||||
$total_count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name");
|
||||
$today_count = $wpdb->get_var($wpdb->prepare("
|
||||
SELECT COUNT(*) FROM $table_name
|
||||
WHERE DATE(created_at) = %s
|
||||
", current_time('Y-m-d')));
|
||||
|
||||
wp_send_json_success(array(
|
||||
'voicemails' => $formatted_voicemails,
|
||||
'total_count' => $total_count,
|
||||
'today_count' => $today_count
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX handler for getting all groups
|
||||
*/
|
||||
|
Reference in New Issue
Block a user