Skip to content

Commit

Permalink
Debug v21
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Nov 11, 2024
1 parent 0436458 commit 8c1f823
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
42 changes: 23 additions & 19 deletions htdocs/opensurvey/wizard/choix_autre.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@
}

if (GETPOST("ajoutcases") || GETPOST("ajoutcases_x")) {
$_SESSION["nbrecases"] += 5;
if ($_SESSION["nbrecases"] < 100) {
$_SESSION["nbrecases"] += 5;
}
}

// Create survey into database
Expand Down Expand Up @@ -132,7 +134,8 @@

print '<br>'.$langs->trans("PollOnChoice").'<br><br>'."\n";

print '<div class=corps>'."\n";
print '<div>'."\n";

print '<table>'."\n";

//affichage des cases texte de formulaire
Expand All @@ -144,45 +147,46 @@
print '<tr><td>'.$langs->trans("TitleChoice").' '.$j.': </td><td><input type="text" name="choix[]" size="40" maxlength="40" value="'.dol_escape_htmltag($_SESSION["choix$i"]).'" id="choix'.$i.'">';
$tmparray = array('checkbox' => $langs->trans("CheckBox"), 'yesno' => $langs->trans("YesNoList"), 'foragainst' => $langs->trans("PourContreList"));

print ' &nbsp; '.$langs->trans("Type").' '.$form->selectarray("typecolonne[]", $tmparray, $_SESSION["typecolonne$i"]);
print ' &nbsp; '.$langs->trans("Type").' '.$form->selectarray("typecolonne[]", $tmparray, $_SESSION["typecolonne".$i]);
print '</td></tr>'."\n";
}

print '</table>'."\n";

//ajout de cases supplementaires
print '<table><tr>'."\n";
print '<td>'.$langs->trans("5MoreChoices").'</td><td>';
print '<td class="center">'.$langs->trans("5MoreChoices").'... ';
if ($conf->use_javascript_ajax) {
print '<div id="addchoice">';
print img_picto('', 'add', '', 0, 0, 0, '', 'fa-2x valignmiddle btnTitle-icon');
print '<div id="addchoice" class="inline-block">';
print img_picto('', 'add', '', 0, 0, 0, '', 'valignmiddle btnTitle-icon cursorpointer');
print '</div>';

print '<input type="hidden" name="ajoutcases" id="ajoutcases" value="">';
print '<script>
// jQuery code to handle the div click event
$(document).ready(function() {
$("#addchoice").on("click", function() {
$("#ajoutcases").val("ajoutcases");
$("#surveyform").submit();
});
});
</script>';
} else {
print '<input type="image" name="ajoutcases" src="../img/add-16.png">';
}
print '</td><td>';
print '</td>'."\n";
print '</tr></table>'."\n";
print'<br>'."\n";

print '<table><tr>'."\n";
print '<td></td><td><input type="submit" class="button" name="confirmecreation" value="'.dol_escape_htmltag($langs->trans("CreatePoll")).'"></td>'."\n";
print '</tr></table>'."\n";

print '<script>
// jQuery code to handle the div click event
$(document).ready(function() {
$("#addchoice").on("click", function() {
$("#surveyform").submit();
});
});
</script>';
print '<input type="submit" class="button" name="confirmecreation" value="'.dol_escape_htmltag($langs->trans("CreatePoll")).'">'."\n";

//fin du formulaire et bandeau de pied
print '</form>'."\n";


print '<a name="bas"></a>'."\n";
print '<br><br><br>'."\n";

print '</div>'."\n";

// End of page
Expand Down
15 changes: 5 additions & 10 deletions htdocs/opensurvey/wizard/create_survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@
}

$testdate = false;
$champdatefin = dol_mktime(0, 0, 0, GETPOSTINT('champdatefinmonth'), GETPOSTINT('champdatefinday'), GETPOSTINT('champdatefinyear'));
$champdatefin = dol_mktime(23, 59, 59, GETPOSTINT('champdatefinmonth'), GETPOSTINT('champdatefinday'), GETPOSTINT('champdatefinyear'));

if (! $error && $champdatefin && ($champdatefin > 0)) { // A date was provided

Check failure on line 95 in htdocs/opensurvey/wizard/create_survey.php

View workflow job for this annotation

GitHub Actions / phpstan / php-stan (8.2)

Negated boolean expression is always true.
$error++;
// Expire date is not before today
if ($champdatefin >= dol_now()) {
$testdate = true;
Expand Down Expand Up @@ -140,16 +139,17 @@

print load_fiche_titre($langs->trans("CreatePoll").' (1 / 2)');

// debut du formulaire

print '<form name="formulaire" action="" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">';

print dol_get_fiche_head();

// Affichage des différents champs textes a remplir
print '<table class="border centpercent">'."\n";

print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("PollTitle").'</td><td><input type="text" name="title" class="minwidth300" maxlength="80" value="'.$_SESSION["title"].'"></td>'."\n";
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("PollTitle").'</td>';

print '<td><input type="text" name="title" class="minwidth300" maxlength="80" value="'.$_SESSION["title"].'" autofocus></td>'."\n";
if (!$_SESSION["title"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre'))) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PollTitle")), null, 'errors');
}
Expand All @@ -170,11 +170,6 @@

print dol_get_fiche_end();

//focus javascript sur le premier champ
print '<script type="text/javascript">'."\n";
print 'document.formulaire.title.focus();'."\n";
print '</script>'."\n";

print '<br>'."\n";

// Check or not
Expand Down
11 changes: 11 additions & 0 deletions htdocs/opensurvey/wizard/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@
print '</div>';
print '</div></form>';

// Clean session variables

$i = 0;
unset($_SESSION["nbrecases"]);
while ($i < 100) {
unset($_SESSION["choix".$i]);
unset($_SESSION["typecolonne".$i]);
$i++;
}


// End of page
llxFooter();
$db->close();

0 comments on commit 8c1f823

Please sign in to comment.