28require
'../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
"/core/class/doleditor.class.php";
39require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
40require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
41require_once DOL_DOCUMENT_ROOT.
"/opensurvey/class/opensurveysondage.class.php";
42require_once DOL_DOCUMENT_ROOT.
"/opensurvey/lib/opensurvey.lib.php";
45if (!$user->hasRight(
'opensurvey',
'read')) {
50$action =
GETPOST(
'action',
'aZ09');
51$cancel =
GETPOST(
'cancel',
'alpha');
56 $numsondage = (string)
GETPOST(
'id',
'alpha');
62$result =
$object->fetch(
'', $numsondage);
68$hookmanager->initHooks(array(
'surveycard',
'globalcard'));
72$permissiontoread = $user->hasRight(
'opensurvey',
'read');
73$permissiontoadd = $user->hasRight(
'opensurvey',
'write');
74$permissiontodelete = $user->hasRight(
'opensurvey',
'write');
81$parameters = array(
'id' => $numsondage);
82$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
84 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
93 if ($action ==
'delete_confirm' && $permissiontodelete) {
95 if (!$user->hasRight(
'opensurvey',
'write')) {
100 $result =
$object->delete($user, 0, $numsondage);
102 header(
'Location: '.
dol_buildpath(
'/opensurvey/list.php', 1));
110 if ($action ==
'close' && $permissiontoadd) {
112 $result =
$object->update($user);
119 if (($action ==
'reopen' || $action ==
'validate') && $permissiontoadd) {
121 $result =
$object->update($user);
128 if ($action ==
'update' && $permissiontoadd) {
130 if (!$user->hasRight(
'opensurvey',
'write')) {
136 if (!
GETPOST(
'nouveautitre')) {
137 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
144 $object->description = (string)
GETPOST(
'nouveauxcommentaires',
'restricthtml');
145 $object->mail_admin = (string)
GETPOST(
'nouvelleadresse',
'alpha');
146 $object->date_fin = $expiredate;
147 $object->allow_comments =
GETPOST(
'cancomment',
'aZ09') ==
'on' ? 1 : 0;
148 $object->allow_spy =
GETPOST(
'canseeothersvote',
'aZ09') ==
'on' ? 1 : 0;
149 $object->mailsonde =
GETPOST(
'mailsonde',
'aZ09') ==
'on' ? 1 : 0;
160 if (
GETPOST(
'ajoutcomment') && $permissiontoadd) {
163 if (!
GETPOST(
'comment',
"alphanohtml")) {
165 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Comment")),
null,
'errors');
167 if (!
GETPOST(
'commentuser',
"alphanohtml")) {
169 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"User")),
null,
'errors');
173 $comment = (string)
GETPOST(
"comment",
"alphanohtml");
174 $comment_user = (string)
GETPOST(
'commentuser',
"alphanohtml");
176 $resql =
$object->addComment($comment, $comment_user);
179 setEventMessages($langs->trans(
'ErrorInsertingComment'),
null,
'errors');
185 if ($action ==
'deletecomment' && $permissiontoadd) {
187 if ($idcomment > 0) {
189 if (!$user->hasRight(
'opensurvey',
'write')) {
193 $resql =
$object->deleteComment($idcomment);
197 if ($action ==
'edit' && $permissiontoadd) {
199 if (!$user->hasRight(
'opensurvey',
'write')) {
210$form =
new Form($db);
214 $userstatic =
new User($db);
215 $userstatic->fetch(
$object->fk_user_creat);
218$title =
$object->title.
" - ".$langs->trans(
'Card');
221$arrayofcss = array(
'/opensurvey/css/style.css');
222llxHeader(
'', $title, $helpurl,
'', 0, 0, $arrayofjs, $arrayofcss);
226$toutsujet = explode(
",",
$object->sujet);
227$listofanswers = array();
228foreach ($toutsujet as $value) {
229 $tmp = explode(
'@', $value);
230 $listofanswers[] = array(
'label' => $tmp[0],
'format' => (!empty($tmp[1]) ? $tmp[1] :
'checkbox'));
232$toutsujet = str_replace(
"@",
"<br>", $toutsujet);
233$toutsujet = str_replace(
"°",
"'", $toutsujet);
235print
'<form name="updatesurvey" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$numsondage.
'" method="POST">'.
"\n";
236print
'<input type="hidden" name="token" value="'.newToken().
'">';
237print
'<input type="hidden" name="action" value="update">';
246$linkback =
'<a href="'.DOL_URL_ROOT.
'/opensurvey/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
248dol_banner_tab($object,
'id', $linkback, 1,
'id_sondage',
'id_sondage', $morehtmlref);
251print
'<div class="fichecenter">';
253print
'<div class="fichehalfleft">';
254print
'<div class="underbanner clearboth"></div>';
255print
'<table class="border tableforfield centpercent">';
258$type = (
$object->format ==
"A") ?
'classic' :
'date';
259print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Type").
'</td><td>';
260print img_picto(
'',
dol_buildpath(
'/opensurvey/img/'.($type ==
'classic' ?
'chart-32.png' :
'calendar-32.png'), 1),
'width="16"', 1);
261print
' '.$langs->trans($type ==
'classic' ?
"TypeClassic" :
"TypeDate").
'</td></tr>';
265print $langs->trans(
"Title").
'</td><td>';
266if ($action ==
'edit') {
267 print
'<input class="width300" type="text" name="nouveautitre" value="'.dolPrintHTML(
$object->title).
'">';
269 print dolPrintHTML(
$object->title);
274print
'<tr><td>'.$langs->trans(
'ToReceiveEMailForEachVote').
'</td><td>';
275if ($action ==
'edit') {
276 print
'<input type="checkbox" name="mailsonde" '.($object->mailsonde ?
'checked="checked"' :
'').
'">';
281 if (
$object->fk_user_creat &&
$object->mailsonde && $userstatic !==
null) {
282 if (!$userstatic->email) {
283 print
' '.img_warning($langs->trans(
'NoEMail'));
290print
'<tr><td>'.$langs->trans(
'CanComment').
'</td><td>';
291if ($action ==
'edit') {
292 print
'<input type="checkbox" name="cancomment" '.($object->allow_comments ?
'checked="checked"' :
'').
'">';
294 print yn(
$object->allow_comments);
299print
'<tr><td>'.$langs->trans(
'CanSeeOthersVote').
'</td><td>';
300if ($action ==
'edit') {
301 print
'<input type="checkbox" name="canseeothersvote" '.($object->allow_spy ?
'checked="checked"' :
'').
'">';
308print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak">';
309if ($action ==
'edit') {
310 $doleditor =
new DolEditor(
'nouveauxcommentaires',
$object->description,
'', 120,
'dolibarr_notes',
'In',
true, 1, 1, ROWS_7,
'100%');
311 $doleditor->Create(0,
'');
320print
'<div class="fichehalfright">';
321print
'<div class="underbanner clearboth"></div>';
323print
'<table class="border tableforfield centpercent">';
326print
'<tr><td>'.$langs->trans(
'ExpireDate').
'</td><td>';
327if ($action ==
'edit') {
328 print $form->selectDate($expiredate ? $expiredate :
$object->date_fin,
'expire', 0, 0, 0,
'', 1, 0);
332 print img_warning($langs->trans(
"Expired"));
339print $langs->trans(
"Author").
'</td><td>';
340if (
$object->fk_user_creat > 0 && $userstatic !==
null) {
341 print $userstatic->getLoginUrl(-1);
343 if ($action ==
'edit') {
344 print
'<input type="text" name="nouvelleadresse" class="minwidth200" value="'.$object->mail_admin.
'">';
352print
'<tr><td>'.$langs->trans(
"UrlForSurvey",
'').
'</td><td>';
356$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
359$url = $urlwithroot.
'/public/opensurvey/studs.php?sondage='.
$object->id_sondage;
360print
'<input type="text" class="quatrevingtpercent" '.($action ==
'edit' ?
'disabled' :
'').
' id="opensurveyurl" name="opensurveyurl" value="'.$url.
'" spellcheck="false">';
368$parameters = array();
369$reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
370print $hookmanager->resPrint;
376print
'<div class="clearboth"></div>';
380if ($action ==
'edit') {
381 print $form->buttonsSaveCancel();
390print
'<div class="tabsAction">';
392if ($action !=
'edit' && $user->hasRight(
'opensurvey',
'write')) {
394 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"Modify").
'</a>';
398 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=validate&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"Valid").
'</a>';
403 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=close&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"Close").
'</a>';
407 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=reopen&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"ReOpen").
'</a>';
411 print dolGetButtonAction($langs->trans(
"Delete"), $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?suppressionsondage=1&id='.urlencode($numsondage).
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
416if ($action ==
'delete') {
417 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?&id='.urlencode($numsondage), $langs->trans(
"RemovePoll"), $langs->trans(
"ConfirmRemovalOfPoll", $numsondage),
'delete_confirm',
'',
'', 1);
423print
'<form name="formulaire5" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
424print
'<input type="hidden" name="token" value="'.newToken().
'">';
425print
'<input type="hidden" name="action" value="addcomment">';
426print
'<input type="hidden" name="id" value="'.urlencode($numsondage).
'">';
427print
'<input type="hidden" name="page_y" value="">';
432$comments =
$object->getComments();
434if (!empty($comments)) {
435 foreach ($comments as $comment) {
436 if ($user->hasRight(
'opensurvey',
'write')) {
437 print
'<a class="reposition" href="'.DOL_URL_ROOT.
'/opensurvey/card.php?action=deletecomment&token='.
newToken().
'&idcomment='.((int) $comment->id_comment).
'&id='.urlencode($numsondage).
'"> '.img_picto(
'',
'delete',
'', 0, 0, 0,
'',
'', 0).
'</a> ';
443 print
'<span class="opacitymedium">'.$langs->trans(
"NoCommentYet").
'</span><br>';
450 print
'<br><textarea name="comment" rows="2" class="quatrevingtpercent" placeholder="'.$langs->trans(
"AddACommentForPoll").
'"></textarea><br>'.
"\n";
451 print $langs->trans(
"Name").
': <input type="text" class="minwidth300" name="commentuser" value="'.
dol_escape_htmltag($user->getFullName($langs)).
'"> '.
"\n";
452 print
'<input type="submit" class="button reposition smallpaddingimp" name="ajoutcomment" value="'.dol_escape_htmltag($langs->trans(
"AddComment")).
'"><br>'.
"\n";
if(! $sortfield) if(! $sortorder) $object
global $dolibarr_main_url_root
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.
Class to manage a WYSIWYG editor.
Put here description of your class.
const STATUS_VALIDATED
Validated/Opened status.
const STATUS_CLOSED
Closed.
const STATUS_DRAFT
Draft status (not used)
Class to manage Dolibarr users.
dol_get_last_hour($date, $gm='tzserver')
Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59...
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_now($mode='gmt')
Return date for now.
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...
dol_print_email($email, $contactid=0, $socid=0, $addlink=0, $max=0, $showinvalid=2, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
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)
opensurvey_prepare_head(Opensurveysondage $object)
Returns an array with the tabs for the "Opensurvey poll" section It loads tabs from modules looking f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.