2020-03-17 16:54:38 +01:00
< ? php
require_once " config.inc.php " ;
require_once " fonctions.php " ;
require_once " db.class.php " ;
require_once " log.php " ;
require_once " donnees.inc.php " ;
require_once " send_mail.php " ;
$db = new db ( " dolibarr " );
$db2 = new db ( " dolibarr " );
$query = " SELECT TIMESTAMPDIFF(MINUTE, ' " . date ( 'Y-m-d H:i:s' ) . " ' , date_fin) as diff, titre, id_sondage, commentaires, sujet FROM llx_opensurvey_sondage WHERE status='1' ORDER BY date_fin " ;
$message = '' ;
$db -> query ( $query );
if ( $db -> result -> num_rows != 0 )
{
while ( $sondage = $db -> result -> fetch_array () )
{
$diff = $sondage [ 'diff' ];
$ateliers [ 'lien' ] = $base_url . " dbarr/public/opensurvey/studs.php?sondage= " . $sondage [ " id_sondage " ];
2020-03-17 21:12:34 +01:00
$ateliers [ " titre " ] = $sondage [ " titre " ];
2021-04-22 17:25:28 +02:00
if ( $diff < 0 )
2020-03-17 16:54:38 +01:00
{
$query = " UPDATE llx_opensurvey_sondage SET STATUS='2' where id_sondage=' " . $sondage [ 'id_sondage' ] . " ' " ;
$db2 -> query ( $query );
} elseif ( $diff <= 2760 )
{
$query = " SELECT * FROM llx_opensurvey_user_studs WHERE id_sondage=' " . $sondage [ " id_sondage " ] . " ' " ;
$id = $sondage [ " id_sondage " ];
2021-04-22 17:25:28 +02:00
$r = explode ( " " , $sondage [ 'sujet' ], 2 );
2023-04-21 19:01:06 +02:00
if ( trim ( $r [ 0 ], " " ) != " Atelier " and ! empty ( $minimPart ))
2021-04-22 17:25:28 +02:00
{
2023-01-26 16:20:12 +01:00
$minParticipants = $minimPart ;
2021-04-22 17:25:28 +02:00
} else
{
2023-04-21 19:01:06 +02:00
$minParticipants = 2 ;
2021-04-22 17:25:28 +02:00
}
2020-03-17 16:54:38 +01:00
$db2 -> query ( $query );
// pour chaque vote on compte les résultats par atelier
2020-03-17 20:46:35 +01:00
if ( $db2 -> result -> num_rows > 0 )
2020-03-17 16:54:38 +01:00
{
$nom_atelier = explode ( " , " , $sondage [ " sujet " ] );
while ( $reponse = $db2 -> result -> fetch_array () )
{
$r = str_split ( $reponse [ " reponses " ] );
$l = count ( $r );
for ( $x = 0 ; $x < $l ; $x ++ )
{
if ( ! isset ( $tab [ $x ]) )
{
$tab [ $x ] = 0 ;
}
$tab [ $x ] += $r [ $x ];
}
}
2020-03-17 18:26:07 +01:00
2020-03-17 16:54:38 +01:00
//$ateliers["commentaire"] = $nom_atelier;
arsort ( $tab );
$ateliers [ " atelier " ] = strstr ( $nom_atelier [ key ( $tab )], " @checkbox " , true );
2021-04-22 17:25:28 +02:00
if ( $tab [ 0 ] < $minParticipants )
{
echo " annulation \n " ;
$ateliers [ 'commentaires' ] = annulation_atelier ( $ateliers [ " titre " ] );
} else
{
$ateliers [ 'commentaires' ] = confirmation_atelier ( $ateliers [ " titre " ], $ateliers [ " atelier " ] );
}
2020-03-17 16:54:38 +01:00
} else
{
echo " annulation \n " ;
$ateliers [ 'commentaires' ] = annulation_atelier ( $ateliers [ " titre " ] );
}
2020-03-17 20:46:35 +01:00
/* if ( $diff <= 21600 )
2020-03-17 16:54:38 +01:00
{
$ateliers [ 'titre' ] = $sondage [ " titre " ];
2020-03-17 18:49:02 +01:00
$ateliers [ 'commentaires' ] .= $sondage [ " commentaires " ];
2020-03-17 16:54:38 +01:00
}
2020-03-17 20:46:35 +01:00
*/
2020-03-17 16:54:38 +01:00
}
}
if ( ! empty ( $ateliers [ 'commentaires' ]) )
{
2020-03-17 21:59:01 +01:00
echo $ateliers [ 'commentaires' ];
2020-03-17 20:46:35 +01:00
send_mail ( " all " , 'dtux@free.fr' , $ateliers [ 'commentaires' ]);
2020-03-17 16:54:38 +01:00
//print_r($ateliers);
}
}
?>