2011-05-15 01:32:47 +02:00
< ? php
//==========================================================================
//
//Université de Strasbourg - Direction Informatique
//Auteur : Guilhem BORGHESI
//Création : Février 2008
//
//borghesi@unistra.fr
//
//Ce logiciel est régi par la licence CeCILL-B soumise au droit français et
//respectant les principes de diffusion des logiciels libres. Vous pouvez
//utiliser, modifier et/ou redistribuer ce programme sous les conditions
//de la licence CeCILL-B telle que diffusée par le CEA, le CNRS et l'INRIA
//sur le site "http://www.cecill.info".
//
//Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
//pris connaissance de la licence CeCILL-B, et que vous en avez accepté les
//termes. Vous pouvez trouver une copie de la licence dans le fichier LICENCE.
//
//==========================================================================
//
//Université de Strasbourg - Direction Informatique
//Author : Guilhem BORGHESI
//Creation : Feb 2008
//
//borghesi@unistra.fr
//
//This software is governed by the CeCILL-B license under French law and
//abiding by the rules of distribution of free software. You can use,
//modify and/ or redistribute the software under the terms of the CeCILL-B
//license as circulated by CEA, CNRS and INRIA at the following URL
//"http://www.cecill.info".
//
//The fact that you are presently reading this means that you have had
//knowledge of the CeCILL-B license and that you accept its terms. You can
//find a copy of this license in the file LICENSE.
//
//==========================================================================
session_start ();
include_once ( 'creation_sondage.php' );
2013-03-13 18:29:48 +01:00
if ( is_readable ( 'bandeaux_local.php' )) {
2011-05-15 03:56:54 +02:00
include_once ( 'bandeaux_local.php' );
} else {
include_once ( 'bandeaux.php' );
2011-05-15 01:32:47 +02:00
}
2011-05-15 03:56:54 +02:00
//si les variables de session ne snot pas valides, il y a une erreur
2011-05-15 05:56:11 +02:00
if ( ! issetAndNoEmpty ( 'nom' , $_SESSION ) && ! issetAndNoEmpty ( 'adresse' , $_SESSION ) && ! issetAndNoEmpty ( 'commentaires' , $_SESSION ) && ! issetAndNoEmpty ( 'mail' , $_SESSION )) {
2011-05-15 03:56:54 +02:00
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">' . " \n " ;
echo '<html>' . " \n " ;
echo '<head>' . " \n " ;
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . " \n " ;
echo '<title>' . NOMAPPLICATION . '</title>' . " \n " ;
echo '<link rel="stylesheet" type="text/css" href="style.css">' . " \n " ;
echo '</head>' . " \n " ;
echo '<body>' . " \n " ;
2011-06-23 16:52:10 +02:00
framanav ();
2011-05-15 03:56:54 +02:00
logo ();
bandeau_tete ();
bandeau_titre ( _ ( " Error! " ));
2011-06-23 01:21:56 +02:00
echo '<div class=corpscentre corps>' . " \n " ;
2011-05-15 03:56:54 +02:00
print " <H2> " . _ ( " You haven't filled the first section of the poll creation. " ) . " !</H2> " . " \n " ;
print _ ( " Back to the homepage of " ) . ' ' . '<a href="index.php">' . NOMAPPLICATION . '</a>.' . " \n " ;
echo '<br><br><br>' . " \n " ;
echo '</div>' . " \n " ;
//bandeau de pied
//sur_bandeau_pied();
bandeau_pied ();
echo '</body>' . " \n " ;
echo '</html>' . " \n " ;
} else { //sinon on peut afficher le calendrier normalement
//partie creation du sondage dans la base SQL
//On prépare les données pour les inserer dans la base
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'confirmation' ) || issetAndNoEmpty ( 'confirmation_x' )) {
if ( issetAndNoEmpty ( 'totalchoixjour' , $_SESSION ) === true ) {
for ( $i = 0 ; $i < count ( $_SESSION [ " totalchoixjour " ]); $i ++ ) {
if ( $_SESSION [ " horaires $i " ][ 0 ] == " " && $_SESSION [ " horaires $i " ][ 1 ] == " " && $_SESSION [ " horaires $i " ][ 2 ] == " " && $_SESSION [ " horaires $i " ][ 3 ] == " " && $_SESSION [ " horaires $i " ][ 4 ] == " " ) {
$choixdate .= " , " ;
$choixdate .= $_SESSION [ " totalchoixjour " ][ $i ];
} else {
for ( $j = 0 ; $j < $_SESSION [ " nbrecaseshoraires " ]; $j ++ ) {
if ( $_SESSION [ " horaires $i " ][ $j ] != " " ) {
$choixdate .= " , " ;
$choixdate .= $_SESSION [ " totalchoixjour " ][ $i ];
$choixdate .= " @ " ;
2011-05-29 03:39:36 +02:00
// On remplace la virgule et l'arobase pour ne pas avoir de problème par la suite
$choixdate .= str_replace ( array ( ',' , '@' ), array ( ',' , '@' ), $_SESSION [ " horaires $i " ][ $j ]);
2011-05-15 05:56:11 +02:00
}
2011-05-15 03:56:54 +02:00
}
}
}
}
$_SESSION [ " toutchoix " ] = substr ( " $choixdate " , 1 );
ajouter_sondage ();
}
//nombre de cases par défaut
2011-05-15 05:56:11 +02:00
if ( ! issetAndNoEmpty ( 'nbrecaseshoraires' , $_SESSION )) {
2011-05-15 03:56:54 +02:00
$_SESSION [ " nbrecaseshoraires " ] = 5 ;
2011-05-15 05:56:11 +02:00
} elseif (( issetAndNoEmpty ( 'ajoutcases' ) || issetAndNoEmpty ( 'ajoutcases_x' )) && $_SESSION [ " nbrecaseshoraires " ] == 5 ) {
2011-05-15 03:56:54 +02:00
$_SESSION [ " nbrecaseshoraires " ] = 10 ;
}
//valeurs de la date du jour actuel
$jourAJ = date ( " j " );
$moisAJ = date ( " n " );
$anneeAJ = date ( " Y " );
2011-05-15 05:56:11 +02:00
// Initialisation des jour, mois et année
if ( issetAndNoEmpty ( 'jour' , $_SESSION ) === false ) {
$_SESSION [ 'jour' ] = date ( 'j' );
}
if ( issetAndNoEmpty ( 'mois' , $_SESSION ) === false ) {
$_SESSION [ 'mois' ] = date ( 'n' );
}
if ( issetAndNoEmpty ( 'annee' , $_SESSION ) === false ) {
$_SESSION [ 'annee' ] = date ( 'Y' );
}
2011-05-15 03:56:54 +02:00
//mise a jour des valeurs de session si bouton retour a aujourd'hui
2011-05-15 05:56:11 +02:00
if (( ! issetAndNoEmpty ( 'anneeavant_x' ) && ! issetAndNoEmpty ( 'anneeapres_x' ) && ! issetAndNoEmpty ( 'moisavant_x' ) && ! issetAndNoEmpty ( 'moisapres_x' ) && ! issetAndNoEmpty ( 'choixjourajout' )) && ! issetAndNoEmpty ( 'choixjourretrait' ) || ( issetAndNoEmpty ( 'retourmois' ) || issetAndNoEmpty ( 'retourmois_x' ))){
2011-05-15 03:56:54 +02:00
$_SESSION [ " jour " ] = date ( " j " );
$_SESSION [ " mois " ] = date ( " n " );
$_SESSION [ " annee " ] = date ( " Y " );
}
//mise a jour des valeurs de session si mois avant
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'moisavant' ) || issetAndNoEmpty ( 'moisavant_x' )) {
if ( $_SESSION [ " mois " ] == 1 ) {
$_SESSION [ " mois " ] = 12 ;
$_SESSION [ " annee " ] = $_SESSION [ " annee " ] - 1 ;
2011-05-15 03:56:54 +02:00
} else {
$_SESSION [ " mois " ] -= 1 ;
}
//On sauvegarde les heures deja entrées
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'totalchoixjour' , $_SESSION ) === true ) {
for ( $i = 0 ; $i < count ( $_SESSION [ " totalchoixjour " ]); $i ++ ) {
//affichage des 5 cases horaires
for ( $j = 0 ; $j < $_SESSION [ " nbrecaseshoraires " ]; $j ++ ) {
$_SESSION [ " horaires $i " ][ $j ] = $_POST [ " horaires $i " ][ $j ];
}
2011-05-15 03:56:54 +02:00
}
}
}
//mise a jour des valeurs de session si mois apres
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'moisapres' ) || issetAndNoEmpty ( 'moisapres_x' )) {
if ( $_SESSION [ " mois " ] == 12 ) {
$_SESSION [ " mois " ] = 1 ;
2011-05-15 03:56:54 +02:00
$_SESSION [ " annee " ] += 1 ;
} else {
$_SESSION [ " mois " ] += 1 ;
}
//On sauvegarde les heures deja entrées
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'totalchoixjour' , $_SESSION ) === true ) {
for ( $i = 0 ; $i < count ( $_SESSION [ " totalchoixjour " ]); $i ++ ) {
//affichage des 5 cases horaires
for ( $j = 0 ; $j < $_SESSION [ " nbrecaseshoraires " ]; $j ++ ) {
$_SESSION [ " horaires $i " ][ $j ] = $_POST [ " horaires $i " ][ $j ];
}
2011-05-15 03:56:54 +02:00
}
}
}
//mise a jour des valeurs de session si annee avant
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'anneeavant' ) || issetAndNoEmpty ( 'anneeavant_x' )) {
2011-05-15 03:56:54 +02:00
$_SESSION [ " annee " ] -= 1 ;
//On sauvegarde les heures deja entrées
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'totalchoixjour' , $_SESSION ) === true ) {
for ( $i = 0 ; $i < count ( $_SESSION [ " totalchoixjour " ]); $i ++ ) {
//affichage des 5 cases horaires
for ( $j = 0 ; $j < $_SESSION [ " nbrecaseshoraires " ]; $j ++ ) {
$_SESSION [ " horaires $i " ][ $j ] = $_POST [ " horaires $i " ][ $j ];
}
2011-05-15 03:56:54 +02:00
}
}
}
//mise a jour des valeurs de session si annee apres
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'anneeapres' ) || issetAndNoEmpty ( 'anneeapres_x' )) {
2011-05-15 03:56:54 +02:00
$_SESSION [ " annee " ] += 1 ;
//On sauvegarde les heures deja entrées
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'totalchoixjour' , $_SESSION ) === true ) {
for ( $i = 0 ; $i < count ( $_SESSION [ " totalchoixjour " ]); $i ++ ) {
//affichage des 5 cases horaires
for ( $j = 0 ; $j < $_SESSION [ " nbrecaseshoraires " ]; $j ++ ) {
$_SESSION [ " horaires $i " ][ $j ] = $_POST [ " horaires $i " ][ $j ];
}
2011-05-15 03:56:54 +02:00
}
}
}
//valeurs du nombre de jour dans le mois et du premier jour du mois
2011-05-15 05:56:11 +02:00
$nbrejourmois = date ( " t " , mktime ( 0 , 0 , 0 , $_SESSION [ " mois " ], 1 , $_SESSION [ " annee " ]));
$premierjourmois = date ( " N " , mktime ( 0 , 0 , 0 , $_SESSION [ " mois " ], 1 , $_SESSION [ " annee " ])) - 1 ;
2011-05-15 03:56:54 +02:00
//le format du sondage est DATE
2011-05-15 05:56:11 +02:00
$_SESSION [ " formatsondage " ] = " D " . $_SESSION [ " studsplus " ];
2011-05-15 03:56:54 +02:00
//traduction de la valeur du mois
if ( is_integer ( $_SESSION [ " mois " ]) && $_SESSION [ " mois " ] > 0 && $_SESSION [ " mois " ] < 13 ) {
$motmois = strftime ( '%B' , mktime ( 0 , 0 , 0 , $_SESSION [ " mois " ], 10 ));
} else {
$motmois = strftime ( '%B' );
}
//debut de la page web
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">' . " \n " ;
echo '<html>' . " \n " ;
echo '<head>' . " \n " ;
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . " \n " ;
echo '<title>' . NOMAPPLICATION . '</title>' . " \n " ;
echo '<link rel="stylesheet" type="text/css" href="style.css">' . " \n " ;
echo '<script type="text/javascript" src="block_enter.js"></script>' ;
echo '</head>' . " \n " ;
echo '<body>' . " \n " ;
//Debut du formulaire et bandeaux de tete
2013-03-13 18:29:48 +01:00
framanav ();
2011-05-15 03:56:54 +02:00
logo ();
bandeau_tete ();
bandeau_titre ( _ ( " Poll dates (2 on 2) " ));
sous_bandeau_choix ();
2013-03-13 18:29:48 +01:00
echo '<form name="formulaire" action="choix_date.php" method="POST" onkeypress="javascript:process_keypress(event)">' . " \n " ;
2011-05-15 03:56:54 +02:00
2011-06-23 01:21:56 +02:00
//ajout pyg pour la cohérence graphique
echo ' <div class="corps">' ;
2011-05-15 03:56:54 +02:00
//affichage de l'aide pour les jours
2011-06-23 01:21:56 +02:00
echo '<div class="bodydate">' . " \n " ;
2011-05-15 03:56:54 +02:00
echo _ ( " Select your dates amoung the free days (green). The selected days are in blue.<br> You can unselect a day previously selected by clicking again on it. " ) . " \n " ;
echo '</div>' . " \n " ;
//debut du tableau qui affiche le calendrier
echo '<div class=calendrier>' . " \n " ;
echo '<table align=center>' . " \n " ;
2013-03-13 19:15:21 +01:00
echo '<tr><td><input type="image" name="anneeavant" value="<<" src="images/rewind.png"></td><td><input type="image" name="moisavant" value="<" src="images/previous.png"></td><td align="center" class="choix_date_mois"> ' . $motmois . ' ' . $_SESSION [ " annee " ] . ' </td><td><input type="image" name="moisapres" value=">" src="images/next.png"></td><td><input type="image" name="anneeapres" value=">>" src="images/fforward.png"></td><td></td><td></td><td></td><td></td><td></td><td><input type="image" name="retourmois" value="Aujourd\'hui" src="images/reload.png"></td></tr>' . " \n " ;
2011-05-15 03:56:54 +02:00
echo '</table>' . " \n " ;
echo '<table>' . " \n " ;
echo '<tr>' . " \n " ;
//affichage des jours de la semaine en haut du tableau
for ( $i = 0 ; $i < 7 ; $i ++ ) {
2011-05-15 05:56:11 +02:00
echo '<td class="joursemaine">' . strftime ( '%A' , mktime ( 0 , 0 , 0 , 0 , $i , 10 )) . '</td>' ;
2011-05-15 03:56:54 +02:00
}
echo '</tr>' . " \n " ;
//ajout d'une entrée dans la variable de session qui contient toutes les dates
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'choixjourajout' )) {
2011-05-15 03:56:54 +02:00
if ( ! isset ( $_SESSION [ " totalchoixjour " ])) {
$_SESSION [ " totalchoixjour " ] = array ();
}
// Test pour éviter les doublons dans la variable qui contient toutes les dates
2011-05-15 05:56:11 +02:00
$journeuf = true ;
if ( issetAndNoEmpty ( 'totalchoixjour' , $_SESSION ) === true && issetAndNoEmpty ( 'choixjourajout' ) === true ) {
for ( $i = 0 ; $i < count ( $_SESSION [ " totalchoixjour " ]); $i ++ ) {
if ( $_SESSION [ " totalchoixjour " ][ $i ] == mktime ( 0 , 0 , 0 , $_SESSION [ " mois " ], $_POST [ " choixjourajout " ][ 0 ], $_SESSION [ " annee " ])) {
$journeuf = false ;
}
2011-05-15 03:56:54 +02:00
}
}
// Si le test est passé, alors on insere la valeur dans la variable de session qui contient les dates
2011-05-15 05:56:11 +02:00
if ( $journeuf && issetAndNoEmpty ( 'choixjourajout' ) === true ) {
array_push ( $_SESSION [ " totalchoixjour " ], mktime ( 0 , 0 , 0 , $_SESSION [ " mois " ], $_POST [ " choixjourajout " ][ 0 ], $_SESSION [ " annee " ]));
2011-05-15 03:56:54 +02:00
sort ( $_SESSION [ " totalchoixjour " ]);
2011-05-15 05:56:11 +02:00
$cle = array_search ( mktime ( 0 , 0 , 0 , $_SESSION [ " mois " ], $_POST [ " choixjourajout " ][ 0 ], $_SESSION [ " annee " ]), $_SESSION [ " totalchoixjour " ]);
2011-05-15 03:56:54 +02:00
//On sauvegarde les heures deja entrées
2011-05-15 05:56:11 +02:00
for ( $i = 0 ; $i < $cle ; $i ++ ) {
for ( $j = 0 ; $j < $_SESSION [ " nbrecaseshoraires " ]; $j ++ ) {
if ( issetAndNoEmpty ( 'horaires' . $i ) === true && issetAndNoEmpty ( $i , $_POST [ 'horaires' . $i ]) === true ) {
$_SESSION [ " horaires $i " ][ $j ] = $_POST [ " horaires $i " ][ $j ];
}
2011-05-15 03:56:54 +02:00
}
}
2011-05-15 05:56:11 +02:00
for ( $i = $cle ; $i < count ( $_SESSION [ " totalchoixjour " ]); $i ++ ) {
$k = $i + 1 ;
if ( issetAndNoEmpty ( 'horaires' . $i ) === true && issetAndNoEmpty ( $i , $_POST [ 'horaires' . $i ]) === true ) {
for ( $j = 0 ; $j < $_SESSION [ " nbrecaseshoraires " ]; $j ++ ) {
$_SESSION [ " horaires $k " ][ $j ] = $_POST [ " horaires $i " ][ $j ];
}
2011-05-15 03:56:54 +02:00
}
}
unset ( $_SESSION [ " horaires $cle " ]);
}
}
//retrait d'une entrée dans la variable de session qui contient toutes les dates
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'choixjourretrait' )) {
2011-05-15 03:56:54 +02:00
//On sauvegarde les heures deja entrées
2011-05-15 05:56:11 +02:00
for ( $i = 0 ; $i < count ( $_SESSION [ " totalchoixjour " ]); $i ++ ) {
2011-05-15 03:56:54 +02:00
//affichage des 5 cases horaires
2011-05-15 05:56:11 +02:00
for ( $j = 0 ; $j < $_SESSION [ " nbrecaseshoraires " ]; $j ++ ) {
$_SESSION [ " horaires $i " ][ $j ] = $_POST [ " horaires $i " ][ $j ];
2011-05-15 03:56:54 +02:00
}
}
2011-05-15 05:56:11 +02:00
for ( $i = 0 ; $i < count ( $_SESSION [ " totalchoixjour " ]); $i ++ ) {
if ( $_SESSION [ " totalchoixjour " ][ $i ] == mktime ( 0 , 0 , 0 , $_SESSION [ " mois " ], $_POST [ " choixjourretrait " ][ 0 ], $_SESSION [ " annee " ])) {
for ( $j = $i ; $j < count ( $_SESSION [ " totalchoixjour " ]); $j ++ ) {
$k = $j + 1 ;
$_SESSION [ " horaires $j " ] = $_SESSION [ " horaires $k " ];
2011-05-15 03:56:54 +02:00
}
2011-05-15 05:56:11 +02:00
array_splice ( $_SESSION [ " totalchoixjour " ], $i , 1 );
2011-05-15 03:56:54 +02:00
}
}
}
//report des horaires dans toutes les cases
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'reporterhoraires' )) {
$_SESSION [ " horaires0 " ] = $_POST [ " horaires0 " ];
for ( $i = 0 ; $i < count ( $_SESSION [ " totalchoixjour " ]); $i ++ ) {
$j = $i + 1 ;
$_SESSION [ " horaires $j " ] = $_SESSION [ " horaires $i " ];
2011-05-15 03:56:54 +02:00
}
}
//report des horaires dans toutes les cases
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'resethoraires' )) {
for ( $i = 0 ; $i < count ( $_SESSION [ " totalchoixjour " ]); $i ++ ) {
2011-05-15 03:56:54 +02:00
unset ( $_SESSION [ " horaires $i " ]);
}
}
// affichage du calendrier
echo '<tr>' . " \n " ;
2011-05-15 05:56:11 +02:00
for ( $i = 0 ; $i < $nbrejourmois + $premierjourmois ; $i ++ ) {
$numerojour = $i - $premierjourmois + 1 ;
2011-05-15 03:56:54 +02:00
// On saute a la ligne tous les 7 jours
2011-05-15 05:56:11 +02:00
if (( $i % 7 ) == 0 && $i != 0 ) {
2011-05-15 03:56:54 +02:00
echo '</tr><tr>' . " \n " ;
}
// On affiche les jours precedants en gris et incliquables
2011-05-15 05:56:11 +02:00
if ( $i < $premierjourmois ) {
2011-05-15 03:56:54 +02:00
echo '<td class=avant></td>' . " \n " ;
} else {
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'totalchoixjour' , $_SESSION ) === true ) {
for ( $j = 0 ; $j < count ( $_SESSION [ " totalchoixjour " ]); $j ++ ) {
//affichage des boutons ROUGES
if ( date ( " j " , $_SESSION [ " totalchoixjour " ][ $j ]) == $numerojour && date ( " n " , $_SESSION [ " totalchoixjour " ][ $j ]) == $_SESSION [ " mois " ] && date ( " Y " , $_SESSION [ " totalchoixjour " ][ $j ]) == $_SESSION [ " annee " ]) {
echo '<td align=center class=choisi><input type=submit class="bouton OFF" name="choixjourretrait[]" value="' . $numerojour . '"></td>' . " \n " ;
$dejafait = $numerojour ;
}
2011-05-15 03:56:54 +02:00
}
}
//Si pas de bouton ROUGE alors on affiche un bouton VERT ou GRIS avec le numéro du jour dessus
2011-05-15 05:56:11 +02:00
if ( isset ( $dejafait ) === false || $dejafait != $numerojour ){
2011-05-15 03:56:54 +02:00
//bouton vert
2011-05-15 05:56:11 +02:00
if (( $numerojour >= $jourAJ && $_SESSION [ " mois " ] == $moisAJ && $_SESSION [ " annee " ] == $anneeAJ ) || ( $_SESSION [ " mois " ] > $moisAJ && $_SESSION [ " annee " ] == $anneeAJ ) || $_SESSION [ " annee " ] > $anneeAJ ) {
2011-05-15 03:56:54 +02:00
echo '<td align=center class=libre><input type=submit class="bouton ON" name="choixjourajout[]" value="' . $numerojour . '"></td>' . " \n " ;
} else { //bouton gris
echo '<td class=avant>' . $numerojour . '</td>' . " \n " ;
}
}
}
}
//fin du tableau
echo '</tr>' . " \n " ;
echo '</table>' . " \n " ;
echo '</div>' . " \n " ;
//traitement de l'entrée des heures dans les cases texte
$errheure = $erreur = false ;
2011-06-23 01:21:56 +02:00
if ( issetAndNoEmpty ( 'choixheures' ) || issetAndNoEmpty ( 'choixheures_x' ) ) {
2011-05-15 03:56:54 +02:00
//On sauvegarde les heures deja entrées
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'totalchoixjour' , $_SESSION ) === true && issetAndNoEmpty ( 'nbrecaseshoraires' , $_SESSION ) === true ) {
for ( $i = 0 ; $i < count ( $_SESSION [ " totalchoixjour " ]); $i ++ ) {
//affichage des 5 cases horaires
for ( $j = 0 ; $j < $_SESSION [ " nbrecaseshoraires " ]; $j ++ ) {
$_SESSION [ " horaires $i " ][ $j ] = $_POST [ " horaires $i " ][ $j ];
}
2011-05-15 03:56:54 +02:00
}
}
//affichage des horaires
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'totalchoixjour' , $_SESSION ) === true && issetAndNoEmpty ( 'nbrecaseshoraires' , $_SESSION ) === true ) {
for ( $i = 0 ; $i < count ( $_SESSION [ " totalchoixjour " ]); $i ++ ) {
//affichage des 5 cases horaires
for ( $j = 0 ; $j < $_SESSION [ " nbrecaseshoraires " ]; $j ++ ) {
$case = $j + 1 ;
2011-05-15 03:56:54 +02:00
2011-05-15 05:56:11 +02:00
if ( isset ( $_POST [ 'horaires' . $i ]) === false || isset ( $_POST [ 'horaires' . $i ][ $j ]) === false ) {
2011-05-15 03:56:54 +02:00
$errheure [ $i ][ $j ] = true ;
$erreur = true ;
2011-05-15 05:56:11 +02:00
$_SESSION [ " horaires $i " ][ $j ] = $_POST [ " horaires $i " ][ $j ];
continue ;
2011-05-15 03:56:54 +02:00
}
2011-05-15 05:56:11 +02:00
//si c'est un creneau type 8:00-11:00
if ( preg_match ( " /( \ d { 1,2}: \ d { 2})-( \ d { 1,2}: \ d { 2})/ " , $_POST [ " horaires $i " ][ $j ], $creneaux )) {
//on recupere les deux parties du preg_match qu'on redécoupe autour des ":"
$debutcreneau = explode ( " : " , $creneaux [ 1 ]);
$fincreneau = explode ( " : " , $creneaux [ 2 ]);
//comparaison des heures de fin et de debut
//si correctes, on entre les données dans la variables de session
if ( $debutcreneau [ 0 ] < 24 && $fincreneau [ 0 ] < 24 && $debutcreneau [ 1 ] < 60 && $fincreneau [ 1 ] < 60 && ( $debutcreneau [ 0 ] < $fincreneau [ 0 ] || ( $debutcreneau [ 0 ] == $fincreneau [ 0 ] && $debutcreneau [ 1 ] < $fincreneau [ 1 ]))) {
$_SESSION [ " horaires $i " ][ $j ] = $creneaux [ 1 ] . '-' . $creneaux [ 2 ];
} else { //sinon message d'erreur et nettoyage de la case
$errheure [ $i ][ $j ] = true ;
$erreur = true ;
}
} elseif ( preg_match ( " ;^( \ d { 1,2}h \ d { 0,2})-( \ d { 1,2}h \ d { 0,2}) $ ;i " , $_POST [ " horaires $i " ][ $j ], $creneaux )) { //si c'est un creneau type 8h00-11h00
//on recupere les deux parties du preg_match qu'on redécoupe autour des "H"
$debutcreneau = preg_split ( " /h/i " , $creneaux [ 1 ]);
$fincreneau = preg_split ( " /h/i " , $creneaux [ 2 ]);
//comparaison des heures de fin et de debut
//si correctes, on entre les données dans la variables de session
if ( $debutcreneau [ 0 ] < 24 && $fincreneau [ 0 ] < 24 && $debutcreneau [ 1 ] < 60 && $fincreneau [ 1 ] < 60 && ( $debutcreneau [ 0 ] < $fincreneau [ 0 ] || ( $debutcreneau [ 0 ] == $fincreneau [ 0 ] && $debutcreneau [ 1 ] < $fincreneau [ 1 ]))) {
$_SESSION [ " horaires $i " ][ $j ] = $creneaux [ 1 ] . '-' . $creneaux [ 2 ];
} else { //sinon message d'erreur et nettoyage de la case
$errheure [ $i ][ $j ] = true ;
$erreur = true ;
}
} elseif ( preg_match ( " ;^( \ d { 1,2}):( \ d { 2}) $ ; " , $_POST [ " horaires $i " ][ $j ], $heures )) { //si c'est une heure simple type 8:00
//si valeures correctes, on entre les données dans la variables de session
if ( $heures [ 1 ] < 24 && $heures [ 2 ] < 60 ) {
$_SESSION [ " horaires $i " ][ $j ] = $heures [ 0 ];
} else { //sinon message d'erreur et nettoyage de la case
$errheure [ $i ][ $j ] = true ;
$erreur = true ;
}
} elseif ( preg_match ( " ;^( \ d { 1,2})h( \ d { 0,2}) $ ;i " , $_POST [ " horaires $i " ][ $j ], $heures )) { //si c'est une heure encore plus simple type 8h
//si valeures correctes, on entre les données dans la variables de session
if ( $heures [ 1 ] < 24 && $heures [ 2 ] < 60 ) {
$_SESSION [ " horaires $i " ][ $j ] = $heures [ 0 ];
} else { //sinon message d'erreur et nettoyage de la case
$errheure [ $i ][ $j ] = true ;
$erreur = true ;
}
} elseif ( preg_match ( " ;^( \ d { 1,2})-( \ d { 1,2}) $ ; " , $_POST [ " horaires $i " ][ $j ], $heures )) { //si c'est un creneau simple type 8-11
//si valeures correctes, on entre les données dans la variables de session
if ( $heures [ 1 ] < $heures [ 2 ] && $heures [ 1 ] < 24 && $heures [ 2 ] < 24 ) {
$_SESSION [ " horaires $i " ][ $j ] = $heures [ 0 ];
} else { //sinon message d'erreur et nettoyage de la case
$errheure [ $i ][ $j ] = true ;
$erreur = true ;
}
} elseif ( preg_match ( " ;^( \ d { 1,2})h-( \ d { 1,2})h $ ; " , $_POST [ " horaires $i " ][ $j ], $heures )) { //si c'est un creneau H type 8h-11h
//si valeures correctes, on entre les données dans la variables de session
if ( $heures [ 1 ] < $heures [ 2 ] && $heures [ 1 ] < 24 && $heures [ 2 ] < 24 ) {
$_SESSION [ " horaires $i " ][ $j ] = $heures [ 0 ];
} else { //sinon message d'erreur et nettoyage de la case
$errheure [ $i ][ $j ] = true ;
$erreur = true ;
}
} elseif ( $_POST [ " horaires $i " ][ $j ] == " " ) { //Si la case est vide
unset ( $_SESSION [ " horaires $i " ][ $j ]);
} else { //pour tout autre format, message d'erreur
2011-05-29 03:39:36 +02:00
//$errheure[$i][$j]=true;
//$erreur=true;
2011-05-15 05:56:11 +02:00
$_SESSION [ " horaires $i " ][ $j ] = $_POST [ " horaires $i " ][ $j ];
2011-05-15 03:56:54 +02:00
}
}
}
}
}
echo '<div class=bodydate>' . " \n " ;
//affichage de tous les jours choisis
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'totalchoixjour' , $_SESSION ) && ( ! issetAndNoEmpty ( 'choixheures_x' ) || $erreur )) {
2011-05-15 03:56:54 +02:00
//affichage des jours
echo '<br>' . " \n " ;
echo '<H2>' . _ ( " Selected days " ) . ' :</H2>' . " \n " ;
//affichage de l'aide pour les jours
2011-06-23 01:21:56 +02:00
//echo _("For each selected day, you can choose, or not, meeting hours in the following format :<br>- empty,<br>- \"8h\", \"8H\" or \"8:00\" to give a meeting's start hour,<br>- \"8-11\", \"8h-11h\", \"8H-11H\" ou \"8:00-11:00\" to give a meeting's start and end hour,<br>- \"8h15-11h15\", \"8H15-11H15\" ou \"8:15-11:15\" for the same thing but with minutes.") .'<br><br>'."\n";
echo _ ( " For each selected day, you can choose, or not, meeting hours (e.g.: \" 8h \" , \" 8:30 \" , \" 8 \" , \" evening \" , etc.) " ) . '<br><br>' . " \n " ;
2011-05-15 03:56:54 +02:00
echo '<table>' . " \n " ;
echo '<tr>' . " \n " ;
echo '<td></td>' . " \n " ;
2011-05-15 05:56:11 +02:00
for ( $i = 0 ; $i < $_SESSION [ " nbrecaseshoraires " ]; $i ++ ) {
$j = $i + 1 ;
2011-05-15 03:56:54 +02:00
echo '<td classe=somme>' . _ ( " Time " ) . ' ' . $j . '</center></td>' . " \n " ;
}
2011-05-15 05:56:11 +02:00
if ( $_SESSION [ " nbrecaseshoraires " ] < 10 ) {
2011-05-15 03:56:54 +02:00
echo '<td classe=somme><input type="image" name="ajoutcases" src="images/add-16.png"></td>' . " \n " ;
}
echo '</tr>' . " \n " ;
//affichage de la liste des jours choisis
for ( $i = 0 ; $i < count ( $_SESSION [ " totalchoixjour " ]); $i ++ ) {
echo '<tr>' . " \n " ;
if ( $_SESSION [ " langue " ] == " EN " ) {
2011-05-15 05:56:11 +02:00
echo '<td>' . date ( " l, F jS Y " , $_SESSION [ " totalchoixjour " ][ $i ]) . ' : </td>' . " \n " ;
2011-05-15 03:56:54 +02:00
} else {
2011-05-15 05:56:11 +02:00
echo '<td>' . strftime ( _ ( " %A, den %e. %B %Y " ), $_SESSION [ " totalchoixjour " ][ $i ]) . ' : </td>' . " \n " ;
2011-05-15 03:56:54 +02:00
}
$affichageerreurfindeligne = false ;
//affichage des cases d'horaires
for ( $j = 0 ; $j < $_SESSION [ " nbrecaseshoraires " ]; $j ++ ) {
//si on voit une erreur, le fond de la case est rouge
2011-05-15 05:56:11 +02:00
if ( isset ( $errheure [ $i ][ $j ]) && $errheure [ $i ][ $j ]) {
2011-05-15 03:56:54 +02:00
echo '<td><input type=text size="10" maxlength="11" name=horaires' . $i . '[] value="' . $_SESSION [ " horaires $i " ][ $j ] . '" style="background-color:#FF6666;"></td>' . " \n " ;
$affichageerreurfindeligne = true ;
} else { //sinon la case est vide normalement
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'horaires' . $i , $_SESSION ) === false || issetAndNoEmpty ( $j , $_SESSION [ 'horaires' . $i ]) === false ) {
if ( issetAndNoEmpty ( 'horaires' . $i , $_SESSION ) === true ) {
$_SESSION [ " horaires $i " ][ $j ] = '' ;
} else {
$_SESSION [ " horaires $i " ] = array ();
$_SESSION [ " horaires $i " ][ $j ] = '' ;
}
}
2011-05-15 03:56:54 +02:00
echo '<td><input type=text size="10" maxlength="11" name=horaires' . $i . '[] value="' . $_SESSION [ " horaires $i " ][ $j ] . '"></td>' . " \n " ;
}
}
if ( $affichageerreurfindeligne ) {
echo '<td><b><font color=#FF0000>' . _ ( " Bad format! " ) . '</font></b></td>' . " \n " ;
}
echo '</tr>' . " \n " ;
}
echo '</table>' . " \n " ;
//affichage des boutons de formulaire pour annuler, effacer les jours ou créer le sondage
echo '<table>' . " \n " ;
echo '<tr>' . " \n " ;
echo '<td><input type=submit name="reset" value="' . _ ( " Remove all days " ) . '"></td><td><input type=submit name="reporterhoraires" value="' . _ ( " Copy hours of the first day " ) . '"></td><td><input type=submit name="resethoraires" value="' . _ ( " Remove all hours " ) . '"></td></tr>' . " \n " ;
2011-06-23 01:21:56 +02:00
# echo'<tr><td><br></td></tr>'."\n";
# echo '<tr><td>'. _("Next") .'</td><td><input type=image name="choixheures" value="'. _("Next") .'" src="images/next-32.png"></td></tr>'."\n";
2011-05-15 03:56:54 +02:00
echo '</table>' . " \n " ;
2011-06-23 01:21:56 +02:00
//patch vraiment crado : on donne le nom "choixheures_x" au bouton pour éviter d'avoir à cleaner le code
echo '<br><button name="choixheures_x" value="' . _ ( " Next " ) . '" type="submit" class="button green poursuivre"><strong>' . _ ( 'Next' ) . '</strong> </button>' ;
echo '<div style="clear:both"></div>' ;
2011-05-15 03:56:54 +02:00
//si un seul jour et aucunes horaires choisies, : message d'erreur
2011-05-15 05:56:11 +02:00
if (( issetAndNoEmpty ( 'choixheures' ) || issetAndNoEmpty ( 'choixheures_x' )) && ( count ( $_SESSION [ " totalchoixjour " ]) == " 1 " && $_POST [ " horaires0 " ][ 0 ] == " " && $_POST [ " horaires0 " ][ 1 ] == " " && $_POST [ " horaires0 " ][ 2 ] == " " && $_POST [ " horaires0 " ][ 3 ] == " " && $_POST [ " horaires0 " ][ 4 ] == " " )) {
2011-05-15 03:56:54 +02:00
echo '<table><tr><td colspan=3><font color=#FF0000>' . _ ( " Enter more choices for the voters " ) . '</font><br></td></tr></table>' . " \n " ;
$erreur = true ;
}
2011-05-15 01:32:47 +02:00
}
2011-05-15 03:56:54 +02:00
//s'il n'y a pas d'erreur et que le bouton de creation est activé, on demande confirmation
2011-05-15 05:56:11 +02:00
if ( ! $erreur && ( issetAndNoEmpty ( 'choixheures' ) || issetAndNoEmpty ( 'choixheures_x' ))) {
2011-05-15 03:56:54 +02:00
$taille_tableau = sizeof ( $_SESSION [ " totalchoixjour " ]) - 1 ;
2011-06-23 01:21:56 +02:00
$jour_arret = $_SESSION [ " totalchoixjour " ][ $taille_tableau ] + 2592000 ;
2011-05-15 03:56:54 +02:00
if ( $_SESSION [ " langue " ] == " EN " ) {
2011-05-15 05:56:11 +02:00
$date_fin = date ( " l, F jS Y " , $jour_arret );
2011-05-15 03:56:54 +02:00
} else {
2011-05-15 05:56:11 +02:00
$date_fin = strftime ( _ ( " %A, den %e. %B %Y " ), $jour_arret );
2011-05-15 03:56:54 +02:00
}
echo '<br><div class="presentationdatefin">' . _ ( " Your poll will expire automatically 2 days after the last date of your poll. " ) . '<br></td></tr><tr><td><br>' . _ ( " Removal date " ) . ' : <b> ' . $date_fin . '</b><br><br>' . " \n " ;
echo '</div>' . " \n " ;
echo '<div class="presentationdatefin">' . " \n " ;
2013-03-13 19:15:21 +01:00
echo '<font color="#DD0000">' . _ ( " Once you have confirmed the creation of your poll, you will be automatically redirected on the page of your poll. <br><br>Then, you will receive quickly an email contening the link to your poll for sending it to the voters. " ) . '</font>' . " \n " ;
2011-05-15 03:56:54 +02:00
echo '</div>' . " \n " ;
// echo'<p class=affichageexport>'."\n";
// echo 'Pour finir la création du sondage, cliquez sur le bouton <img src="images/add-16.png" alt="ajout"> ci-dessous'."\n";
// echo '</p>'."\n";
2011-06-23 01:21:56 +02:00
//echo '<table>'."\n";
//echo '<tr><td>'. _("Back to hours") .'</td><td></td><td><input type="image" name="retourhoraires" src="images/back-32.png"></td></tr>'."\n";
//echo'<tr><td>'. _("Create the poll") .'</td><td></td><td><input type="image" name="confirmation" value="Valider la création" src="images/add.png"></td></tr>'."\n";
//echo '</table>'."\n";
echo '<br/><br/>' ;
// patch crado : on attribue les noms de boutons avec _x pour faire croire qu'on a cliqué sur une image
echo '<button name="retourhoraires_x" value="retourhoraires" type="submit" class="button red retour"><strong>' . _ ( 'Back to hours' ) . '</strong> </button>' ;
echo '<button name="confirmation_x" value="confirmation" type="submit" class="button green poursuivre"><strong>' . _ ( 'Create the poll' ) . '</strong> </button>' ;
echo '<div style="clear:both"></div>' ;
2011-05-15 03:56:54 +02:00
}
echo '</tr>' . " \n " ;
echo '</table>' . " \n " ;
echo '<a name=bas></a>' . " \n " ;
//fin du formulaire et bandeau de pied
echo '</form>' . " \n " ;
//bandeau de pied
2011-06-23 01:21:56 +02:00
//echo '<br><br><br><br>'."\n";
2011-05-15 03:56:54 +02:00
echo '</div>' . " \n " ;
2011-06-23 01:21:56 +02:00
echo '</div>' ; // ajout pyg pour cohérence graphique
2011-05-15 03:56:54 +02:00
bandeau_pied_mobile ();
echo '</body>' . " \n " ;
echo '</html>' . " \n " ;
//bouton de nettoyage de tous les jours choisis
2011-05-15 05:56:11 +02:00
if ( issetAndNoEmpty ( 'reset' )) {
for ( $i = 0 ; $i < count ( $_SESSION [ " totalchoixjour " ]); $i ++ ) {
for ( $j = 0 ; $j < $_SESSION [ " nbrecaseshoraires " ]; $j ++ ) {
2011-05-15 03:56:54 +02:00
unset ( $_SESSION [ " horaires $i " ][ $j ]);
}
}
unset ( $_SESSION [ " totalchoixjour " ]);
unset ( $_SESSION [ " nbrecaseshoraires " ]);
echo '<meta http-equiv="refresh" content="0">' ;
}
}