From: gburri Date: Mon, 29 Sep 2008 21:50:14 +0000 (+0000) Subject: ADD informations concernant les jours pendant lesquels les participants sont présent... X-Git-Tag: cl7~18 X-Git-Url: http://git.euphorik.ch/?p=cl7.git;a=commitdiff_plain;h=9f4608bb190f3cd49c45aefbb4076182a1449cf8 ADD informations concernant les jours pendant lesquels les participants sont présent (avancement, pas fini) git-svn-id: svn://localhost/cl7/trunk@5 4c3d3983-c6fa-4c6c-9935-18c3bbef1bf0 --- diff --git a/css/style.css b/css/style.css index 5db7678..eefd885 100644 --- a/css/style.css +++ b/css/style.css @@ -126,10 +126,13 @@ ul#menu { #contenu col#inscriptionColonneValeur { width: 70%; } - #contenu #formulaireJeuxJoues .aVote { color: #ffff00; -} +} +#contenu #formulaireInscription p { + margin-top: 1px; + margin-bottom: 0px; +} #informations { margin: 5px; diff --git a/index.php b/index.php index 6d614a3..d8467fa 100644 --- a/index.php +++ b/index.php @@ -34,6 +34,9 @@ echo ''; + '; + ?> Corcelles-Lan 7 diff --git a/js/cl7.js b/js/cl7.js index 10b1c52..d482fdc 100644 --- a/js/cl7.js +++ b/js/cl7.js @@ -41,32 +41,54 @@ cl7.verification_formulaire_inscription = function(util) { return false; } return true; -} +}; + +cl7.maj_prix_inscription = function() { + var nbPeriodes = $('#formulaireInscription input[name="periodes[]"]:checked').length; + var prix = 5; + if (nbPeriodes === 3) { + prix = 40; + } else if (nbPeriodes != 0) { + prix = 15 * nbPeriodes; + } + $('#formulaireInscription span#prix').html(prix.toString()); +}; $(document).ready( function() { var util = new cl7.Util(); $('form#formulaireInscription').submit(function() { return cl7.verification_formulaire_inscription(util); - }); - + }); + + var messageUtilisateur = $('meta[name="messageUtilisateur"]').attr('content'); + if (messageUtilisateur !== undefined) { + util.messageDialogue(messageUtilisateur); + } + $('form#formulaireInscription select[name="clanChoix"]').change(function() { if ($(this).val() === '0') { return; } $clan = $(this).val().split(';'); - $('form#formulaireInscription input[name="clan_nom"]').val($clan [0]); - $('form#formulaireInscription input[name="clan_tag"]').val($clan [1]); + $('form#formulaireInscription input[name="clan_nom"]').val($clan[0]); + $('form#formulaireInscription input[name="clan_tag"]').val($clan[1]); }); - // inscrit les emails codés (page contact) - $('a#contactPifou').attr('href', util.rot13('znvygb:tert.oheev@tznvy.pbz')) - $('a#contactLePiaf').attr('href', util.rot13('znvygb:tyrcvns695@zfa.pbz')) + // inscrit les emails codés (page contacts) + $('a#contactPifou').attr('href', util.rot13('znvygb:tert.oheev@tznvy.pbz')); + $('a#contactLePiaf').attr('href', util.rot13('znvygb:tyrcvns695@zfa.pbz')); + + $('#formulaireInscription input[name="periodes[]"]').change(function() { + cl7.maj_prix_inscription(); + }); + // met à jour le prix d'inscription + cl7.maj_prix_inscription(); // permet d'éviter de faire plus de choix qu'il n'en faut sur la page des jeux joués var nbVotesMax = 3; var coches = []; - $('#formulaireJeuxJoues input:checked').each(function() { + $('#formulaireJeuxJoues input[name="votes[]"]:checked').each(function() { coches.unshift(parseInt($(this).attr("value"))); }); $('#formulaireJeuxJoues input[name="votes[]"]').change(function() { diff --git a/php/config.php b/php/config.php index ffc342a..220da45 100644 --- a/php/config.php +++ b/php/config.php @@ -8,6 +8,9 @@ $SQL_HOTE = "localhost"; $SQL_LOGIN = "cl7"; $SQL_PASS = "123soleil"; $NOM_BASE = "corcelles_lan7"; + +$COUT_PERIODE = 15; +$COUT_TOTAL = 40; # nombre maximum de participant $NB_MAX_PARTICIPANT = 25; diff --git a/php/connexion.php b/php/connexion.php index 6b5e26c..6f0ea85 100644 --- a/php/connexion.php +++ b/php/connexion.php @@ -14,14 +14,14 @@ mysql_query('SET AUTOCOMMIT=0'); if (isset($_POST['effacer_cookie'])) # le membre se délogue { - setcookie("COOKIE_INFO_PATICIPANT", "", time() - 100); #'efface' le cookie membre + setcookie("COOKIE_INFO_PATICIPANT", "", time() - 100); # 'efface' le cookie membre unset($HTTP_COOKIE_VARS["COOKIE_INFO_PATICIPANT"]); unset($log); } if (isset($_POST['log'])) # le membre se logue { - $le_participant = new Participant($pseudo, $password); + $le_participant = new Participant($_POST['pseudo'], $_POST['password']); if ($le_participant->valide) { setcookie ("COOKIE_INFO_PATICIPANT", $le_participant->info->id, time() + 31104000); diff --git a/php/controller.php b/php/controller.php index ff47132..75a4668 100644 --- a/php/controller.php +++ b/php/controller.php @@ -3,6 +3,33 @@ * Traite les données envoyées par le client. */ include_once("class_participant.php"); + +// un message peut être produit par le controlleur +$message_utilisateur = NULL; + +/** + * Traiter les données de l'inscription (trim par exemple). + */ +function traiter_donnees_inscription() +{ + $_POST['pseudo'] = trim($_POST['pseudo']); +} + +function login_deja_pris() +{ + global $le_participant; + global $message_utilisateur; + if ($le_participant->valide && strtolower($le_participant->info->pseudo) === strtolower($_POST['pseudo'])) // le pseudo n'a pas changé + return FALSE; + + $loginDejaPris = mysql_fetch_array(mysql_query("SELECT count(*) FROM participants WHERE pseudo = '".addslashes($_POST['pseudo'])."'")); + if ($loginDejaPris[0] > 0) + { + $message_utilisateur = "Le pseudo '".$_POST["pseudo"]."' est déjà pris"; + return TRUE; + } + return FALSE; +} /** * Renvoie TRUE si les données d'une inscription sont valides (POST). @@ -17,13 +44,34 @@ function donnees_inscription_valides() $_POST['nom'] != "" && $_POST['prenom'] != "" && $_POST['e_mail'] != ""; +} + +/** + * Met à jour les periodes du participant dont l'id est donnée + * en fonction de $_POST["periodes"] + * Attention, cette fonction doit être appelée dans une transaction. + */ +function set_periodes($id) +{ + $periodes = $_POST['periodes']; + if (!$periodes) + $periodes = array(); + + mysql_query("DELETE FROM participations WHERE participant_id = " . (int)$id); + for ($i = 0; $i < count($periodes); $i++) + { + mysql_query(" + INSERT INTO participations (participant_id, periode_id) + VALUES (".$id.", ".(int)$periodes[$i].") + "); + } } -# insciption d'un nouveau participant +# inscription d'un nouveau participant if (isset($_POST['inscription']) && !Participant::nombre_participant_max_atteint()) -{ - # vérification des données - if ( +{ + traiter_donnees_inscription(); + if (!login_deja_pris() && # vérification des données donnees_inscription_valides() && $_POST['accord'] == "on" ) @@ -43,17 +91,21 @@ if (isset($_POST['inscription']) && !Participant::nombre_participant_max_atteint '".addslashes($_POST['e_mail'])."', '".addslashes($_POST['remarques'])."' )" - ); - mysql_query("COMMIT"); - } + ); + $id = mysql_insert_id(); + set_periodes($id); + mysql_query("COMMIT"); - $le_participant = new participant($_POST['pseudo'], $_POST['pass1']); - setcookie("COOKIE_INFO_PATICIPANT", $le_participant->info->id, time() + 31104000); + $le_participant = new participant($_POST['pseudo'], $_POST['pass1']); + setcookie("COOKIE_INFO_PATICIPANT", $le_participant->info->id, time() + 31104000); + $page = "bienvenue"; + } } # un participant modifie ses infos else if(isset($_POST['modification_participant']) && $le_participant->valide) -{ - if (donnees_inscription_valides()) +{ + traiter_donnees_inscription(); + if (!login_deja_pris() && donnees_inscription_valides()) { mysql_query("BEGIN TRANSACTION"); mysql_query("UPDATE participants SET pseudo = '".addslashes($_POST['pseudo'])."' WHERE id = " . $le_participant->info->id); @@ -64,8 +116,12 @@ else if(isset($_POST['modification_participant']) && $le_participant->valide) mysql_query("UPDATE participants SET prenom = '".addslashes($_POST['prenom'])."' WHERE id = " . $le_participant->info->id); mysql_query("UPDATE participants SET age = '".addslashes($_POST['age'])."' WHERE id = " . $le_participant->info->id); mysql_query("UPDATE participants SET e_mail = '".addslashes($_POST['e_mail'])."' WHERE id = " . $le_participant->info->id); - mysql_query("UPDATE participants SET remarques = '".addslashes($_POST['remarques'])."' WHERE id = " . $le_participant->info->id); - mysql_query("COMMIT"); + mysql_query("UPDATE participants SET remarques = '".addslashes($_POST['remarques'])."' WHERE id = " . $le_participant->info->id); + set_periodes($le_participant->info->id); + mysql_query("COMMIT"); + //header("Location: /inscrits.html"); + $message_utilisateur = "Les modifications ont été enregistrées"; + $page = "inscrits"; // TODO : moche car la page ne va plus correspondre à l'url } } # vote pour des jeux diff --git a/php/tx_inscription.php b/php/tx_inscription.php index 742e153..949b996 100644 --- a/php/tx_inscription.php +++ b/php/tx_inscription.php @@ -6,7 +6,7 @@ else

Elles peuvent se désinscrirent en cas d\'empèchements majeurs.

'; ?> -
+ valide) echo '

'; @@ -23,7 +23,7 @@ else pseudo (login) - valide?('value="'.$le_participant->info->pseudo.'"'):''); ?> /> + " /> @@ -31,8 +31,8 @@ else password (pour pouvoir par la suite modifier mes infos) - valide?('value="'.$le_participant->info->password.'"'):''); ?> /> - re: valide?('value="'.$le_participant->info->password.'"'):''); ?> /> + " /> + re: " /> @@ -40,7 +40,7 @@ else clan name - valide?('value="'.$le_participant->info->clan_nom.'"'):''); ?> /> + " /> valide?('value="'.$le_participant->info->clan_tag.'"'):''); ?> /> + @@ -66,7 +66,7 @@ else nom - valide?('value="'.$le_participant->info->nom.'"'):''); ?> /> + @@ -74,7 +74,7 @@ else prénom - valide?('value="'.$le_participant->info->prenom.'"'):''); ?> /> + @@ -82,7 +82,7 @@ else age - valide?('value="'.$le_participant->info->age.'"'):''); ?> /> + @@ -90,7 +90,7 @@ else email (non-public) - valide?('value="'.$le_participant->info->e_mail.'"'):''); ?> /> + @@ -104,20 +104,29 @@ else FROM periodes LEFT JOIN participations ON periodes.id = participations.periode_id AND participations.participant_id = ".($le_participant->valide ? $le_participant->info->id : "0")." + ORDER BY periodes.id "); while($periode = mysql_fetch_object($res)) { - echo '

valide || $periode->participant_id ? 'checked="checked"' : '').' id="periode'.$periode->id.'" type="checkbox" />

'; + echo '

valide && (!$_POST['periodes'] || in_array($periode->id, $_POST['periodes']))) || $periode->participant_id ? 'checked="checked"' : '').' id="periode'.$periode->id.'" type="checkbox" />

'; } ?> + + + prix + + + CHF + + remarques - + - + '; ?> diff --git a/php/update_db.php b/php/update_db.php index 5ff5904..c094a9e 100644 --- a/php/update_db.php +++ b/php/update_db.php @@ -87,6 +87,7 @@ function update_db() if ($version == 1) { mysql_query("BEGIN TRANSACTION"); + mysql_query("ALTER TABLE participants ADD CONSTRAINT UNIQUE INDEX pseudo_unique (pseudo);"); mysql_query(" CREATE TABLE IF NOT EXISTS periodes ( id mediumint(3) unsigned NOT NULL auto_increment,