27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
"/core/class/doleditor.class.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/class/opensurveysondage.class.php";
32require_once DOL_DOCUMENT_ROOT.
"/opensurvey/lib/opensurvey.lib.php";
36if (!$user->hasRight(
'opensurvey',
'read')) {
41$action =
GETPOST(
'action',
'aZ09');
42$cancel =
GETPOST(
'cancel',
'alpha');
47 $numsondage = (string)
GETPOST(
'id',
'alpha');
53$result =
$object->fetch(0, $numsondage);
60$hookmanager->initHooks(array(
'surveycard',
'globalcard'));
64$permissiontoread = $user->hasRight(
'opensurvey',
'read');
65$permissiontoadd = $user->hasRight(
'opensurvey',
'write');
66$permissiontodelete = $user->hasRight(
'opensurvey',
'write');
73$parameters = array(
'id' => $numsondage);
74$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
85 if ($action ==
'delete_confirm' && $permissiontodelete) {
87 if (!$user->hasRight(
'opensurvey',
'write')) {
91 $result =
$object->delete($user,
'', $numsondage);
93 header(
'Location: '.
dol_buildpath(
'/opensurvey/list.php', 1));
98 if ($action ==
'close' && $permissiontoadd) {
104 if (($action ==
'reopen' || $action ==
'validate') && $permissiontoadd) {
110 if ($action ==
'update' && $permissiontoadd) {
112 if (!$user->hasRight(
'opensurvey',
'write')) {
118 if (!
GETPOST(
'nouveautitre')) {
119 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
126 $object->description = (string)
GETPOST(
'nouveauxcommentaires',
'restricthtml');
127 $object->mail_admin = (string)
GETPOST(
'nouvelleadresse',
'alpha');
128 $object->date_fin = $expiredate;
129 $object->allow_comments =
GETPOST(
'cancomment',
'aZ09') ==
'on' ? 1 : 0;
130 $object->allow_spy =
GETPOST(
'canseeothersvote',
'aZ09') ==
'on' ? 1 : 0;
131 $object->mailsonde =
GETPOST(
'mailsonde',
'aZ09') ==
'on' ? 1 : 0;
142 if (
GETPOST(
'ajoutcomment') && $permissiontoadd) {
145 if (!
GETPOST(
'comment',
"alphanohtml")) {
147 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Comment")),
null,
'errors');
149 if (!
GETPOST(
'commentuser',
"alphanohtml")) {
151 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"User")),
null,
'errors');
155 $comment = (string)
GETPOST(
"comment",
"alphanohtml");
156 $comment_user = (string)
GETPOST(
'commentuser',
"alphanohtml");
158 $resql =
$object->addComment($comment, $comment_user);
167 if ($action ==
'deletecomment' && $permissiontoadd) {
169 if ($idcomment > 0) {
171 if (!$user->hasRight(
'opensurvey',
'write')) {
175 $resql =
$object->deleteComment($idcomment);
179 if ($action ==
'edit' && $permissiontoadd) {
181 if (!$user->hasRight(
'opensurvey',
'write')) {
192$form =
new Form($db);
195 $userstatic =
new User($db);
196 $userstatic->fetch(
$object->fk_user_creat);
199$title =
$object->title.
" - ".$langs->trans(
'Card');
202$arrayofcss = array(
'/opensurvey/css/style.css');
203llxHeader(
'', $title, $helpurl,
'', 0, 0, $arrayofjs, $arrayofcss);
207$toutsujet = explode(
",",
$object->sujet);
208$listofanswers = array();
209foreach ($toutsujet as $value) {
210 $tmp = explode(
'@', $value);
211 $listofanswers[] = array(
'label'=>$tmp[0],
'format'=>(!empty($tmp[1]) ? $tmp[1] :
'checkbox'));
213$toutsujet = str_replace(
"@",
"<br>", $toutsujet);
214$toutsujet = str_replace(
"°",
"'", $toutsujet);
216print
'<form name="updatesurvey" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$numsondage.
'" method="POST">'.
"\n";
217print
'<input type="hidden" name="token" value="'.newToken().
'">';
218print
'<input type="hidden" name="action" value="update">';
227$linkback =
'<a href="'.DOL_URL_ROOT.
'/opensurvey/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
229dol_banner_tab(
$object,
'id', $linkback, 1,
'id_sondage',
'id_sondage', $morehtmlref);
232print
'<div class="fichecenter">';
234print
'<div class="fichehalfleft">';
235print
'<div class="underbanner clearboth"></div>';
236print
'<table class="border tableforfield centpercent">';
239$type = (
$object->format ==
"A") ?
'classic' :
'date';
240print
'<tr><td class="titlefieldmax45">'.$langs->trans(
"Type").
'</td><td>';
241print
img_picto(
'',
dol_buildpath(
'/opensurvey/img/'.($type ==
'classic' ?
'chart-32.png' :
'calendar-32.png'), 1),
'width="16"', 1);
242print
' '.$langs->trans($type ==
'classic' ?
"TypeClassic" :
"TypeDate").
'</td></tr>';
246$adresseadmin =
$object->mail_admin;
247print $langs->trans(
"Title").
'</td><td>';
248if ($action ==
'edit') {
249 print
'<input type="text" name="nouveautitre" style="width: 95%" value="'.dol_escape_htmltag(
dol_htmlentities(
$object->title)).
'">';
256print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak">';
257if ($action ==
'edit') {
258 $doleditor =
new DolEditor(
'nouveauxcommentaires',
$object->description,
'', 120,
'dolibarr_notes',
'In', 1, 1, 1, ROWS_7,
'90%');
259 $doleditor->Create(0,
'');
266print
'<tr><td>'.$langs->trans(
'ToReceiveEMailForEachVote').
'</td><td>';
267if ($action ==
'edit') {
268 print
'<input type="checkbox" name="mailsonde" '.($object->mailsonde ?
'checked="checked"' :
'').
'">';
274 if (!$userstatic->email) {
275 print
' '.img_warning($langs->trans(
'NoEMail'));
282print
'<tr><td>'.$langs->trans(
'CanComment').
'</td><td>';
283if ($action ==
'edit') {
284 print
'<input type="checkbox" name="cancomment" '.($object->allow_comments ?
'checked="checked"' :
'').
'">';
291print
'<tr><td>'.$langs->trans(
'CanSeeOthersVote').
'</td><td>';
292if ($action ==
'edit') {
293 print
'<input type="checkbox" name="canseeothersvote" '.($object->allow_spy ?
'checked="checked"' :
'').
'">';
302print
'<div class="fichehalfright">';
303print
'<div class="underbanner clearboth"></div>';
305print
'<table class="border tableforfield centpercent">';
308print
'<tr><td>'.$langs->trans(
'ExpireDate').
'</td><td>';
309if ($action ==
'edit') {
310 print $form->selectDate($expiredate ? $expiredate :
$object->date_fin,
'expire', 0, 0, 0,
'', 1, 0);
321print $langs->trans(
"Author").
'</td><td>';
322if (
$object->fk_user_creat > 0) {
323 print $userstatic->getLoginUrl(-1);
325 if ($action ==
'edit') {
326 print
'<input type="text" name="nouvelleadresse" class="minwith200" value="'.$object->mail_admin.
'">';
334print
'<tr><td>'.$langs->trans(
"UrlForSurvey",
'').
'</td><td>';
337$urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
338$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
341$url = $urlwithroot.
'/public/opensurvey/studs.php?sondage='.
$object->id_sondage;
342print
'<input type="text" class="quatrevingtpercent" '.($action ==
'edit' ?
'disabled' :
'').
' id="opensurveyurl" name="opensurveyurl" value="'.$url.
'">';
350$parameters = array();
351$reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
352print $hookmanager->resPrint;
358print
'<div class="clearboth"></div>';
362if ($action ==
'edit') {
363 print $form->buttonsSaveCancel();
372print
'<div class="tabsAction">';
374if ($action !=
'edit' && $user->hasRight(
'opensurvey',
'write')) {
376 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"Modify").
'</a>';
380 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=validate&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"Valid").
'</a>';
385 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=close&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"Close").
'</a>';
389 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=reopen&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"ReOpen").
'</a>';
393 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?suppressionsondage=1&id='.urlencode($numsondage).
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete);
398if ($action ==
'delete') {
399 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?&id='.urlencode($numsondage), $langs->trans(
"RemovePoll"), $langs->trans(
"ConfirmRemovalOfPoll", $id),
'delete_confirm',
'',
'', 1);
405print
'<form name="formulaire5" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
406print
'<input type="hidden" name="token" value="'.newToken().
'">';
407print
'<input type="hidden" name="action" value="addcomment">';
408print
'<input type="hidden" name="id" value="'.urlencode($numsondage).
'">';
409print
'<input type="hidden" name="page_y" value="">';
414$comments =
$object->getComments();
416if (!empty($comments)) {
417 foreach ($comments as $comment) {
418 if ($user->hasRight(
'opensurvey',
'write')) {
419 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.png',
'', 0, 0, 0,
'',
'', 0).
'</a> ';
425 print
'<span class="opacitymedium">'.$langs->trans(
"NoCommentYet").
'</span><br>';
432 print $langs->trans(
"AddACommentForPoll").
'<br>';
433 print
'<textarea name="comment" rows="2" class="quatrevingtpercent"></textarea><br>'.
"\n";
434 print $langs->trans(
"Name").
': <input type="text" class="minwidth300" name="commentuser" value="'.
dol_escape_htmltag($user->getFullName($langs)).
'"> '.
"\n";
435 print
'<input type="submit" class="button reposition smallpaddingimp" name="ajoutcomment" value="'.dol_escape_htmltag($langs->trans(
"AddComment")).
'"><br>'.
"\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
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_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.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_now($mode='auto')
Return date for now.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
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).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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...
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.