233 lines
11 KiB
PHP
233 lines
11 KiB
PHP
<?php
|
||
/**
|
||
* Created by PhpStorm.
|
||
* User: jsp
|
||
* Date: 2015-10-22
|
||
* Time: 11:26
|
||
*/
|
||
require_once 'php/inc_fonctions.php';
|
||
|
||
// r<>cup<75>rer les <20>v<EFBFBD>nements
|
||
function fxGetEvenementsRabais() {
|
||
global $objDatabase;
|
||
|
||
$sqlEvenements = "SELECT eve_id, eve_nom_fr FROM inscriptions_evenements WHERE eve_actif = 1 AND eve_date_fin >= '" . fxGetDate() . "' ORDER BY eve_nom_fr";
|
||
$tabEvenements = $objDatabase->fxGetResults($sqlEvenements);
|
||
|
||
return $tabEvenements;
|
||
}
|
||
|
||
// r<>cup<75>rer les <20>preuves
|
||
function fxGetEpreuvesRabais($intEvenement) {
|
||
global $objDatabase;
|
||
|
||
$sqlEpreuves = "SELECT epr_id, epr_type_fr, epr_nom_fr FROM inscriptions_epreuves WHERE epr_actif = 1 AND eve_id = " . intval($intEvenement) . " ORDER BY epr_tri";
|
||
$tabEpreuves = $objDatabase->fxGetResults($sqlEpreuves);
|
||
|
||
return $tabEpreuves;
|
||
}
|
||
|
||
function fxShowEvenement($intEvenement) {
|
||
global $objDatabase;
|
||
|
||
$sqlEvenement = "SELECT eve_nom_fr FROM inscriptions_evenements WHERE eve_id = " . intval($intEvenement);
|
||
$strEvenement = $objDatabase->fxGetVar($sqlEvenement);
|
||
|
||
return $strEvenement;
|
||
}
|
||
|
||
function fxShowEpreuve($intEpreuve) {
|
||
global $objDatabase;
|
||
|
||
if ($intEpreuve > 0) {
|
||
$sqlEpreuve = "SELECT CONCAT(epr_type_fr, ' ', epr_nom_fr) FROM inscriptions_epreuves WHERE epr_id = " . intval($intEpreuve);
|
||
$strEpreuve = $objDatabase->fxGetVar($sqlEpreuve);
|
||
}
|
||
else
|
||
$strEpreuve = 'Toutes les <20>preuves';
|
||
|
||
return $strEpreuve;
|
||
}
|
||
|
||
function fxMajAge($intEvenement = 0, $intEpreuve = 0) {
|
||
global $objDatabase;
|
||
$blnRetour = false;
|
||
|
||
if ($intEvenement != 0) {
|
||
if ($intEpreuve != 0)
|
||
$strWhere = "epr_id = " . intval($intEpreuve);
|
||
else
|
||
$strWhere = "eve_id = " . intval($intEvenement);
|
||
}
|
||
else
|
||
$strWhere = '';
|
||
|
||
if ($strWhere != '') {
|
||
$sqlEpreuves = "SELECT epr_id, epr_date_age FROM inscriptions_epreuves WHERE " . $strWhere;
|
||
$tabEpreuves = $objDatabase->fxGetResults($sqlEpreuves);
|
||
|
||
if ($tabEpreuves != null) {
|
||
for ($intCtr = 1; $intCtr <= count($tabEpreuves); $intCtr++) {
|
||
// r<>cup<75>rer les inscriptions pour cette <20>preuve
|
||
$sqlParticipants = "SELECT par_id, par_naissance FROM resultats_participants p, resultats_epreuves_commandees e WHERE p.pec_id = e.pec_id_original AND e.epr_id = " . intval($tabEpreuves[$intCtr]['epr_id']);
|
||
$tabParticipants = $objDatabase->fxGetResults($sqlParticipants);
|
||
|
||
if ($tabParticipants != null) {
|
||
for ($intCtr2 = 1; $intCtr2 <= count($tabParticipants); $intCtr2++) {
|
||
$intAge = fxGetAge($tabParticipants[$intCtr2]['par_naissance'], $tabEpreuves[$intCtr]['epr_date_age']);
|
||
echo $tabEpreuves[$intCtr]['epr_date_age'] . ' - ' . $tabParticipants[$intCtr2]['par_naissance'] . '<br>';
|
||
|
||
// mettre <20> jour la table r<>sultats_participants
|
||
$sqlUpdate = "UPDATE resultats_participants SET par_age = " . intval($intAge) . " WHERE par_id = " . intval($tabParticipants[$intCtr2]['par_id']);
|
||
$qryUpdate = $objDatabase->fxQuery($sqlUpdate);
|
||
|
||
if ($qryUpdate != null) {
|
||
echo $sqlUpdate . '<br />';
|
||
$blnRetour = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
return $blnRetour;
|
||
}
|
||
|
||
header('Content-type: text/html; charset=UTF-8');
|
||
?>
|
||
<style type="text/css">
|
||
body {color: #fff; font-family: "Arial"; font-size: 12px;}
|
||
h1 {color: #000; font-size: 24px;}
|
||
h2 {color: #000; font-size: 16px;}
|
||
.codes {color: #333;}
|
||
.resume {background: #ddd; border: 1px solid #bbb; color: #000; margin-bottom: 10px; padding: 10px; width: 400px;}
|
||
/* FORMULAIRES */
|
||
label.error {background-position: left top; background-repeat: no-repeat; display: block; float: left; font-size: 0.9em; font-style: italic; font-weight: bold; line-height: 18px; margin: 5px; padding-left: 18px; width: auto;}
|
||
div.msg label.error, label.success, label.msg, label.promo {background-position: left top; background-repeat: no-repeat; display: block; float: none; font-size: 0.9em; font-style: italic; font-weight: bold; line-height: 18px; margin: 5px; padding-left: 18px; width: auto;}
|
||
label.error {background-image: url(images/error.png); color: #c33;}
|
||
label.success {background-image: url(images/tick.png); color: #529214;}
|
||
label.msg {background-image: url(images/information.png); color: #0072bc;}
|
||
div.error {display: none;}
|
||
div.error, div.msg {background-color: #ffb; border: 1px solid #feb; margin-bottom: 10px; padding: 3px;}
|
||
|
||
input, textarea, select {background: #fff; border: 1px solid #ffa200; color: #333; font-size: 1em; padding: 1px;}
|
||
textarea {font-size: 1.2em;}
|
||
select {padding: 0;}
|
||
select option {padding-right: 10px;}
|
||
input.error, textarea.error {background: #e99; border: 1px solid #c33;}
|
||
|
||
fieldset {border: none; margin-bottom: 10px;}
|
||
fieldset legend {color: #000; font-weight: bold; padding: 2px 5px;}
|
||
fieldset label.form {color: #333; float: left; margin: 5px; text-align: right; width: 180px;}
|
||
fieldset label.info {color: #666; float: left; font: italic bold 11px "Trebuchet MS"; margin: 5px;}
|
||
fieldset input, fieldset textarea, fieldset select, fieldset p, fieldset button, fieldset img {float: left; margin: 5px;}
|
||
fieldset br {clear: left;}
|
||
fieldset input.chk_input, fieldset #panier input.chk_input, fieldset #panier input.chk_termes, fieldset label.chk_label {float: left; margin: 0 5px 0 0;}
|
||
fieldset label.chk_label {color: #333;}
|
||
fieldset p img {float: none; margin: 0; padding-right: 3px; vertical-align: text-top;}
|
||
|
||
button {background: #ffa200; border: 1px solid #ddd; color: #333; cursor: pointer; display: block; font-size: 1em; font-weight: bold; line-height: 130%; outline: none; overflow: visible; padding: 5px 10px; text-decoration: none; text-transform: lowercase; width: auto;}
|
||
button:hover {background: #000; color: #ddd; cursor: pointer; text-decoration: none;}
|
||
button:active {background: #999; color: #333; cursor: pointer; text-decoration: none;}
|
||
</style>
|
||
<link type="text/css" rel="stylesheet" href="<?php echo $vDomaine; ?>/libs/jquery-ui-1.12.1/jquery-ui.min.css">
|
||
<script type="text/javascript" src="<?php echo $vDomaine; ?>/libs/jquery/jquery-3.4.1.min.js"></script>
|
||
<script type="text/javascript" src="<?php echo $vDomaine; ?>/libs/jquery-ui-1.12.1/jquery-ui.min.js"></script>
|
||
<script type="text/javascript" src="<?php echo $vDomaine; ?>/plugins/jqery.validate-1.19.1/jquery.validate.min.js"></script>
|
||
<script type="text/javascript" src="<?php echo $vDomaine; ?>/plugins/jqery.validate-1.19.1/additional-methods.min.js"></script>
|
||
<?php
|
||
if (isset($_POST['btn_save'])) {
|
||
?>
|
||
<h1>Mettre à jour l'âge des participants</h1>
|
||
<div class="resume">
|
||
<p><strong>Événement:</strong> <?php echo fxShowEvenement($_POST['sel_evenement']); ?></p>
|
||
<p><strong>Épreuve:</strong> <?php echo fxShowEpreuve($_POST['sel_epreuve']); ?></p>
|
||
</div>
|
||
<div class="codes">
|
||
<?php
|
||
fxMajAge($_POST['sel_evenement'], $_POST['sel_epreuve']);
|
||
?>
|
||
</div>
|
||
<br />
|
||
<a href="<?php echo $vDomaine; ?>/maj_age.php?p=<?php echo $_POST['txt_ajoute_par']; ?>">« retour</a>
|
||
<?php
|
||
}
|
||
elseif (isset($_POST['btn_next'])) { // <20>TAPE 2
|
||
$tabEpreuves = fxGetEpreuvesRabais($_POST['sel_evenement']);
|
||
?>
|
||
<h1>Mettre a jour l'âge des participants</h1>
|
||
<h2>Étape 2: Choisir l'épreuve</h2>
|
||
<form action="maj_age.php" method="post" id="frm_age" name="frm_age">
|
||
<fieldset>
|
||
<input type="hidden" id="txt_ajoute_par" name="txt_ajoute_par" value="<?php echo $_POST['txt_ajoute_par']; ?>" />
|
||
<input type="hidden" id="sel_evenement" name="sel_evenement" value="<?php echo $_POST['sel_evenement']; ?>" />
|
||
<label for="sel_epreuve" class="form">Épreuve :</label>
|
||
<select id="sel_epreuve" name="sel_epreuve">
|
||
<option value="0" selected="selected">Toutes les épreuves</option>
|
||
<?php
|
||
for ($intCtr = 1; $intCtr <= count($tabEpreuves); $intCtr++) {
|
||
?>
|
||
<option value="<?php echo $tabEpreuves[$intCtr]['epr_id']; ?>"><?php echo fxUnescape($tabEpreuves[$intCtr]['epr_type_fr']); ?> <?php echo fxUnescape($tabEpreuves[$intCtr]['epr_nom_fr']); ?></option>
|
||
<?php
|
||
}
|
||
?>
|
||
</select>
|
||
<br />
|
||
<label class="form"><span></span></label>
|
||
<button type="submit" id="btn_save" name="btn_save">Mettre à jour</button>
|
||
<br>
|
||
<label class="form"><span></span></label>
|
||
<p><a href="maj_age.php?p=<?php echo $_POST['txt_ajoute_par']; ?>">« retour</a></p>
|
||
<br>
|
||
</fieldset>
|
||
</form>
|
||
<?php
|
||
}
|
||
else { // <20>TAPE 1
|
||
if (empty($_GET['p'])) {
|
||
?>
|
||
<h1>Accès refusé !</h1>
|
||
<?php
|
||
}
|
||
else {
|
||
?>
|
||
<script type="text/javascript">
|
||
$().ready(function () {
|
||
$("#frm_age").validate({
|
||
rules: {
|
||
sel_evenement: "required"
|
||
},
|
||
messages: {
|
||
sel_evenement: "Veuillez choisir un événement"
|
||
}
|
||
});
|
||
});
|
||
</script>
|
||
|
||
<h1>Mettre à jour l'âge des participants</h1>
|
||
<h2>Étape 1: Choisir l'événement</h2>
|
||
<form action="maj_age.php" method="post" id="frm_age" name="frm_age">
|
||
<fieldset>
|
||
<input type="hidden" id="txt_ajoute_par" name="txt_ajoute_par" value="<?php echo $_GET['p']; ?>" />
|
||
<label for="sel_evenement" class="form">Événement :</label>
|
||
<select id="sel_evenement" name="sel_evenement">
|
||
<option value="" selected="selected">-- Faites un choix --</option>
|
||
<?php
|
||
$tabEvenements = fxGetEvenementsRabais();
|
||
|
||
for ($intCtr = 1; $intCtr <= count($tabEvenements); $intCtr++) {
|
||
?>
|
||
<option value="<?php echo $tabEvenements[$intCtr]['eve_id']; ?>"><?php echo $tabEvenements[$intCtr]['eve_nom_fr']; ?></option>
|
||
<?php
|
||
}
|
||
?>
|
||
</select>
|
||
<br />
|
||
<label class="form"><span></span></label>
|
||
<button type="submit" id="btn_next" name="btn_next">Suivant</button>
|
||
</fieldset>
|
||
</form>
|
||
<?php
|
||
}
|
||
}
|