Please log in to view the dashboard.

Login

'; } if (!current_user_can('view_hvac_dashboard')) { return '

You do not have permission to view this dashboard.

'; } return $this->get_dashboard_content(); } /** * Render dashboard content for the page */ public function render_dashboard_content($content) { // Only process if content contains our shortcode if (has_shortcode($content, 'hvac_trainer_dashboard')) { return do_shortcode($content); } return $content; } /** * Get dashboard content */ private function get_dashboard_content() { $user_id = get_current_user_id(); // Include dashboard data class require_once HVAC_CE_PLUGIN_DIR . 'includes/class-hvac-dashboard-data.php'; $dashboard_data = new HVAC_Dashboard_Data($user_id); // Get data $data = array( 'total_events' => $dashboard_data->get_total_events_count(), 'upcoming_events' => $dashboard_data->get_upcoming_events_count(), 'past_events' => $dashboard_data->get_past_events_count(), 'total_sold' => $dashboard_data->get_total_tickets_sold(), 'total_revenue' => $dashboard_data->get_total_revenue(), 'revenue_target' => $dashboard_data->get_annual_revenue_target(), 'events_table' => $dashboard_data->get_events_table_data(isset($_GET['event_status']) ? sanitize_key($_GET['event_status']) : 'all'), 'current_filter' => isset($_GET['event_status']) ? sanitize_key($_GET['event_status']) : 'all' ); // Get dashboard HTML ob_start(); ?>

Trainer Dashboard

Your Stats

Total Events

Upcoming Events

Past Events

Tickets Sold

Total Revenue

$

Target: $

Your Events

Filter:
Status Event Name Date Organizer Capacity Sold Revenue Actions
$ Edit | Summary

No events found.

'Security check failed.')); return; } // Get current user ID $user_id = get_current_user_id(); if (!$user_id || !current_user_can('view_hvac_dashboard')) { wp_send_json_error(array('message' => 'Access denied.')); return; } // Get all filters and parameters $args = array( 'status' => isset($_POST['status']) ? sanitize_key($_POST['status']) : 'all', 'search' => isset($_POST['search']) ? sanitize_text_field($_POST['search']) : '', 'orderby' => isset($_POST['orderby']) ? sanitize_key($_POST['orderby']) : 'date', 'order' => isset($_POST['order']) ? sanitize_key($_POST['order']) : 'DESC', 'page' => isset($_POST['page']) ? absint($_POST['page']) : 1, 'per_page' => isset($_POST['per_page']) ? absint($_POST['per_page']) : 10, 'date_from' => isset($_POST['date_from']) ? sanitize_text_field($_POST['date_from']) : '', 'date_to' => isset($_POST['date_to']) ? sanitize_text_field($_POST['date_to']) : '', ); // Include dashboard data class require_once HVAC_CE_PLUGIN_DIR . 'includes/class-hvac-dashboard-data.php'; $dashboard_data = new HVAC_Dashboard_Data($user_id); // Get filtered events data $result = $dashboard_data->get_events_table_data($args); $events = $result['events']; $pagination = $result['pagination']; // Build HTML for events table ob_start(); ?>
Status Event Name Date Organizer Capacity Sold Revenue Actions
$ Edit | Summary | View
No events found.
items 1) : ?> First page Previous page of Next page Last page
$html, 'count' => count($events), 'pagination' => $pagination, 'args' => $args )); } /** * Enqueue dashboard assets (CSS and JavaScript) */ public function enqueue_dashboard_assets() { // Check if we're on the dashboard page global $post; if (!is_a($post, 'WP_Post') || !has_shortcode($post->post_content, 'hvac_trainer_dashboard')) { return; } // Enqueue UX enhancements (CSS and JS) wp_enqueue_style( 'hvac-ux-enhancements-css', HVAC_CE_PLUGIN_URL . 'assets/css/hvac-ux-enhancements.css', array(), HVAC_CE_VERSION ); wp_enqueue_script( 'hvac-ux-enhancements-js', HVAC_CE_PLUGIN_URL . 'assets/js/hvac-ux-enhancements.js', array('jquery'), HVAC_CE_VERSION, true ); // Enqueue enhanced dashboard CSS wp_enqueue_style( 'hvac-dashboard-enhanced-css', HVAC_CE_PLUGIN_URL . 'assets/css/hvac-dashboard-enhanced.css', array('hvac-ux-enhancements-css'), HVAC_CE_VERSION ); // Enqueue enhanced dashboard JavaScript wp_enqueue_script( 'hvac-dashboard-enhanced-js', HVAC_CE_PLUGIN_URL . 'assets/js/hvac-dashboard-enhanced.js', array('jquery', 'hvac-ux-enhancements-js'), HVAC_CE_VERSION, true ); // Localize script with AJAX URL and nonce wp_localize_script('hvac-dashboard-enhanced-js', 'hvac_dashboard', array( 'ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('hvac_dashboard_nonce') )); // Inline CSS for now - can be moved to external file later $css = ' .hvac-dashboard-wrapper { max-width: 1200px; margin: 0 auto; padding: 20px; } .hvac-dashboard-header { margin-bottom: 30px; } .hvac-dashboard-header h1 { margin-bottom: 20px; } .hvac-dashboard-nav { display: flex; gap: 10px; flex-wrap: wrap; } .hvac-button { display: inline-block; padding: 10px 20px; text-decoration: none; border-radius: 4px; transition: all 0.3s ease; } .hvac-button-primary { background-color: #E9AF28; color: #000; } .hvac-button-primary:hover { background-color: #d49b20; } .hvac-button-secondary { background-color: #0B5C7D; color: #fff; } .hvac-button-secondary:hover { background-color: #084562; } .hvac-dashboard-stats { margin-bottom: 40px; } .hvac-stats-row { display: flex; flex-direction: row; flex-wrap: wrap; margin: -10px; /* Counteract the padding on columns */ justify-content: space-between; align-items: stretch; margin-top: 20px; } .hvac-stat-col { flex: 1; min-width: 160px; /* Ensure minimum width for readability */ padding: 10px; } .hvac-stat-card { background: #f8f9fa; border: 1px solid #e9ecef; border-radius: 8px; padding: 20px; text-align: center; } .hvac-stat-card h3 { margin: 0 0 10px; font-size: 16px; color: #666; } .hvac-stat-card .metric-value { font-size: 32px; font-weight: bold; color: #E9AF28; margin: 0; } .hvac-stat-card small { display: block; margin-top: 5px; color: #666; } .hvac-dashboard-events { margin-top: 40px; } .hvac-event-filters { margin: 20px 0; display: flex; gap: 10px; align-items: center; } .hvac-filter { padding: 5px 15px; border: 1px solid #ddd; border-radius: 4px; text-decoration: none; color: #333; transition: all 0.3s ease; } .hvac-filter:hover, .hvac-filter-active { background-color: #E9AF28; color: #000; border-color: #E9AF28; } .hvac-events-table-wrapper { overflow-x: auto; } .hvac-events-table { width: 100%; border-collapse: collapse; margin-top: 20px; } .hvac-events-table th, .hvac-events-table td { padding: 12px; text-align: left; border-bottom: 1px solid #ddd; } .hvac-events-table th { background-color: #f8f9fa; font-weight: bold; } .hvac-events-table tr:hover { background-color: #f8f9fa; } .hvac-events-table a { color: #0B5C7D; text-decoration: none; } .hvac-events-table a:hover { text-decoration: underline; } @media (max-width: 768px) { .hvac-stats-grid { grid-template-columns: 1fr; } .hvac-events-table { font-size: 14px; } .hvac-events-table th, .hvac-events-table td { padding: 8px; } } '; wp_add_inline_style('astra-theme-css', $css); } } // Initialize the dashboard new HVAC_Dashboard();