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