28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
30require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
31require_once DOL_DOCUMENT_ROOT.
"/opensurvey/lib/opensurvey.lib.php";
42if (!$user->hasRight(
'opensurvey',
'write')) {
52$arrayofchoices =
GETPOST(
'choix',
'array');
53$arrayoftypecolumn =
GETPOST(
'typecolonne',
'array');
56if (isset($_SESSION[
"nbrecases"])) {
57 for ($i = 0; $i < $_SESSION[
"nbrecases"]; $i++) {
58 if (isset($arrayofchoices[$i])) {
59 $_SESSION[
"choix".$i] = $arrayofchoices[$i];
61 if (isset($arrayoftypecolumn[$i])) {
62 $_SESSION[
"typecolonne".$i] = $arrayoftypecolumn[$i];
66 $_SESSION[
"nbrecases"] = 5;
70 if ($_SESSION[
"nbrecases"] < 100) {
71 $_SESSION[
"nbrecases"] += 5;
76if (GETPOSTISSET(
"confirmecreation")) {
78 for ($i = 0; $i < $_SESSION[
"nbrecases"] + 1; $i++) {
79 $tmpchoice = $arrayofchoices[$i];
80 $tmptypecolumn =
GETPOST(
'typecolonne'.$i,
'alphanohtml');
81 if (!empty($tmpchoice)) {
83 $toutchoix .= str_replace(array(
",",
"@"),
" ", $tmpchoice).(empty($tmptypecolumn) ?
'' :
'@'.$tmptypecolumn);
87 $toutchoix = substr($toutchoix, 1);
88 $_SESSION[
"toutchoix"] = $toutchoix;
91 $testremplissage =
'';
92 for ($i = 0; $i < $_SESSION[
"nbrecases"]; $i++) {
93 if (isset($arrayofchoices[$i])) {
94 $testremplissage =
"ok";
99 if ($testremplissage !=
"ok" || (!$toutchoix)) {
100 setEventMessages($langs->trans(
"ErrorOpenSurveyOneChoice"),
null,
'errors');
103 $_SESSION[
"formatsondage"] =
"A";
114$form =
new Form($db);
117$arrayofcss = array(
'/opensurvey/css/style.css');
118llxHeader(
'', $langs->trans(
"OpenSurvey"),
"",
'', 0, 0, $arrayofjs, $arrayofcss);
120if (empty($_SESSION[
'title'])) {
121 dol_print_error(
null, $langs->trans(
'ErrorOpenSurveyFillFirstSection'));
130print
'<form name="formulaire" id="surveyform" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
131print
'<input type="hidden" name="token" value="'.newToken().
'">';
136print
'<br>'.$langs->trans(
"PollOnChoice").
'<br><br>'.
"\n";
143for ($i = 0; $i < $_SESSION[
"nbrecases"]; $i++) {
145 if (!isset($_SESSION[
"choix$i"])) {
146 $_SESSION[
"choix$i"] =
'';
148 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.
'">';
149 $tmparray = array(
'checkbox' => $langs->trans(
"CheckBox"),
'yesno' => $langs->trans(
"YesNoList"),
'foragainst' => $langs->trans(
"PourContreList"));
151 print
' '.$langs->trans(
"Type").
' '.$form->selectarray(
"typecolonne".$i, $tmparray, $_SESSION[
"typecolonne".$i]);
152 print
'</td></tr>'.
"\n";
155print
'</table>'.
"\n";
158print
'<table><tr>'.
"\n";
159print
'<td class="center">'.$langs->trans(
"5MoreChoices").
'... ';
160if ($conf->use_javascript_ajax) {
161 print
'<div id="addchoice" class="inline-block">';
162 print
img_picto(
'',
'add',
'', 0, 0, 0,
'',
'valignmiddle btnTitle-icon cursorpointer');
165 print
'<input type="hidden" name="ajoutcases" id="ajoutcases" value="">';
167 // jQuery code to handle the div click event
168 $(document).ready(function() {
169 $("#addchoice").on("click", function() {
170 console.log("Click on adchoice");
171 $("#ajoutcases").val("ajoutcases");
172 $("#surveyform").submit();
177 print
'<input type="image" name="ajoutcases" src="../img/add-16.png">';
181print
'</tr></table>'.
"\n";
184print
'<input type="submit" class="button" name="confirmecreation" value="'.dol_escape_htmltag($langs->trans(
"CreatePoll")).
'">'.
"\n";
189print
'<a name="bas"></a>'.
"\n";
190print
'<br><br><br>'.
"\n";
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
ajouter_sondage()
Add a poll.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.