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")) {
79 for ($i = 0; $i < $_SESSION[
"nbrecases"] + 1; $i++) {
80 if (!empty($arrayofchoices[$i])) {
82 $toutchoix .= str_replace(array(
",",
"@"),
" ", $arrayofchoices[$i]).(empty($arrayoftypecolumn[$i]) ?
'' :
'@'.$arrayoftypecolumn[$i]);
86 $toutchoix = substr(
"$toutchoix", 1);
87 $_SESSION[
"toutchoix"] = $toutchoix;
90 $testremplissage =
'';
91 for ($i = 0; $i < $_SESSION[
"nbrecases"]; $i++) {
92 if (isset($arrayofchoices[$i])) {
93 $testremplissage =
"ok";
98 if ($testremplissage !=
"ok" || (!$toutchoix)) {
102 $_SESSION[
"formatsondage"] =
"A";
113$form =
new Form($db);
116$arrayofcss = array(
'/opensurvey/css/style.css');
117llxHeader(
'', $langs->trans(
"OpenSurvey"),
"",
'', 0, 0, $arrayofjs, $arrayofcss);
119if (empty($_SESSION[
'title'])) {
120 dol_print_error(
null, $langs->trans(
'ErrorOpenSurveyFillFirstSection'));
129print
'<form name="formulaire" id="surveyform" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
130print
'<input type="hidden" name="token" value="'.newToken().
'">';
135print
'<br>'.$langs->trans(
"PollOnChoice").
'<br><br>'.
"\n";
142for ($i = 0; $i < $_SESSION[
"nbrecases"]; $i++) {
144 if (!isset($_SESSION[
"choix$i"])) {
145 $_SESSION[
"choix$i"] =
'';
147 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.
'">';
148 $tmparray = array(
'checkbox' => $langs->trans(
"CheckBox"),
'yesno' => $langs->trans(
"YesNoList"),
'foragainst' => $langs->trans(
"PourContreList"));
150 print
' '.$langs->trans(
"Type").
' '.$form->selectarray(
"typecolonne[]", $tmparray, $_SESSION[
"typecolonne".$i]);
151 print
'</td></tr>'.
"\n";
154print
'</table>'.
"\n";
157print
'<table><tr>'.
"\n";
158print
'<td class="center">'.$langs->trans(
"5MoreChoices").
'... ';
159if (
$conf->use_javascript_ajax) {
160 print
'<div id="addchoice" class="inline-block">';
161 print
img_picto(
'',
'add',
'', 0, 0, 0,
'',
'valignmiddle btnTitle-icon cursorpointer');
164 print
'<input type="hidden" name="ajoutcases" id="ajoutcases" value="">';
166 // jQuery code to handle the div click event
167 $(document).ready(function() {
168 $("#addchoice").on("click", function() {
169 $("#ajoutcases").val("ajoutcases");
170 $("#surveyform").submit();
175 print
'<input type="image" name="ajoutcases" src="../img/add-16.png">';
179print
'</tr></table>'.
"\n";
182print
'<input type="submit" class="button" name="confirmecreation" value="'.dol_escape_htmltag($langs->trans(
"CreatePoll")).
'">'.
"\n";
187print
'<a name="bas"></a>'.
"\n";
188print
'<br><br><br>'.
"\n";
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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)
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...
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.