29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
31require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
32require_once DOL_DOCUMENT_ROOT.
"/core/class/doleditor.class.php";
33require_once DOL_DOCUMENT_ROOT.
"/opensurvey/lib/opensurvey.lib.php";
44if (!$user->hasRight(
'opensurvey',
'write')) {
48$langs->load(
"opensurvey");
51$description =
GETPOST(
'description',
'restricthtml');
52$mailsonde =
GETPOST(
'mailsonde');
53$creation_sondage_date =
GETPOST(
'creation_sondage_date');
54$creation_sondage_autre =
GETPOST(
'creation_sondage_autre');
57$session_var = array(
'title',
'description',
'mailsonde');
58foreach ($session_var as $var) {
59 if (isset($_SESSION[$var])) {
60 $_SESSION[$var] =
null;
69if (!empty($creation_sondage_date) || !empty($creation_sondage_autre)) {
72 $_SESSION[
"title"] = $title;
73 $_SESSION[
"description"] = $description;
75 if (
GETPOST(
'mailsonde') ==
'on') {
76 $_SESSION[
"mailsonde"] =
true;
78 $_SESSION[
"mailsonde"] =
false;
81 if (
GETPOST(
'allow_comments') ==
'on') {
82 $_SESSION[
'allow_comments'] =
true;
84 $_SESSION[
'allow_comments'] =
false;
87 if (
GETPOST(
'allow_spy') ==
'on') {
88 $_SESSION[
'allow_spy'] =
true;
90 $_SESSION[
'allow_spy'] =
false;
96 if ($champdatefin > 0) {
98 if ($champdatefin >=
dol_now()) {
100 $_SESSION[
'champdatefin'] =
dol_print_date($champdatefin,
'dayrfc');
104 $_SESSION[
'champdatefin'] =
dol_print_date($champdatefin,
'dayrfc');
112 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"ExpireDate")),
null,
'errors');
115 if (!$error && $title && $testdate) {
116 if (!empty($creation_sondage_date)) {
117 header(
"Location: choix_date.php");
121 if (!empty($creation_sondage_autre)) {
122 header(
"Location: choix_autre.php");
135$form =
new Form($db);
138$arrayofcss = array(
'/opensurvey/css/style.css');
139llxHeader(
'', $langs->trans(
"OpenSurvey"),
'',
"", 0, 0, $arrayofjs, $arrayofcss);
144print
'<form name="formulaire" action="" method="POST">'.
"\n";
145print
'<input type="hidden" name="token" value="'.newToken().
'">';
149print
'<table class="border centpercent">'.
"\n";
151print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"PollTitle").
'</td>';
153print
'<td><input type="text" name="title" class="minwidth300" maxlength="80" value="'.$_SESSION[
"title"].
'" autofocus></td>'.
"\n";
154if (!$_SESSION[
"title"] && (
GETPOST(
'creation_sondage_date') ||
GETPOST(
'creation_sondage_autre'))) {
155 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PollTitle")),
null,
'errors');
159print
'<tr><td>'.$langs->trans(
"Description").
'</td><td>';
160$doleditor =
new DolEditor(
'description', $_SESSION[
"description"],
'', 120,
'dolibarr_notes',
'In',
true, 1, 1, ROWS_7,
'90%');
161$doleditor->Create(0,
'');
165print
'<tr><td class="fieldrequired">'.$langs->trans(
"ExpireDate").
'</td><td>';
167print $form->selectDate($champdatefin ? $champdatefin : -1,
'champdatefin', 0, 0, 0,
"add", 1, 0);
170print
'</table>'.
"\n";
178if ($_SESSION[
"mailsonde"]) {
179 $cochemail =
"checked";
182print
'<input type="checkbox" id="mailsonde" name="mailsonde" '.$cochemail.
'> <label for="mailsonde">'.$langs->trans(
"ToReceiveEMailForEachVote").
'</label><br>'.
"\n";
184if ($_SESSION[
'allow_comments']) {
185 $allow_comments =
'checked';
187if (GETPOSTISSET(
'allow_comments')) {
188 $allow_comments =
GETPOST(
'allow_comments') ?
'checked' :
'';
190print
'<input type="checkbox" id="allow_comments" name="allow_comments" '.$allow_comments.
'"> <label for="allow_comments">'.$langs->trans(
'CanComment').
'</label><br>'.
"\n";
192if ($_SESSION[
'allow_spy']) {
193 $allow_spy =
'checked';
195if (GETPOSTISSET(
'allow_spy')) {
196 $allow_spy =
GETPOST(
'allow_spy') ?
'checked' :
'';
198print
'<input type="checkbox" id="allow_spy" name="allow_spy" '.$allow_spy.
'> <label for="allow_spy">'.$langs->trans(
'CanSeeOthersVote').
'</label><br>'.
"\n";
201 if (
GETPOST(
'choix_sondage') ==
'date') {
202 print
'<input type="hidden" name="creation_sondage_date" value="date">';
204 print
'<input type="hidden" name="creation_sondage_autre" value="autre">';
206 print
'<input type="hidden" name="choix_sondage" value="'.GETPOST(
'choix_sondage').
'">';
207 print
'<br><input type="submit" class="button" name="submit" value="'.$langs->trans(
"CreatePoll").
' ('.(
GETPOST(
'choix_sondage') ==
'date' ? $langs->trans(
"TypeDate") : $langs->trans(
"TypeClassic")).
')">';
210 print
'<br><table>'.
"\n";
211 print
'<tr><td>'.$langs->trans(
"CreateSurveyDate").
'</td><td></td> '.
"\n";
212 print
'<td><input type="image" name="creation_sondage_date" value="'.$langs->trans(
'CreateSurveyDate').
'" src="../img/calendar-32.png"></td></tr>'.
"\n";
213 print
'<tr><td>'.$langs->trans(
"CreateSurveyStandard").
'</td><td></td> '.
"\n";
214 print
'<td><input type="image" name="creation_sondage_autre" value="'.$langs->trans(
'CreateSurveyStandard').
'" src="../img/chart-32.png"></td></tr>'.
"\n";
215 print
'</table>'.
"\n";
217print
'<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.
Class to manage a WYSIWYG editor.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
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.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.