Fix opensurvey

This commit is contained in:
Laurent Destailleur 2018-12-11 10:52:59 +01:00
parent a107d16338
commit 4aff0b6471
2 changed files with 15 additions and 10 deletions

View File

@ -1050,18 +1050,20 @@ $toutsujet = explode(",", $object->sujet); // With old versions, this field was
$compteursujet = 0; $compteursujet = 0;
$meilleursujet = ''; $meilleursujet = '';
for ($i = 0; $i < $nbcolonnes; $i++) { for ($i = 0; $i < $nbcolonnes; $i++)
if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne) { {
if (isset($sumfor[$i]) === true && isset($meilleurecolonne) === true && $sumfor[$i] == $meilleurecolonne)
{
$meilleursujet.=", "; $meilleursujet.=", ";
if ($object->format == "D") { if ($object->format == "D") {
$meilleursujetexport = $toutsujet[$i]; $meilleursujetexport = $toutsujet[$i];
//var_dump($toutsujet);
if (strpos($toutsujet[$i], '@') !== false) { if (strpos($toutsujet[$i], '@') !== false) {
$toutsujetdate = explode("@", $toutsujet[$i]); $toutsujetdate = explode("@", $toutsujet[$i]);
$meilleursujet .= dol_print_date($toutsujetdate[0],'daytext'). ' ('.dol_print_date($toutsujetdate[0],'%A').')' . ' - ' . $toutsujetdate[1]; $meilleursujet .= dol_print_date($toutsujetdate[0],'daytext'). ($toutsujetdate[0] ? ' ('.dol_print_date($toutsujetdate[0],'%A').')' : '') . ' - ' . $toutsujetdate[1];
} else { } else {
$meilleursujet .= dol_print_date($toutsujet[$i],'daytext'). ' ('.dol_print_date($toutsujet[$i],'%A').')'; $meilleursujet .= dol_print_date($toutsujet[$i],'daytext'). ($toutsujet[$i] ? ' ('.dol_print_date($toutsujet[$i],'%A').')' : '');
} }
} }
else else
@ -1083,9 +1085,9 @@ if ($nbofcheckbox >= 2)
print '<p class="affichageresultats">'."\n"; print '<p class="affichageresultats">'."\n";
if (isset($meilleurecolonne) && $compteursujet == "1") { if (isset($meilleurecolonne) && $compteursujet == "1") {
print "<img src=\"".DOL_URL_ROOT.'/opensurvey/img/medaille.png'."\"> " . $langs->trans('TheBestChoice') . ": <b>".$meilleursujet." </b>" . $langs->trans("with") . " <b>".$meilleurecolonne."</b>" . $vote_str . ".\n"; print "<img src=\"".DOL_URL_ROOT.'/opensurvey/img/medaille.png'."\"> " . $langs->trans('TheBestChoice') . ": <b>".$meilleursujet." </b>" . $langs->trans("with") . " <b>".$meilleurecolonne."</b> " . $vote_str . ".\n";
} elseif (isset($meilleurecolonne)) { } elseif (isset($meilleurecolonne)) {
print "<img src=\"".DOL_URL_ROOT.'/opensurvey/img/medaille.png'."\"> " . $langs->trans('TheBestChoices') . ": <b>".$meilleursujet." </b>" . $langs->trans("with") . " <b>".$meilleurecolonne."</b>" . $vote_str . ".\n"; print "<img src=\"".DOL_URL_ROOT.'/opensurvey/img/medaille.png'."\"> " . $langs->trans('TheBestChoices') . ": <b>".$meilleursujet." </b>" . $langs->trans("with") . " <b>".$meilleurecolonne."</b> " . $vote_str . ".\n";
} }
print '<br></p><br>'."\n"; print '<br></p><br>'."\n";
} }

View File

@ -95,7 +95,7 @@ if (GETPOST('ajoutcomment','alpha'))
} }
// Add vote // Add vote
if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // boutonp for chrom, boutonp_x for firefox if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // boutonp for chrome, boutonp_x for firefox
{ {
if (!$canbemodified) accessforbidden(); if (!$canbemodified) accessforbidden();
@ -160,9 +160,12 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout
if ($email) { if ($email) {
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$body = $langs->trans('EmailSomeoneVoted', $nom, getUrlSondage($numsondage, true)); $application = ($conf->global->MAIN_APPLICATION_TITLE ? $conf->global->MAIN_APPLICATION_TITLE : 'Dolibarr ERP/CRM');
$cmailfile=new CMailFile("[".MAIN_APPLICATION_TITLE."] ".$langs->trans("Poll").': '.$object->titre, $email, $conf->global->MAIN_MAIL_EMAIL_FROM, $body); $body = str_replace('\n', '<br>', $langs->transnoentities('EmailSomeoneVoted', $nom, getUrlSondage($numsondage, true)));
//var_dump($body);exit;
$cmailfile=new CMailFile("[".$application."] ".$langs->trans("Poll").': '.$object->titre, $email, $conf->global->MAIN_MAIL_EMAIL_FROM, $body, null, null, null, '', '', 0, -1);
$result=$cmailfile->sendfile(); $result=$cmailfile->sendfile();
} }
} }