Added display contry and club

This commit is contained in:
2026-08-01 21:10:36 +02:00
parent 17998dc7b2
commit 2139a31e7c
5 changed files with 40 additions and 12 deletions
+2
View File
@@ -15,6 +15,8 @@ CREATE TABLE wp_go_form_entries (
last_name varchar(100) NOT NULL, last_name varchar(100) NOT NULL,
country varchar(100) DEFAULT NULL, country varchar(100) DEFAULT NULL,
club varchar(100) DEFAULT NULL, club varchar(100) DEFAULT NULL,
display_country varchar(150) DEFAULT NULL,
display_club varchar(100) DEFAULT NULL,
rank tinyint(2) DEFAULT 0, rank tinyint(2) DEFAULT 0,
rating smallint(5) DEFAULT 0, rating smallint(5) DEFAULT 0,
egd_number varchar(20) DEFAULT NULL, egd_number varchar(20) DEFAULT NULL,
+8 -1
View File
@@ -5,6 +5,7 @@ if (!defined('ABSPATH'))
// Load helpers // Load helpers
require_once plugin_dir_path(__FILE__) . 'helpers.php'; require_once plugin_dir_path(__FILE__) . 'helpers.php';
require_once plugin_dir_path(__FILE__) . 'countries.php';
// ========== Database =========== // ========== Database ===========
function go_form_activate() function go_form_activate()
@@ -32,6 +33,8 @@ function go_form_activate()
last_name varchar(100) NOT NULL, last_name varchar(100) NOT NULL,
country varchar(100) DEFAULT NULL, country varchar(100) DEFAULT NULL,
club varchar(100) DEFAULT NULL, club varchar(100) DEFAULT NULL,
display_country varchar(150) DEFAULT NULL,
display_club varchar(100) DEFAULT NULL,
rank tinyint(2) DEFAULT 0, rank tinyint(2) DEFAULT 0,
rating smallint(5) DEFAULT 0, rating smallint(5) DEFAULT 0,
egd_number varchar(20) DEFAULT NULL, egd_number varchar(20) DEFAULT NULL,
@@ -183,6 +186,8 @@ function go_form_handle_submission()
'last_name' => sanitize_text_field($_POST['last_name']), 'last_name' => sanitize_text_field($_POST['last_name']),
'country' => sanitize_text_field($_POST['country'] ?? ''), 'country' => sanitize_text_field($_POST['country'] ?? ''),
'club' => sanitize_text_field($_POST['club'] ?? ''), 'club' => sanitize_text_field($_POST['club'] ?? ''),
'display_country' => sanitize_text_field($_POST['display_country'] ?? ''),
'display_club' => sanitize_text_field($_POST['display_club'] ?? ''),
'rank' => $rank, 'rank' => $rank,
'rating' => $rating, 'rating' => $rating,
'egd_number' => sanitize_text_field($_POST['egd_number'] ?? ''), 'egd_number' => sanitize_text_field($_POST['egd_number'] ?? ''),
@@ -251,7 +256,7 @@ add_action('admin_post_nopriv_go_form_handle_submission', 'go_form_handle_submis
// ========== Shortcode ========== // ========== Shortcode ==========
function go_form_shortcode($atts) function go_form_shortcode($atts)
{ {
global $ranks; global $ranks, $countries;
$form_id = intval($atts['id']); $form_id = intval($atts['id']);
$form = go_form_get_form_by_id($form_id); $form = go_form_get_form_by_id($form_id);
@@ -542,6 +547,8 @@ function go_form_update_entry()
'last_name' => sanitize_text_field($_POST['last_name']), 'last_name' => sanitize_text_field($_POST['last_name']),
'country' => sanitize_text_field($_POST['country'] ?? ''), 'country' => sanitize_text_field($_POST['country'] ?? ''),
'club' => sanitize_text_field($_POST['club'] ?? ''), 'club' => sanitize_text_field($_POST['club'] ?? ''),
'display_country' => sanitize_text_field($_POST['display_country'] ?? ''),
'display_club' => sanitize_text_field($_POST['display_club'] ?? ''),
'rank' => $rank, 'rank' => $rank,
'rating' => $rating, 'rating' => $rating,
'egd_number' => sanitize_text_field($_POST['egd_number'] ?? ''), 'egd_number' => sanitize_text_field($_POST['egd_number'] ?? ''),
+8 -3
View File
@@ -71,7 +71,9 @@
<input type="hidden" name="action" value="go_form_handle_submission"> <input type="hidden" name="action" value="go_form_handle_submission">
<input type="hidden" name="form_id" value="<?php echo esc_attr($form_id); ?>"> <input type="hidden" name="form_id" value="<?php echo esc_attr($form_id); ?>">
<input type="hidden" name="rating" id="rating" value="-1000"> <input type="hidden" name="rating" id="rating" value="-1000">
<input type="hidden" name="country" id="country">
<input type="hidden" name="club" id="club">
<div class="go-form-user-grid"> <div class="go-form-user-grid">
<div> <div>
@@ -105,11 +107,11 @@
</div> </div>
<div> <div>
<label for="country">Country*:</label><input type="text" name="country" id="country" required> <label for="display_country">Country*:</label><input type="text" name="display_country" id="display_country" required>
</div> </div>
<div> <div>
<label for="club">Club:</label><input type="text" name="club" id="club"> <label for="display_club">Club:</label><input type="text" name="display_club" id="display_club">
</div> </div>
<?php <?php
@@ -218,6 +220,7 @@
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
const contentDiv = document.getElementById('egd-results-content'); const contentDiv = document.getElementById('egd-results-content');
const egdOverlay = document.getElementById('egd-popup-overlay'); const egdOverlay = document.getElementById('egd-popup-overlay');
const countryMap = <?php echo wp_json_encode($countries); ?>;
function fetchPlayers() { function fetchPlayers() {
const firstName = document.getElementById('first_name').value.trim(); const firstName = document.getElementById('first_name').value.trim();
@@ -269,6 +272,8 @@
document.getElementById('last_name').value = player.Last_Name || player.Real_Last_Name || ''; document.getElementById('last_name').value = player.Last_Name || player.Real_Last_Name || '';
document.getElementById('country').value = player.Country_Code || ''; document.getElementById('country').value = player.Country_Code || '';
document.getElementById('club').value = player.Club || ''; document.getElementById('club').value = player.Club || '';
document.getElementById('display_country').value = countryMap[player.Country_Code] || player.Country_Code || '';
document.getElementById('display_club').value = player.Club || '';
document.getElementById('rank').value = player.Grade_n || 0; document.getElementById('rank').value = player.Grade_n || 0;
document.getElementById('egd_number').value = player.Pin_Player || ''; document.getElementById('egd_number').value = player.Pin_Player || '';
document.getElementById('rating').value = player.Gor || 0; document.getElementById('rating').value = player.Gor || 0;
@@ -174,6 +174,8 @@ if (isset($_GET['error']) && $_GET['error'] == 'egd_update_failed')
echo '<tr><th><label for="last_name">Last Name*:</label></th><td><input type="text" name="last_name" id="last_name" value="' . esc_attr($entry->last_name) . '" required></td></tr>'; echo '<tr><th><label for="last_name">Last Name*:</label></th><td><input type="text" name="last_name" id="last_name" value="' . esc_attr($entry->last_name) . '" required></td></tr>';
echo '<tr><th><label for="country">Country:</label></th><td><input type="text" name="country" id="country" value="' . esc_attr($entry->country) . '"></td></tr>'; echo '<tr><th><label for="country">Country:</label></th><td><input type="text" name="country" id="country" value="' . esc_attr($entry->country) . '"></td></tr>';
echo '<tr><th><label for="club">Club:</label></th><td><input type="text" name="club" id="club" value="' . esc_attr($entry->club) . '"></td></tr>'; echo '<tr><th><label for="club">Club:</label></th><td><input type="text" name="club" id="club" value="' . esc_attr($entry->club) . '"></td></tr>';
echo '<tr><th><label for="display_country">Display Country:</label></th><td><input type="text" name="display_country" id="display_country" value="' . esc_attr($entry->display_country) . '"></td></tr>';
echo '<tr><th><label for="display_club">Display Club:</label></th><td><input type="text" name="display_club" id="display_club" value="' . esc_attr($entry->display_club) . '"></td></tr>';
echo '<tr><th><label for="rank">Rank:</label></th><td>'; echo '<tr><th><label for="rank">Rank:</label></th><td>';
echo '<select name="rank" id="rank">'; echo '<select name="rank" id="rank">';
global $ranks; global $ranks;
+20 -8
View File
@@ -6,8 +6,15 @@
<th>First Name</th> <th>First Name</th>
<th>Last Name</th> <th>Last Name</th>
<th>Rank</th> <th>Rank</th>
<?php if ($show_admin): ?>
<th>Rating</th>
<?php endif; ?>
<th>Country</th> <th>Country</th>
<th>Club</th> <th>Club</th>
<?php if ($show_admin): ?>
<th>Country (raw)</th>
<th>Club (raw)</th>
<?php endif; ?>
<th>EGD Number</th> <th>EGD Number</th>
<th>Date Added</th> <th>Date Added</th>
<?php <?php
@@ -17,11 +24,10 @@
echo '<th>' . esc_html($field->field_name) . '</th>'; echo '<th>' . esc_html($field->field_name) . '</th>';
endif; endif;
endforeach; endforeach;
?>
<?php if ($show_admin): ?> if ($show_admin):
<th>Rating</th> echo '<th>Action</th>';
<th>Action</th> endif; ?>
<?php endif; ?>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -33,8 +39,15 @@
<td> <?= esc_html($e->first_name) ?> </td> <td> <?= esc_html($e->first_name) ?> </td>
<td> <?= esc_html($e->last_name) ?> </td> <td> <?= esc_html($e->last_name) ?> </td>
<td> <?= esc_html($ranks[$e->rank]) ?> </td> <td> <?= esc_html($ranks[$e->rank]) ?> </td>
<td> <?= esc_html($e->country) ?> </td> <?php if ($show_admin): ?>
<td> <?= esc_html($e->club) ?> </td> <td> <?= esc_html($e->rating) ?> </td>
<?php endif; ?>
<td> <?= esc_html($e->display_country) ?> </td>
<td> <?= esc_html($e->display_club) ?> </td>
<?php if ($show_admin): ?>
<td> <?= esc_html($e->country) ?> </td>
<td> <?= esc_html($e->club) ?> </td>
<?php endif; ?>
<td><a <td><a
href="<?= esc_url('https://europeangodatabase.eu/EGD/Player_Card.php?&key=' . $e->egd_number) ?>"><?= esc_html($e->egd_number) ?> href="<?= esc_url('https://europeangodatabase.eu/EGD/Player_Card.php?&key=' . $e->egd_number) ?>"><?= esc_html($e->egd_number) ?>
</a> </td> </a> </td>
@@ -57,7 +70,6 @@
<?php if ($show_admin): ?> <?php if ($show_admin): ?>
<td> <?= esc_html($e->rating) ?> </td>
<td style="white-space: nowrap;"> <td style="white-space: nowrap;">
<a href="<?= add_query_arg(array('page' => 'go-form-settings', 'form_id' => $form_id ?? 0, 'edit_entry' => $e->id), admin_url('admin.php')) ?>" <a href="<?= add_query_arg(array('page' => 'go-form-settings', 'form_id' => $form_id ?? 0, 'edit_entry' => $e->id), admin_url('admin.php')) ?>"
class="button" style="margin-right: 4px;">Edit</a> class="button" style="margin-right: 4px;">Edit</a>