28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
"/core/class/doleditor.class.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.
"/opensurvey/class/opensurveysondage.class.php";
33require_once DOL_DOCUMENT_ROOT.
"/opensurvey/lib/opensurvey.lib.php";
37if (!$user->hasRight(
'opensurvey',
'read')) {
42$action =
GETPOST(
'action',
'aZ09');
43$cancel =
GETPOST(
'cancel',
'alpha');
48 $numsondage = (string)
GETPOST(
'id',
'alpha');
54$result =
$object->fetch(0, $numsondage);
61$hookmanager->initHooks(array(
'surveycard',
'globalcard'));
65$permissiontoread = $user->hasRight(
'opensurvey',
'read');
66$permissiontoadd = $user->hasRight(
'opensurvey',
'write');
67$permissiontodelete = $user->hasRight(
'opensurvey',
'write');
74$parameters = array(
'id' => $numsondage);
75$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
86 if ($action ==
'delete_confirm' && $permissiontodelete) {
88 if (!$user->hasRight(
'opensurvey',
'write')) {
92 $result =
$object->delete($user,
'', $numsondage);
94 header(
'Location: '.
dol_buildpath(
'/opensurvey/list.php', 1));
99 if ($action ==
'close' && $permissiontoadd) {
105 if (($action ==
'reopen' || $action ==
'validate') && $permissiontoadd) {
111 if ($action ==
'update' && $permissiontoadd) {
113 if (!$user->hasRight(
'opensurvey',
'write')) {
119 if (!
GETPOST(
'nouveautitre')) {
120 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
127 $object->description = (string)
GETPOST(
'nouveauxcommentaires',
'restricthtml');
128 $object->mail_admin = (string)
GETPOST(
'nouvelleadresse',
'alpha');
129 $object->date_fin = $expiredate;
130 $object->allow_comments =
GETPOST(
'cancomment',
'aZ09') ==
'on' ? 1 : 0;
131 $object->allow_spy =
GETPOST(
'canseeothersvote',
'aZ09') ==
'on' ? 1 : 0;
132 $object->mailsonde =
GETPOST(
'mailsonde',
'aZ09') ==
'on' ? 1 : 0;
143 if (
GETPOST(
'ajoutcomment') && $permissiontoadd) {
146 if (!
GETPOST(
'comment',
"alphanohtml")) {
148 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Comment")),
null,
'errors');
150 if (!
GETPOST(
'commentuser',
"alphanohtml")) {
152 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"User")),
null,
'errors');
156 $comment = (string)
GETPOST(
"comment",
"alphanohtml");
157 $comment_user = (string)
GETPOST(
'commentuser',
"alphanohtml");
159 $resql =
$object->addComment($comment, $comment_user);
168 if ($action ==
'deletecomment' && $permissiontoadd) {
170 if ($idcomment > 0) {
172 if (!$user->hasRight(
'opensurvey',
'write')) {
176 $resql =
$object->deleteComment($idcomment);
180 if ($action ==
'edit' && $permissiontoadd) {
182 if (!$user->hasRight(
'opensurvey',
'write')) {
193$form =
new Form($db);
196 $userstatic =
new User($db);
197 $userstatic->fetch(
$object->fk_user_creat);
200$title =
$object->title.
" - ".$langs->trans(
'Card');
203$arrayofcss = array(
'/opensurvey/css/style.css');
204llxHeader(
'', $title, $helpurl,
'', 0, 0, $arrayofjs, $arrayofcss);
208$toutsujet = explode(
",",
$object->sujet);
209$listofanswers = array();
210foreach ($toutsujet as $value) {
211 $tmp = explode(
'@', $value);
212 $listofanswers[] = array(
'label'=>$tmp[0],
'format'=>(!empty($tmp[1]) ? $tmp[1] :
'checkbox'));
214$toutsujet = str_replace(
"@",
"<br>", $toutsujet);
215$toutsujet = str_replace(
"°",
"'", $toutsujet);
217print
'<form name="updatesurvey" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$numsondage.
'" method="POST">'.
"\n";
218print
'<input type="hidden" name="token" value="'.newToken().
'">';
219print
'<input type="hidden" name="action" value="update">';
228$linkback =
'<a href="'.DOL_URL_ROOT.
'/opensurvey/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
230dol_banner_tab(
$object,
'id', $linkback, 1,
'id_sondage',
'id_sondage', $morehtmlref);
233print
'<div class="fichecenter">';
235print
'<div class="fichehalfleft">';
236print
'<div class="underbanner clearboth"></div>';
237print
'<table class="border tableforfield centpercent">';
240$type = (
$object->format ==
"A") ?
'classic' :
'date';
241print
'<tr><td class="titlefieldmax45">'.$langs->trans(
"Type").
'</td><td>';
242print
img_picto(
'',
dol_buildpath(
'/opensurvey/img/'.($type ==
'classic' ?
'chart-32.png' :
'calendar-32.png'), 1),
'width="16"', 1);
243print
' '.$langs->trans($type ==
'classic' ?
"TypeClassic" :
"TypeDate").
'</td></tr>';
247$adresseadmin =
$object->mail_admin;
248print $langs->trans(
"Title").
'</td><td>';
249if ($action ==
'edit') {
250 print
'<input type="text" name="nouveautitre" style="width: 95%" value="'.dol_escape_htmltag(
dol_htmlentities(
$object->title)).
'">';
257print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak">';
258if ($action ==
'edit') {
259 $doleditor =
new DolEditor(
'nouveauxcommentaires',
$object->description,
'', 120,
'dolibarr_notes',
'In',
true, 1, 1, ROWS_7,
'90%');
260 $doleditor->Create(0,
'');
267print
'<tr><td>'.$langs->trans(
'ToReceiveEMailForEachVote').
'</td><td>';
268if ($action ==
'edit') {
269 print
'<input type="checkbox" name="mailsonde" '.($object->mailsonde ?
'checked="checked"' :
'').
'">';
275 if (!$userstatic->email) {
276 print
' '.img_warning($langs->trans(
'NoEMail'));
283print
'<tr><td>'.$langs->trans(
'CanComment').
'</td><td>';
284if ($action ==
'edit') {
285 print
'<input type="checkbox" name="cancomment" '.($object->allow_comments ?
'checked="checked"' :
'').
'">';
292print
'<tr><td>'.$langs->trans(
'CanSeeOthersVote').
'</td><td>';
293if ($action ==
'edit') {
294 print
'<input type="checkbox" name="canseeothersvote" '.($object->allow_spy ?
'checked="checked"' :
'').
'">';
303print
'<div class="fichehalfright">';
304print
'<div class="underbanner clearboth"></div>';
306print
'<table class="border tableforfield centpercent">';
309print
'<tr><td>'.$langs->trans(
'ExpireDate').
'</td><td>';
310if ($action ==
'edit') {
311 print $form->selectDate($expiredate ? $expiredate :
$object->date_fin,
'expire', 0, 0, 0,
'', 1, 0);
322print $langs->trans(
"Author").
'</td><td>';
323if (
$object->fk_user_creat > 0) {
324 print $userstatic->getLoginUrl(-1);
326 if ($action ==
'edit') {
327 print
'<input type="text" name="nouvelleadresse" class="minwidth200" value="'.$object->mail_admin.
'">';
335print
'<tr><td>'.$langs->trans(
"UrlForSurvey",
'').
'</td><td>';
338$urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
339$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
342$url = $urlwithroot.
'/public/opensurvey/studs.php?sondage='.
$object->id_sondage;
343print
'<input type="text" class="quatrevingtpercent" '.($action ==
'edit' ?
'disabled' :
'').
' id="opensurveyurl" name="opensurveyurl" value="'.$url.
'">';
351$parameters = array();
352$reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
353print $hookmanager->resPrint;
359print
'<div class="clearboth"></div>';
363if ($action ==
'edit') {
364 print $form->buttonsSaveCancel();
373print
'<div class="tabsAction">';
375if ($action !=
'edit' && $user->hasRight(
'opensurvey',
'write')) {
377 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"Modify").
'</a>';
381 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=validate&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"Valid").
'</a>';
386 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=close&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"Close").
'</a>';
390 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=reopen&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"ReOpen").
'</a>';
394 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?suppressionsondage=1&id='.urlencode($numsondage).
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete);
399if ($action ==
'delete') {
400 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?&id='.urlencode($numsondage), $langs->trans(
"RemovePoll"), $langs->trans(
"ConfirmRemovalOfPoll", $id),
'delete_confirm',
'',
'', 1);
406print
'<form name="formulaire5" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
407print
'<input type="hidden" name="token" value="'.newToken().
'">';
408print
'<input type="hidden" name="action" value="addcomment">';
409print
'<input type="hidden" name="id" value="'.urlencode($numsondage).
'">';
410print
'<input type="hidden" name="page_y" value="">';
415$comments =
$object->getComments();
417if (!empty($comments)) {
418 foreach ($comments as $comment) {
419 if ($user->hasRight(
'opensurvey',
'write')) {
420 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> ';
426 print
'<span class="opacitymedium">'.$langs->trans(
"NoCommentYet").
'</span><br>';
433 print $langs->trans(
"AddACommentForPoll").
'<br>';
434 print
'<textarea name="comment" rows="2" class="quatrevingtpercent"></textarea><br>'.
"\n";
435 print $langs->trans(
"Name").
': <input type="text" class="minwidth300" name="commentuser" value="'.
dol_escape_htmltag($user->getFullName($langs)).
'"> '.
"\n";
436 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.
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.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
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.