26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
28 require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
29 require_once DOL_DOCUMENT_ROOT.
"/core/class/doleditor.class.php";
30 require_once DOL_DOCUMENT_ROOT.
"/opensurvey/class/opensurveysondage.class.php";
31 require_once DOL_DOCUMENT_ROOT.
"/opensurvey/fonctions.php";
38 $action =
GETPOST(
'action',
'aZ09');
39 $cancel =
GETPOST(
'cancel',
'alpha');
44 $numsondage = (string)
GETPOST(
'id',
'alpha');
49 $result = $object->fetch(0, $numsondage);
63 $parameters = array(
'id' => $numsondage);
64 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
65 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
69 if ($cancel) $action =
'';
72 if ($action ==
'delete_confirm')
77 $result = $object->delete($user,
'', $numsondage);
79 header(
'Location: '.
dol_buildpath(
'/opensurvey/list.php', 1));
84 if ($action ==
'close')
87 $object->update($user);
91 if ($action ==
'reopen')
94 $object->update($user);
98 if ($action ==
'update')
107 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")), null,
'errors');
114 $object->title = (string)
GETPOST(
'nouveautitre',
'alphanohtml');
115 $object->description = (string)
GETPOST(
'nouveauxcommentaires',
'restricthtml');
116 $object->mail_admin = (string)
GETPOST(
'nouvelleadresse',
'alpha');
117 $object->date_fin = $expiredate;
118 $object->allow_comments =
GETPOST(
'cancomment',
'aZ09') ==
'on' ? 1 : 0;
119 $object->allow_spy =
GETPOST(
'canseeothersvote',
'aZ09') ==
'on' ? 1 : 0;
120 $object->mailsonde =
GETPOST(
'mailsonde',
'aZ09') ==
'on' ? 1 : 0;
122 $res = $object->update($user);
137 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Comment")), null,
'errors');
141 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"User")), null,
'errors');
145 $comment = (string)
GETPOST(
"comment",
"restricthtml");
146 $comment_user = (string)
GETPOST(
'commentuser',
"restricthtml");
148 $resql = $object->addComment($comment, $comment_user);
158 $idcomment =
GETPOST(
'deletecomment',
'int');
164 $resql = $object->deleteComment($idcomment);
167 if ($action ==
'edit') {
178 $form =
new Form($db);
180 if ($object->fk_user_creat)
182 $userstatic =
new User($db);
183 $userstatic->fetch($object->fk_user_creat);
186 $title = $object->title.
" - ".$langs->trans(
'Card');
188 $arrayofjs = array();
189 $arrayofcss = array(
'/opensurvey/css/style.css');
190 llxHeader(
'', $title, $helpurl, 0, 0, 0, $arrayofjs, $arrayofcss);
194 $toutsujet = explode(
",", $object->sujet);
195 $listofanswers = array();
196 foreach ($toutsujet as $value)
198 $tmp = explode(
'@', $value);
199 $listofanswers[] = array(
'label'=>$tmp[0],
'format'=>($tmp[1] ? $tmp[1] :
'checkbox'));
201 $toutsujet = str_replace(
"@",
"<br>", $toutsujet);
202 $toutsujet = str_replace(
"°",
"'", $toutsujet);
204 print '<form name="updatesurvey" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$numsondage.
'" method="POST">'.
"\n";
205 print '<input type="hidden" name="token" value="'.newToken().
'">';
206 print '<input type="hidden" name="action" value="update">';
215 $linkback =
'<a href="'.DOL_URL_ROOT.
'/opensurvey/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
217 dol_banner_tab($object,
'id', $linkback, 1,
'id_sondage',
'id_sondage', $morehtmlref);
220 print '<div class="fichecenter">';
221 print '<div class="underbanner clearboth"></div>';
223 print '<table class="border tableforfield centpercent">';
226 $type = ($object->format ==
"A") ?
'classic' :
'date';
227 print '<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td colspan="2">';
228 print img_picto(
'',
dol_buildpath(
'/opensurvey/img/'.($type ==
'classic' ?
'chart-32.png' :
'calendar-32.png'), 1),
'width="16"', 1);
229 print ' '.$langs->trans($type ==
'classic' ?
"TypeClassic" :
"TypeDate").
'</td></tr>';
233 $adresseadmin = $object->mail_admin;
234 print $langs->trans(
"Title").
'</td><td colspan="2">';
235 if ($action ==
'edit')
237 print '<input type="text" name="nouveautitre" style="width: 95%" value="'.dol_escape_htmltag(
dol_htmlentities($object->title)).
'">';
242 print '<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td colspan="2">';
243 if ($action ==
'edit')
245 $doleditor =
new DolEditor(
'nouveauxcommentaires', $object->description,
'', 120,
'dolibarr_notes',
'In', 1, 1, 1, ROWS_7,
'90%');
246 $doleditor->Create(0,
'');
254 if (!$object->fk_user_creat) {
255 print '<tr><td>'.$langs->trans(
"EMail").
'</td><td colspan="2">';
256 if ($action ==
'edit')
258 print '<input type="text" name="nouvelleadresse" class="minwith200" value="'.$object->mail_admin.
'">';
264 print '<tr><td>'.$langs->trans(
'ToReceiveEMailForEachVote').
'</td><td colspan="2">';
265 if ($action ==
'edit')
267 print '<input type="checkbox" name="mailsonde" '.($object->mailsonde ?
'checked="checked"' :
'').
'">';
272 if ($object->fk_user_creat && $object->mailsonde) {
273 if (!$userstatic->email) {
274 print ' '.img_warning($langs->trans(
'NoEMail'));
281 print '<tr><td>'.$langs->trans(
'CanComment').
'</td><td colspan="2">';
282 if ($action ==
'edit')
284 print '<input type="checkbox" name="cancomment" '.($object->allow_comments ?
'checked="checked"' :
'').
'">';
285 }
else print yn($object->allow_comments);
289 print '<tr><td>'.$langs->trans(
'CanSeeOthersVote').
'</td><td colspan="2">';
290 if ($action ==
'edit')
292 print '<input type="checkbox" name="canseeothersvote" '.($object->allow_spy ?
'checked="checked"' :
'').
'">';
293 }
else print yn($object->allow_spy);
297 print '<tr><td>'.$langs->trans(
'ExpireDate').
'</td><td colspan="2">';
298 if ($action ==
'edit')
print $form->selectDate($expiredate ? $expiredate : $object->date_fin,
'expire', 0, 0, 0,
'', 1, 0);
307 print $langs->trans(
"Author").
'</td><td colspan="2">';
308 if ($object->fk_user_creat) {
309 print $userstatic->getLoginUrl(1);
316 print '<tr><td>'.img_picto(
'',
'globe').
' '.$langs->trans(
"UrlForSurvey",
'').
'</td><td colspan="2">';
319 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
320 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
323 $url = $urlwithroot.
'/public/opensurvey/studs.php?sondage='.$object->id_sondage;
324 print '<input type="text" style="width: 60%" '.($action ==
'edit' ?
'disabled' :
'').
' id="opensurveyurl" name="opensurveyurl" value="'.$url.
'">';
335 if ($action ==
'edit')
337 print '<div class="center">';
338 print '<input type="submit" class="button button-save" name="save" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
340 print '<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
344 print '</form>'.
"\n";
351 print '<div class="tabsAction">';
353 if ($action !=
'edit' && $user->rights->opensurvey->write) {
355 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&id='.$numsondage.
'">'.$langs->trans(
"Modify").
'</a>';
360 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=close&id='.$numsondage.
'">'.$langs->trans(
"Close").
'</a>';
365 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=reopen&id='.$numsondage.
'">'.$langs->trans(
"ReOpen").
'</a>';
369 print '<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?suppressionsondage=1&id='.$numsondage.
'&action=delete&token='.
newToken().
'">'.$langs->trans(
'Delete').
'</a>';
374 if ($action ==
'delete')
376 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?&id='.$numsondage, $langs->trans(
"RemovePoll"), $langs->trans(
"ConfirmRemovalOfPoll", $id),
'delete_confirm',
'',
'', 1);
382 print '<form name="formulaire5" action="#" method="POST">'.
"\n";
383 print '<input type="hidden" name="token" value="'.newToken().
'">';
388 $comments = $object->getComments();
391 foreach ($comments as $comment) {
392 if ($user->rights->opensurvey->write) {
393 print '<a href="'.dol_buildpath(
'/opensurvey/card.php', 1).
'?deletecomment='.$comment->id_comment.
'&id='.$numsondage.
'"> '.
img_picto(
'',
'delete.png',
'',
false, 0, 0,
'',
'', 0).
'</a> ';
399 print '<span class="opacitymedium">'.$langs->trans(
"NoCommentYet").
'</span><br>';
405 if ($object->allow_comments) {
406 print $langs->trans(
"AddACommentForPoll").
'<br>';
407 print '<textarea name="comment" rows="2" class="quatrevingtpercent"></textarea><br>'.
"\n";
408 print $langs->trans(
"Name").
': <input type="text" class="minwidth300" name="commentuser" value="'.$user->getFullName($langs).
'"> '.
"\n";
409 print '<input type="submit" class="button" name="ajoutcomment" value="'.dol_escape_htmltag($langs->trans(
"AddComment")).
'"><br>'.
"\n";
410 if (isset($erreur_commentaire_vide) && $erreur_commentaire_vide ==
"yes") {
411 print "<font color=#FF0000>".$langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Name")).
"</font>";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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...
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
dol_htmlentities($string, $flags=null, $encoding= 'UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
const STATUS_CLOSED
Closed.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
const STATUS_VALIDATED
Validated/Opened status.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Put here description of your class.
ajax_autoselect($htmlname, $addlink= '')
Make content of an input box selected when we click into input field.
print $_SERVER["PHP_SELF"]
Edit parameters.
opensurvey_prepare_head(Opensurveysondage $object)
Returns an array with the tabs for the "Opensurvey poll" section It loads tabs from modules looking f...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage a WYSIWYG editor.
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.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
dol_textishtml($msg, $option=0)
Return if a text is a html content.