function display_client_bookings() { global $wpdb; // Define the query to get the bookings $query = " SELECT b.id, b.booking_code, b.start_date, b.end_date, b.start_time, b.end_time, b.status, b.payment_status, c.first_name as client_name, s.name as service_name FROM {$wpdb->prefix}latepoint_bookings b JOIN {$wpdb->prefix}latepoint_customers c ON b.customer_id = c.id JOIN {$wpdb->prefix}latepoint_services s ON b.service_id = s.id WHERE b.agent_id = 1 ORDER BY b.start_date DESC "; // Execute the query and fetch the results $bookings = $wpdb->get_results($query); // Check if bookings are returned if (!empty($bookings)) { echo ''; foreach ($bookings as $booking) { // Calculate start and end time $start_time = date('H:i', mktime(0, $booking->start_time)); $end_time = date('H:i', mktime(0, $booking->end_time)); echo ''; } echo '
Client Name Service Date Time
' . esc_html($booking->client_name) . ' ' . esc_html($booking->service_name) . ' ' . esc_html($booking->start_date) . ' ' . esc_html($start_time) . ' - ' . esc_html($end_time) . '
'; } else { echo 'No bookings found.'; } }