File: /var/www/test.kaunokolegija.lt/kk_wp_content/plugins/events/admin/submissions.php
<?php
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
global $wpdb;
// Handle status updates
if (isset($_GET['action']) && isset($_GET['submission_id'])) {
$submission_id = intval($_GET['submission_id']);
$action = sanitize_text_field($_GET['action']);
if (wp_verify_nonce($_GET['_wpnonce'], 'update_submission_' . $submission_id)) {
$submissions_table = $wpdb->base_prefix . 'kauno_event_submissions';
if ($action === 'mark_read') {
$wpdb->update($submissions_table, array('status' => 'read'), array('id' => $submission_id));
$success_message = __('Submission marked as read.', 'kauno-events');
} elseif ($action === 'mark_unread') {
$wpdb->update($submissions_table, array('status' => 'new'), array('id' => $submission_id));
$success_message = __('Submission marked as unread.', 'kauno-events');
} elseif ($action === 'delete') {
$wpdb->delete($submissions_table, array('id' => $submission_id));
$success_message = __('Submission deleted successfully.', 'kauno-events');
}
}
}
// Handle filters
$filter_status = isset($_GET['filter_status']) ? sanitize_text_field($_GET['filter_status']) : '';
$filter_event = isset($_GET['filter_event']) ? intval($_GET['filter_event']) : '';
$filter_date_from = isset($_GET['filter_date_from']) ? sanitize_text_field($_GET['filter_date_from']) : '';
$filter_date_to = isset($_GET['filter_date_to']) ? sanitize_text_field($_GET['filter_date_to']) : '';
$search_query = isset($_GET['search']) ? sanitize_text_field($_GET['search']) : '';
// Get submissions for current site with filters
$site_id = get_current_blog_id();
$submissions_table = $wpdb->base_prefix . 'kauno_event_submissions';
$events_table = $wpdb->base_prefix . 'kauno_events';
$where_conditions = array("s.site_id = %d");
$query_params = array($site_id);
// Apply filters
if (!empty($filter_status)) {
$where_conditions[] = "s.status = %s";
$query_params[] = $filter_status;
}
if (!empty($filter_event)) {
$where_conditions[] = "s.event_id = %d";
$query_params[] = $filter_event;
}
if (!empty($filter_date_from)) {
$where_conditions[] = "DATE(s.submitted_at) >= %s";
$query_params[] = $filter_date_from;
}
if (!empty($filter_date_to)) {
$where_conditions[] = "DATE(s.submitted_at) <= %s";
$query_params[] = $filter_date_to;
}
if (!empty($search_query)) {
$where_conditions[] = "(s.name LIKE %s OR s.email LIKE %s OR s.phone LIKE %s OR s.message LIKE %s OR e.title LIKE %s)";
$search_term = '%' . $wpdb->esc_like($search_query) . '%';
$query_params[] = $search_term;
$query_params[] = $search_term;
$query_params[] = $search_term;
$query_params[] = $search_term;
$query_params[] = $search_term;
}
$where_clause = implode(' AND ', $where_conditions);
$submissions = $wpdb->get_results($wpdb->prepare("
SELECT s.*, e.title as event_title, e.event_date
FROM $submissions_table s
LEFT JOIN $events_table e ON s.event_id = e.id
WHERE $where_clause
ORDER BY s.submitted_at DESC
", $query_params));
// Get all events for the filter dropdown
$all_events = $wpdb->get_results($wpdb->prepare("
SELECT id, title
FROM $events_table
WHERE site_id = %d
ORDER BY title ASC
", $site_id));
$total_submissions = count($submissions);
$new_submissions = count(array_filter($submissions, function($sub) {
return $sub->status === 'new';
}));
$read_submissions = $total_submissions - $new_submissions;
?>
<style>
.kauno-submissions-admin {
background: #f8fafc;
margin: 0 -20px;
padding: 0;
min-height: 100vh;
}
.submissions-header {
background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
color: white;
padding: 2rem 2rem 1.5rem;
margin-bottom: 2rem;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.header-content {
max-width: 1400px;
margin: 0 auto;
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 2rem;
}
.header-left h1 {
font-size: 2rem;
font-weight: 700;
margin: 0 0 0.5rem 0;
display: flex;
align-items: center;
gap: 0.75rem;
}
.header-subtitle {
font-size: 0.875rem;
opacity: 0.8;
font-weight: 500;
}
.header-actions {
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
.btn {
display: inline-flex;
align-items: center;
gap: 0.5rem;
padding: 0.75rem 1.5rem;
border-radius: 8px;
font-weight: 600;
text-decoration: none;
border: none;
cursor: pointer;
transition: all 0.2s;
font-size: 0.875rem;
line-height: 1;
}
.btn-secondary {
background: rgba(255, 255, 255, 0.2);
color: white;
border: 1px solid rgba(255, 255, 255, 0.3);
}
.btn-secondary:hover {
background: rgba(255, 255, 255, 0.3);
color: white;
}
.submissions-content {
max-width: 1400px;
margin: 0 auto;
padding: 0 2rem;
}
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 1.5rem;
margin-bottom: 2rem;
}
.stat-card {
background: white;
border-radius: 12px;
padding: 1.5rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
border: 1px solid #e2e8f0;
transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.stat-header {
display: flex;
align-items: center;
gap: 0.75rem;
margin-bottom: 1rem;
}
.stat-icon {
width: 40px;
height: 40px;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.25rem;
}
.stat-icon.total {
background: #dbeafe;
color: #1d4ed8;
}
.stat-icon.new {
background: #fef3c7;
color: #d97706;
}
.stat-icon.read {
background: #dcfce7;
color: #16a34a;
}
.stat-title {
font-size: 0.875rem;
font-weight: 600;
color: #64748b;
margin: 0;
}
.stat-number {
font-size: 2rem;
font-weight: 700;
color: #1e293b;
margin: 0;
}
.submissions-table-card {
background: white;
border-radius: 12px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
border: 1px solid #e2e8f0;
overflow: hidden;
}
.table-header {
background: #f8fafc;
padding: 1.5rem 2rem;
border-bottom: 1px solid #e2e8f0;
display: flex;
justify-content: space-between;
align-items: center;
}
.table-title {
font-size: 1.25rem;
font-weight: 700;
margin: 0;
color: #1e293b;
}
.table-filters {
display: flex;
gap: 1rem;
align-items: center;
}
.filter-select {
padding: 0.5rem 1rem;
border: 1px solid #d1d5db;
border-radius: 6px;
font-size: 0.875rem;
background: white;
}
.submissions-table {
width: 100%;
border-collapse: collapse;
}
.submissions-table th {
background: #f8fafc;
padding: 1rem 1.5rem;
text-align: left;
font-weight: 600;
color: #374151;
font-size: 0.875rem;
border-bottom: 1px solid #e2e8f0;
}
.submissions-table td {
padding: 1rem 1.5rem;
border-bottom: 1px solid #f1f5f9;
vertical-align: top;
}
.submission-row {
transition: background-color 0.2s;
}
.submission-row:hover {
background: #f8fafc;
}
.submission-row.new-submission {
background: #fefce8;
border-left: 4px solid #eab308;
}
.submission-row.new-submission:hover {
background: #fef3c7;
}
.event-info {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.event-title {
font-weight: 600;
color: #1e293b;
margin: 0;
}
.event-date {
font-size: 0.75rem;
color: #64748b;
}
.participant-info {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.participant-name {
font-weight: 600;
color: #1e293b;
}
.participant-details {
font-size: 0.875rem;
color: #64748b;
}
.contact-link {
color: #0d9488;
text-decoration: none;
font-weight: 500;
}
.contact-link:hover {
text-decoration: underline;
}
.status-badge {
display: inline-block;
padding: 0.25rem 0.75rem;
border-radius: 9999px;
font-size: 0.75rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.025em;
}
.status-new {
background: #fef3c7;
color: #92400e;
}
.status-read {
background: #dcfce7;
color: #166534;
}
.actions-group {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
.btn-small {
padding: 0.375rem 0.75rem;
font-size: 0.75rem;
border-radius: 6px;
font-weight: 500;
text-decoration: none;
border: none;
cursor: pointer;
transition: all 0.2s;
}
.btn-view {
background: #dbeafe;
color: #1d4ed8;
}
.btn-view:hover {
background: #bfdbfe;
}
.btn-mark-read {
background: #dcfce7;
color: #166534;
}
.btn-mark-read:hover {
background: #bbf7d0;
}
.btn-mark-unread {
background: #fef3c7;
color: #92400e;
}
.btn-mark-unread:hover {
background: #fde68a;
}
.btn-delete {
background: #fecaca;
color: #dc2626;
}
.btn-delete:hover {
background: #fca5a5;
}
.no-submissions {
text-align: center;
padding: 3rem 2rem;
color: #64748b;
}
.no-submissions-icon {
font-size: 3rem;
margin-bottom: 1rem;
opacity: 0.5;
}
.empty-state-text {
font-size: 1.125rem;
font-weight: 600;
margin-bottom: 0.5rem;
}
.empty-state-subtitle {
color: #9ca3af;
}
.notice-success {
background: #dcfce7;
color: #166534;
padding: 1rem 1.5rem;
border-radius: 8px;
border: 1px solid #bbf7d0;
margin-bottom: 1.5rem;
display: flex;
align-items: center;
gap: 0.75rem;
}
/* Modal Styles */
.modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
z-index: 10000;
display: flex;
align-items: center;
justify-content: center;
padding: 2rem;
}
.modal-content {
background: white;
border-radius: 12px;
max-width: 500px;
width: 100%;
max-height: 80vh;
overflow-y: auto;
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}
.modal-header {
background: #f8fafc;
padding: 1.5rem 2rem;
border-bottom: 1px solid #e2e8f0;
display: flex;
justify-content: space-between;
align-items: center;
border-radius: 12px 12px 0 0;
}
.modal-header h3 {
margin: 0;
font-size: 1.25rem;
font-weight: 700;
color: #1e293b;
}
.modal-close {
background: none;
border: none;
font-size: 1.5rem;
cursor: pointer;
color: #64748b;
padding: 0;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 6px;
transition: all 0.2s;
}
.modal-close:hover {
background: #f1f5f9;
color: #374151;
}
.modal-body {
padding: 2rem;
}
.message-content {
background: #f8fafc;
padding: 1.5rem;
border-radius: 8px;
border: 1px solid #e2e8f0;
font-size: 0.875rem;
line-height: 1.6;
color: #374151;
white-space: pre-wrap;
}
/* Responsive */
@media (max-width: 1200px) {
.header-content {
flex-direction: column;
gap: 1rem;
}
.header-actions {
width: 100%;
justify-content: flex-start;
}
}
@media (max-width: 768px) {
.submissions-header {
padding: 1.5rem 1rem 1rem;
}
.submissions-content {
padding: 0 1rem;
}
.stats-grid {
grid-template-columns: 1fr;
gap: 1rem;
}
.table-header {
padding: 1rem;
flex-direction: column;
gap: 1rem;
align-items: flex-start;
}
.submissions-table th,
.submissions-table td {
padding: 0.75rem 1rem;
}
.actions-group {
flex-direction: column;
}
.modal {
padding: 1rem;
}
.modal-header {
padding: 1rem 1.5rem;
}
.modal-body {
padding: 1.5rem;
}
}
/* Filters */
.filters-card {
background: white;
border-radius: 12px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
border: 1px solid #e2e8f0;
margin-bottom: 1.5rem;
overflow: hidden;
}
.filters-header {
background: #f8fafc;
padding: 1rem 1.5rem;
border-bottom: 1px solid #e2e8f0;
display: flex;
justify-content: space-between;
align-items: center;
}
.filters-header h3 {
margin: 0;
color: #374151;
font-size: 1rem;
font-weight: 600;
}
.btn-clear-filters {
background: #fecaca;
color: #dc2626;
border: none;
padding: 0.5rem 1rem;
border-radius: 6px;
font-size: 0.875rem;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
}
.btn-clear-filters:hover {
background: #fca5a5;
}
.filters-form {
padding: 1.5rem;
}
.filters-row {
display: flex;
gap: 1rem;
margin-bottom: 1rem;
align-items: end;
}
.filters-row:last-child {
margin-bottom: 0;
}
.filter-group-submission {
display: flex
;
flex-direction: column;
gap: 0.5rem;
box-sizing: border-box;
position: relative;
float: left;
margin: 0 1% 0 0;
padding: 20px 10px 10px;
width: 24%;
background: #fff;
box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
}
.filter-group-submission.filter-actions {
justify-content: flex-end;
}
.filter-group-submission label {
font-size: 0.875rem;
font-weight: 500;
color: #374151;
margin-bottom: 0.25rem;
}
.filter-input,
.filter-select {
padding: 0.75rem;
border: 1px solid #d1d5db;
border-radius: 6px;
font-size: 0.875rem;
transition: all 0.2s;
background: white;
}
.filter-input:focus,
.filter-select:focus {
outline: none;
border-color: #0d9488;
box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}
.filter-input::placeholder {
color: #9ca3af;
}
.btn-filter {
background: #0d9488;
color: white;
border: none;
padding: 0.75rem 1.5rem;
border-radius: 6px;
font-weight: 600;
cursor: pointer;
transition: all 0.2s;
}
.btn-filter:hover {
background: #0f766e;
transform: translateY(-1px);
}
.table-meta {
display: flex;
align-items: center;
gap: 1rem;
}
.results-count {
font-size: 0.875rem;
color: #64748b;
font-weight: 500;
}
@media (max-width: 768px) {
.filters-row {
display: flex;
flex-direction: column;
gap: 1rem;
}
}
@media (max-width: 480px) {
.submissions-table {
font-size: 0.875rem;
}
.btn-small {
padding: 0.25rem 0.5rem;
font-size: 0.6875rem;
}
.filters-form {
padding: 1rem;
}
}
</style>
<div class="wrap kauno-submissions-admin">
<!-- Header -->
<div class="submissions-header">
<div class="header-content">
<div class="header-left">
<h1>
<span>📋</span>
<?php _e('Event Submissions', 'kauno-events'); ?>
</h1>
<div class="header-subtitle"><?php _e('Manage and review event registration submissions', 'kauno-events'); ?></div>
</div>
<div class="header-actions">
<a href="<?php echo admin_url('admin.php?page=kauno-events'); ?>" class="btn btn-secondary">
← <?php _e('Back to Events', 'kauno-events'); ?>
</a>
</div>
</div>
</div>
<div class="submissions-content">
<!-- Success Message -->
<?php if (isset($success_message)): ?>
<div class="notice-success">
<span>✅</span>
<span><?php echo esc_html($success_message); ?></span>
</div>
<?php endif; ?>
<!-- Stats Grid -->
<div class="stats-grid">
<div class="stat-card">
<div class="stat-header">
<div class="stat-icon total">📊</div>
<div>
<h3 class="stat-title"><?php _e('Total Submissions', 'kauno-events'); ?></h3>
</div>
</div>
<p class="stat-number"><?php echo $total_submissions; ?></p>
</div>
<div class="stat-card">
<div class="stat-header">
<div class="stat-icon new">🔔</div>
<div>
<h3 class="stat-title"><?php _e('New Submissions', 'kauno-events'); ?></h3>
</div>
</div>
<p class="stat-number"><?php echo $new_submissions; ?></p>
</div>
<div class="stat-card">
<div class="stat-header">
<div class="stat-icon read">✅</div>
<div>
<h3 class="stat-title"><?php _e('Read Submissions', 'kauno-events'); ?></h3>
</div>
</div>
<p class="stat-number"><?php echo $read_submissions; ?></p>
</div>
</div>
<!-- Filters -->
<div class="filters-card">
<div class="filters-header">
<h3><?php _e('Filter Submissions', 'kauno-events'); ?></h3>
<button type="button" id="clearFilters" class="btn-clear-filters"><?php _e('Clear All', 'kauno-events'); ?></button>
</div>
<form method="GET" class="filters-form" id="filtersForm">
<input type="hidden" name="page" value="kauno-events-submissions">
<div class="filters-row">
<div class="filter-group-submission">
<label for="search"><?php _e('Search', 'kauno-events'); ?></label>
<input type="text"
name="search"
id="search"
value="<?php echo esc_attr($search_query); ?>"
placeholder="<?php _e('Search by name, email, phone, message or event...', 'kauno-events'); ?>"
class="filter-input">
</div>
<div class="filter-group-submission">
<label for="filter_status"><?php _e('Status', 'kauno-events'); ?></label>
<select name="filter_status" id="filter_status" class="filter-select">
<option value=""><?php _e('All Status', 'kauno-events'); ?></option>
<option value="new" <?php selected($filter_status, 'new'); ?>><?php _e('New', 'kauno-events'); ?></option>
<option value="read" <?php selected($filter_status, 'read'); ?>><?php _e('Read', 'kauno-events'); ?></option>
</select>
</div>
<div class="filter-group-submission">
<label for="filter_event"><?php _e('Event', 'kauno-events'); ?></label>
<select name="filter_event" id="filter_event" class="filter-select">
<option value=""><?php _e('All Events', 'kauno-events'); ?></option>
<?php foreach ($all_events as $event): ?>
<option value="<?php echo $event->id; ?>" <?php selected($filter_event, $event->id); ?>>
<?php echo esc_html($event->title); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="filter-group-submission">
<label for="filter_date_from"><?php _e('Submitted From', 'kauno-events'); ?></label>
<input type="date"
name="filter_date_from"
id="filter_date_from"
value="<?php echo esc_attr($filter_date_from); ?>"
class="filter-input">
</div>
<div class="filter-group-submission">
<label for="filter_date_to"><?php _e('Submitted To', 'kauno-events'); ?></label>
<input type="date"
name="filter_date_to"
id="filter_date_to"
value="<?php echo esc_attr($filter_date_to); ?>"
class="filter-input">
</div>
<div class="filter-group-submission filter-actions">
<button type="submit" class="btn-filter"><?php _e('Apply Filters', 'kauno-events'); ?></button>
</div>
</div>
</form>
</div>
<!-- Submissions Table -->
<div class="submissions-table-card">
<div class="table-header">
<h2 class="table-title"><?php _e('All Submissions', 'kauno-events'); ?></h2>
<div class="table-meta">
<?php if ($search_query || $filter_status || $filter_event || $filter_date_from || $filter_date_to): ?>
<span class="results-count"><?php printf(__('%d submissions found', 'kauno-events'), count($submissions)); ?></span>
<?php endif; ?>
</div>
</div>
<div class="table-container">
<table class="submissions-table">
<thead>
<tr>
<th><?php _e('Event', 'kauno-events'); ?></th>
<th><?php _e('Participant', 'kauno-events'); ?></th>
<th><?php _e('Contact', 'kauno-events'); ?></th>
<th><?php _e('Submitted', 'kauno-events'); ?></th>
<th><?php _e('Status', 'kauno-events'); ?></th>
<th><?php _e('Actions', 'kauno-events'); ?></th>
</tr>
</thead>
<tbody>
<?php if (empty($submissions)): ?>
<tr>
<td colspan="6" class="no-submissions">
<div class="no-submissions-icon">📝</div>
<div class="empty-state-text"><?php _e('No submissions yet', 'kauno-events'); ?></div>
<div class="empty-state-subtitle"><?php _e('Event registrations will appear here when people sign up', 'kauno-events'); ?></div>
</td>
</tr>
<?php else: ?>
<?php foreach ($submissions as $submission): ?>
<tr class="submission-row <?php echo $submission->status === 'new' ? 'new-submission' : ''; ?>" data-status="<?php echo $submission->status; ?>">
<td>
<div class="event-info">
<div class="event-title"><?php echo esc_html($submission->event_title ?: 'Event Deleted'); ?></div>
<?php if ($submission->event_date): ?>
<div class="event-date"><?php echo date('M j, Y \a\t H:i', strtotime($submission->event_date)); ?></div>
<?php endif; ?>
</div>
</td>
<td>
<div class="participant-info">
<div class="participant-name"><?php echo esc_html($submission->name); ?></div>
<?php if ($submission->participants > 1): ?>
<div class="participant-details"><?php echo $submission->participants; ?> <?php _e('participants', 'kauno-events'); ?></div>
<?php endif; ?>
</div>
</td>
<td>
<div class="participant-info">
<a href="mailto:<?php echo esc_attr($submission->email); ?>" class="contact-link">
<?php echo esc_html($submission->email); ?>
</a>
<?php if ($submission->phone): ?>
<a href="tel:<?php echo esc_attr($submission->phone); ?>" class="contact-link">
<?php echo esc_html($submission->phone); ?>
</a>
<?php endif; ?>
</div>
</td>
<td>
<div class="participant-details">
<?php echo date('M j, Y', strtotime($submission->submitted_at)); ?><br>
<small><?php echo date('H:i', strtotime($submission->submitted_at)); ?></small>
</div>
</td>
<td>
<span class="status-badge status-<?php echo $submission->status; ?>">
<?php echo ucfirst($submission->status); ?>
</span>
</td>
<td>
<div class="actions-group">
<button class="btn-small btn-view view-message" data-message="<?php echo esc_attr($submission->message); ?>">
👁 <?php _e('View', 'kauno-events'); ?>
</button>
<?php if ($submission->status === 'new'): ?>
<a href="<?php echo wp_nonce_url(admin_url('admin.php?page=kauno-events-submissions&action=mark_read&submission_id=' . $submission->id), 'update_submission_' . $submission->id); ?>"
class="btn-small btn-mark-read">✓ <?php _e('Read', 'kauno-events'); ?></a>
<?php else: ?>
<a href="<?php echo wp_nonce_url(admin_url('admin.php?page=kauno-events-submissions&action=mark_unread&submission_id=' . $submission->id), 'update_submission_' . $submission->id); ?>"
class="btn-small btn-mark-unread">↻ <?php _e('Unread', 'kauno-events'); ?></a>
<?php endif; ?>
<a href="<?php echo wp_nonce_url(admin_url('admin.php?page=kauno-events-submissions&action=delete&submission_id=' . $submission->id), 'update_submission_' . $submission->id); ?>"
class="btn-small btn-delete"
onclick="return confirm('<?php _e('Are you sure you want to delete this submission?', 'kauno-events'); ?>')">🗑 <?php _e('Delete', 'kauno-events'); ?></a>
</div>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Message Modal -->
<div id="message-modal" class="modal" style="display: none;">
<div class="modal-content">
<div class="modal-header">
<h3><?php _e('Submission Message', 'kauno-events'); ?></h3>
<button class="modal-close" onclick="closeModal()">×</button>
</div>
<div class="modal-body">
<div class="message-content" id="modal-message"></div>
</div>
</div>
</div>
<script>
jQuery(document).ready(function($) {
// View message functionality
$('.view-message').click(function() {
var message = $(this).data('message');
$('#modal-message').text(message || '<?php _e('No message provided.', 'kauno-events'); ?>');
$('#message-modal').show();
});
// Clear filters functionality
$('#clearFilters').click(function() {
// Clear all form inputs
$('#filtersForm')[0].reset();
// Submit the form to refresh page without filters
var form = $('#filtersForm');
var url = form.attr('action') || window.location.pathname;
var hiddenInput = form.find('input[name="page"]').val();
// Navigate to clean URL
window.location.href = url + '?page=' + hiddenInput;
});
// Auto-submit on filter change for better UX (optional)
$('.filter-select').change(function() {
if ($(this).val() !== '') {
$('#filtersForm').submit();
}
});
// Enter key support for search
$('#search').keypress(function(e) {
if (e.which === 13) {
$('#filtersForm').submit();
}
});
});
function closeModal() {
document.getElementById('message-modal').style.display = 'none';
}
// Close modal when clicking outside
window.onclick = function(event) {
var modal = document.getElementById('message-modal');
if (event.target === modal) {
modal.style.display = 'none';
}
}
</script>