get_charset_collate(); // SQL to create necessary tables $sql = " CREATE TABLE {$wpdb->prefix}sige_place ( id MEDIUMINT(9) NOT NULL AUTO_INCREMENT, place TINYTEXT NOT NULL, comments TEXT NOT NULL, PRIMARY KEY (id) ) $charset_collate; CREATE TABLE {$wpdb->prefix}sige_speakers ( id MEDIUMINT(9) NOT NULL AUTO_INCREMENT, research_degree VARCHAR(50) NOT NULL, full_name TINYTEXT NOT NULL, email VARCHAR(100) NOT NULL, institution TINYTEXT NOT NULL, PRIMARY KEY (id) ) $charset_collate; CREATE TABLE {$wpdb->prefix}sige_event_names ( id MEDIUMINT(9) NOT NULL AUTO_INCREMENT, acronym VARCHAR(50) NOT NULL, name TINYTEXT NOT NULL, responsible_for TINYTEXT NOT NULL, PRIMARY KEY (id) ) $charset_collate; CREATE TABLE {$wpdb->prefix}sige_meta_keys ( id MEDIUMINT(9) NOT NULL AUTO_INCREMENT, meta_key VARCHAR(255) NOT NULL, status TINYINT(1) NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE KEY meta_key (meta_key) ) $charset_collate; CREATE TABLE {$wpdb->prefix}sige_activities ( id MEDIUMINT(9) NOT NULL AUTO_INCREMENT, name TINYTEXT NOT NULL, description TEXT NOT NULL, start_date DATE NOT NULL, start_time TIME NOT NULL, end_date DATE NOT NULL, end_time TIME NOT NULL, type VARCHAR(50) NOT NULL, modality VARCHAR(50) NOT NULL, status VARCHAR(50) NOT NULL, curriculum TEXT NOT NULL, comment TEXT NOT NULL, place_id MEDIUMINT(9) NOT NULL, speaker_id MEDIUMINT(9) NOT NULL, event_name_id MEDIUMINT(9), security_credential VARCHAR(20) NOT NULL, chair TINYTEXT NOT NULL, target_audience VARCHAR(50) NOT NULL, attendance_control ENUM('yes', 'no') NOT NULL DEFAULT 'no', PRIMARY KEY (id), KEY place_id (place_id), KEY speaker_id (speaker_id), KEY event_name_id (event_name_id), CONSTRAINT fk_place FOREIGN KEY (place_id) REFERENCES {$wpdb->prefix}sige_place(id) ON DELETE CASCADE, CONSTRAINT fk_speaker FOREIGN KEY (speaker_id) REFERENCES {$wpdb->prefix}sige_speakers(id) ON DELETE CASCADE, CONSTRAINT fk_event_name FOREIGN KEY (event_name_id) REFERENCES {$wpdb->prefix}sige_event_names(id) ON DELETE SET NULL ) $charset_collate; CREATE TABLE {$wpdb->prefix}sige_enrollments ( id MEDIUMINT(9) NOT NULL AUTO_INCREMENT, activity_id MEDIUMINT(9) NOT NULL, user_id BIGINT(20) UNSIGNED NOT NULL, enrollment_date DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, status VARCHAR(50) NOT NULL, PRIMARY KEY (id), FOREIGN KEY (activity_id) REFERENCES {$wpdb->prefix}sige_activities(id) ON DELETE CASCADE, FOREIGN KEY (user_id) REFERENCES {$wpdb->prefix}users(ID) ON DELETE CASCADE ) $charset_collate; CREATE TABLE {$wpdb->prefix}sige_cancellation_record ( id MEDIUMINT(9) NOT NULL AUTO_INCREMENT, activity_id MEDIUMINT(9) NOT NULL, user_id BIGINT(20) UNSIGNED NOT NULL, date_of_cancelation DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, reasons VARCHAR(50) NULL, PRIMARY KEY (id), FOREIGN KEY (activity_id) REFERENCES {$wpdb->prefix}sige_activities(id) ON DELETE CASCADE, FOREIGN KEY (user_id) REFERENCES {$wpdb->prefix}users(ID) ON DELETE CASCADE ) $charset_collate; CREATE TABLE {$wpdb->prefix}sige_activity_notices ( id MEDIUMINT(9) NOT NULL AUTO_INCREMENT, type VARCHAR(50) NOT NULL, notice TEXT NOT NULL, PRIMARY KEY (id) ) $charset_collate; CREATE TABLE {$wpdb->prefix}sige_display_options ( id MEDIUMINT(9) NOT NULL AUTO_INCREMENT, field_name VARCHAR(50) NOT NULL, display TINYINT(1) NOT NULL DEFAULT 1, PRIMARY KEY (id) ) $charset_collate; CREATE TABLE {$wpdb->prefix}sige_enrollment_button_style ( button_action VARCHAR(50) NOT NULL, button_label VARCHAR(50) NOT NULL, background_color VARCHAR(7) NOT NULL, font_size VARCHAR(10) NOT NULL, font_family VARCHAR(100) NOT NULL, font_weight VARCHAR(10) NOT NULL, PRIMARY KEY (button_action) ) $charset_collate; CREATE TABLE {$wpdb->prefix}sige_enrollment_status_style ( status_action VARCHAR(50) NOT NULL, status_label VARCHAR(50) NOT NULL, font_color VARCHAR(7) NOT NULL, font_size VARCHAR(10) NOT NULL, font_family VARCHAR(100) NOT NULL, font_weight VARCHAR(10) NOT NULL, PRIMARY KEY (status_action) ) $charset_collate; CREATE TABLE {$wpdb->prefix}sige_email_messages ( id MEDIUMINT(9) NOT NULL AUTO_INCREMENT, email_sender VARCHAR(100) NOT NULL, email_subject VARCHAR(255) NOT NULL, email_message TEXT NOT NULL, status_action VARCHAR(50) NOT NULL, PRIMARY KEY (id), FOREIGN KEY (status_action) REFERENCES {$wpdb->prefix}sige_enrollment_status_style(status_action) ON DELETE CASCADE ) $charset_collate; CREATE TABLE {$wpdb->prefix}sige_enrollment_attendance_control ( id MEDIUMINT(9) NOT NULL AUTO_INCREMENT, enrollment_id MEDIUMINT(9) NOT NULL, attended ENUM('yes', 'no') DEFAULT NULL, PRIMARY KEY (id), FOREIGN KEY (enrollment_id) REFERENCES {$wpdb->prefix}sige_enrollments(id) ON DELETE CASCADE ) $charset_collate; "; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); // Insert default display options $default_options = [ 'Notices', 'Speaker', 'Curriculum Vitae', 'Data', 'Place', 'Enrollment Status', 'Comment', 'Security Credential', 'Target Audience', 'Chair' ]; foreach ($default_options as $option) { if (!$wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}sige_display_options WHERE field_name = %s", $option))) { $wpdb->insert("{$wpdb->prefix}sige_display_options", ['field_name' => $option, 'display' => 1]); } } // Insert default button styles $default_styles = [ ['button_action' => 'request_enrollment', 'button_label' => 'Request Enrollment', 'background_color' => '#0073aa', 'font_size' => '14px', 'font_family' => 'Arial, sans-serif', 'font_weight' => 'normal'], ['button_action' => 'cancel_enrollment', 'button_label' => 'Cancel Enrollment', 'background_color' => '#ac1226', 'font_size' => '14px', 'font_family' => 'Arial, sans-serif', 'font_weight' => 'normal'] ]; foreach ($default_styles as $style) { $wpdb->insert("{$wpdb->prefix}sige_enrollment_button_style", $style); } // Insert default status styles $default_status_styles = [ ['status_action' => 'Not Requested', 'status_label' => 'Not Requested', 'font_color' => '#000000', 'font_size' => '14px', 'font_family' => 'Arial, sans-serif', 'font_weight' => 'normal'], ['status_action' => 'Enrollment Canceled by User', 'status_label' => 'Enrollment Canceled by User', 'font_color' => '#ac1226', 'font_size' => '14px', 'font_family' => 'Arial, sans-serif', 'font_weight' => 'normal'], ['status_action' => 'Under Analysis', 'status_label' => 'Under Analysis', 'font_color' => '#0073aa', 'font_size' => '14px', 'font_family' => 'Arial, sans-serif', 'font_weight' => 'normal'], ['status_action' => 'Approved', 'status_label' => 'Approved', 'font_color' => '#008000', 'font_size' => '14px', 'font_family' => 'Arial, sans-serif', 'font_weight' => 'normal'], ['status_action' => 'Waiting List', 'status_label' => 'Waiting List', 'font_color' => '#CC9900', 'font_size' => '14px', 'font_family' => 'Arial, sans-serif', 'font_weight' => 'normal'], ['status_action' => 'Not Approved', 'status_label' => 'Not Approved', 'font_color' => '#bc97cd', 'font_size' => '14px', 'font_family' => 'Arial, sans-serif', 'font_weight' => 'normal'] ]; foreach ($default_status_styles as $style) { $wpdb->insert("{$wpdb->prefix}sige_enrollment_status_style", $style); } // Insert default email messages $default_email_messages = [ ['email_sender' => get_bloginfo('admin_email'), 'email_subject' => 'Not Requested', 'email_message' => 'Your enrollment status is Not Requested.', 'status_action' => 'Not Requested'], ['email_sender' => get_bloginfo('admin_email'), 'email_subject' => 'Enrollment Canceled by User', 'email_message' => 'Your enrollment has been canceled by user.', 'status_action' => 'Enrollment Canceled by User'], ['email_sender' => get_bloginfo('admin_email'), 'email_subject' => 'Under Analysis', 'email_message' => 'Your enrollment is under analysis.', 'status_action' => 'Under Analysis'], ['email_sender' => get_bloginfo('admin_email'), 'email_subject' => 'Approved', 'email_message' => 'Your enrollment has been approved.', 'status_action' => 'Approved'], ['email_sender' => get_bloginfo('admin_email'), 'email_subject' => 'Waiting List', 'email_message' => 'You have been placed on the waiting list.', 'status_action' => 'Waiting List'], ['email_sender' => get_bloginfo('admin_email'), 'email_subject' => 'Not Approved', 'email_message' => 'Your enrollment has not been approved.', 'status_action' => 'Not Approved'] ]; foreach ($default_email_messages as $message) { $wpdb->insert("{$wpdb->prefix}sige_email_messages", $message); } // Ensure wp_usermeta has specified meta_keys $required_meta_keys = [ 'forca', 'full_name', 'posto', 'militar', 'instituição', 'nacionalidade', 'efetivo_dcta', 'cidade', 'estado', 'areaatividadeprincipal', 'setordeatuacao', 'cargofuncao', 'ehativa', 'circulo hierárquico', 'telefone', 'passaporte', 'pais', 'formacao_academica', 'regiao_do_brasil' ]; foreach ($required_meta_keys as $meta_key) { if (!$wpdb->get_var($wpdb->prepare("SELECT meta_key FROM {$wpdb->prefix}usermeta WHERE meta_key = %s", $meta_key))) { $wpdb->insert("{$wpdb->prefix}usermeta", ['meta_key' => $meta_key, 'meta_value' => '']); } } // Check if the JSON file with saved data exists and restore data if available $json_file_path = plugin_dir_path(__FILE__) . 'sige_events_data.json'; if (file_exists($json_file_path)) { $json_data = json_decode(file_get_contents($json_file_path), true); if ($json_data) { $tables_to_replace = [ 'sige_enrollment_status_style', 'sige_email_messages', 'sige_enrollment_button_style', 'sige_display_options', 'sige_activities', 'sige_enrollments', 'sige_cancellation_record', 'sige_enrollment_attendance_control' ]; // Restore the non-replacement tables first foreach ($json_data as $table => $records) { if (!in_array($table, $tables_to_replace)) { foreach ($records as $record) { $wpdb->insert("{$wpdb->prefix}$table", $record); } } } // Restore the replacement tables last foreach ($tables_to_replace as $table) { if (isset($json_data[$table])) { foreach ($json_data[$table] as $record) { $wpdb->replace("{$wpdb->prefix}$table", $record); } } } } } } function sige_events_uninstall() { global $wpdb; // Export data to JSON file before dropping tables $tables = [ 'sige_activity_notices', 'sige_display_options', 'sige_enrollment_button_style', 'sige_meta_keys', 'sige_email_messages', 'sige_enrollment_status_style', 'sige_event_names', 'sige_place', 'sige_speakers', 'sige_activities', 'sige_enrollments', 'sige_cancellation_record', 'sige_enrollment_attendance_control' ]; $data = []; // Save non-replacement tables first foreach ($tables as $table) { if (!in_array($table, ['sige_activities', 'sige_enrollments', 'sige_enrollment_attendance_control','sige_cancellation_record'])) { $data[$table] = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}$table", ARRAY_A); } } // Save replacement tables last foreach (['sige_activities', 'sige_enrollments', 'sige_enrollment_attendance_control','sige_cancellation_record'] as $table) { $data[$table] = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}$table", ARRAY_A); } $json_file_path = plugin_dir_path(__FILE__) . 'sige_events_data.json'; file_put_contents($json_file_path, json_encode($data)); // Drop the tables $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}sige_activity_notices"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}sige_display_options"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}sige_enrollment_button_style"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}sige_meta_keys"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}sige_email_messages"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}sige_enrollment_status_style"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}sige_enrollment_attendance_control"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}sige_enrollments"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}sige_cancellation_record"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}sige_activities"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}sige_event_names"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}sige_place"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}sige_speakers"); } add_action('admin_menu', 'addAdminPageContent'); function addAdminPageContent() { add_menu_page('SIGE Events', 'SIGE Events', 'manage_options', 'sige-events', 'SigeEventmenuPage', 'dashicons-wordpress'); add_submenu_page('sige-events', 'Dashboard', 'Dashboard', 'manage_options', 'dashboard-submenu', 'dashboardSubmenuPage'); add_submenu_page('sige-events', 'Available Activities', 'Available Activities', 'manage_options', 'available-activities-submenu', 'availableActivitiesSubmenuPage'); add_submenu_page('sige-events', 'Enrollment Control', 'Enrollment Control', 'manage_options', 'enrollment-submenu', 'enrollmentSubmenuPage'); add_submenu_page('sige-events', 'Attendance Control', 'Attendance Control', 'manage_options', 'attendance-control-submenu', 'attendanceControlSubmenuPage'); add_submenu_page('sige-events', 'Settings', 'Settings', 'manage_options', 'settings-submenu', 'settingsSubmenuPage'); } function SigeEventmenuPage() { echo '
Sige Events is a comprehensive plugin designed to facilitate the management of enrollments for short courses and events. It offers a user-friendly interface and a variety of features that help administrators efficiently handle all aspects of event management.
'; echo 'Key Features:
'; echo 'This plugin is an ideal solution for institutions, organizations, or individuals who need a reliable and efficient system to manage their educational or informational events.
'; echo 'The development of Sige Events was a collaborative effort involving the following contributors:
'; echo 'To display the open activities on any page or post, use the following shortcode:
'; echo '[open_activities]';
echo 'To display the enrollments on any page or post, use the following shortcode:
'; echo '[enrollments]';
echo 'To manage attendance control on any page or post, use the following shortcode:
'; echo '[frontend_attendance_control]';
echo 'To generate the QR CODE for user purpose, use the following shortcode:
'; echo '[userbadge_qr_code]';
echo '[open_activities][enrollments][frontend_attendance_control]Content for the Dashboard submenu page.
The end date cannot be before the start date.
The end date cannot be before the start date.
| Activity Name | Activity Description | Start Date | Start Time | End Date | End Time | Type | Modality | Status | Place | Speaker | Event Name | Chair | Curriculum | Security Credential | Target Audience | Attendance Control | Comment | ||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ' . esc_html($activity->name) . ' | ' . esc_html($activity->description) . ' | ' . esc_html($activity->start_date) . ' | ' . esc_html($activity->start_time) . ' | ' . esc_html($activity->end_date) . ' | ' . esc_html($activity->end_time) . ' | ' . esc_html($activity->type) . ' | ' . esc_html($activity->modality) . ' | ' . esc_html($activity->status) . ' | ' . esc_html($activity->place) . ' | ' . esc_html($activity->speaker) . ' | ' . esc_html($activity->event_name) . ' | ' . esc_html($activity->chair) . ' | ' . esc_html($activity->curriculum) . ' | ' . esc_html($activity->security_credential) . ' | ' . esc_html($activity->target_audience) . ' | ' . esc_html($activity->attendance_control) . ' | ' . esc_html($activity->comment) . ' | Edit | Delete |
Error updating enrollment ID ' . $enrollment_id . '.
Enrollment status updated successfully.
Please select at least one enrollment.
Email settings saved successfully.
You must be logged in to view the available activities.
'; } global $wpdb; $current_user_id = get_current_user_id(); // Fetch the required meta keys from wp_sige_meta_keys excluding specific keys $required_meta_keys = $wpdb->get_col(" SELECT meta_key FROM {$wpdb->prefix}sige_meta_keys WHERE status = 1 AND meta_key NOT IN ('militar', 'forca', 'posto', 'efetivo_dcta', 'ehativa', 'circulo hierárquico') "); // Check if all required meta keys are filled $user_meta = get_user_meta($current_user_id); $missing_keys = []; foreach ($required_meta_keys as $meta_key) { if (empty($user_meta[$meta_key][0])) { $missing_keys[] = $meta_key; } } // Check if 'militar' meta key is set to '1', if so, check additional meta keys if (!empty($user_meta['militar'][0]) && $user_meta['militar'][0] == '1') { $additional_keys = ['forca', 'posto', 'efetivo_dcta', 'ehativa', 'circulo hierárquico']; foreach ($additional_keys as $key) { if (empty($user_meta[$key][0])) { $missing_keys[] = $key; } } } if (!empty($missing_keys)) { echo 'You need to update your profile information to view the available activities. Please make sure all required fields are filled out.
No open activities available for this year.
'; } $display_options = $wpdb->get_results("SELECT field_name, display FROM {$wpdb->prefix}sige_display_options", OBJECT_K); // CSS for tabbed interface and active tab highlighting echo ''; ob_start(); echo 'No open activities available for this event.
'; } else { foreach (['Presentation', 'Short-course', 'Lecture', 'Workshop', 'Others'] as $type_name) { $grouped_activities = array_filter($event_activities, function($activity) use ($type_name) { return $activity->type == $type_name; }); if (!empty($grouped_activities)) { $notice = $wpdb->get_var($wpdb->prepare("SELECT notice FROM {$wpdb->prefix}sige_activity_notices WHERE type = %s", $type_name)); echo '' . ($notice ? esc_html($notice) : 'No notice available for this type.') . '
'; } foreach ($grouped_activities as $activity) { $formatted_start_date = date('d-m-Y', strtotime($activity->start_date)); $formatted_end_date = date('d-m-Y', strtotime($activity->end_date)); $end_date = $activity->end_date == $activity->start_date ? '' : ' to ' . $formatted_end_date; $enrollment_status_action = $wpdb->get_var($wpdb->prepare(" SELECT status FROM {$wpdb->prefix}sige_enrollments WHERE activity_id = %d AND user_id = %d ", $activity->id, $current_user_id)); if (!$enrollment_status_action) { $enrollment_status_action = 'Not Requested'; } echo '' . esc_html($activity->type) . ': ' . $activity->name . '
'; if ($display_options['Comment']->display) { echo 'Comment: ' . esc_html($activity->comment) . '
'; } if ($display_options['Speaker']->display) { echo 'Speaker: ' . $activity->speaker . '
'; } if ($display_options['Curriculum Vitae']->display) { echo 'Curriculum Vitae: ' . esc_url($activity->curriculum) . '
'; } if ($display_options['Data']->display) { echo 'Data: ' . esc_html($formatted_start_date) . $end_date . '
'; } if ($display_options['Place']->display) { echo 'Place: ' . esc_html($activity->place) . '
'; } if ($display_options['Security Credential']->display) { echo 'Security Credential: ' . esc_html($activity->security_credential) . '
'; } if ($display_options['Target Audience']->display) { echo 'Target Audience: ' . esc_html($activity->target_audience) . '
'; } if ($display_options['Chair']->display) { echo 'Chair: ' . esc_html($activity->chair) . '
'; } // Display the activity status echo 'Activity Status: ' . esc_html($activity->status) . '
'; if ($activity->status != 'Not applicable' && $display_options['Enrollment Status']->display) { $status_style = $wpdb->get_row($wpdb->prepare(" SELECT * FROM {$wpdb->prefix}sige_enrollment_status_style WHERE status_action = %s ", $enrollment_status_action)); $font_color = $status_style->font_color; $font_size = $status_style->font_size; $font_family = $status_style->font_family; $font_weight = $status_style->font_weight; $status_label = $status_style->status_label; echo 'Enrollment Status: ' . esc_html($status_label) . '
'; } if ($activity->status != 'Closed') { // Determine button label, action, and style if ($enrollment_status_action == 'Not Requested' || $enrollment_status_action == 'Enrollment Canceled by User') { $button_action = 'request_enrollment'; } elseif ($enrollment_status_action == 'Under Analysis' || $enrollment_status_action == 'Waiting List' || $enrollment_status_action == 'Approved') { $button_action = 'cancel_enrollment'; } if ($enrollment_status_action != 'Not Approved') { // Get button styles $button_style = $wpdb->get_row($wpdb->prepare(" SELECT * FROM {$wpdb->prefix}sige_enrollment_button_style WHERE button_action = %s ", $button_action)); $button_label = $button_style->button_label; $button_background_color = $button_style->background_color; $button_font_size = $button_style->font_size; $button_font_family = $button_style->font_family; $button_font_weight = $button_style->font_weight; echo ''; } } echo 'Content for Main Options tab.
Content for Dashboard Options tab.
Place saved successfully.
Place deleted successfully.
| Place | Comments | Actions |
|---|---|---|
| {$place->place} | {$place->comments} | Edit Delete |
Speaker saved successfully.
Speaker deleted successfully.
| Research Degree | Full Name | Institution | Actions | |
|---|---|---|---|---|
| {$speaker->research_degree} | {$speaker->full_name} | {$speaker->email} | {$speaker->institution} | Edit Delete |
Event Name saved successfully.
Event Name deleted successfully.
| Acronym | Name | Responsible For | Actions |
|---|---|---|---|
| {$major_event->acronym} | {$major_event->name} | {$major_event->responsible_for} | Edit Delete |
Display options saved successfully.
Button styles saved successfully.
Status styles saved successfully.
Notice saved successfully.
| Type | Notice |
|---|---|
| {$notice->type} | {$notice->notice} |
Content for Email Options tab.
Meta Key status saved successfully.
Meta Key deleted successfully.
| Meta Key | Status | Action |
|---|---|---|
| ' . esc_html($meta_key) . ' | ' . ($data->status ? 'Enabled' : 'Disabled') . ' |
You need to be logged in to view the registrations that have been made.
'; } // Check if the user has administrator or contributor role if (!current_user_can('administrator') && !current_user_can('contributor')) { return 'You do not have the required permissions to handle the attendance control.
'; } global $wpdb; $current_user = wp_get_current_user(); $user_id = $current_user->ID; // Define the additional meta keys $additional_meta_keys = [ 'forca', 'full_name', 'posto', 'militar', 'instituição', 'nacionalidade', 'efetivo_dcta', 'cidade', 'estado', 'areaatividadeprincipal', 'setordeatuacao', 'cargofuncao', 'ehativa', 'circulo_hierárquico', 'pais', 'formacao_academica', 'regiao_do_brasil' ]; // Handle saving additional features selection if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['additional_features'])) { $selected_meta_keys = array_intersect($additional_meta_keys, $_POST['additional_features']); update_user_meta($user_id, 'selected_additional_features_frontend', $selected_meta_keys); // Redirect to avoid resubmission wp_safe_redirect(add_query_arg([], wp_get_referer())); exit; } else { $selected_meta_keys = get_user_meta($user_id, 'selected_additional_features_frontend', true); if (!$selected_meta_keys) { $selected_meta_keys = []; } } // Handle form submission for updating enrollment status if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['apply_status']) && isset($_POST['selected_enrollments'])) { $new_status = sanitize_text_field($_POST['new_status']); $selected_enrollments = array_map('intval', $_POST['selected_enrollments']); if (!empty($selected_enrollments)) { foreach ($selected_enrollments as $enrollment_id) { $wpdb->update( "{$wpdb->prefix}sige_enrollments", ['status' => $new_status], ['id' => $enrollment_id] ); } // Redirect to the same page to clear POST data wp_safe_redirect(add_query_arg([], wp_get_referer())); exit; } else { echo 'Please select at least one enrollment.
| Activity Name | User ID | User Full Name | Enrollment Date | Status | Attended | Action | |
|---|---|---|---|---|---|---|---|
| ' . esc_html($enrollment->activity_name) . ' | ' . esc_html($enrollment->user_id) . ' | ' . esc_html($enrollment->user_full_name) . ' | ' . esc_html($enrollment->user_email) . ' | ' . esc_html($enrollment->enrollment_date) . ' | ' . esc_html($enrollment->status) . ' | ' . esc_html($enrollment->attended) . ' | |
| No approved enrollments found. | |||||||
You must be logged in to handle the attendance control.
'; } // Check if the user has administrator or contributor role if (!current_user_can('administrator') && !current_user_can('contributor')) { return 'You do not have the required permissions to handle the attendance control.
'; } // Handle form submission to update attendance if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update_attendance'])) { $enrollment_id = isset($_POST['enrollment_id']) ? intval($_POST['enrollment_id']) : 0; $attended = isset($_POST['attended']) ? sanitize_text_field($_POST['attended']) : ''; $user_id = isset($_POST['user_id']) ? intval($_POST['user_id']) : 0; if ($enrollment_id && $attended) { global $wpdb; $existing_record = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->prefix}sige_enrollment_attendance_control WHERE enrollment_id = %d", $enrollment_id)); if ($existing_record) { $wpdb->update( "{$wpdb->prefix}sige_enrollment_attendance_control", ['attended' => $attended], ['id' => $existing_record] ); } else { $wpdb->insert( "{$wpdb->prefix}sige_enrollment_attendance_control", [ 'enrollment_id' => $enrollment_id, 'attended' => $attended ] ); } } } // Handle QR code verification if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['qr_scanner_used']) && $_POST['qr_scanner_used'] == '1') { $hashed_user_id = sanitize_text_field($_POST['filtered_user_id']); $filtered_user_id = verifyUserBasedOnQRCode($hashed_user_id); } else { $filtered_user_id = isset($_POST['filtered_user_id']) ? intval($_POST['filtered_user_id']) : ''; } } else { $filtered_user_id = ''; } // Fetch enrollments with status "Approved" global $wpdb; $query = " SELECT e.id as enrollment_id, e.activity_id, a.name as activity_name, e.user_id, um1.meta_value as full_name, u.user_email, e.enrollment_date, e.status, ac.attended FROM {$wpdb->prefix}sige_enrollments e LEFT JOIN {$wpdb->prefix}sige_activities a ON e.activity_id = a.id LEFT JOIN {$wpdb->prefix}usermeta um1 ON e.user_id = um1.user_id AND um1.meta_key = 'full_name' LEFT JOIN {$wpdb->prefix}users u ON e.user_id = u.ID LEFT JOIN {$wpdb->prefix}sige_enrollment_attendance_control ac ON e.id = ac.enrollment_id WHERE e.status = 'Approved' "; if ($filtered_user_id) { $query .= $wpdb->prepare(" AND e.user_id = %d", $filtered_user_id); } $enrollments = $wpdb->get_results($query); ?>| Activity Name | User ID | User Full Name | Enrollment Date | Status | Attended | Action | |
|---|---|---|---|---|---|---|---|
| activity_name); ?> | user_id); ?> | full_name); ?> | user_email); ?> | enrollment_date); ?> | status); ?> | attended); ?> | |
| No approved enrollments found. | |||||||
Dear ,
SIGE is an open event promoted by the Technological Institute of Aeronautics with the aim of creating an environment for the exchange of experiences between the academic, industrial and operational sectors of the Armed Forces, on issues of teaching, research and development in Defense areas.
The organizing team is made up of master’s and doctoral students from the Graduate Program in Operational Applications (PPGAO) at ITA.
No activities available for this year.
Contact the event Organizing Committee for questions via email at sige@ita.br
Dear ' . esc_html($full_name) . ',
'; $html_content .= 'SIGE is an open event promoted by the Technological Institute of Aeronautics with the aim of creating an environment for the exchange of experiences between the academic, industrial and operational sectors of the Armed Forces, on issues of teaching, research and development in Defense areas.
'; $html_content .= 'The organizing team is made up of master’s and doctoral students from the Graduate Program in Operational Applications (PPGAO) at ITA.
'; $html_content .= ''; // Add
to separate content } } else { $html_content .= '
No activities available for this year.
'; } $html_content .= 'Contact the event Organizing Committee for questions via email at sige@ita.br
'; $html_content .= 'Generated on: ' . date('d-m-Y - H:i:s') . '
'; $html_content .= '