diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/assets/css/hvac-common.css b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/assets/css/hvac-common.css
index f8fb81c7..ecac1ade 100644
--- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/assets/css/hvac-common.css
+++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/assets/css/hvac-common.css
@@ -465,7 +465,6 @@ body.page-trainer-registration,
body.page-trainer-profile,
body.page-event-summary,
body.page-email-attendees,
-body.page-my-events,
body.page-manage-event {
/* Base font settings */
font-size: 16px;
diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php
index 320da117..9460d393 100644
--- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php
+++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php
@@ -637,22 +637,40 @@ class HVAC_Community_Events {
// Check if TEC Community Events is active and working
if (class_exists('Tribe__Events__Community__Main')) {
- // Check if we're not in an infinite loop
+ // Check if the TEC shortcode handler exists
global $shortcode_tags;
- $original_handler = isset($shortcode_tags['tribe_community_events']) ? $shortcode_tags['tribe_community_events'] : null;
+ $tec_handler = null;
- // Temporarily remove our handler to let TEC's handler run
- if ($original_handler === array($this, 'render_tribe_community_events')) {
- remove_shortcode('tribe_community_events');
+ // Look for TEC's original handler
+ if (isset($shortcode_tags['tribe_community_events'])) {
+ $current_handler = $shortcode_tags['tribe_community_events'];
- // Let TEC process the shortcode
- $output = do_shortcode('[tribe_community_events view="' . esc_attr($atts['view']) . '"]');
-
- // Re-add our handler
- add_shortcode('tribe_community_events', array($this, 'render_tribe_community_events'));
-
- if (!empty($output)) {
- return $output;
+ // If it's our handler, temporarily remove it to find TEC's
+ if ($current_handler === array($this, 'render_tribe_community_events')) {
+ remove_shortcode('tribe_community_events');
+
+ // Try to get TEC's handler by calling their main class
+ if (class_exists('Tribe__Events__Community__Shortcodes')) {
+ $tec_shortcodes = new Tribe__Events__Community__Shortcodes();
+ if (method_exists($tec_shortcodes, 'tribe_community_events')) {
+ $tec_handler = array($tec_shortcodes, 'tribe_community_events');
+ }
+ }
+
+ // If we found TEC's handler, use it
+ if ($tec_handler && is_callable($tec_handler)) {
+ $output = call_user_func($tec_handler, $atts);
+
+ // Re-add our handler for next time
+ add_shortcode('tribe_community_events', array($this, 'render_tribe_community_events'));
+
+ if (!empty($output) && !is_wp_error($output)) {
+ return $output;
+ }
+ }
+
+ // Re-add our handler if TEC didn't work
+ add_shortcode('tribe_community_events', array($this, 'render_tribe_community_events'));
}
}
}
@@ -661,8 +679,6 @@ class HVAC_Community_Events {
switch ($atts['view']) {
case 'submission_form':
return $this->render_event_submission_form();
- case 'my_events':
- return $this->render_my_events_list();
default:
return '
Unknown view: ' . esc_html($atts['view']) . '
';
}
@@ -686,6 +702,12 @@ class HVAC_Community_Events {
@@ -767,73 +789,6 @@ class HVAC_Community_Events {
return ob_get_clean();
}
- /**
- * Render my events list
- */
- private function render_my_events_list() {
- ob_start();
- ?>
-
-
-
-
-
Note: Event management is available on your main dashboard. This is a simplified view.
-
Go to Dashboard
-
-
- 'tribe_events',
- 'author' => $current_user_id,
- 'posts_per_page' => 20,
- 'meta_query' => array(
- array(
- 'key' => '_EventStartDate',
- 'value' => date('Y-m-d H:i:s'),
- 'compare' => '>=',
- 'type' => 'DATETIME'
- )
- ),
- 'orderby' => 'meta_value',
- 'meta_key' => '_EventStartDate',
- 'order' => 'ASC'
- ));
-
- if ($events): ?>
-
- ID, '_EventStartDate', true);
- $formatted_date = $start_date ? date('M j, Y g:i A', strtotime($start_date)) : 'Date TBD';
- ?>
-
-
-
-
Status: post_status === 'publish' ? 'Published' : ucfirst($event->post_status);
- echo esc_html($status_display);
- ?>
-
-
-
-
-
-
-
-
- 0, 'active' => 0, 'revoked' => 0, 'emailed' => 0);
+$events = array();
+$filter_event = isset($_GET['filter_event']) ? absint($_GET['filter_event']) : 0;
+$filter_status = isset($_GET['filter_status']) ? sanitize_text_field($_GET['filter_status']) : 'active';
+
+// Start output buffering to prevent issues
+ob_start();
+
try {
- // Get certificate manager instance
- if (!class_exists('HVAC_Certificate_Manager')) {
- require_once HVAC_CE_PLUGIN_DIR . 'includes/certificates/class-certificate-manager.php';
- }
- $certificate_manager = HVAC_Certificate_Manager::instance();
-
- // Get certificate security instance
- if (!class_exists('HVAC_Certificate_Security')) {
- require_once HVAC_CE_PLUGIN_DIR . 'includes/certificates/class-certificate-security.php';
- }
- $certificate_security = HVAC_Certificate_Security::instance();
-
- // Check if certificate tables exist
- if (!class_exists('HVAC_Certificate_Installer')) {
- require_once HVAC_CE_PLUGIN_DIR . 'includes/certificates/class-certificate-installer.php';
- }
- $installer = HVAC_Certificate_Installer::instance();
-
- $tables_exist = $installer->check_tables();
-
- if (!$tables_exist) {
- echo 'Certificate database tables are not properly set up. Please contact the administrator.
';
- return;
- }
-
- // Get filtering parameters
- $filter_event = isset($_GET['filter_event']) ? absint($_GET['filter_event']) : 0;
- $filter_status = isset($_GET['filter_status']) ? sanitize_text_field($_GET['filter_status']) : 'active';
- $page = isset($_GET['certificate_page']) ? absint($_GET['certificate_page']) : 1;
- $per_page = 20;
-
- // Build filter args
- $filter_args = array(
- 'page' => $page,
- 'per_page' => $per_page,
- 'orderby' => 'date_generated',
- 'order' => 'DESC',
- );
-
- // Add event filter if selected
- if ($filter_event > 0) {
- $filter_args['event_id'] = $filter_event;
- }
-
- // Add status filter
- if ($filter_status === 'active') {
- $filter_args['revoked'] = 0;
- } elseif ($filter_status === 'revoked') {
- $filter_args['revoked'] = 1;
- }
- // Default 'all' doesn't add a filter
-
- // Get user's events for filtering using direct database query (bypassing TEC interference)
+ // Get user's events directly from database to bypass TEC issues
global $wpdb;
- // Build author filter
- $author_filter = current_user_can('edit_others_posts') ? '' : 'AND post_author = ' . intval($current_user_id);
-
- // Get events directly from database
- $events = $wpdb->get_results(
+ // Build author filter - only current user's events
+ $events = $wpdb->get_results($wpdb->prepare(
"SELECT ID, post_title, post_date
FROM {$wpdb->posts}
WHERE post_type = 'tribe_events'
+ AND post_author = %d
AND post_status = 'publish'
- {$author_filter}
- ORDER BY post_date DESC"
- );
+ ORDER BY post_date DESC",
+ $current_user_id
+ ));
+
+ // Check if certificate table exists
+ $cert_table = $wpdb->prefix . 'hvac_certificates';
+ $table_exists = $wpdb->get_var("SHOW TABLES LIKE '$cert_table'") === $cert_table;
- // Check if user has any events
- if (empty($events)) {
- // No certificates to show since user has no events
- $certificates = array();
- $total_certificates = 0;
- $total_pages = 0;
- $certificate_stats = array(
- 'total' => 0,
- 'active' => 0,
- 'revoked' => 0,
- 'emailed' => 0
- );
- } else {
- // Get certificates for the current user with filters
- $certificates = $certificate_manager->get_user_certificates($current_user_id, $filter_args);
-
- // Get total certificate count for pagination
- $total_certificates = $certificate_manager->get_user_certificate_count($current_user_id, $filter_args);
- $total_pages = ceil($total_certificates / $per_page);
-
+ if ($table_exists && !empty($events)) {
+ // Get event IDs for the user
+ $event_ids = array_column($events, 'ID');
+ $event_ids_placeholder = implode(',', array_fill(0, count($event_ids), '%d'));
+
// Get certificate statistics
- $certificate_stats = $certificate_manager->get_user_certificate_stats($current_user_id);
+ $total_certs = $wpdb->get_var($wpdb->prepare(
+ "SELECT COUNT(*) FROM $cert_table WHERE event_id IN ($event_ids_placeholder)",
+ ...$event_ids
+ ));
+
+ $active_certs = $wpdb->get_var($wpdb->prepare(
+ "SELECT COUNT(*) FROM $cert_table WHERE event_id IN ($event_ids_placeholder) AND revoked = 0",
+ ...$event_ids
+ ));
+
+ $revoked_certs = $wpdb->get_var($wpdb->prepare(
+ "SELECT COUNT(*) FROM $cert_table WHERE event_id IN ($event_ids_placeholder) AND revoked = 1",
+ ...$event_ids
+ ));
+
+ $emailed_certs = $wpdb->get_var($wpdb->prepare(
+ "SELECT COUNT(*) FROM $cert_table WHERE event_id IN ($event_ids_placeholder) AND email_sent = 1",
+ ...$event_ids
+ ));
+
+ $certificate_stats = array(
+ 'total' => intval($total_certs),
+ 'active' => intval($active_certs),
+ 'revoked' => intval($revoked_certs),
+ 'emailed' => intval($emailed_certs)
+ );
+
+ // Get certificates based on filters
+ $where_conditions = array("event_id IN ($event_ids_placeholder)");
+ $query_params = $event_ids;
+
+ // Add event filter if specified
+ if ($filter_event > 0 && in_array($filter_event, $event_ids)) {
+ $where_conditions = array("event_id = %d");
+ $query_params = array($filter_event);
+ }
+
+ // Add status filter
+ if ($filter_status === 'active') {
+ $where_conditions[] = "revoked = 0";
+ } elseif ($filter_status === 'revoked') {
+ $where_conditions[] = "revoked = 1";
+ }
+
+ $where_clause = "WHERE " . implode(" AND ", $where_conditions);
+
+ $certificates = $wpdb->get_results($wpdb->prepare(
+ "SELECT * FROM $cert_table $where_clause ORDER BY date_generated DESC LIMIT 50",
+ ...$query_params
+ ));
}
-
- // Get header and footer
- get_header();
+
} catch (Exception $e) {
- echo 'Error initializing certificate system: ' . esc_html($e->getMessage()) . '
';
- return;
+ // Log error but continue with empty data
+ error_log('Certificate Reports Error: ' . $e->getMessage());
}
+
+// Clean output buffer
+ob_end_clean();
+
+// Get header
+get_header();
?>
@@ -122,9 +119,9 @@ try {
@@ -186,7 +183,7 @@ try {
- Apply Filters
+ Apply Filters
@@ -195,14 +192,19 @@ try {
Certificate Listing
-
+
+
+
You don't have any events yet. Create your first event to start generating certificates.
+
Create Event
+
+
No certificates found matching your filters.
- 0 || $filter_status !== 'active') : ?>
+ 0 || $filter_status !== 'all') : ?>
Clear filters to see all your certificates.
-
Generate certificates for your event attendees on the Generate Certificates page.
+
Generate certificates for your event attendees on the Generate Certificates page.
@@ -220,27 +222,24 @@ try {
certificate_number;
- $event_id = $certificate->event_id;
- $attendee_id = $certificate->attendee_id;
- $generated_date = date_i18n(get_option('date_format'), strtotime($certificate->date_generated));
- $is_revoked = (bool) $certificate->revoked;
- $is_emailed = (bool) $certificate->email_sent;
+ // Get certificate data safely
+ $certificate_number = esc_html($certificate->certificate_number ?? 'N/A');
+ $event_id = intval($certificate->event_id ?? 0);
+ $attendee_id = intval($certificate->attendee_id ?? 0);
+ $generated_date = $certificate->date_generated ? date_i18n(get_option('date_format'), strtotime($certificate->date_generated)) : 'Unknown';
+ $is_revoked = !empty($certificate->revoked);
+ $is_emailed = !empty($certificate->email_sent);
- // Get event and attendee information
- $event_title = get_the_title($event_id);
- $attendee_name = get_post_meta($attendee_id, '_tribe_tickets_full_name', true);
- if (empty($attendee_name)) {
- $attendee_name = 'Attendee #' . $attendee_id;
- }
+ // Get event and attendee information safely
+ $event_title = get_the_title($event_id) ?: 'Unknown Event';
+ $attendee_name = get_post_meta($attendee_id, '_tribe_tickets_full_name', true) ?: 'Attendee #' . $attendee_id;
// Status text and class
$status_text = $is_revoked ? 'Revoked' : 'Active';
$status_class = $is_revoked ? 'hvac-status-revoked' : 'hvac-status-active';
?>
-
+
@@ -252,19 +251,13 @@ try {
- revoked_date)) : ?>
-
- revoked_date))); ?>
-
-
- View
-
- Revoke
+ View
+
- Certificate has been revoked
+ Certificate revoked
@@ -272,57 +265,163 @@ try {
-
- 1) : ?>
-
-
-
-
-
-
- ×
-
Certificate Preview
-
-
+
+
admin_url('admin-ajax.php'),
- 'viewNonce' => wp_create_nonce('hvac_view_certificate'),
- 'emailNonce' => wp_create_nonce('hvac_email_certificate'),
- 'revokeNonce' => wp_create_nonce('hvac_revoke_certificate')
-));
-
-// Close the try block
get_footer();
-?>
+?>
\ No newline at end of file
diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/certificates/template-certificate-reports.php.backup b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/certificates/template-certificate-reports.php.backup
new file mode 100644
index 00000000..9ab3f06b
--- /dev/null
+++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/certificates/template-certificate-reports.php.backup
@@ -0,0 +1,328 @@
+check_tables();
+
+ if (!$tables_exist) {
+ echo 'Certificate database tables are not properly set up. Please contact the administrator.
';
+ return;
+ }
+
+ // Get filtering parameters
+ $filter_event = isset($_GET['filter_event']) ? absint($_GET['filter_event']) : 0;
+ $filter_status = isset($_GET['filter_status']) ? sanitize_text_field($_GET['filter_status']) : 'active';
+ $page = isset($_GET['certificate_page']) ? absint($_GET['certificate_page']) : 1;
+ $per_page = 20;
+
+ // Build filter args
+ $filter_args = array(
+ 'page' => $page,
+ 'per_page' => $per_page,
+ 'orderby' => 'date_generated',
+ 'order' => 'DESC',
+ );
+
+ // Add event filter if selected
+ if ($filter_event > 0) {
+ $filter_args['event_id'] = $filter_event;
+ }
+
+ // Add status filter
+ if ($filter_status === 'active') {
+ $filter_args['revoked'] = 0;
+ } elseif ($filter_status === 'revoked') {
+ $filter_args['revoked'] = 1;
+ }
+ // Default 'all' doesn't add a filter
+
+ // Get user's events for filtering using direct database query (bypassing TEC interference)
+ global $wpdb;
+
+ // Build author filter
+ $author_filter = current_user_can('edit_others_posts') ? '' : 'AND post_author = ' . intval($current_user_id);
+
+ // Get events directly from database
+ $events = $wpdb->get_results(
+ "SELECT ID, post_title, post_date
+ FROM {$wpdb->posts}
+ WHERE post_type = 'tribe_events'
+ AND post_status = 'publish'
+ {$author_filter}
+ ORDER BY post_date DESC"
+ );
+
+ // Check if user has any events
+ if (empty($events)) {
+ // No certificates to show since user has no events
+ $certificates = array();
+ $total_certificates = 0;
+ $total_pages = 0;
+ $certificate_stats = array(
+ 'total' => 0,
+ 'active' => 0,
+ 'revoked' => 0,
+ 'emailed' => 0
+ );
+ } else {
+ // Get certificates for the current user with filters
+ $certificates = $certificate_manager->get_user_certificates($current_user_id, $filter_args);
+
+ // Get total certificate count for pagination
+ $total_certificates = $certificate_manager->get_user_certificate_count($current_user_id, $filter_args);
+ $total_pages = ceil($total_certificates / $per_page);
+
+ // Get certificate statistics
+ $certificate_stats = $certificate_manager->get_user_certificate_stats($current_user_id);
+ }
+
+ // Get header and footer
+ get_header();
+} catch (Exception $e) {
+ echo 'Error initializing certificate system: ' . esc_html($e->getMessage()) . '
';
+ return;
+}
+?>
+
+
+
+
+
+
+
+
+
+
+
Certificate Statistics
+
+
+
+
+
+
Active Certificates
+
+
+
+
+
Revoked Certificates
+
+
+
+
+
Emailed Certificates
+
+
+
+
+
+
+
+
Certificate Filters
+
+
+
+
+
+
+
Certificate Listing
+
+
+
+
No certificates found matching your filters.
+
+ 0 || $filter_status !== 'active') : ?>
+
Clear filters to see all your certificates.
+
+
Generate certificates for your event attendees on the Generate Certificates page.
+
+
+
+
+
+
+
+ Certificate #
+ Event
+ Attendee
+ Date Generated
+ Status
+ Actions
+
+
+
+ certificate_number;
+ $event_id = $certificate->event_id;
+ $attendee_id = $certificate->attendee_id;
+ $generated_date = date_i18n(get_option('date_format'), strtotime($certificate->date_generated));
+ $is_revoked = (bool) $certificate->revoked;
+ $is_emailed = (bool) $certificate->email_sent;
+
+ // Get event and attendee information
+ $event_title = get_the_title($event_id);
+ $attendee_name = get_post_meta($attendee_id, '_tribe_tickets_full_name', true);
+ if (empty($attendee_name)) {
+ $attendee_name = 'Attendee #' . $attendee_id;
+ }
+
+ // Status text and class
+ $status_text = $is_revoked ? 'Revoked' : 'Active';
+ $status_class = $is_revoked ? 'hvac-status-revoked' : 'hvac-status-active';
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ revoked_date)) : ?>
+
+ revoked_date))); ?>
+
+
+
+
+
+ View
+
+ Revoke
+
+ Certificate has been revoked
+
+
+
+
+
+
+
+
+ 1) : ?>
+
+
+
+
+
+
+
+
+ ×
+
Certificate Preview
+
+
+
+
+
+ admin_url('admin-ajax.php'),
+ 'viewNonce' => wp_create_nonce('hvac_view_certificate'),
+ 'emailNonce' => wp_create_nonce('hvac_email_certificate'),
+ 'revokeNonce' => wp_create_nonce('hvac_revoke_certificate')
+));
+
+// Close the try block
+get_footer();
+?>
diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/certificates/template-generate-certificates.php b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/certificates/template-generate-certificates.php
index 2c5d282f..d80f141e 100644
--- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/certificates/template-generate-certificates.php
+++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/certificates/template-generate-certificates.php
@@ -1,6 +1,6 @@
get_results($wpdb->prepare(
+ "SELECT ID, post_title, post_date
+ FROM {$wpdb->posts}
+ WHERE post_type = 'tribe_events'
+ AND post_author = %d
+ AND post_status = 'publish'
+ ORDER BY post_date DESC",
+ $current_user_id
+ ));
- // Get certificate generator instance
- $certificate_generator = HVAC_Certificate_Generator::instance();
-
- // Get certificate template instance
- $certificate_template = HVAC_Certificate_Template::instance();
-
- // Check if certificate tables exist
- if (!class_exists('HVAC_Certificate_Installer')) {
- require_once HVAC_CE_PLUGIN_DIR . 'includes/certificates/class-certificate-installer.php';
- }
- $installer = HVAC_Certificate_Installer::instance();
- $tables_exist = $installer->check_tables();
-
- if (!$tables_exist) {
- echo 'Certificate database tables are not properly set up. Please contact the administrator.
';
- return;
- }
-
-// Handle certificate generation form submission
-$generation_results = null;
-$errors = array();
-$success_message = '';
-
-if (isset($_POST['generate_certificates']) && isset($_POST['event_id'])) {
- // Verify nonce
- if (!isset($_POST['hvac_certificate_nonce']) || !wp_verify_nonce($_POST['hvac_certificate_nonce'], 'hvac_generate_certificates')) {
- $errors[] = 'Security verification failed. Please try again.';
- } else {
- $submitted_event_id = absint($_POST['event_id']);
- $selected_attendees = isset($_POST['attendee_ids']) && is_array($_POST['attendee_ids']) ? array_map('absint', $_POST['attendee_ids']) : array();
- $checked_in_only = isset($_POST['checked_in_only']) && $_POST['checked_in_only'] === 'yes';
-
- // Check if any attendees were selected
- if (empty($selected_attendees)) {
- $errors[] = 'Please select at least one attendee to generate certificates for.';
- } else {
- // Generate certificates in batch
- $generation_results = $certificate_generator->generate_certificates_batch(
- $submitted_event_id,
- $selected_attendees,
- array(), // Custom data (none for now)
- $current_user_id, // Generated by current user
- $checked_in_only // Only for checked-in attendees if selected
- );
-
- // Set success message if at least one certificate was generated
- if ($generation_results['success'] > 0) {
- $message_parts = array(
- sprintf('Successfully generated %d certificate(s).', $generation_results['success'])
- );
-
- if ($generation_results['duplicate'] > 0) {
- $message_parts[] = sprintf('%d duplicate(s) skipped.', $generation_results['duplicate']);
- }
-
- if ($generation_results['not_checked_in'] > 0) {
- $message_parts[] = sprintf('%d attendee(s) not checked in.', $generation_results['not_checked_in']);
- }
-
- if ($generation_results['error'] > 0) {
- $message_parts[] = sprintf('%d error(s).', $generation_results['error']);
- }
-
- $success_message = implode(' ', $message_parts);
- } elseif ($generation_results['duplicate'] > 0 && $generation_results['error'] === 0 && $generation_results['not_checked_in'] === 0) {
- $success_message = sprintf(
- 'No new certificates generated. %d certificate(s) already exist for the selected attendees.',
- $generation_results['duplicate']
- );
- } elseif ($generation_results['not_checked_in'] > 0 && $checked_in_only) {
- $success_message = sprintf(
- 'No new certificates generated. %d selected attendee(s) have not been checked in.',
- $generation_results['not_checked_in']
- );
- } else {
- $errors[] = 'Failed to generate certificates. Please try again.';
+ // If event is selected, get attendees
+ if ($event_id > 0) {
+ // Verify the event belongs to the current user
+ $event_found = false;
+ foreach ($events as $event) {
+ if ($event->ID == $event_id) {
+ $event_found = true;
+ $selected_event_title = $event->post_title;
+ break;
}
}
+
+ if ($event_found) {
+ // Get attendees for the selected event
+ $attendees = $wpdb->get_results($wpdb->prepare(
+ "SELECT p.ID as attendee_id,
+ pm1.meta_value as holder_name,
+ pm2.meta_value as holder_email,
+ pm3.meta_value as check_in
+ FROM {$wpdb->posts} p
+ LEFT JOIN {$wpdb->postmeta} pm1 ON p.ID = pm1.post_id AND pm1.meta_key = '_tribe_tickets_full_name'
+ LEFT JOIN {$wpdb->postmeta} pm2 ON p.ID = pm2.post_id AND pm2.meta_key = '_tribe_tickets_email'
+ LEFT JOIN {$wpdb->postmeta} pm3 ON p.ID = pm3.post_id AND pm3.meta_key = '_tribe_tickets_checked_in'
+ LEFT JOIN {$wpdb->postmeta} pm4 ON p.ID = pm4.post_id AND pm4.meta_key = '_tribe_tickets_event'
+ WHERE p.post_type = 'tribe_ticket_attendee'
+ AND p.post_status = 'publish'
+ AND pm4.meta_value = %d
+ ORDER BY pm1.meta_value ASC",
+ $event_id
+ ));
+ }
}
-}
-
-// Get user's events for the event selection step using direct database query (bypassing TEC interference)
-global $wpdb;
-
-// Build author filter
-$author_filter = current_user_can('edit_others_posts') ? '' : 'AND post_author = ' . intval($current_user_id);
-
-// Get events directly from database
-$events = $wpdb->get_results(
- "SELECT ID, post_title, post_date
- FROM {$wpdb->posts}
- WHERE post_type = 'tribe_events'
- AND post_status = 'publish'
- {$author_filter}
- ORDER BY post_date DESC"
-);
-
-// Get attendees for the selected event using direct database query
-$attendees = array();
-if ($event_id > 0) {
- // Use direct database query to get attendees (both TEC and TPP formats)
- $tec_attendees = $wpdb->get_results($wpdb->prepare(
- "SELECT
- p.ID as attendee_id,
- p.post_parent as event_id,
- COALESCE(tec_full_name.meta_value, tpp_full_name.meta_value, tickets_full_name.meta_value, 'Unknown Attendee') as holder_name,
- COALESCE(tec_email.meta_value, tpp_email.meta_value, tickets_email.meta_value, tpp_attendee_email.meta_value, 'no-email@example.com') as holder_email,
- COALESCE(checked_in.meta_value, '0') as check_in
- FROM {$wpdb->posts} p
- LEFT JOIN {$wpdb->postmeta} tec_full_name ON p.ID = tec_full_name.post_id AND tec_full_name.meta_key = '_tec_tickets_commerce_full_name'
- LEFT JOIN {$wpdb->postmeta} tpp_full_name ON p.ID = tpp_full_name.post_id AND tpp_full_name.meta_key = '_tribe_tpp_full_name'
- LEFT JOIN {$wpdb->postmeta} tickets_full_name ON p.ID = tickets_full_name.post_id AND tickets_full_name.meta_key = '_tribe_tickets_full_name'
- LEFT JOIN {$wpdb->postmeta} tec_email ON p.ID = tec_email.post_id AND tec_email.meta_key = '_tec_tickets_commerce_email'
- LEFT JOIN {$wpdb->postmeta} tpp_email ON p.ID = tpp_email.post_id AND tpp_email.meta_key = '_tribe_tpp_email'
- LEFT JOIN {$wpdb->postmeta} tickets_email ON p.ID = tickets_email.post_id AND tickets_email.meta_key = '_tribe_tickets_email'
- LEFT JOIN {$wpdb->postmeta} tpp_attendee_email ON p.ID = tpp_attendee_email.post_id AND tpp_attendee_email.meta_key = '_tribe_tpp_attendee_email'
- LEFT JOIN {$wpdb->postmeta} checked_in ON p.ID = checked_in.post_id AND checked_in.meta_key = '_tribe_tickets_attendee_checked_in'
- WHERE p.post_type IN ('tec_tc_attendee', 'tribe_tpp_attendees')
- AND p.post_parent = %d
- ORDER BY p.ID ASC",
- $event_id
- ));
- // Convert to format expected by template
- foreach ($tec_attendees as $attendee) {
- $attendees[] = array(
- 'attendee_id' => $attendee->attendee_id,
- 'event_id' => $attendee->event_id,
- 'holder_name' => $attendee->holder_name,
- 'holder_email' => $attendee->holder_email,
- 'check_in' => intval($attendee->check_in)
- );
- }
+} catch (Exception $e) {
+ error_log('Generate Certificates Error: ' . $e->getMessage());
}
-// Get header and footer
+// Get header
get_header();
-
-// Ensure certificate CSS is loaded
-wp_enqueue_style(
- 'hvac-certificates-style',
- HVAC_CE_PLUGIN_URL . 'assets/css/hvac-certificates.css',
- ['hvac-common-style'],
- HVAC_CE_VERSION
-);
-
-// Ensure dashboard CSS is loaded for proper styling
-wp_enqueue_style(
- 'hvac-dashboard-style',
- HVAC_CE_PLUGIN_URL . 'assets/css/hvac-dashboard.css',
- ['hvac-common-style'],
- HVAC_CE_VERSION
-);
?>
@@ -202,340 +83,379 @@ wp_enqueue_style(
-
-
-
-
-
-
-
-
-
+
-
+
Step 1: Select Event
-
You don't have any events. Create an event first.
+
+
You don't have any events yet. Create your first event to start generating certificates.
+
Create Event
+
-
-
-
0 ? '' : 'style="display: none;"'; ?>>
-
Step 2: Select Attendees
-
-
-
-
-
-
';
-}
?>
\ No newline at end of file
diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/certificates/template-generate-certificates.php.backup b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/certificates/template-generate-certificates.php.backup
new file mode 100644
index 00000000..2c5d282f
--- /dev/null
+++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/certificates/template-generate-certificates.php.backup
@@ -0,0 +1,541 @@
+check_tables();
+
+ if (!$tables_exist) {
+ echo '
Certificate database tables are not properly set up. Please contact the administrator.
';
+ return;
+ }
+
+// Handle certificate generation form submission
+$generation_results = null;
+$errors = array();
+$success_message = '';
+
+if (isset($_POST['generate_certificates']) && isset($_POST['event_id'])) {
+ // Verify nonce
+ if (!isset($_POST['hvac_certificate_nonce']) || !wp_verify_nonce($_POST['hvac_certificate_nonce'], 'hvac_generate_certificates')) {
+ $errors[] = 'Security verification failed. Please try again.';
+ } else {
+ $submitted_event_id = absint($_POST['event_id']);
+ $selected_attendees = isset($_POST['attendee_ids']) && is_array($_POST['attendee_ids']) ? array_map('absint', $_POST['attendee_ids']) : array();
+ $checked_in_only = isset($_POST['checked_in_only']) && $_POST['checked_in_only'] === 'yes';
+
+ // Check if any attendees were selected
+ if (empty($selected_attendees)) {
+ $errors[] = 'Please select at least one attendee to generate certificates for.';
+ } else {
+ // Generate certificates in batch
+ $generation_results = $certificate_generator->generate_certificates_batch(
+ $submitted_event_id,
+ $selected_attendees,
+ array(), // Custom data (none for now)
+ $current_user_id, // Generated by current user
+ $checked_in_only // Only for checked-in attendees if selected
+ );
+
+ // Set success message if at least one certificate was generated
+ if ($generation_results['success'] > 0) {
+ $message_parts = array(
+ sprintf('Successfully generated %d certificate(s).', $generation_results['success'])
+ );
+
+ if ($generation_results['duplicate'] > 0) {
+ $message_parts[] = sprintf('%d duplicate(s) skipped.', $generation_results['duplicate']);
+ }
+
+ if ($generation_results['not_checked_in'] > 0) {
+ $message_parts[] = sprintf('%d attendee(s) not checked in.', $generation_results['not_checked_in']);
+ }
+
+ if ($generation_results['error'] > 0) {
+ $message_parts[] = sprintf('%d error(s).', $generation_results['error']);
+ }
+
+ $success_message = implode(' ', $message_parts);
+ } elseif ($generation_results['duplicate'] > 0 && $generation_results['error'] === 0 && $generation_results['not_checked_in'] === 0) {
+ $success_message = sprintf(
+ 'No new certificates generated. %d certificate(s) already exist for the selected attendees.',
+ $generation_results['duplicate']
+ );
+ } elseif ($generation_results['not_checked_in'] > 0 && $checked_in_only) {
+ $success_message = sprintf(
+ 'No new certificates generated. %d selected attendee(s) have not been checked in.',
+ $generation_results['not_checked_in']
+ );
+ } else {
+ $errors[] = 'Failed to generate certificates. Please try again.';
+ }
+ }
+ }
+}
+
+// Get user's events for the event selection step using direct database query (bypassing TEC interference)
+global $wpdb;
+
+// Build author filter
+$author_filter = current_user_can('edit_others_posts') ? '' : 'AND post_author = ' . intval($current_user_id);
+
+// Get events directly from database
+$events = $wpdb->get_results(
+ "SELECT ID, post_title, post_date
+ FROM {$wpdb->posts}
+ WHERE post_type = 'tribe_events'
+ AND post_status = 'publish'
+ {$author_filter}
+ ORDER BY post_date DESC"
+);
+
+// Get attendees for the selected event using direct database query
+$attendees = array();
+if ($event_id > 0) {
+ // Use direct database query to get attendees (both TEC and TPP formats)
+ $tec_attendees = $wpdb->get_results($wpdb->prepare(
+ "SELECT
+ p.ID as attendee_id,
+ p.post_parent as event_id,
+ COALESCE(tec_full_name.meta_value, tpp_full_name.meta_value, tickets_full_name.meta_value, 'Unknown Attendee') as holder_name,
+ COALESCE(tec_email.meta_value, tpp_email.meta_value, tickets_email.meta_value, tpp_attendee_email.meta_value, 'no-email@example.com') as holder_email,
+ COALESCE(checked_in.meta_value, '0') as check_in
+ FROM {$wpdb->posts} p
+ LEFT JOIN {$wpdb->postmeta} tec_full_name ON p.ID = tec_full_name.post_id AND tec_full_name.meta_key = '_tec_tickets_commerce_full_name'
+ LEFT JOIN {$wpdb->postmeta} tpp_full_name ON p.ID = tpp_full_name.post_id AND tpp_full_name.meta_key = '_tribe_tpp_full_name'
+ LEFT JOIN {$wpdb->postmeta} tickets_full_name ON p.ID = tickets_full_name.post_id AND tickets_full_name.meta_key = '_tribe_tickets_full_name'
+ LEFT JOIN {$wpdb->postmeta} tec_email ON p.ID = tec_email.post_id AND tec_email.meta_key = '_tec_tickets_commerce_email'
+ LEFT JOIN {$wpdb->postmeta} tpp_email ON p.ID = tpp_email.post_id AND tpp_email.meta_key = '_tribe_tpp_email'
+ LEFT JOIN {$wpdb->postmeta} tickets_email ON p.ID = tickets_email.post_id AND tickets_email.meta_key = '_tribe_tickets_email'
+ LEFT JOIN {$wpdb->postmeta} tpp_attendee_email ON p.ID = tpp_attendee_email.post_id AND tpp_attendee_email.meta_key = '_tribe_tpp_attendee_email'
+ LEFT JOIN {$wpdb->postmeta} checked_in ON p.ID = checked_in.post_id AND checked_in.meta_key = '_tribe_tickets_attendee_checked_in'
+ WHERE p.post_type IN ('tec_tc_attendee', 'tribe_tpp_attendees')
+ AND p.post_parent = %d
+ ORDER BY p.ID ASC",
+ $event_id
+ ));
+
+ // Convert to format expected by template
+ foreach ($tec_attendees as $attendee) {
+ $attendees[] = array(
+ 'attendee_id' => $attendee->attendee_id,
+ 'event_id' => $attendee->event_id,
+ 'holder_name' => $attendee->holder_name,
+ 'holder_email' => $attendee->holder_email,
+ 'check_in' => intval($attendee->check_in)
+ );
+ }
+}
+
+// Get header and footer
+get_header();
+
+// Ensure certificate CSS is loaded
+wp_enqueue_style(
+ 'hvac-certificates-style',
+ HVAC_CE_PLUGIN_URL . 'assets/css/hvac-certificates.css',
+ ['hvac-common-style'],
+ HVAC_CE_VERSION
+);
+
+// Ensure dashboard CSS is loaded for proper styling
+wp_enqueue_style(
+ 'hvac-dashboard-style',
+ HVAC_CE_PLUGIN_URL . 'assets/css/hvac-dashboard.css',
+ ['hvac-common-style'],
+ HVAC_CE_VERSION
+);
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Step 1: Select Event
+
+
+
You don't have any events. Create an event first.
+
+
+
+
+
+
+
0 ? '' : 'style="display: none;"'; ?>>
+
Step 2: Select Attendees
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Generate Certificates
+
+
+
+
+
+
+
Certificate Management Tools
+
After generating certificates, you can:
+
+ View all certificates on the Certificate Reports page
+ Email certificates to attendees directly from the reports page
+ Revoke certificates that were issued incorrectly
+ Download certificates in PDF format for printing or distribution
+
+
+
+
+
+
+
+Error in certificate generation: ' . esc_html($e->getMessage()) . '
';
+}
+?>
\ No newline at end of file
diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/template-hvac-dashboard.php b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/template-hvac-dashboard.php
index bfed3dd7..a4f00806 100644
--- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/template-hvac-dashboard.php
+++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/template-hvac-dashboard.php
@@ -123,10 +123,7 @@ get_header(); // Use theme's header
'
View Profile ',
'Update your professional credentials, business information, and training specialties'
); ?>
- Help',
- 'Access comprehensive documentation and help guides'
- ); ?>
+
Help
Logout