1
0
Fork 0
This repository has been archived on 2023-11-30. You can view files and clone it, but cannot push or open issues or pull requests.
dtux__gestion_ateliers/cron.php

91 lines
2.5 KiB
PHP

<?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"];
$ateliers["titre"] = $sondage["titre"];
if ($diff < 0)
{
$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"];
$r = explode(" ", $sondage['sujet'], 2);
if ( trim( $r[0], " ") != "Atelier" and !empty($minimPart))
{
$minParticipants = $minimPart;
}else
{
$minParticipants = 2;
}
$db2->query($query);
// pour chaque vote on compte les résultats par atelier
if ($db2->result->num_rows > 0)
{
$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];
}
}
//$ateliers["commentaire"] = $nom_atelier;
arsort($tab);
$ateliers["atelier"] = strstr($nom_atelier[key($tab)], "@checkbox" , true );
if ( $tab[0] < $minParticipants )
{
echo "annulation\n";
$ateliers['commentaires'] = annulation_atelier( $ateliers["titre"] );
}else
{
$ateliers['commentaires'] = confirmation_atelier( $ateliers["titre"], $ateliers["atelier"] );
}
}else
{
echo "annulation\n";
$ateliers['commentaires'] = annulation_atelier( $ateliers["titre"] );
}
/*if ( $diff <= 21600 )
{
$ateliers['titre'] = $sondage["titre"];
$ateliers['commentaires'] .= $sondage["commentaires"];
}
*/
}
}
if ( !empty($ateliers['commentaires']) )
{
echo $ateliers['commentaires'];
send_mail("all", 'dtux@free.fr', $ateliers['commentaires']);
//print_r($ateliers);
}
}
?>