2013-04-09 23:05:50 +02:00
< ? php
/* Copyright ( C ) 2013 Laurent Destailleur < eldy @ users . sourceforge . net >
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http :// www . gnu . org / licenses />.
*/
/**
2013-08-22 16:49:23 +02:00
* \file htdocs / opensurvey / adminstuds_preview . php
2013-04-09 23:05:50 +02:00
* \ingroup opensurvey
* \brief Page to preview votes of a survey
*/
$res = 0 ;
require_once ( '../main.inc.php' );
require_once ( DOL_DOCUMENT_ROOT . " /core/lib/admin.lib.php " );
require_once ( DOL_DOCUMENT_ROOT . " /core/lib/files.lib.php " );
require_once ( DOL_DOCUMENT_ROOT . " /opensurvey/class/opensurveysondage.class.php " );
2013-06-05 16:24:32 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /opensurvey/fonctions.php " );
2013-04-09 23:05:50 +02:00
// Security check
if ( ! $user -> admin ) accessforbidden ();
// Init vars
$action = GETPOST ( 'action' );
$numsondageadmin = GETPOST ( " sondage " );
$numsondage = substr ( $numsondageadmin , 0 , 16 );
$object = new Opensurveysondage ( $db );
2013-06-05 16:24:32 +02:00
$result = $object -> fetch ( 0 , $numsondage );
2013-04-13 15:43:31 +02:00
if ( $result <= 0 ) dol_print_error ( '' , 'Failed to get survey id ' . $numsondage );
2013-04-09 23:05:50 +02:00
$nblignes = count ( $object -> fetch_lines ());
/*
* Actions
*/
2013-06-05 16:24:32 +02:00
$nbcolonnes = substr_count ( $object -> sujet , ',' ) + 1 ;
2013-04-09 23:05:50 +02:00
// Add vote
if ( isset ( $_POST [ " boutonp " ]) || isset ( $_POST [ " boutonp_x " ]))
{
if ( GETPOST ( 'nom' ))
{
$erreur_prenom = false ;
$nouveauchoix = '' ;
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ )
{
if ( isset ( $_POST [ " choix $i " ]) && $_POST [ " choix $i " ] == '1' )
{
$nouveauchoix .= " 1 " ;
}
else if ( isset ( $_POST [ " choix $i " ]) && $_POST [ " choix $i " ] == '2' )
{
$nouveauchoix .= " 2 " ;
}
else { // sinon c'est 0
$nouveauchoix .= " 0 " ;
}
}
2013-06-05 16:24:32 +02:00
$nom = substr ( GETPOST ( " nom " ), 0 , 64 );
2013-04-09 23:05:50 +02:00
// Check if vote already exists
$sql = 'SELECT id_users, nom' ;
2013-04-13 15:09:57 +02:00
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'opensurvey_user_studs' ;
$sql .= " WHERE id_sondage=' " . $db -> escape ( $numsondage ) . " ' AND nom = ' " . $db -> escape ( $nom ) . " ' " ;
2013-04-09 23:05:50 +02:00
$sql .= ' ORDER BY id_users' ;
$resql = $db -> query ( $sql );
$num_rows = $db -> num_rows ( $resql );
if ( $num_rows > 0 )
{
setEventMessage ( $langs -> trans ( " VoteNameAlreadyExists " ), 'errors' );
$error ++ ;
}
else
{
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'opensurvey_user_studs (nom, id_sondage, reponses)' ;
$sql .= " VALUES (' " . $db -> escape ( $nom ) . " ', ' " . $db -> escape ( $numsondage ) . " ',' " . $db -> escape ( $nouveauchoix ) . " ') " ;
$resql = $db -> query ( $sql );
if ( ! $resql ) dol_print_error ( $db );
}
}
}
// Update vote
$testmodifier = false ;
$testligneamodifier = false ;
$ligneamodifier = - 1 ;
for ( $i = 0 ; $i < $nblignes ; $i ++ )
{
if ( isset ( $_POST [ 'modifierligne' . $i ]))
{
$ligneamodifier = $i ;
$testligneamodifier = true ;
}
//test pour voir si une ligne est a modifier
if ( isset ( $_POST [ 'validermodifier' . $i ]))
{
$modifier = $i ;
$testmodifier = true ;
}
}
if ( $testmodifier )
{
//var_dump($_POST);exit;
$nouveauchoix = '' ;
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ )
{
//var_dump($_POST["choix$i"]);
if ( isset ( $_POST [ " choix $i " ]) && $_POST [ " choix $i " ] == '1' )
{
$nouveauchoix .= " 1 " ;
}
else if ( isset ( $_POST [ " choix $i " ]) && $_POST [ " choix $i " ] == '2' )
{
$nouveauchoix .= " 2 " ;
}
else { // sinon c'est 0
$nouveauchoix .= " 0 " ;
}
}
$idtomodify = $_POST [ " idtomodify " . $modifier ];
$sql = 'UPDATE ' . MAIN_DB_PREFIX . " opensurvey_user_studs " ;
$sql .= " SET reponses = ' " . $db -> escape ( $nouveauchoix ) . " ' " ;
$sql .= " WHERE id_users = ' " . $db -> escape ( $idtomodify ) . " ' " ;
dol_syslog ( " sql= " . $sql );
$resql = $db -> query ( $sql );
if ( ! $resql ) dol_print_error ( $db );
}
2013-06-05 16:24:32 +02:00
// Add column (not for date)
if ( GETPOST ( " ajoutercolonne " ) && GETPOST ( 'nouvellecolonne' ) && ( $object -> format == " A " || $object -> format == " A+ " ))
{
$nouveauxsujets = $object -> sujet ;
//on rajoute la valeur a la fin de tous les sujets deja entrés
$nouveauxsujets .= ',' ;
$nouveauxsujets .= str_replace ( array ( " , " , " @ " ), " " , $_POST [ " nouvellecolonne " ]) . ( empty ( $_POST [ " typecolonne " ]) ? '' : '@' . $_POST [ " typecolonne " ]);
//mise a jour avec les nouveaux sujets dans la base
2013-04-09 23:05:50 +02:00
$sql = 'UPDATE ' . MAIN_DB_PREFIX . " opensurvey_sondage " ;
$sql .= " SET sujet = ' " . $db -> escape ( $nouveauxsujets ) . " ' " ;
2013-06-05 16:24:32 +02:00
$sql .= " WHERE id_sondage = ' " . $db -> escape ( $numsondage ) . " ' " ;
2013-04-09 23:05:50 +02:00
dol_syslog ( " sql= " . $sql );
$resql = $db -> query ( $sql );
2013-06-05 16:24:32 +02:00
if ( ! $resql ) dol_print_error ( $db );
}
2013-04-09 23:05:50 +02:00
// Add column (with format date)
if ( isset ( $_POST [ " ajoutercolonne " ]) && ( $object -> format == " D " || $object -> format == " D+ " ))
{
$nouveauxsujets = $object -> sujet ;
if ( isset ( $_POST [ " nouveaujour " ]) && $_POST [ " nouveaujour " ] != " vide " &&
isset ( $_POST [ " nouveaumois " ]) && $_POST [ " nouveaumois " ] != " vide " &&
isset ( $_POST [ " nouvelleannee " ]) && $_POST [ " nouvelleannee " ] != " vide " ) {
$nouvelledate = dol_mktime ( 0 , 0 , 0 , $_POST [ " nouveaumois " ], $_POST [ " nouveaujour " ], $_POST [ " nouvelleannee " ]);
if ( isset ( $_POST [ " nouvelleheuredebut " ]) && $_POST [ " nouvelleheuredebut " ] != " vide " ){
$nouvelledate .= " @ " ;
$nouvelledate .= $_POST [ " nouvelleheuredebut " ];
$nouvelledate .= " h " ;
if ( $_POST [ " nouvelleminutedebut " ] != " vide " ) {
$nouvelledate .= $_POST [ " nouvelleminutedebut " ];
}
}
if ( isset ( $_POST [ " nouvelleheurefin " ]) && $_POST [ " nouvelleheurefin " ] != " vide " ){
$nouvelledate .= " - " ;
$nouvelledate .= $_POST [ " nouvelleheurefin " ];
$nouvelledate .= " h " ;
if ( $_POST [ " nouvelleminutefin " ] != " vide " ) {
$nouvelledate .= $_POST [ " nouvelleminutefin " ];
}
}
if ( $_POST [ " nouvelleheuredebut " ] == " vide " || ( isset ( $_POST [ " nouvelleheuredebut " ]) && isset ( $_POST [ " nouvelleheurefin " ]) && (( $_POST [ " nouvelleheuredebut " ] < $_POST [ " nouvelleheurefin " ]) || (( $_POST [ " nouvelleheuredebut " ] == $_POST [ " nouvelleheurefin " ]) && ( $_POST [ " nouvelleminutedebut " ] < $_POST [ " nouvelleminutefin " ]))))) {
$erreur_ajout_date = false ;
} else {
$erreur_ajout_date = " yes " ;
}
//on rajoute la valeur dans les valeurs
$datesbase = explode ( " , " , $object -> sujet );
2013-04-10 19:55:21 +02:00
$taillebase = count ( $datesbase );
2013-04-09 23:05:50 +02:00
//recherche de l'endroit de l'insertion de la nouvelle date dans les dates deja entrées dans le tableau
if ( $nouvelledate < $datesbase [ 0 ]) {
$cleinsertion = 0 ;
} elseif ( $nouvelledate > $datesbase [ $taillebase - 1 ]) {
$cleinsertion = count ( $datesbase );
} else {
2013-04-10 12:20:45 +02:00
$nbdatesbase = count ( $datesbase );
2013-04-13 15:09:57 +02:00
for ( $i = 0 ; $i < $nbdatesbase ; $i ++ )
2013-04-10 12:20:45 +02:00
{
2013-04-09 23:05:50 +02:00
$j = $i + 1 ;
if ( $nouvelledate > $datesbase [ $i ] && $nouvelledate < $datesbase [ $j ]) {
$cleinsertion = $j ;
}
}
}
array_splice ( $datesbase , $cleinsertion , 0 , $nouvelledate );
$cle = array_search ( $nouvelledate , $datesbase );
$dateinsertion = '' ;
2013-04-14 11:22:00 +02:00
$nbofdates = count ( $datesbase );
for ( $i = 0 ; $i < $nbofdates ; $i ++ ) {
2013-04-09 23:05:50 +02:00
$dateinsertion .= " , " ;
$dateinsertion .= $datesbase [ $i ];
}
$dateinsertion = substr ( " $dateinsertion " , 1 );
//mise a jour avec les nouveaux sujets dans la base
if ( isset ( $erreur_ajout_date ) && ! $erreur_ajout_date )
{
2013-06-05 16:24:32 +02:00
$sql = 'UPDATE ' . MAIN_DB_PREFIX . " opensurvey_sondage " ;
2013-04-09 23:05:50 +02:00
$sql .= " SET sujet = ' " . $db -> escape ( $dateinsertion ) . " ' " ;
2013-06-05 16:24:32 +02:00
$sql .= " WHERE id_sondage = ' " . $db -> escape ( $numsondage ) . " ' " ;
2013-04-09 23:05:50 +02:00
dol_syslog ( " sql= " . $sql );
2013-06-05 16:24:32 +02:00
$resql = $db -> query ( $sql );
if ( ! $resql ) dol_print_error ( $db );
2013-04-09 23:05:50 +02:00
if ( $nouvelledate > strtotime ( $object -> date_fin ))
{
$date_fin = $nouvelledate + 200000 ;
$sql = 'UPDATE ' . MAIN_DB_PREFIX . 'opensurvey_sondage' ;
$sql .= " SET date_fin = ' " . $db -> escape ( $date_fin ) . " ' " ;
$sql .= " WHERE id_sondage = ' " . $db -> escape ( $numsondage ) . " ' " ;
dol_syslog ( " sql= " . $sql );
$resql = $db -> query ( $sql );
2013-06-05 16:24:32 +02:00
if ( ! $resql ) dol_print_error ( $db );
2013-04-09 23:05:50 +02:00
}
}
$adresseadmin = $object -> mail_admin ;
}
else
{
$erreur_ajout_date = " yes " ;
}
}
// Delete line
for ( $i = 0 ; $i < $nblignes ; $i ++ )
{
if ( isset ( $_POST [ " effaceligne $i " ]) || isset ( $_POST [ 'effaceligne' . $i . '_x' ]))
{
$compteur = 0 ;
2013-06-05 16:24:32 +02:00
// Loop on each answer
$compteur = 0 ;
$sql = " SELECT id_users, nom, id_sondage, reponses " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " opensurvey_user_studs " ;
$sql .= " WHERE id_sondage = ' " . $db -> escape ( $numsondage ) . " ' " ;
dol_syslog ( 'sql=' . $sql );
$resql = $db -> query ( $sql );
if ( ! $resql ) dol_print_error ( $db );
$num = $db -> num_rows ( $resql );
while ( $compteur < $num )
{
2013-04-09 23:05:50 +02:00
$obj = $db -> fetch_object ( $resql );
if ( $compteur == $i )
{
$sql2 = 'DELETE FROM ' . MAIN_DB_PREFIX . 'opensurvey_user_studs' ;
$sql2 .= ' WHERE id_users = ' . $db -> escape ( $obj -> id_users );
$resql2 = $db -> query ( $sql2 );
}
$compteur ++ ;
}
}
}
// Delete column
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ )
{
if (( isset ( $_POST [ " effacecolonne $i " ]) || isset ( $_POST [ 'effacecolonne' . $i . '_x' ])) && $nbcolonnes > 1 )
{
$db -> begin ();
$toutsujet = explode ( " , " , $object -> sujet );
$j = 0 ;
$nouveauxsujets = '' ;
//parcours de tous les sujets actuels
while ( isset ( $toutsujet [ $j ]))
{
//si le sujet n'est pas celui qui a été effacé alors on concatene
if ( $i != $j )
{
if ( ! empty ( $nouveauxsujets )) $nouveauxsujets .= ',' ;
$nouveauxsujets .= $toutsujet [ $j ];
}
$j ++ ;
}
// Mise a jour des sujets dans la base
$sql = 'UPDATE ' . MAIN_DB_PREFIX . " opensurvey_sondage " ;
$sql .= " SET sujet = ' " . $db -> escape ( $nouveauxsujets ) . " ' WHERE id_sondage = ' " . $db -> escape ( $numsondage ) . " ' " ;
dol_syslog ( " sql= " . $sql );
$resql = $db -> query ( $sql );
if ( ! $resql ) dol_print_error ( $db );
// Clean current answer to remove deleted columns
2013-06-05 16:24:32 +02:00
$compteur = 0 ;
$sql = " SELECT id_users, nom, id_sondage, reponses " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " opensurvey_user_studs " ;
$sql .= " WHERE id_sondage = ' " . $db -> escape ( $numsondage ) . " ' " ;
dol_syslog ( 'sql=' . $sql );
$resql = $db -> query ( $sql );
if ( ! $resql )
{
dol_print_error ( $db );
exit ;
}
$num = $db -> num_rows ( $resql );
while ( $compteur < $num )
{
2013-04-09 23:05:50 +02:00
$obj = $db -> fetch_object ( $resql );
$newcar = '' ;
$ensemblereponses = $obj -> reponses ;
// parcours de toutes les réponses actuelles
for ( $j = 0 ; $j < $nbcolonnes ; $j ++ )
{
$car = substr ( $ensemblereponses , $j , 1 );
//si les reponses ne concerne pas la colonne effacée, on concatene
if ( $i != $j ) {
$newcar .= $car ;
}
}
// mise a jour des reponses utilisateurs dans la base
$sql2 = 'UPDATE ' . MAIN_DB_PREFIX . 'opensurvey_user_studs' ;
$sql2 .= " SET reponses = ' " . $db -> escape ( $newcar ) . " ' " ;
$sql2 .= " WHERE id_users = ' " . $db -> escape ( $obj -> id_users ) . " ' " ;
//print $sql2;
dol_syslog ( 'sql=' . $sql2 );
$resql2 = $db -> query ( $sql2 );
$compteur ++ ;
}
$db -> commit ();
}
}
/*
* View
*/
$form = new Form ( $db );
2013-06-05 16:24:32 +02:00
$result = $object -> fetch ( 0 , $numsondage );
if ( $result <= 0 )
{
print $langs -> trans ( " ErrorRecordNotFound " );
llxFooter ();
exit ;
}
2013-04-09 23:05:50 +02:00
$arrayofjs = array ();
$arrayofcss = array ( '/opensurvey/css/style.css' );
llxHeader ( '' , $object -> titre , 0 , 0 , 0 , 0 , $arrayofjs , $arrayofcss );
// Define format of choices
$toutsujet = explode ( " , " , $object -> sujet );
$listofanswers = array ();
foreach ( $toutsujet as $value )
{
$tmp = explode ( '@' , $value );
$listofanswers [] = array ( 'label' => $tmp [ 0 ], 'format' => ( $tmp [ 1 ] ? $tmp [ 1 ] : 'checkbox' ));
}
$toutsujet = str_replace ( " @ " , " <br> " , $toutsujet );
$toutsujet = str_replace ( " ° " , " ' " , $toutsujet );
print '<form name="formulaire4" action="#" method="POST" onkeypress="javascript:process_keypress(event)">' . " \n " ;
$head = array ();
$head [ 0 ][ 0 ] = 'adminstuds.php?sondage=' . $object -> id_sondage_admin ;
$head [ 0 ][ 1 ] = $langs -> trans ( " Card " );
$head [ 0 ][ 2 ] = 'general' ;
$h ++ ;
$head [ 1 ][ 0 ] = 'adminstuds_preview.php?sondage=' . $object -> id_sondage_admin ;
$head [ 1 ][ 1 ] = $langs -> trans ( " SurveyResults " ) . '/' . $langs -> trans ( " Preview " );
$head [ 1 ][ 2 ] = 'preview' ;
$h ++ ;
print dol_get_fiche_head ( $head , 'preview' , $langs -> trans ( " Survey " ), 0 , dol_buildpath ( '/opensurvey/img/object_opensurvey.png' , 1 ), 1 );
print '<table class="border" width="100%">' ;
$linkback = '<a href="' . dol_buildpath ( '/opensurvey/list.php' , 1 ) . ( ! empty ( $socid ) ? '?socid=' . $socid : '' ) . '">' . $langs -> trans ( " BackToList " ) . '</a>' ;
// Ref
print '<tr><td width="18%">' . $langs -> trans ( 'Ref' ) . '</td>' ;
print '<td colspan="3">' ;
print $form -> showrefnav ( $object , 'sondage' , $linkback , 1 , 'id_sondage_admin' , 'id_sondage_admin' );
print '</td>' ;
print '</tr>' ;
// Type
$type = ( $object -> format == " A " || $object -> format == " A+ " ) ? 'classic' : 'date' ;
print '<tr><td>' . $langs -> trans ( " Type " ) . '</td><td colspan="2">' ;
print img_picto ( '' , dol_buildpath ( '/opensurvey/img/' . ( $type == 'classic' ? 'chart-32.png' : 'calendar-32.png' ), 1 ), 'width="16"' , 1 );
print ' ' . $langs -> trans ( $type == 'classic' ? " TypeClassic " : " TypeDate " ) . '</td></tr>' ;
// Link
print '<tr><td>' . img_picto ( '' , 'object_globe.png' ) . ' ' . $langs -> trans ( " UrlForSurvey " , '' ) . '</td><td>' ;
// Define $urlwithroot
$urlwithouturlroot = preg_replace ( '/' . preg_quote ( DOL_URL_ROOT , '/' ) . '$/i' , '' , trim ( $dolibarr_main_url_root ));
$urlwithroot = $urlwithouturlroot . DOL_URL_ROOT ; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$url = $urlwithouturlroot . dol_buildpath ( '/opensurvey/public/studs.php' , 1 ) . '?sondage=' . $numsondage ;
$urlvcal = '<a href="' . $url . '" target="_blank">' . $url . '</a>' ;
print $urlvcal ;
print '</table>' ;
dol_fiche_end ();
print '</form>' . " \n " ;
print '<div class="tabsAction">' ;
print '<a class="butAction" href="public/exportcsv.php?sondage=' . $numsondage . '">' . $langs -> trans ( " ExportSpreadsheet " ) . ' (.CSV)' . '</a>' ;
print '</div>' ;
showlogo ();
// Add form to add a field
if ( GETPOST ( 'ajoutsujet' ))
{
//on recupere les données et les sujets du sondage
print '<form name="formulaire" action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' . " \n " ;
print '<input type="hidden" name="sondage" value="' . $numsondageadmin . '">' ;
print '<input type="hidden" name="backtourl" value="' . GETPOST ( 'backtourl' ) . '">' ;
print '<div class="center">' . " \n " ;
print " <br><br> " . " \n " ;
// Add new column
if ( $object -> format == " A " || $object -> format == " A+ " )
{
print $langs -> trans ( " AddNewColumn " ) . ' :<br><br>' ;
print $langs -> trans ( " Title " ) . ' <input type="text" name="nouvellecolonne" size="40"><br>' ;
$tmparray = array ( 'checkbox' => $langs -> trans ( " CheckBox " ), 'yesno' => $langs -> trans ( " YesNoList " ), 'foragainst' => $langs -> trans ( " PourContreList " ));
print $langs -> trans ( " Type " ) . ' ' . $form -> selectarray ( " typecolonne " , $tmparray , GETPOST ( 'typecolonne' )) . '<br><br>' ;
print '<input type="submit" class="button" name="ajoutercolonne" value="' . dol_escape_htmltag ( $langs -> trans ( " Add " )) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
print '<br><br>' . " \n " ;
}
else
{
//ajout d'une date avec creneau horaire
//print _("You can add a new scheduling date to your poll.<br> If you just want to add a new hour to an existant date, put the same date and choose a new hour.") .'<br><br> '."\n";
print $langs -> trans ( " AddADate " ) . ' :<br><br>' . " \n " ;
print '<select name="nouveaujour"> ' . " \n " ;
print '<OPTION VALUE="vide"></OPTION>' . " \n " ;
for ( $i = 1 ; $i < 32 ; $i ++ ){
print '<OPTION VALUE="' . $i . '">' . $i . '</OPTION>' . " \n " ;
}
print '</SELECT>' . " \n " ;
print '<select name="nouveaumois"> ' . " \n " ;
print '<OPTION VALUE="vide"></OPTION>' . " \n " ;
for ( $i = 1 ; $i < 13 ; $i ++ ) {
print '<OPTION VALUE="' . $i . '">' . strftime ( '%B' , mktime ( 0 , 0 , 0 , $i )) . '</OPTION>' . " \n " ;
}
print '</SELECT>' . " \n " ;
print '<select name="nouvelleannee"> ' . " \n " ;
print '<OPTION VALUE="vide"></OPTION>' . " \n " ;
2013-04-14 11:22:00 +02:00
$maxyear = date ( " Y " ) + 5 ;
for ( $i = date ( " Y " ); $i < $maxyear ; $i ++ )
{
2013-04-09 23:05:50 +02:00
print '<OPTION VALUE="' . $i . '">' . $i . '</OPTION>' . " \n " ;
}
print '</SELECT>' . " \n " ;
print '<br><br>' . $langs -> trans ( " AddStartHour " ) . ' : <br><br>' . " \n " ;
print '<select name="nouvelleheuredebut"> ' . " \n " ;
print '<OPTION VALUE="vide"></OPTION>' . " \n " ;
for ( $i = 0 ; $i < 24 ; $i ++ ) {
print '<OPTION VALUE="' . $i . '">' . $i . ' H</OPTION>' . " \n " ;
}
print '</SELECT>' . " \n " ;
print '<select name="nouvelleminutedebut"> ' . " \n " ;
print '<OPTION VALUE="vide"></OPTION>' . " \n " ;
print '<OPTION VALUE="00">00</OPTION>' . " \n " ;
print '<OPTION VALUE="15">15</OPTION>' . " \n " ;
print '<OPTION VALUE="30">30</OPTION>' . " \n " ;
print '<OPTION VALUE="45">45</OPTION>' . " \n " ;
print '</SELECT>' . " \n " ;
print '<br><br>' . $langs -> trans ( " AddEndHour " ) . ' : <br><br>' . " \n " ;
print '<select name="nouvelleheurefin"> ' . " \n " ;
print '<OPTION VALUE="vide"></OPTION>' . " \n " ;
for ( $i = 0 ; $i < 24 ; $i ++ ) {
print '<OPTION VALUE="' . $i . '">' . $i . ' H</OPTION>' . " \n " ;
}
print '</SELECT>' . " \n " ;
print '<select name="nouvelleminutefin"> ' . " \n " ;
print '<OPTION VALUE="vide"></OPTION>' . " \n " ;
print '<OPTION VALUE="00">00</OPTION>' . " \n " ;
print '<OPTION VALUE="15">15</OPTION>' . " \n " ;
print '<OPTION VALUE="30">30</OPTION>' . " \n " ;
print '<OPTION VALUE="45">45</OPTION>' . " \n " ;
print '</SELECT>' . " \n " ;
print '<br><br>' ;
print ' <input type="submit" class="button" name="ajoutercolonne" value="' . dol_escape_htmltag ( $langs -> trans ( " Add " )) . '">' . " \n " ;
print ' ' ;
print '<input type="submit" class="button" name="retoursondage" value="' . $langs -> trans ( " Cancel " ) . '">' ;
}
print '</form>' . " \n " ;
print '<br><br><br><br>' . " \n " ;
print '</div>' . " \n " ;
exit ;
}
print $langs -> trans ( " PollAdminDesc " , img_picto ( '' , 'cancel.png@opensurvey' ), img_picto ( '' , 'add-16.png@opensurvey' )) . '<br><br>' ;
print '<div class="corps"> ' . " \n " ;
//affichage du titre du sondage
$titre = str_replace ( " \\ " , " " , $object -> titre );
print '<strong>' . $titre . '</strong><br>' . " \n " ;
//affichage du nom de l'auteur du sondage
print $langs -> trans ( " InitiatorOfPoll " ) . ' : ' . $object -> nom_admin . '<br>' . " \n " ;
//affichage des commentaires du sondage
if ( $object -> commentaires )
{
print '<br>' . $langs -> trans ( " Description " ) . ' :<br>' . " \n " ;
$commentaires = dol_nl2br ( $object -> commentaires );
print $commentaires ;
print '<br>' . " \n " ;
}
print '</div>' . " \n " ;
$nbcolonnes = substr_count ( $object -> sujet , ',' ) + 1 ;
print '<form name="formulaire" action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' . " \n " ;
print '<input type="hidden" name="sondage" value="' . $numsondageadmin . '">' ;
print '<div class="cadre"> ' . " \n " ;
print '<br>' . " \n " ;
2013-04-13 15:43:31 +02:00
// Start to show survey result
2013-04-09 23:05:50 +02:00
print '<table class="resultats">' . " \n " ;
//reformatage des données des sujets du sondage
$toutsujet = explode ( " , " , $object -> sujet );
$toutsujet = str_replace ( " ° " , " ' " , $toutsujet );
print '<tr>' . " \n " ;
print '<td></td>' . " \n " ;
print '<td></td>' . " \n " ;
//boucle pour l'affichage des boutons de suppression de colonne
for ( $i = 0 ; isset ( $toutsujet [ $i ]); $i ++ ) {
print '<td class=somme><input type="image" name="effacecolonne' . $i . '" value="Effacer la colonne" src="' . dol_buildpath ( '/opensurvey/img/cancel.png' , 1 ) . '"></td>' . " \n " ;
}
print '</tr>' . " \n " ;
// Show choice titles
if ( $object -> format == " D " || $object -> format == " D+ " )
{
//affichage des sujets du sondage
print '<tr>' . " \n " ;
print '<td></td>' . " \n " ;
print '<td></td>' . " \n " ;
//affichage des années
$colspan = 1 ;
2013-04-14 11:22:00 +02:00
$nbofsujet = count ( $toutsujet );
for ( $i = 0 ; $i < $nbofsujet ; $i ++ )
2013-04-09 23:05:50 +02:00
{
$current = $toutsujet [ $i ];
if ( strpos ( $toutsujet [ $i ], '@' ) !== false ) {
$current = substr ( $toutsujet [ $i ], 0 , strpos ( $toutsujet [ $i ], '@' ));
}
if ( isset ( $toutsujet [ $i + 1 ]) && strpos ( $toutsujet [ $i + 1 ], '@' ) !== false ) {
$next = substr ( $toutsujet [ $i + 1 ], 0 , strpos ( $toutsujet [ $i + 1 ], '@' ));
} elseif ( isset ( $toutsujet [ $i + 1 ])) {
$next = $toutsujet [ $i + 1 ];
}
if ( isset ( $toutsujet [ $i + 1 ]) && strftime ( " %Y " , $current ) == strftime ( " %Y " , $next )){
$colspan ++ ;
} else {
print '<td colspan=' . $colspan . ' class="annee">' . strftime ( " %Y " , $current ) . '</td>' . " \n " ;
$colspan = 1 ;
}
}
print '<td class="annee"><a href="' . $_SERVER [ " PHP_SELF " ] . '?ajoutsujet=1&sondage=' . $object -> id_sondage_admin . '">' . $langs -> trans ( " Add " ) . '</a></td>' . " \n " ;
print '</tr>' . " \n " ;
print '<tr>' . " \n " ;
print '<td></td>' . " \n " ;
print '<td></td>' . " \n " ;
//affichage des mois
$colspan = 1 ;
2013-04-14 11:22:00 +02:00
for ( $i = 0 ; $i < $nbofsujet ; $i ++ ) {
2013-04-09 23:05:50 +02:00
$cur = intval ( $toutsujet [ $i ]); // intval() est utiliser pour supprimer le suffixe @* qui déplaît logiquement à strftime()
if ( isset ( $toutsujet [ $i + 1 ]) === false ) {
$next = false ;
} else {
$next = intval ( $toutsujet [ $i + 1 ]);
}
if ( $next && dol_print_date ( $cur , " %B " ) == dol_print_date ( $next , " %B " ) && dol_print_date ( $cur , " %Y " ) == dol_print_date ( $next , " %Y " )){
$colspan ++ ;
} else {
print '<td colspan=' . $colspan . ' class="mois">' . dol_print_date ( $cur , " %B " ) . '</td>' . " \n " ;
$colspan = 1 ;
}
}
print '<td class="mois"><a href="' . $_SERVER [ " PHP_SELF " ] . '?ajoutsujet=1&sondage=' . $object -> id_sondage_admin . '">' . $langs -> trans ( " Add " ) . '</a></td>' . " \n " ;
print '</tr>' . " \n " ;
print '<tr>' . " \n " ;
print '<td></td>' . " \n " ;
print '<td></td>' . " \n " ;
//affichage des jours
$colspan = 1 ;
2013-04-14 11:22:00 +02:00
for ( $i = 0 ; $i < $nbofsujet ; $i ++ ) {
2013-04-09 23:05:50 +02:00
$cur = intval ( $toutsujet [ $i ]);
if ( isset ( $toutsujet [ $i + 1 ]) === false ) {
$next = false ;
} else {
$next = intval ( $toutsujet [ $i + 1 ]);
}
if ( $next && dol_print_date ( $cur , " %a %e " ) == dol_print_date ( $next , " %a %e " ) && dol_print_date ( $cur , " %B " ) == dol_print_date ( $next , " %B " )) {
$colspan ++ ;
} else {
print '<td colspan=' . $colspan . ' class="jour">' . dol_print_date ( $cur , " %a %e " ) . '</td>' . " \n " ;
$colspan = 1 ;
}
}
print '<td class="jour"><a href="' . $_SERVER [ " PHP_SELF " ] . '?ajoutsujet=1&sondage=' . $object -> id_sondage_admin . '">' . $langs -> trans ( " Add " ) . '</a></td>' . " \n " ;
print '</tr>' . " \n " ;
//affichage des horaires
if ( strpos ( $object -> sujet , '@' ) !== false ) {
print '<tr>' . " \n " ;
print '<td></td>' . " \n " ;
print '<td></td>' . " \n " ;
for ( $i = 0 ; isset ( $toutsujet [ $i ]); $i ++ ) {
$heures = explode ( '@' , $toutsujet [ $i ]);
if ( isset ( $heures [ 1 ])) {
print '<td class="heure">' . $heures [ 1 ] . '</td>' . " \n " ;
} else {
print '<td class="heure"></td>' . " \n " ;
}
}
print '<td class="heure"><a href="' . $_SERVER [ " PHP_SELF " ] . '?ajoutsujet=1&sondage=' . $object -> id_sondage_admin . '">' . $langs -> trans ( " Add " ) . '</a></td>' . " \n " ;
print '</tr>' . " \n " ;
}
}
else
{
//affichage des sujets du sondage
print '<tr>' . " \n " ;
print '<td></td>' . " \n " ;
print '<td></td>' . " \n " ;
for ( $i = 0 ; isset ( $toutsujet [ $i ]); $i ++ )
{
$tmp = explode ( '@' , $toutsujet [ $i ]);
print '<td class="sujet">' . $tmp [ 0 ] . '</td>' . " \n " ;
}
print '<td class="sujet"><a href="' . $_SERVER [ " PHP_SELF " ] . '?sondage=' . $numsondageadmin . '&ajoutsujet=1&backtourl=' . urlencode ( $_SERVER [ " PHP_SELF " ] . '?sondage=' . $numsondageadmin ) . '">' . img_picto ( '' , dol_buildpath ( '/opensurvey/img/add-16.png' , 1 ), '' , 1 ) . '</a></td>' . " \n " ;
print '</tr>' . " \n " ;
}
// Loop on each answer
$sumfor = array ();
$sumagainst = array ();
$compteur = 0 ;
$sql = " SELECT id_users, nom, id_sondage, reponses " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " opensurvey_user_studs " ;
$sql .= " WHERE id_sondage = ' " . $db -> escape ( $numsondage ) . " ' " ;
dol_syslog ( 'sql=' . $sql );
$resql = $db -> query ( $sql );
if ( ! $resql )
{
dol_print_error ( $db );
exit ;
}
$num = $db -> num_rows ( $resql );
while ( $compteur < $num )
{
$obj = $db -> fetch_object ( $resql );
$ensemblereponses = $obj -> reponses ;
print '<tr>' . " \n " ;
print '<td><input type="image" name="effaceligne' . $compteur . '" value="Effacer" src="' . dol_buildpath ( '/opensurvey/img/cancel.png' , 1 ) . '"></td>' . " \n " ;
// Name
$nombase = str_replace ( " ° " , " ' " , $obj -> nom );
print '<td class="nom">' . $nombase . '</td>' . " \n " ;
// si la ligne n'est pas a changer, on affiche les données
if ( ! $testligneamodifier )
{
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ )
{
$car = substr ( $ensemblereponses , $i , 1 );
2013-06-05 16:24:32 +02:00
//print 'xx'.$i."-".$car.'-'.$listofanswers[$i]['format'].'zz';
2013-04-09 23:05:50 +02:00
if ( empty ( $listofanswers [ $i ][ 'format' ]) || ! in_array ( $listofanswers [ $i ][ 'format' ], array ( 'yesno' , 'foragainst' )))
{
if ((( string ) $car ) == " 1 " ) print '<td class="ok">OK</td>' . " \n " ;
else print '<td class="non">KO</td>' . " \n " ;
// Total
if ( ! isset ( $sumfor [ $i ])) $sumfor [ $i ] = 0 ;
if ((( string ) $car ) == " 1 " ) $sumfor [ $i ] ++ ;
}
if ( ! empty ( $listofanswers [ $i ][ 'format' ]) && $listofanswers [ $i ][ 'format' ] == 'yesno' )
{
if ((( string ) $car ) == " 1 " ) print '<td class="ok">' . $langs -> trans ( " Yes " ) . '</td>' . " \n " ;
else if ((( string ) $car ) == " 0 " ) print '<td class="non">' . $langs -> trans ( " No " ) . '</td>' . " \n " ;
else print '<td class="vide"> </td>' . " \n " ;
// Total
if ( ! isset ( $sumfor [ $i ])) $sumfor [ $i ] = 0 ;
if ( ! isset ( $sumagainst [ $i ])) $sumagainst [ $i ] = 0 ;
if ((( string ) $car ) == " 1 " ) $sumfor [ $i ] ++ ;
if ((( string ) $car ) == " 0 " ) $sumagainst [ $i ] ++ ;
}
if ( ! empty ( $listofanswers [ $i ][ 'format' ]) && $listofanswers [ $i ][ 'format' ] == 'foragainst' )
{
if ((( string ) $car ) == " 1 " ) print '<td class="ok">' . $langs -> trans ( " For " ) . '</td>' . " \n " ;
else if ((( string ) $car ) == " 0 " ) print '<td class="non">' . $langs -> trans ( " Against " ) . '</td>' . " \n " ;
else print '<td class="vide"> </td>' . " \n " ;
// Total
if ( ! isset ( $sumfor [ $i ])) $sumfor [ $i ] = 0 ;
if ( ! isset ( $sumagainst [ $i ])) $sumagainst [ $i ] = 0 ;
if ((( string ) $car ) == " 1 " ) $sumfor [ $i ] ++ ;
if ((( string ) $car ) == " 0 " ) $sumagainst [ $i ] ++ ;
}
}
}
else
{
//sinon on remplace les choix de l'utilisateur par une ligne de checkbox pour recuperer de nouvelles valeurs
if ( $compteur == $ligneamodifier )
{
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ )
{
$car = substr ( $ensemblereponses , $i , 1 );
print '<td class="vide">' ;
if ( empty ( $listofanswers [ $i ][ 'format' ]) || ! in_array ( $listofanswers [ $i ][ 'format' ], array ( 'yesno' , 'foragainst' )))
{
print '<input type="checkbox" name="choix' . $i . '" value="1" ' ;
if ( $car == '1' ) print 'checked="checked"' ;
print '>' ;
}
if ( ! empty ( $listofanswers [ $i ][ 'format' ]) && $listofanswers [ $i ][ 'format' ] == 'yesno' )
{
$arraychoice = array ( '2' => ' ' , '0' => $langs -> trans ( " No " ), '1' => $langs -> trans ( " Yes " ));
print $form -> selectarray ( " choix " . $i , $arraychoice , $car );
}
if ( ! empty ( $listofanswers [ $i ][ 'format' ]) && $listofanswers [ $i ][ 'format' ] == 'foragainst' )
{
$arraychoice = array ( '2' => ' ' , '0' => $langs -> trans ( " Against " ), '1' => $langs -> trans ( " For " ));
print $form -> selectarray ( " choix " . $i , $arraychoice , $car );
}
print '</td>' . " \n " ;
}
}
else
{
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ )
{
$car = substr ( $ensemblereponses , $i , 1 );
if ( empty ( $listofanswers [ $i ][ 'format' ]) || ! in_array ( $listofanswers [ $i ][ 'format' ], array ( 'yesno' , 'foragainst' )))
{
if ((( string ) $car ) == " 1 " ) print '<td class="ok">OK</td>' . " \n " ;
else print '<td class="non">KO</td>' . " \n " ;
// Total
if ( ! isset ( $sumfor [ $i ])) $sumfor [ $i ] = 0 ;
if ((( string ) $car ) == " 1 " ) $sumfor [ $i ] ++ ;
}
if ( ! empty ( $listofanswers [ $i ][ 'format' ]) && $listofanswers [ $i ][ 'format' ] == 'yesno' )
{
if ((( string ) $car ) == " 1 " ) print '<td class="ok">' . $langs -> trans ( " For " ) . '</td>' . " \n " ;
else if ((( string ) $car ) == " 0 " ) print '<td class="non">' . $langs -> trans ( " Against " ) . '</td>' . " \n " ;
else print '<td class="vide"> </td>' . " \n " ;
// Total
if ( ! isset ( $sumfor [ $i ])) $sumfor [ $i ] = 0 ;
if ( ! isset ( $sumagainst [ $i ])) $sumagainst [ $i ] = 0 ;
if ((( string ) $car ) == " 1 " ) $sumfor [ $i ] ++ ;
if ((( string ) $car ) == " 0 " ) $sumagainst [ $i ] ++ ;
}
if ( ! empty ( $listofanswers [ $i ][ 'format' ]) && $listofanswers [ $i ][ 'format' ] == 'foragainst' )
{
if ((( string ) $car ) == " 1 " ) print '<td class="ok">' . $langs -> trans ( " For " ) . '</td>' . " \n " ;
else if ((( string ) $car ) == " 0 " ) print '<td class="non">' . $langs -> trans ( " Against " ) . '</td>' . " \n " ;
else print '<td class="vide"> </td>' . " \n " ;
// Total
if ( ! isset ( $sumfor [ $i ])) $sumfor [ $i ] = 0 ;
if ( ! isset ( $sumagainst [ $i ])) $sumagainst [ $i ] = 0 ;
if ((( string ) $car ) == " 1 " ) $sumfor [ $i ] ++ ;
if ((( string ) $car ) == " 0 " ) $sumagainst [ $i ] ++ ;
}
}
}
}
2013-04-13 15:43:31 +02:00
// Button edit at end of line
2013-04-09 23:05:50 +02:00
if ( $compteur != $ligneamodifier )
{
print '<td class="casevide"><input type="submit" class="button" name="modifierligne' . $compteur . '" value="' . dol_escape_htmltag ( $langs -> trans ( " Edit " )) . '"></td>' . " \n " ;
}
//demande de confirmation pour modification de ligne
2013-04-13 15:43:31 +02:00
for ( $i = 0 ; $i < $nblignes ; $i ++ )
2013-04-09 23:05:50 +02:00
{
if ( isset ( $_POST [ " modifierligne " . $i ]))
{
if ( $compteur == $i )
{
print '<td class="casevide">' ;
print '<input type="hidden" name="idtomodify' . $compteur . '" value="' . $obj -> id_users . '">' ;
print '<input type="submit" class="button" name="validermodifier' . $compteur . '" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '">' ;
print '</td>' . " \n " ;
}
}
}
$compteur ++ ;
print '</tr>' . " \n " ;
}
// Add line to add new record
if ( empty ( $testligneamodifier ))
{
print '<tr>' . " \n " ;
print '<td></td>' . " \n " ;
print '<td class="nom">' . " \n " ;
print '<input type="text" placeholder="' . dol_escape_htmltag ( $langs -> trans ( " Name " )) . '" name="nom" maxlength="64" size="24">' . " \n " ;
print '</td>' . " \n " ;
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ )
{
print '<td class="vide">' ;
if ( empty ( $listofanswers [ $i ][ 'format' ]) || ! in_array ( $listofanswers [ $i ][ 'format' ], array ( 'yesno' , 'foragainst' )))
{
print '<input type="checkbox" name="choix' . $i . '" value="1"' ;
if ( isset ( $_POST [ 'choix' . $i ]) && $_POST [ 'choix' . $i ] == '1' && is_error ( NAME_EMPTY ) )
{
print ' checked="checked"' ;
}
print '>' ;
}
if ( ! empty ( $listofanswers [ $i ][ 'format' ]) && $listofanswers [ $i ][ 'format' ] == 'yesno' )
{
$arraychoice = array ( '2' => ' ' , '0' => $langs -> trans ( " No " ), '1' => $langs -> trans ( " Yes " ));
print $form -> selectarray ( " choix " . $i , $arraychoice );
}
if ( ! empty ( $listofanswers [ $i ][ 'format' ]) && $listofanswers [ $i ][ 'format' ] == 'foragainst' )
{
$arraychoice = array ( '2' => ' ' , '0' => $langs -> trans ( " Against " ), '1' => $langs -> trans ( " For " ));
print $form -> selectarray ( " choix " . $i , $arraychoice );
}
print '</td>' . " \n " ;
}
// Affichage du bouton de formulaire pour inscrire un nouvel utilisateur dans la base
print '<td><input type="image" name="boutonp" value="' . $langs -> trans ( " Vote " ) . '" src="' . dol_buildpath ( '/opensurvey/img/add-24.png' , 1 ) . '"></td>' . " \n " ;
print '</tr>' . " \n " ;
}
// Select value of best choice (for checkbox columns only)
$nbofcheckbox = 0 ;
for ( $i = 0 ; $i < $nbcolonnes + 1 ; $i ++ )
{
if ( empty ( $listofanswers [ $i ][ 'format' ]) || ! in_array ( $listofanswers [ $i ][ 'format' ], array ( 'yesno' , 'foragainst' )))
$nbofcheckbox ++ ;
if ( isset ( $sumfor [ $i ]))
{
2013-04-13 15:43:31 +02:00
if ( $i == 0 )
{
2013-04-09 23:05:50 +02:00
$meilleurecolonne = $sumfor [ $i ];
}
2013-04-13 15:43:31 +02:00
if ( isset ( $sumfor [ $i ]) && $sumfor [ $i ] > $meilleurecolonne )
{
2013-04-09 23:05:50 +02:00
$meilleurecolonne = $sumfor [ $i ];
}
}
}
// Show line total
print '<tr>' . " \n " ;
print '<td></td>' . " \n " ;
print '<td align="center">' . $langs -> trans ( " Total " ) . '</td>' . " \n " ;
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ )
{
$showsumfor = isset ( $sumfor [ $i ]) ? $sumfor [ $i ] : '' ;
$showsumagainst = isset ( $sumagainst [ $i ]) ? $sumagainst [ $i ] : '' ;
if ( empty ( $showsumfor )) $showsumfor = 0 ;
if ( empty ( $showsumagainst )) $showsumagainst = 0 ;
print '<td>' ;
if ( empty ( $listofanswers [ $i ][ 'format' ]) || ! in_array ( $listofanswers [ $i ][ 'format' ], array ( 'yesno' , 'foragainst' ))) print $showsumfor ;
if ( ! empty ( $listofanswers [ $i ][ 'format' ]) && $listofanswers [ $i ][ 'format' ] == 'yesno' ) print $langs -> trans ( " Yes " ) . ': ' . $showsumfor . '<br>' . $langs -> trans ( " No " ) . ': ' . $showsumagainst ;
if ( ! empty ( $listofanswers [ $i ][ 'format' ]) && $listofanswers [ $i ][ 'format' ] == 'foragainst' ) print $langs -> trans ( " For " ) . ': ' . $showsumfor . '<br>' . $langs -> trans ( " Against " ) . ': ' . $showsumagainst ;
print '</td>' . " \n " ;
}
print '</tr>' ;
// Show picto winner
if ( $nbofcheckbox >= 2 )
{
print '<tr>' . " \n " ;
print '<td></td>' . " \n " ;
print '<td></td>' . " \n " ;
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ ) {
if ( empty ( $listofanswers [ $i ][ 'format' ]) || ! in_array ( $listofanswers [ $i ][ 'format' ], array ( 'yesno' , 'foragainst' )) && isset ( $sumfor [ $i ]) && isset ( $meilleurecolonne ) && $sumfor [ $i ] == $meilleurecolonne )
{
print '<td class="somme"><img src="' . dol_buildpath ( '/opensurvey/img/medaille.png' , 1 ) . '"></td>' . " \n " ;
} else {
print '<td class="somme"></td>' . " \n " ;
}
}
print '</tr>' . " \n " ;
}
// S'il a oublié de remplir un nom
if (( isset ( $_POST [ " boutonp " ]) || isset ( $_POST [ " boutonp_x " ])) && $_POST [ " nom " ] == " " ) {
print '<tr>' . " \n " ;
print " <td colspan=10><font color=#FF0000> " . _ ( " Enter a name ! " ) . " </font> \n " ;
print '</tr>' . " \n " ;
}
if ( isset ( $erreur_prenom ) && $erreur_prenom ) {
print '<tr>' . " \n " ;
print " <td colspan=10><font color=#FF0000> " . _ ( " The name you've chosen already exist in this poll! " ) . " </font></td> \n " ;
print '</tr>' . " \n " ;
}
if ( isset ( $erreur_injection ) && $erreur_injection ) {
print '<tr>' . " \n " ;
print " <td colspan=10><font color=#FF0000> " . _ ( " Characters \" ' < et > are not permitted " ) . " </font></td> \n " ;
print '</tr>' . " \n " ;
}
if ( isset ( $erreur_ajout_date ) && $erreur_ajout_date ) {
print '<tr>' . " \n " ;
print " <td colspan=10><font color=#FF0000> " . _ ( " The date is not correct ! " ) . " </font></td> \n " ;
print '</tr>' . " \n " ;
}
//fin du tableau
print '</table>' . " \n " ;
print '</div>' . " \n " ;
$toutsujet = explode ( " , " , $object -> sujet );
$compteursujet = 0 ;
$meilleursujet = '' ;
for ( $i = 0 ; $i < $nbcolonnes ; $i ++ ) {
2013-04-13 15:43:31 +02:00
if ( isset ( $sumfor [ $i ]) === true && isset ( $meilleurecolonne ) === true && $sumfor [ $i ] == $meilleurecolonne ) {
2013-04-09 23:05:50 +02:00
$meilleursujet .= " , " ;
if ( $object -> format == " D " || $object -> format == " D+ " ) {
$meilleursujetexport = $toutsujet [ $i ];
if ( strpos ( $toutsujet [ $i ], '@' ) !== false ) {
$toutsujetdate = explode ( " @ " , $toutsujet [ $i ]);
$meilleursujet .= dol_print_date ( $toutsujetdate [ 0 ], 'daytext' ) . ' (' . dol_print_date ( $toutsujetdate [ 0 ], '%A' ) . ')' . ' - ' . $toutsujetdate [ 1 ];
} else {
$meilleursujet .= dol_print_date ( $toutsujet [ $i ], 'daytext' ) . ' (' . dol_print_date ( $toutsujet [ $i ], '%A' ) . ')' ;
}
}
else
{
$tmps = explode ( '@' , $toutsujet [ $i ]);
$meilleursujet .= $tmps [ 0 ];
}
$compteursujet ++ ;
}
}
$meilleursujet = substr ( " $meilleursujet " , 1 );
$meilleursujet = str_replace ( " ° " , " ' " , $meilleursujet );
// Show best choice
if ( $nbofcheckbox >= 2 )
{
$vote_str = $langs -> trans ( 'votes' );
2013-04-13 15:43:31 +02:00
print '<p class="affichageresultats">' . " \n " ;
2013-04-09 23:05:50 +02:00
if ( isset ( $meilleurecolonne ) && $compteursujet == " 1 " ) {
2013-04-13 15:43:31 +02:00
print " <img src= \" " . dol_buildpath ( '/opensurvey/img/medaille.png' , 1 ) . " \" > " . $langs -> trans ( 'TheBestChoice' ) . " : <b> $meilleursujet </b> " . $langs -> trans ( " with " ) . " <b> $meilleurecolonne </b> " . $vote_str . " . \n " ;
2013-04-09 23:05:50 +02:00
} elseif ( isset ( $meilleurecolonne )) {
2013-04-13 15:43:31 +02:00
print " <img src= \" " . dol_buildpath ( '/opensurvey/img/medaille.png' , 1 ) . " \" > " . $langs -> trans ( 'TheBestChoices' ) . " : <b> $meilleursujet </b> " . $langs -> trans ( " with " ) . " <b> $meilleurecolonne </b> " . $vote_str . " . \n " ;
2013-04-09 23:05:50 +02:00
}
2013-04-13 15:43:31 +02:00
print '<br></p><br>' . " \n " ;
2013-04-09 23:05:50 +02:00
}
print '</form>' . " \n " ;
2013-06-05 16:24:32 +02:00
print '<a name="bas"></a>' . " \n " ;
2013-04-13 15:43:31 +02:00
2013-04-09 23:05:50 +02:00
llxFooterSurvey ();
$db -> close ();
2013-04-11 10:04:27 +02:00
?>