Add rating
This commit is contained in:
@@ -15,7 +15,7 @@ header('Content-Type: text/csv; charset=utf-8');
|
|||||||
header('Content-Disposition: attachment; filename="go-form-' . sanitize_title($form_name) . '-export.csv"');
|
header('Content-Disposition: attachment; filename="go-form-' . sanitize_title($form_name) . '-export.csv"');
|
||||||
|
|
||||||
$output = fopen('php://output', 'w');
|
$output = fopen('php://output', 'w');
|
||||||
fputcsv($output, ['ID', 'First Name', 'Last Name', 'Country', 'Club', 'Rank', 'Email', 'EGD Number', 'Comment', 'Date Added']);
|
fputcsv($output, ['ID', 'First Name', 'Last Name', 'Country', 'Club', 'Rank', 'Rating', 'Email', 'EGD Number', 'Comment', 'Date Added']);
|
||||||
|
|
||||||
foreach ($entries as $e) {
|
foreach ($entries as $e) {
|
||||||
global $ranks;
|
global $ranks;
|
||||||
@@ -26,6 +26,7 @@ foreach ($entries as $e) {
|
|||||||
$e->country,
|
$e->country,
|
||||||
$e->club,
|
$e->club,
|
||||||
$ranks[$e->rank] ?? '',
|
$ranks[$e->rank] ?? '',
|
||||||
|
$e->rating,
|
||||||
$e->email,
|
$e->email,
|
||||||
$e->egd_number,
|
$e->egd_number,
|
||||||
$e->comment,
|
$e->comment,
|
||||||
|
|||||||
@@ -33,8 +33,9 @@ function go_form_activate()
|
|||||||
country varchar(100) DEFAULT NULL,
|
country varchar(100) DEFAULT NULL,
|
||||||
club varchar(100) DEFAULT NULL,
|
club varchar(100) DEFAULT NULL,
|
||||||
rank tinyint(2) DEFAULT 0,
|
rank tinyint(2) DEFAULT 0,
|
||||||
|
rating smallint(5) DEFAULT 0,
|
||||||
email varchar(255) DEFAULT NULL,
|
email varchar(255) DEFAULT NULL,
|
||||||
egd_number varchar(50) DEFAULT NULL,
|
egd_number varchar(20) DEFAULT NULL,
|
||||||
comment text DEFAULT NULL,
|
comment text DEFAULT NULL,
|
||||||
created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
@@ -55,8 +56,8 @@ function go_form_uninstall()
|
|||||||
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_entries");
|
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_entries");
|
||||||
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_forms");
|
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_forms");
|
||||||
}
|
}
|
||||||
register_uninstall_hook(__FILE__, 'go_form_uninstall');
|
//register_uninstall_hook(__FILE__, 'go_form_uninstall');
|
||||||
|
register_deactivation_hook(__FILE__, 'go_form_uninstall');
|
||||||
// ========== Helpers ==========
|
// ========== Helpers ==========
|
||||||
$ranks = [
|
$ranks = [
|
||||||
0 => '30k', 1 => '29k', 2 => '28k', 3 => '27k', 4 => '26k',
|
0 => '30k', 1 => '29k', 2 => '28k', 3 => '27k', 4 => '26k',
|
||||||
@@ -117,13 +118,20 @@ function go_form_handle_submission()
|
|||||||
$form_id = 1; // Fallback to default form
|
$form_id = 1; // Fallback to default form
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$rating = intval($_POST['rating']);
|
||||||
|
$rank = intval($_POST['rank']);
|
||||||
|
if($rating < -900) {
|
||||||
|
$rating = ($rank * 100) - 900;
|
||||||
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'form_id' => $form_id,
|
'form_id' => $form_id,
|
||||||
'first_name' => sanitize_text_field($_POST['first_name']),
|
'first_name' => sanitize_text_field($_POST['first_name']),
|
||||||
'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'] ?? ''),
|
||||||
'rank' => intval($_POST['rank']),
|
'rank' => $rank,
|
||||||
|
'rating' => $rating,
|
||||||
'email' => sanitize_email($_POST['email'] ?? ''),
|
'email' => sanitize_email($_POST['email'] ?? ''),
|
||||||
'egd_number' => sanitize_text_field($_POST['egd_number'] ?? ''),
|
'egd_number' => sanitize_text_field($_POST['egd_number'] ?? ''),
|
||||||
'comment' => sanitize_textarea_field($_POST['comment'] ?? '')
|
'comment' => sanitize_textarea_field($_POST['comment'] ?? '')
|
||||||
@@ -133,10 +141,6 @@ function go_form_handle_submission()
|
|||||||
wp_redirect($_SERVER['HTTP_REFERER']);
|
wp_redirect($_SERVER['HTTP_REFERER']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if ($data['rank'] < 0 || $data['rank'] > 47) {
|
|
||||||
wp_redirect($_SERVER['HTTP_REFERER']);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$wpdb->insert("{$wpdb->prefix}go_form_entries", $data);
|
$wpdb->insert("{$wpdb->prefix}go_form_entries", $data);
|
||||||
wp_redirect($_SERVER['HTTP_REFERER']);
|
wp_redirect($_SERVER['HTTP_REFERER']);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
<?php echo wp_nonce_field('go_form_action', 'go_form_nonce', true, false); ?>
|
<?php echo wp_nonce_field('go_form_action', 'go_form_nonce', true, false); ?>
|
||||||
<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">
|
||||||
<div class="go-form-grid">
|
<div class="go-form-grid">
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@@ -184,6 +184,7 @@
|
|||||||
document.getElementById('club').value = player.Club || '';
|
document.getElementById('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;
|
||||||
closePopup();
|
closePopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
<th>Rank</th>
|
<th>Rank</th>
|
||||||
<th>EGD Number</th>
|
<th>EGD Number</th>
|
||||||
<?php if ($show_admin): ?>
|
<?php if ($show_admin): ?>
|
||||||
|
<th>Rating</th>
|
||||||
<th>Email</th>
|
<th>Email</th>
|
||||||
<th>Date Added</th>
|
<th>Date Added</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
@@ -29,6 +30,7 @@
|
|||||||
|
|
||||||
<?php if ($show_admin): ?>
|
<?php if ($show_admin): ?>
|
||||||
|
|
||||||
|
<td> <?= esc_html($e->rating) ?> </td>
|
||||||
<td> <?= esc_html($e->email) ?> </td>
|
<td> <?= esc_html($e->email) ?> </td>
|
||||||
<td> <?= esc_html($e->created_at) ?> </td>
|
<td> <?= esc_html($e->created_at) ?> </td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
Reference in New Issue
Block a user