Updates
This commit is contained in:
parent
e0f5bbe905
commit
a8688ba4b8
|
|
@ -11,8 +11,13 @@ class CASS_View_Race_Edit
|
|||
$race = new Race;
|
||||
|
||||
|
||||
|
||||
|
||||
//Default state of form
|
||||
$stateForm = "create";
|
||||
$race->setSubscriptionEnable(true);
|
||||
$race->setSubscriptionStart("0001-01-01T00:00:00");
|
||||
$race->setSubscriptionEnd("0001-01-01T00:00:00");
|
||||
|
||||
//Default values tramsitted
|
||||
$IDRace = 0;
|
||||
|
|
@ -36,8 +41,6 @@ class CASS_View_Race_Edit
|
|||
//Create mode
|
||||
$race->setStart(date("Y-m-d H:i:s"));
|
||||
$race->setEnd(date("Y-m-d H:i:s"));
|
||||
$race->setSubscriptionStart(null);
|
||||
|
||||
}
|
||||
|
||||
//Validating data
|
||||
|
|
@ -115,33 +118,33 @@ class CASS_View_Race_Edit
|
|||
$race->setMeetingPlaceName(SantizeGlobal($_POST["meetingPlaceName"]));
|
||||
}
|
||||
|
||||
if (intval($_POST["participantMax"])>0) {
|
||||
if (intval($_POST["participantMax"]) > 0) {
|
||||
if (intval($_POST["participantMin"]) > intval($_POST["participantMax"])) {
|
||||
echo "<p>* Le nombre de participants minimum doit être inférieur au nombre de participants maximum</p>";
|
||||
$dataValidationSuccess = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (strtotime($_POST["start"]) > strtotime($_POST["end"])) {
|
||||
echo "<p>* La date de début de course doit être inférieur à la date de fin.</p>";
|
||||
$dataValidationSuccess = false;
|
||||
}
|
||||
if (strtotime($_POST["start"]) > strtotime($_POST["end"])) {
|
||||
echo "<p>* La date de début de course doit être inférieur à la date de fin.</p>";
|
||||
$dataValidationSuccess = false;
|
||||
}
|
||||
|
||||
|
||||
if (strtotime($_POST["subscriptionStart"]) > strtotime($_POST["subscriptionEnd"])) {
|
||||
echo "<p>* La date de début des inscriptions doit être inférieur à la date de fin des inscriptions</p>";
|
||||
$dataValidationSuccess = false;
|
||||
}
|
||||
|
||||
if (strtotime($_POST["subscriptionStart"]) > strtotime($_POST["start"])) {
|
||||
echo "<p>* La date de début des inscriptions doit être inférieur à la date de début de la course</p>";
|
||||
$dataValidationSuccess = false;
|
||||
}
|
||||
if (strtotime($_POST["subscriptionStart"]) > strtotime($_POST["subscriptionEnd"])) {
|
||||
echo "<p>* La date de début des inscriptions doit être inférieur à la date de fin des inscriptions</p>";
|
||||
$dataValidationSuccess = false;
|
||||
}
|
||||
|
||||
if (strtotime($_POST["subscriptionEnd"]) > strtotime($_POST["start"])) {
|
||||
echo "<p>* La date de fin des inscriptions doit être inférieur à la date de début de la course</p>";
|
||||
$dataValidationSuccess = false;
|
||||
}
|
||||
if (strtotime($_POST["subscriptionStart"]) > strtotime($_POST["start"])) {
|
||||
echo "<p>* La date de début des inscriptions doit être inférieur à la date de début de la course</p>";
|
||||
$dataValidationSuccess = false;
|
||||
}
|
||||
|
||||
if (strtotime($_POST["subscriptionEnd"]) > strtotime($_POST["start"])) {
|
||||
echo "<p>* La date de fin des inscriptions doit être inférieur à la date de début de la course</p>";
|
||||
$dataValidationSuccess = false;
|
||||
}
|
||||
|
||||
if (intval($_POST["IDType"]) == 0) {
|
||||
// echo "<p>* le type de course est obligatoire</p>";
|
||||
|
|
@ -151,7 +154,7 @@ class CASS_View_Race_Edit
|
|||
}
|
||||
|
||||
if (intval($_POST["IDGroup"]) == 0) {
|
||||
$dataValidationSuccess = false;
|
||||
$dataValidationSuccess = false;
|
||||
} else {
|
||||
$race->setIDGroup(intval($_POST["IDGroup"]));
|
||||
}
|
||||
|
|
@ -163,7 +166,7 @@ class CASS_View_Race_Edit
|
|||
$race->setMeetingPlaceLongitude(doubleval($_POST["meetingPlaceLongitude"]));
|
||||
$race->setMeetingPlaceLatitude(doubleval($_POST["meetingPlaceLatitude"]));
|
||||
$race->setDescriptionPublic($_POST["descriptionPublic"]);
|
||||
$race->setDescriptionMemberSubscribed(SantizeGlobal($_POST["descriptionMemberSubscribed"]));
|
||||
$race->setDescriptionMemberSubscribed($_POST["descriptionMemberSubscribed"]);
|
||||
$race->setFormType(intval($_POST["formType"]));
|
||||
$race->setComment(SantizeGlobal($_POST["comment"]));
|
||||
$race->setParticipantMax(intval($_POST["participantMax"]));
|
||||
|
|
@ -174,7 +177,7 @@ class CASS_View_Race_Edit
|
|||
$race->setSubscriptionStart($_POST["subscriptionStart"]);
|
||||
$race->setSubscriptionEnd($_POST["subscriptionEnd"]);
|
||||
|
||||
if ($dataValidationSuccess) {
|
||||
if ($dataValidationSuccess) {
|
||||
switch ($stateForm) {
|
||||
case 'create':
|
||||
$race->setDtCreation(date("Y-m-d H:i:s"));
|
||||
|
|
@ -273,8 +276,7 @@ class CASS_View_Race_Edit
|
|||
<br />
|
||||
<div class="form-element">
|
||||
<label class="form-element">Etat*</label>
|
||||
<select name="state" id="state" required
|
||||
onchange="stateChangeNotification()">
|
||||
<select name="state" id="state" required onchange="stateChangeNotification()">
|
||||
<option value="">Sélectionner un état</option>;
|
||||
<?php
|
||||
$selDrafted = "";
|
||||
|
|
@ -313,16 +315,17 @@ class CASS_View_Race_Edit
|
|||
</select>
|
||||
<script>
|
||||
function stateChangeNotification() {
|
||||
//show stateChangeNotification
|
||||
document.getElementById("stateChangeNotification").removeAttribute("hidden");
|
||||
//show stateChangeNotification
|
||||
document.getElementById("stateChangeNotification").removeAttribute("hidden");
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div hidden class="form-element" id='stateChangeNotification'>
|
||||
<br />
|
||||
|
||||
<div hidden class="form-element" id='stateChangeNotification'>
|
||||
<br />
|
||||
<label class="form-element">Notification</label>
|
||||
<span class="cass" style='color:red;'>Vous pouvez notifier le changement du status en activant la notifiation par mail (fond du formulaire)</span>
|
||||
<span class="cass" style='color:red;'>Vous pouvez notifier le changement du status en activant la notifiation par
|
||||
mail (fond du formulaire)</span>
|
||||
</div>
|
||||
<br />
|
||||
<div class="form-element">
|
||||
|
|
@ -352,7 +355,7 @@ class CASS_View_Race_Edit
|
|||
<br />
|
||||
<div class="form-element">
|
||||
<label class="form-element">Adjoint</label>
|
||||
<select id="IDWPUser_Deputy" name="IDWPUser_Deputy" value="<?php echo intval($race->getIDWPUser_Deputy()) ?>" >
|
||||
<select id="IDWPUser_Deputy" name="IDWPUser_Deputy" value="<?php echo intval($race->getIDWPUser_Deputy()) ?>">
|
||||
<option value=0 selected>Sélectionner un adjoint</option>";
|
||||
<?php
|
||||
$args = array(
|
||||
|
|
@ -408,7 +411,8 @@ class CASS_View_Race_Edit
|
|||
<br />
|
||||
<div class="form-element">
|
||||
<label class="form-element">Localité*</label>
|
||||
<input required class="cass" type="text" name="placeLocality" value="<?php echo ReadGlobal($race->getPlaceLocality()) ?>" required>
|
||||
<input required class="cass" type="text" name="placeLocality"
|
||||
value="<?php echo ReadGlobal($race->getPlaceLocality()) ?>" required>
|
||||
</div>
|
||||
<br />
|
||||
<div class="form-element">
|
||||
|
|
@ -420,54 +424,55 @@ class CASS_View_Race_Edit
|
|||
<label class="form-element">Longitude</label>
|
||||
<input class="cass" type="text" name="placeLongitude" value="<?php echo $race->getPlaceLongitude() ?>">
|
||||
</div>
|
||||
<br/>
|
||||
<br />
|
||||
<div class="form-element">
|
||||
<label class="form-element">Inscription activée</label>
|
||||
<input type="checkbox" id="subscriptionEnable" name="subscriptionEnable" <?php if ($race->getSubscriptionEnable() == 1) {
|
||||
echo "checked";
|
||||
} ?>>
|
||||
echo "checked";
|
||||
} ?>>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
<div class="form-element">
|
||||
<label class="form-element">Choisir date inscriptions</label>
|
||||
<input type="checkbox" id="inscriptionsDate"/>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
<div id="inscriptionFields" class="hidden">
|
||||
<div class="form-element">
|
||||
<label class="form-element">Début des inscriptions</label>
|
||||
<input class="cass" type="datetime-local" name="subscriptionStart"
|
||||
value="<?php echo date('Y-m-d\TH:i', strtotime($race->getSubscriptionStart())) ?>">
|
||||
|
||||
</div>
|
||||
<br />
|
||||
<!--
|
||||
<div class="form-element">
|
||||
<label class="form-element">Fin des inscriptions</label>
|
||||
<input class="cass" type="datetime-local" name="subscriptionEnd"
|
||||
value="<?php echo date('Y-m-d\TH:i', strtotime($race->getSubscriptionEnd())) ?>">
|
||||
<label class="form-element">Choisir date inscriptions</label>
|
||||
<input type="checkbox" id="inscriptionsDate" />
|
||||
</div>
|
||||
!-->
|
||||
<br />
|
||||
|
||||
<div id="inscriptionFields">
|
||||
<div class="form-element">
|
||||
<label class="form-element">Début des inscriptions</label>
|
||||
<input class="cass" type="datetime-local" name="subscriptionStart"
|
||||
value="<?php echo date('Y-m-d\TH:i', strtotime($race->getSubscriptionStart())) ?>">
|
||||
|
||||
</div>
|
||||
<br />
|
||||
<div class="form-element">
|
||||
<label class="form-element">Fin des inscriptions</label>
|
||||
<input class="cass" type="datetime-local" name="subscriptionEnd"
|
||||
value="<?php echo date('Y-m-d\TH:i', strtotime($race->getSubscriptionEnd())) ?>">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<div class="form-element">
|
||||
<label class="form-element">Début*</label>
|
||||
<input class="cass" type="datetime-local" name="start" required
|
||||
value="<?php echo date('Y-m-d\TH:i', strtotime($race->getStart())) ?>">
|
||||
value="<?php echo date('Y-m-d\TH:i', strtotime($race->getStart())) ?>">
|
||||
</div>
|
||||
<br />
|
||||
<div class="form-element">
|
||||
<label class="form-element">Fin*</label>
|
||||
<input class="cass" type="datetime-local" name="end" required
|
||||
value="<?php echo date('Y-m-d\TH:i', strtotime($race->getEnd())) ?>">
|
||||
value="<?php echo date('Y-m-d\TH:i', strtotime($race->getEnd())) ?>">
|
||||
</div>
|
||||
<br />
|
||||
<div class="form-element">
|
||||
<label class="form-element">Niveau*</label>
|
||||
<select name="level" id="level" required>
|
||||
<select name="level" id="level" required>
|
||||
<option value="">Sélectionner un niveau</option>";
|
||||
<?php
|
||||
//Select all group
|
||||
|
|
@ -488,7 +493,8 @@ class CASS_View_Race_Edit
|
|||
<br />
|
||||
<div class="form-element">
|
||||
<label class="form-element">Lieu de rencontre*</label>
|
||||
<input class="cass" type="text" name="meetingPlaceName" value="<?php echo ReadGlobal($race->getMeetingPlaceName()) ?>" required>
|
||||
<input class="cass" type="text" name="meetingPlaceName"
|
||||
value="<?php echo ReadGlobal($race->getMeetingPlaceName()) ?>" required>
|
||||
</div>
|
||||
<br />
|
||||
<div class="form-element">
|
||||
|
|
@ -515,7 +521,7 @@ class CASS_View_Race_Edit
|
|||
<br />
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="form-element">
|
||||
<label class="form-element">Description</label>
|
||||
<textarea id="descriptionPublic" name="descriptionPublic" rows="12"
|
||||
|
|
@ -632,21 +638,24 @@ class CASS_View_Race_Edit
|
|||
|
||||
<script>initializeTinyMCE("#descriptionPublic, #descriptionMemberSubscribed");</script>
|
||||
|
||||
<script>
|
||||
document.getElementById('inscriptionsDate').addEventListener('change', function () {
|
||||
const inscriptionFields = document.getElementById('inscriptionFields');
|
||||
if (this.checked) {
|
||||
inscriptionFields.classList.remove('hidden');
|
||||
} else {
|
||||
inscriptionFields.classList.add('hidden');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<!--
|
||||
<script>
|
||||
document.getElementById('inscriptionsDate').addEventListener('change', function () {
|
||||
const inscriptionFields = document.getElementById('inscriptionFields');
|
||||
if (this.checked) {
|
||||
inscriptionFields.classList.remove('hidden');
|
||||
} else {
|
||||
inscriptionFields.classList.add('hidden');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
-->
|
||||
|
||||
<style>
|
||||
.form-element {
|
||||
display: flex; /* Disposition en ligne */
|
||||
}
|
||||
.form-element {
|
||||
display: flex;
|
||||
/* Disposition en ligne */
|
||||
}
|
||||
</style>
|
||||
|
||||
<?php
|
||||
|
|
|
|||
|
|
@ -18,6 +18,23 @@ function view_race_list_initialisation()
|
|||
});
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const links = document.querySelectorAll('th a'); // Sélectionner les liens de tri dans les colonnes
|
||||
const seasonField = document.querySelector('#IDSeason'); // Sélectionner le champ de filtre IDSeason
|
||||
|
||||
if (seasonField) {
|
||||
const currentIDSeason = seasonField.value; // Récupérer la saison actuellement sélectionnée
|
||||
|
||||
links.forEach(function(link) {
|
||||
const url = new URL(link.href); // Transformer l'URL en objet manipulable
|
||||
url.searchParams.set('IDSeason', currentIDSeason); // Ajouter ou remplacer le paramètre IDSeason
|
||||
link.href = url.toString(); // Appliquer la nouvelle URL au lien
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
";
|
||||
|
||||
|
||||
|
|
@ -86,7 +103,12 @@ function view_race_list_initialisation()
|
|||
$season = new Season();
|
||||
|
||||
$rows = Season::selectAll();
|
||||
$selectedValue = isset($_POST['IDSeason']) ? $_POST['IDSeason'] : $season->getCurrentSeason();
|
||||
$selectedValue = isset($_POST['IDSeason']) && $_POST['IDSeason'] !== ''
|
||||
? $_POST['IDSeason'] // Priorité à POST
|
||||
: (isset($_GET['IDSeason']) && $_GET['IDSeason'] !== ''
|
||||
? $_GET['IDSeason'] // Sinon, GET
|
||||
: $season->getCurrentSeason() // Sinon, saison actuelle
|
||||
);
|
||||
|
||||
foreach ($rows as $type) {
|
||||
$selected = ($selectedValue !== null && intval($selectedValue) == intval($type->IDSeason)) ? "selected" : "";
|
||||
|
|
@ -109,6 +131,7 @@ function view_race_list_initialisation()
|
|||
$table->prepare_items();
|
||||
// Display table
|
||||
echo "<form id='cass-admin-race-list' method='post'>";
|
||||
echo '<input type="hidden" name="IDSeason" value="' . esc_attr($_POST['IDSeason'] ?? '') . '">';
|
||||
$table->display();
|
||||
echo "</form>";
|
||||
|
||||
|
|
@ -162,6 +185,9 @@ class CASS_View_Race_List extends WP_List_Table
|
|||
|
||||
function prepare_items()
|
||||
{
|
||||
echo "HHAH :" + $_POST["IDSeason"];
|
||||
|
||||
|
||||
//Result of bulk action
|
||||
$action = $this->current_action();
|
||||
|
||||
|
|
@ -170,7 +196,6 @@ class CASS_View_Race_List extends WP_List_Table
|
|||
|
||||
$selected_ids = isset($_POST[$this->_args['singular']]) ? $_POST[$this->_args['singular']] : array();
|
||||
|
||||
|
||||
// Faire quelque chose avec les IDs
|
||||
foreach ($selected_ids as $id) {
|
||||
// Traitement pour chaque ID
|
||||
|
|
@ -229,27 +254,49 @@ class CASS_View_Race_List extends WP_List_Table
|
|||
|
||||
$results = null;
|
||||
|
||||
if (isset($_POST["IDSeason"]) && $_POST["IDSeason"] == "all") {
|
||||
// Récupération de l'ID de la saison
|
||||
$currentSeasonID = intval($season->getCurrentSeason()); // Saison actuelle par défaut
|
||||
|
||||
// Priorité à $_POST
|
||||
if (isset($_POST['IDSeason']) && $_POST['IDSeason'] !== '') {
|
||||
$IDSeason = $_POST['IDSeason'];
|
||||
}
|
||||
// Ensuite vérifier $_GET
|
||||
else if (isset($_GET['IDSeason']) && $_GET['IDSeason'] !== '') {
|
||||
$IDSeason = $_GET['IDSeason'];
|
||||
}
|
||||
// Sinon, utiliser la saison actuelle comme fallback
|
||||
else {
|
||||
$IDSeason = $currentSeasonID;
|
||||
}
|
||||
|
||||
// S'assurer que IDSeason est dans $_POST pour une utilisation ultérieure
|
||||
$_POST['IDSeason'] = $IDSeason;
|
||||
|
||||
// Construire la requête en fonction de IDSeason
|
||||
if ($IDSeason === "all") {
|
||||
// Sélectionner toutes les courses
|
||||
$results = $wpdb->get_results(
|
||||
"SELECT * from {$table}",
|
||||
"SELECT * FROM {$table}",
|
||||
ARRAY_A
|
||||
|
||||
);
|
||||
} else if (isset($_POST["IDSeason"]) && intval($_POST["IDSeason"]) != 0) {
|
||||
$IDSeason = intval($_POST['IDSeason']);
|
||||
|
||||
} else if (intval($IDSeason) != 0) {
|
||||
// Sélectionner les courses pour une saison spécifique
|
||||
$results = $wpdb->get_results(
|
||||
$wpdb->prepare("SELECT * FROM {$table} WHERE IDSeason = %d", $IDSeason),
|
||||
$wpdb->prepare("SELECT * FROM {$table} WHERE IDSeason = %d", intval($IDSeason)),
|
||||
ARRAY_A
|
||||
);
|
||||
} else {
|
||||
// Utilisez l'ID de la saison en cours pour filtrer les résultats
|
||||
$results = $wpdb->get_results("SELECT * FROM {$table}", ARRAY_A);
|
||||
// Si aucune condition, retourner toutes les courses par défaut
|
||||
$results = $wpdb->get_results(
|
||||
"SELECT * FROM {$table}",
|
||||
ARRAY_A
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//Filter on CdC or Deputy
|
||||
$filtered_data = array();
|
||||
|
||||
|
|
@ -267,7 +314,7 @@ class CASS_View_Race_List extends WP_List_Table
|
|||
$ItemCdCName = "";
|
||||
$ItemDeputyName = "";
|
||||
|
||||
foreach ($users as $user) {
|
||||
foreach ($users as $user) {
|
||||
if ($result['IDWPUser_RL'] == $user->id) {
|
||||
$ItemCdCName = $user->last_name . " " . $user->first_name;
|
||||
}
|
||||
|
|
@ -276,15 +323,15 @@ class CASS_View_Race_List extends WP_List_Table
|
|||
}
|
||||
}
|
||||
|
||||
if($search_CdC != "" && $search_Deputy != ""){
|
||||
if ($search_CdC != "" && $search_Deputy != "") {
|
||||
if (strpos($ItemCdCName, $search_CdC) !== false && strpos($ItemDeputyName, $search_Deputy) !== false) {
|
||||
$filtered_data[] = $result;
|
||||
}
|
||||
} else if($search_CdC != ""){
|
||||
} else if ($search_CdC != "") {
|
||||
if (strpos($ItemCdCName, $search_CdC) !== false) {
|
||||
$filtered_data[] = $result;
|
||||
}
|
||||
} else if($search_Deputy != ""){
|
||||
} else if ($search_Deputy != "") {
|
||||
if (strpos($ItemDeputyName, $search_Deputy) !== false) {
|
||||
$filtered_data[] = $result;
|
||||
}
|
||||
|
|
@ -472,19 +519,20 @@ class CASS_View_Race_List extends WP_List_Table
|
|||
return sprintf('%1$s %2$s', ReadGlobal($item['name']), $this->row_actions($actions));
|
||||
}
|
||||
|
||||
|
||||
function search_box($text, $input_id)
|
||||
{
|
||||
$input_id = $input_id . '-search-input';
|
||||
|
||||
echo '<form method="post">';
|
||||
echo '<p class="search-box">';
|
||||
echo '<input type="hidden" name="IDSeason" value="' . esc_attr($_POST['IDSeason'] ?? '') . '">';
|
||||
echo '<label class="screen-reader-text" for="' . esc_attr($input_id) . '">' . $text . ':</label>';
|
||||
echo '<input type="search" id="' . esc_attr($input_id) . '" name="' . esc_attr($input_id) . '" value="' . esc_attr($_REQUEST[$input_id] ?? '') . '" />';
|
||||
echo '<button type="submit" class="button">' . esc_attr($text) . '</button>';
|
||||
echo '</p>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,47 +8,68 @@ function view_race_user_all_courses_list_initialisation()
|
|||
{
|
||||
global $wpdb;
|
||||
|
||||
$table = new CASS_View_Race_User_All_Courses_List();
|
||||
?>
|
||||
<div class="wrap">
|
||||
<?php
|
||||
$user = get_userdata($_GET["element"]);
|
||||
echo "<h2>Liste des courses pour le membre : ".$user->user_lastname. " ".$user->user_firstname;
|
||||
echo "
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const links = document.querySelectorAll('th a'); // Sélectionner les liens de tri dans les colonnes
|
||||
const seasonField = document.querySelector('#IDSeason'); // Sélectionner le champ de filtre IDSeason
|
||||
|
||||
?>
|
||||
<form action='#' method='POST'>
|
||||
<div class="form-element">
|
||||
<select name="IDSeason" id="IDSeason">
|
||||
<option value="all" <?php echo isset($_POST['IDSeason']) && $_POST['IDSeason'] === 'all' ? 'selected' : ''; ?>>Toutes les saisons</option>
|
||||
<?php
|
||||
$season = new Season() ;
|
||||
//Select all type
|
||||
$sql = "SELECT IDSeason, name FROM cass_season ORDER BY name ASC;";
|
||||
$rows = $wpdb->get_results($sql);
|
||||
$selectedValue = isset($_POST['IDSeason']) ? $_POST['IDSeason'] : $season->getCurrentSeason() ;
|
||||
if (seasonField) {
|
||||
const currentIDSeason = seasonField.value; // Récupérer la saison actuellement sélectionnée
|
||||
|
||||
foreach ($rows as $type) {
|
||||
$selected = ($selectedValue !== null && intval($selectedValue) == intval($type->IDSeason)) ? "selected" : "";
|
||||
|
||||
echo "<option value=" . $type->IDSeason . " " . $selected . ">" . $type->name . "</option>";
|
||||
links.forEach(function(link) {
|
||||
const url = new URL(link.href); // Transformer l'URL en objet manipulable
|
||||
url.searchParams.set('IDSeason', currentIDSeason); // Ajouter ou remplacer le paramètre IDSeason
|
||||
link.href = url.toString(); // Appliquer la nouvelle URL au lien
|
||||
});
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<button
|
||||
type="submit"
|
||||
class="button-secondary"
|
||||
id="refresh-cache">Filtrer
|
||||
</button>
|
||||
</form>
|
||||
});
|
||||
</script>
|
||||
";
|
||||
|
||||
$table = new CASS_View_Race_User_All_Courses_List();
|
||||
?>
|
||||
<div class="wrap">
|
||||
<?php
|
||||
$user = get_userdata($_GET["element"]);
|
||||
echo "<h2>Liste des courses pour le membre : " . $user->user_lastname . " " . $user->user_firstname;
|
||||
|
||||
?>
|
||||
<form action='#' method='POST'>
|
||||
<div class="form-element">
|
||||
<select name="IDSeason" id="IDSeason">
|
||||
<option value="all" <?php echo isset($_POST['IDSeason']) && $_POST['IDSeason'] === 'all' ? 'selected' : ''; ?>>Toutes les saisons</option>
|
||||
<?php
|
||||
$season = new Season();
|
||||
//Select all type
|
||||
$sql = "SELECT IDSeason, name FROM cass_season ORDER BY name ASC;";
|
||||
$rows = $wpdb->get_results($sql);
|
||||
$selectedValue = isset($_POST['IDSeason']) && $_POST['IDSeason'] !== ''
|
||||
? $_POST['IDSeason'] // Priorité à POST
|
||||
: (isset($_GET['IDSeason']) && $_GET['IDSeason'] !== ''
|
||||
? $_GET['IDSeason'] // Sinon, GET
|
||||
: $season->getCurrentSeason() // Sinon, saison actuelle
|
||||
);
|
||||
|
||||
foreach ($rows as $type) {
|
||||
$selected = ($selectedValue !== null && intval($selectedValue) == intval($type->IDSeason)) ? "selected" : "";
|
||||
|
||||
echo "<option value=" . $type->IDSeason . " " . $selected . ">" . $type->name . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="button-secondary" id="refresh-cache">Filtrer
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
// Prepare table
|
||||
$table->prepare_items();
|
||||
// Display table
|
||||
$table->display();
|
||||
echo '</div></form>';
|
||||
// Prepare table
|
||||
$table->prepare_items();
|
||||
// Display table
|
||||
$table->display();
|
||||
echo '</div></form>';
|
||||
}
|
||||
|
||||
class CASS_View_Race_User_All_Courses_List extends WP_List_Table
|
||||
|
|
@ -75,6 +96,7 @@ class CASS_View_Race_User_All_Courses_List extends WP_List_Table
|
|||
{
|
||||
$this->table_data = $this->get_table_data();
|
||||
|
||||
|
||||
$columns = $this->get_columns();
|
||||
$hidden = array();
|
||||
$sortable = $this->get_sortable_columns();
|
||||
|
|
@ -104,51 +126,74 @@ class CASS_View_Race_User_All_Courses_List extends WP_List_Table
|
|||
|
||||
// Get table data
|
||||
private function get_table_data()
|
||||
{
|
||||
global $wpdb;
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
$table = 'cass_race';
|
||||
$season = new Season();
|
||||
$table = 'cass_race';
|
||||
$season = new Season();
|
||||
|
||||
// Récupération de l'utilisateur en cours
|
||||
$user = get_userdata($_GET["element"]);
|
||||
$currentUser = $user->id ;
|
||||
// Récupération de l'utilisateur en cours
|
||||
$user = get_userdata($_GET["element"]);
|
||||
$currentUser = $user->id;
|
||||
|
||||
// Obtenez l'ID de la saison en cours
|
||||
$currentSeasonID = $season->getCurrentSeason();
|
||||
// Obtenez l'ID de la saison actuelle
|
||||
$currentSeasonID = intval($season->getCurrentSeason()); // Saison actuelle par défaut
|
||||
|
||||
if (isset($_POST["IDSeason"]) && $_POST["IDSeason"] == "all") {
|
||||
// Afficher toutes les courses auxquelles l'utilisateur est inscrit
|
||||
$results = $wpdb->get_results(
|
||||
$wpdb->prepare("SELECT * FROM {$table} INNER JOIN cass_race_user ON cass_race.IDRace = cass_race_user.IDRace WHERE IDWPUser = %d", $currentUser),
|
||||
ARRAY_A
|
||||
);
|
||||
// Priorité à $_POST
|
||||
if (isset($_POST['IDSeason']) && $_POST['IDSeason'] !== '') {
|
||||
$IDSeason = $_POST['IDSeason'];
|
||||
}
|
||||
// Ensuite vérifier $_GET
|
||||
else if (isset($_GET['IDSeason']) && $_GET['IDSeason'] !== '') {
|
||||
$IDSeason = $_GET['IDSeason'];
|
||||
}
|
||||
// Sinon, utiliser la saison actuelle comme fallback
|
||||
else {
|
||||
$IDSeason = $currentSeasonID;
|
||||
}
|
||||
|
||||
return $results;
|
||||
// S'assurer que IDSeason est dans $_POST pour une utilisation ultérieure
|
||||
$_POST['IDSeason'] = $IDSeason;
|
||||
|
||||
} else if (isset($_POST["IDSeason"]) && intval($_POST["IDSeason"]) != 0) {
|
||||
// Afficher toutes les courses auxquelles l'utilisateur est inscrit dans la saison selectionné
|
||||
$IDSeason = intval($_POST['IDSeason']);
|
||||
// Construire la requête en fonction de IDSeason
|
||||
if ($IDSeason === "all") {
|
||||
// Afficher toutes les courses auxquelles l'utilisateur est inscrit
|
||||
$results = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"SELECT * FROM {$table} INNER JOIN cass_race_user ON cass_race.IDRace = cass_race_user.IDRace WHERE IDWPUser = %d",
|
||||
$currentUser
|
||||
),
|
||||
ARRAY_A
|
||||
);
|
||||
|
||||
$results = $wpdb->get_results(
|
||||
$wpdb->prepare("SELECT * FROM {$table} INNER JOIN cass_race_user ON cass_race.IDRace = cass_race_user.IDRace WHERE IDWPUser = %d AND IDSeason = %d", $currentUser, $IDSeason),
|
||||
ARRAY_A
|
||||
);
|
||||
return $results;
|
||||
} else if (intval($IDSeason) != 0) {
|
||||
// Afficher toutes les courses auxquelles l'utilisateur est inscrit pour une saison spécifique
|
||||
$results = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"SELECT * FROM {$table} INNER JOIN cass_race_user ON cass_race.IDRace = cass_race_user.IDRace WHERE IDWPUser = %d AND IDSeason = %d",
|
||||
$currentUser,
|
||||
intval($IDSeason)
|
||||
),
|
||||
ARRAY_A
|
||||
);
|
||||
|
||||
return $results;
|
||||
return $results;
|
||||
} else {
|
||||
// Afficher toutes les courses auxquelles l'utilisateur est inscrit dans la saison actuelle
|
||||
$results = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"SELECT * FROM {$table} INNER JOIN cass_race_user ON cass_race.IDRace = cass_race_user.IDRace WHERE IDWPUser = %d AND IDSeason = %d",
|
||||
$currentUser,
|
||||
$currentSeasonID
|
||||
),
|
||||
ARRAY_A
|
||||
);
|
||||
|
||||
} else {
|
||||
// Afficher toutes les courses auxquelles l'utilisateur est inscrit dans la saison en cours
|
||||
|
||||
$results = $wpdb->get_results(
|
||||
$wpdb->prepare("SELECT * FROM {$table} INNER JOIN cass_race_user ON cass_race.IDRace = cass_race_user.IDRace WHERE IDWPUser = %d AND IDSeason = %d", $currentUser, $currentSeasonID),
|
||||
ARRAY_A
|
||||
);
|
||||
|
||||
return $results;
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function column_default($item, $column_name)
|
||||
{
|
||||
|
|
@ -163,21 +208,21 @@ class CASS_View_Race_User_All_Courses_List extends WP_List_Table
|
|||
break;
|
||||
case 3:
|
||||
return "Désinscrit";
|
||||
break;
|
||||
break;
|
||||
case 4:
|
||||
return "Excusé";
|
||||
break;
|
||||
break;
|
||||
}
|
||||
case 'IDWPUser_RL':
|
||||
$args = array(
|
||||
'role' => 'CASS_RL',
|
||||
'role' => 'CASS_RL',
|
||||
'orderby' => 'user_nicename',
|
||||
'order' => 'ASC'
|
||||
'order' => 'ASC'
|
||||
);
|
||||
$users = get_users( $args );
|
||||
$users = get_users($args);
|
||||
$retuned = "";
|
||||
foreach ( $users as $user ) {
|
||||
if($item[$column_name] == $user->id){
|
||||
foreach ($users as $user) {
|
||||
if ($item[$column_name] == $user->id) {
|
||||
$retuned = $user->display_name;
|
||||
}
|
||||
}
|
||||
|
|
@ -187,7 +232,7 @@ class CASS_View_Race_User_All_Courses_List extends WP_List_Table
|
|||
$level->loadFromId($item[$column_name]);
|
||||
return ReadGlobal($level->getName());
|
||||
case 'IDType':
|
||||
GLOBAL $wpdb;
|
||||
global $wpdb;
|
||||
//Type
|
||||
//Select all type
|
||||
$sql = "SELECT IDType,name FROM cass_type ORDER BY name ASC;";
|
||||
|
|
@ -200,7 +245,7 @@ class CASS_View_Race_User_All_Courses_List extends WP_List_Table
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
default:
|
||||
return $item[$column_name];
|
||||
|
|
@ -243,33 +288,33 @@ class CASS_View_Race_User_All_Courses_List extends WP_List_Table
|
|||
return ($order === 'asc') ? $result : -$result;
|
||||
}
|
||||
|
||||
// Adding action links to column
|
||||
function column_name($item)
|
||||
{
|
||||
?>
|
||||
<script>
|
||||
// Adding action links to column
|
||||
function column_name($item)
|
||||
{
|
||||
?>
|
||||
<script>
|
||||
// The function below will start the confirmation dialog
|
||||
function DeleteRaceConfirmAction(IDType) {
|
||||
let confirmAction = confirm("Voulez supprimer la course <?php echo $item['name'] ?> ?");
|
||||
if (confirmAction) {
|
||||
var url = window.location.href;
|
||||
url+="&action=delete&element="+IDType;
|
||||
var url = window.location.href;
|
||||
url += "&action=delete&element=" + IDType;
|
||||
location.href = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
$actions = array(
|
||||
//Race
|
||||
'editrace_user' => sprintf('<a href="'.admin_url()."admin.php?page=cass-admin-race-user-list&action=edit&IDRace=".$item['IDRace'].'">Participants</a>',$_REQUEST['page'], 'edit', $item['IDRace']),
|
||||
|
||||
);
|
||||
|
||||
//Race
|
||||
'editrace_user' => sprintf('<a href="' . admin_url() . "admin.php?page=cass-admin-race-user-list&action=edit&IDRace=" . $item['IDRace'] . '">Participants</a>', $_REQUEST['page'], 'edit', $item['IDRace']),
|
||||
|
||||
);
|
||||
|
||||
return sprintf('%1$s %2$s', ReadGlobal($item['name']), $this->row_actions($actions));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ function view_race_user_list_initialisation()
|
|||
<button type="submit" class="button-secondary" id="refresh-cache">Ajouter</button>
|
||||
</form>
|
||||
|
||||
<form action='<?php echo admin_url() . "admin.php?page=cass-admin-race-list"; ?>' method='get'>
|
||||
<form action='<?php echo admin_url() . "admin.php?page=cass-admin-race-list"; ?>' method='POST'>
|
||||
<button type="submit" class="button">Retour aux courses</button>
|
||||
</form>
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
if (oneRace.descriptionMemberSubscribed == '' || oneRace.descriptionMemberSubscribed == null) {
|
||||
document.getElementById("raceDescriptionMemberSubscribed").innerHTML = "Il n'y a aucune description pour cette course";
|
||||
} else {
|
||||
document.getElementById("raceDescriptionMemberSubscribed").innerHTML = ReadGlobal(oneRace.descriptionMemberSubscribed, false);
|
||||
document.getElementById("raceDescriptionMemberSubscribed").innerHTML = ReadGlobal(oneRace.descriptionMemberSubscribed,false);
|
||||
}
|
||||
} else {
|
||||
document.getElementById("raceDescriptionMemberSubscribed").innerHTML = "Vous devez être inscrit pour accéder à ces informations.";
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
submitForm: function () {
|
||||
const adminUrl = window.adminPostUrl;
|
||||
const siteUrl = window.siteUrl;
|
||||
|
||||
this.errors = [];
|
||||
|
||||
if (this.errors.length === 0) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ function cass_shortcode_member_register()
|
|||
|
||||
<script>
|
||||
window.addEventListener('DOMContentLoaded', function () {
|
||||
var input = document.querySelector('#phone');
|
||||
var input = document.querySelector('#inputTelephone');
|
||||
if (input) {
|
||||
window.intlTelInput(input, {
|
||||
separateDialCode: true,
|
||||
|
|
@ -69,7 +69,7 @@ function cass_shortcode_member_register()
|
|||
</div>
|
||||
<div class='pure-control-group'>
|
||||
<label for='inputTelephone'>Téléphone*</label>
|
||||
<input name='phone' type='text' id='phone'/>
|
||||
<input name='inputTelephone' type='text' id='inputTelephone' v-model='user.inputTelephone' required/>
|
||||
</div>
|
||||
<div class='pure-control-group'>
|
||||
<label for='inputAddress'>Adresse*</label>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user