27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
"/core/class/doleditor.class.php";
29 require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
30 require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
31 require_once DOL_DOCUMENT_ROOT.
"/opensurvey/class/opensurveysondage.class.php";
32 require_once DOL_DOCUMENT_ROOT.
"/opensurvey/lib/opensurvey.lib.php";
36 if (empty($user->rights->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->rights->opensurvey->read;
65 $permissiontoadd = $user->rights->opensurvey->write;
67 $permissiontodelete = $user->rights->opensurvey->write;
75 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
80 if (empty($reshook)) {
86 if ($action ==
'delete_confirm') {
88 if (!$user->rights->opensurvey->write) {
92 $result = $object->delete($user,
'', $numsondage);
94 header(
'Location: '.
dol_buildpath(
'/opensurvey/list.php', 1));
99 if ($action ==
'close') {
101 $object->update($user);
105 if ($action ==
'reopen') {
107 $object->update($user);
111 if ($action ==
'update') {
113 if (!$user->rights->opensurvey->write) {
119 if (!
GETPOST(
'nouveautitre')) {
120 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
126 $object->title = (string)
GETPOST(
'nouveautitre',
'alphanohtml');
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;
134 $res = $object->update($user);
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') {
169 $idcomment =
GETPOST(
'idcomment',
'int');
170 if ($idcomment > 0) {
172 if (!$user->rights->opensurvey->write) {
176 $resql = $object->deleteComment($idcomment);
180 if ($action ==
'edit') {
182 if (!$user->rights->opensurvey->write) {
195 if ($object->fk_user_creat) {
196 $userstatic =
new User($db);
197 $userstatic->fetch($object->fk_user_creat);
200 $title = $object->title.
" - ".$langs->trans(
'Card');
202 $arrayofjs = array();
203 $arrayofcss = array(
'/opensurvey/css/style.css');
204 llxHeader(
'', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss);
208 $toutsujet = explode(
",", $object->sujet);
209 $listofanswers = array();
210 foreach ($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);
217 print
'<form name="updatesurvey" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$numsondage.
'" method="POST">'.
"\n";
218 print
'<input type="hidden" name="token" value="'.newToken().
'">';
219 print
'<input type="hidden" name="action" value="update">';
221 $head = opensurvey_prepare_head($object);
228 $linkback =
'<a href="'.DOL_URL_ROOT.
'/opensurvey/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
230 dol_banner_tab($object,
'id', $linkback, 1,
'id_sondage',
'id_sondage', $morehtmlref);
233 print
'<div class="fichecenter">';
235 print
'<div class="fichehalfleft">';
236 print
'<div class="underbanner clearboth"></div>';
237 print
'<table class="border tableforfield centpercent">';
240 $type = ($object->format ==
"A") ?
'classic' :
'date';
241 print
'<tr><td class="titlefieldmax45">'.$langs->trans(
"Type").
'</td><td>';
242 print
img_picto(
'',
dol_buildpath(
'/opensurvey/img/'.($type ==
'classic' ?
'chart-32.png' :
'calendar-32.png'), 1),
'width="16"', 1);
243 print
' '.$langs->trans($type ==
'classic' ?
"TypeClassic" :
"TypeDate").
'</td></tr>';
247 $adresseadmin = $object->mail_admin;
248 print $langs->trans(
"Title").
'</td><td>';
249 if ($action ==
'edit') {
250 print
'<input type="text" name="nouveautitre" style="width: 95%" value="'.dol_escape_htmltag(
dol_htmlentities($object->title)).
'">';
257 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
258 if ($action ==
'edit') {
259 $doleditor =
new DolEditor(
'nouveauxcommentaires', $object->description,
'', 120,
'dolibarr_notes',
'In', 1, 1, 1, ROWS_7,
'90%');
260 $doleditor->Create(0,
'');
262 print (
dol_textishtml($object->description) ? $object->description :
dol_nl2br($object->description, 1,
true));
267 print
'<tr><td>'.$langs->trans(
'ToReceiveEMailForEachVote').
'</td><td>';
268 if ($action ==
'edit') {
269 print
'<input type="checkbox" name="mailsonde" '.($object->mailsonde ?
'checked="checked"' :
'').
'">';
271 print
yn($object->mailsonde);
274 if ($object->fk_user_creat && $object->mailsonde) {
275 if (!$userstatic->email) {
276 print
' '.img_warning($langs->trans(
'NoEMail'));
283 print
'<tr><td>'.$langs->trans(
'CanComment').
'</td><td>';
284 if ($action ==
'edit') {
285 print
'<input type="checkbox" name="cancomment" '.($object->allow_comments ?
'checked="checked"' :
'').
'">';
287 print
yn($object->allow_comments);
292 print
'<tr><td>'.$langs->trans(
'CanSeeOthersVote').
'</td><td>';
293 if ($action ==
'edit') {
294 print
'<input type="checkbox" name="canseeothersvote" '.($object->allow_spy ?
'checked="checked"' :
'').
'">';
296 print
yn($object->allow_spy);
303 print
'<div class="fichehalfright">';
304 print
'<div class="underbanner clearboth"></div>';
306 print
'<table class="border tableforfield centpercent">';
309 print
'<tr><td>'.$langs->trans(
'ExpireDate').
'</td><td>';
310 if ($action ==
'edit') {
311 print
$form->selectDate($expiredate ? $expiredate : $object->date_fin,
'expire', 0, 0, 0,
'', 1, 0);
322 print $langs->trans(
"Author").
'</td><td>';
323 if ($object->fk_user_creat > 0) {
324 print $userstatic->getLoginUrl(1);
326 if ($action ==
'edit') {
327 print
'<input type="text" name="nouvelleadresse" class="minwith200" value="'.$object->mail_admin.
'">';
335 print
'<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;
343 print
'<input type="text" class="quatrevingtpercent" '.($action ==
'edit' ?
'disabled' :
'').
' id="opensurveyurl" name="opensurveyurl" value="'.$url.
'">';
344 if ($action !=
'edit') {
352 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
353 print $hookmanager->resPrint;
359 print
'<div class="clearboth"></div>';
363 if ($action ==
'edit') {
364 print
$form->buttonsSaveCancel();
367 print
'</form>'.
"\n";
373 print
'<div class="tabsAction">';
375 if ($action !=
'edit' && $user->rights->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=close&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"Close").
'</a>';
385 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=reopen&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"ReOpen").
'</a>';
389 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?suppressionsondage=1&id='.urlencode($numsondage).
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete);
394 if ($action ==
'delete') {
395 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?&id='.urlencode($numsondage), $langs->trans(
"RemovePoll"), $langs->trans(
"ConfirmRemovalOfPoll", $id),
'delete_confirm',
'',
'', 1);
401 print
'<form name="formulaire5" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
402 print
'<input type="hidden" name="token" value="'.newToken().
'">';
403 print
'<input type="hidden" name="action" value="addcomment">';
404 print
'<input type="hidden" name="id" value="'.urlencode($numsondage).
'">';
405 print
'<input type="hidden" name="page_y" value="">';
410 $comments = $object->getComments();
412 if (!empty($comments)) {
413 foreach ($comments as $comment) {
414 if ($user->rights->opensurvey->write) {
415 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',
'',
false, 0, 0,
'',
'', 0).
'</a> ';
421 print
'<span class="opacitymedium">'.$langs->trans(
"NoCommentYet").
'</span><br>';
427 if ($object->allow_comments) {
428 print $langs->trans(
"AddACommentForPoll").
'<br>';
429 print
'<textarea name="comment" rows="2" class="quatrevingtpercent"></textarea><br>'.
"\n";
430 print $langs->trans(
"Name").
': <input type="text" class="minwidth300" name="commentuser" value="'.
dol_escape_htmltag($user->getFullName($langs)).
'"> '.
"\n";
431 print
'<input type="submit" class="button reposition" name="ajoutcomment" value="'.dol_escape_htmltag($langs->trans(
"AddComment")).
'"><br>'.
"\n";
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage a WYSIWYG editor.
Put here description of your class.
const STATUS_VALIDATED
Validated/Opened status.
const STATUS_CLOSED
Closed.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
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_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.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.