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";
 
   47if (!$user->hasRight(
'opensurvey', 
'read')) {
 
   52$action = 
GETPOST(
'action', 
'aZ09');
 
   53$cancel = 
GETPOST(
'cancel', 
'alpha');
 
   58  $numsondage = (string) 
GETPOST(
'id', 
'alpha');
 
   64$result = 
$object->fetch(0, $numsondage);
 
   71$hookmanager->initHooks(array(
'surveycard', 
'globalcard'));
 
   75$permissiontoread = $user->hasRight(
'opensurvey', 
'read');
 
   76$permissiontoadd = $user->hasRight(
'opensurvey', 
'write');
 
   77$permissiontodelete = $user->hasRight(
'opensurvey', 
'write'); 
 
   84$parameters = array(
'id' => $numsondage);
 
   85$reshook = $hookmanager->executeHooks(
'doActions', $parameters, 
$object, $action); 
 
   96  if ($action == 
'delete_confirm' && $permissiontodelete) {
 
   98    if (!$user->hasRight(
'opensurvey', 
'write')) {
 
  102    $result = 
$object->delete($user, 0, $numsondage);
 
  104    header(
'Location: '.
dol_buildpath(
'/opensurvey/list.php', 1));
 
  109  if ($action == 
'close' && $permissiontoadd) {
 
  115  if (($action == 
'reopen' || $action == 
'validate') && $permissiontoadd) {
 
  121  if ($action == 
'update' && $permissiontoadd) {
 
  123    if (!$user->hasRight(
'opensurvey', 
'write')) {
 
  129    if (!
GETPOST(
'nouveautitre')) {
 
  130      setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")), 
null, 
'errors');
 
  137      $object->description = (string) 
GETPOST(
'nouveauxcommentaires', 
'restricthtml');
 
  138      $object->mail_admin = (string) 
GETPOST(
'nouvelleadresse', 
'alpha');
 
  139      $object->date_fin = $expiredate;
 
  140      $object->allow_comments = 
GETPOST(
'cancomment', 
'aZ09') == 
'on' ? 1 : 0;
 
  141      $object->allow_spy = 
GETPOST(
'canseeothersvote', 
'aZ09') == 
'on' ? 1 : 0;
 
  142      $object->mailsonde = 
GETPOST(
'mailsonde', 
'aZ09') == 
'on' ? 1 : 0;
 
  153  if (
GETPOST(
'ajoutcomment') && $permissiontoadd) {
 
  156    if (!
GETPOST(
'comment', 
"alphanohtml")) {
 
  158      setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Comment")), 
null, 
'errors');
 
  160    if (!
GETPOST(
'commentuser', 
"alphanohtml")) {
 
  162      setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"User")), 
null, 
'errors');
 
  166      $comment = (string) 
GETPOST(
"comment", 
"alphanohtml");
 
  167      $comment_user = (string) 
GETPOST(
'commentuser', 
"alphanohtml");
 
  169      $resql = 
$object->addComment($comment, $comment_user);
 
  178  if ($action == 
'deletecomment' && $permissiontoadd) {
 
  180    if ($idcomment > 0) {
 
  182      if (!$user->hasRight(
'opensurvey', 
'write')) {
 
  186      $resql = 
$object->deleteComment($idcomment);
 
  190  if ($action == 
'edit' && $permissiontoadd) {
 
  192    if (!$user->hasRight(
'opensurvey', 
'write')) {
 
  203$form = 
new Form($db);
 
  206  $userstatic = 
new User($db);
 
  207  $userstatic->fetch(
$object->fk_user_creat);
 
  210$title = 
$object->title.
" - ".$langs->trans(
'Card');
 
  213$arrayofcss = array(
'/opensurvey/css/style.css');
 
  214llxHeader(
'', $title, $helpurl, 
'', 0, 0, $arrayofjs, $arrayofcss);
 
  218$toutsujet = explode(
",", 
$object->sujet);
 
  219$listofanswers = array();
 
  220foreach ($toutsujet as $value) {
 
  221  $tmp = explode(
'@', $value);
 
  222  $listofanswers[] = array(
'label' => $tmp[0], 
'format' => (!empty($tmp[1]) ? $tmp[1] : 
'checkbox'));
 
  224$toutsujet = str_replace(
"@", 
"<br>", $toutsujet);
 
  225$toutsujet = str_replace(
"°", 
"'", $toutsujet);
 
  227print 
'<form name="updatesurvey" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$numsondage.
'" method="POST">'.
"\n";
 
  228print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  229print 
'<input type="hidden" name="action" value="update">';
 
  238$linkback = 
'<a href="'.DOL_URL_ROOT.
'/opensurvey/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
 
  240dol_banner_tab(
$object, 
'id', $linkback, 1, 
'id_sondage', 
'id_sondage', $morehtmlref);
 
  243print 
'<div class="fichecenter">';
 
  245print 
'<div class="fichehalfleft">';
 
  246print 
'<div class="underbanner clearboth"></div>';
 
  247print 
'<table class="border tableforfield centpercent">';
 
  250$type = (
$object->format == 
"A") ? 
'classic' : 
'date';
 
  251print 
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Type").
'</td><td>';
 
  252print 
img_picto(
'', 
dol_buildpath(
'/opensurvey/img/'.($type == 
'classic' ? 
'chart-32.png' : 
'calendar-32.png'), 1), 
'width="16"', 1);
 
  253print 
' '.$langs->trans($type == 
'classic' ? 
"TypeClassic" : 
"TypeDate").
'</td></tr>';
 
  257$adresseadmin = 
$object->mail_admin;
 
  258print $langs->trans(
"Title").
'</td><td>';
 
  259if ($action == 
'edit') {
 
  260  print 
'<input class="width300" type="text" name="nouveautitre" value="'.dolPrintHTML(
$object->title).
'">';
 
  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"' : 
'').
'">';
 
  301print 
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak">';
 
  302if ($action == 
'edit') {
 
  303  $doleditor = 
new DolEditor(
'nouveauxcommentaires', 
$object->description, 
'', 120, 
'dolibarr_notes', 
'In', 
true, 1, 1, ROWS_7, 
'90%');
 
  304  $doleditor->Create(0, 
'');
 
  313print 
'<div class="fichehalfright">';
 
  314print 
'<div class="underbanner clearboth"></div>';
 
  316print 
'<table class="border tableforfield centpercent">';
 
  319print 
'<tr><td>'.$langs->trans(
'ExpireDate').
'</td><td>';
 
  320if ($action == 
'edit') {
 
  321  print $form->selectDate($expiredate ? $expiredate : 
$object->date_fin, 
'expire', 0, 0, 0, 
'', 1, 0);
 
  332print $langs->trans(
"Author").
'</td><td>';
 
  333if (
$object->fk_user_creat > 0) {
 
  334  print $userstatic->getLoginUrl(-1);
 
  336  if ($action == 
'edit') {
 
  337    print 
'<input type="text" name="nouvelleadresse" class="minwidth200" value="'.$object->mail_admin.
'">';
 
  345print 
'<tr><td>'.$langs->trans(
"UrlForSurvey", 
'').
'</td><td>';
 
  348$urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT, 
'/').
'$/i', 
'', trim($dolibarr_main_url_root));
 
  349$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; 
 
  352$url = $urlwithroot.
'/public/opensurvey/studs.php?sondage='.
$object->id_sondage;
 
  353print 
'<input type="text" class="quatrevingtpercent" '.($action == 
'edit' ? 
'disabled' : 
'').
' id="opensurveyurl" name="opensurveyurl" value="'.$url.
'">';
 
  361$parameters = array();
 
  362$reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, 
$object, $action); 
 
  363print $hookmanager->resPrint;
 
  369print 
'<div class="clearboth"></div>';
 
  373if ($action == 
'edit') {
 
  374  print $form->buttonsSaveCancel();
 
  383print 
'<div class="tabsAction">';
 
  385if ($action != 
'edit' && $user->hasRight(
'opensurvey', 
'write')) {
 
  387  print 
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"Modify").
'</a>';
 
  391    print 
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=validate&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"Valid").
'</a>';
 
  396    print 
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=close&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"Close").
'</a>';
 
  400    print 
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=reopen&token='.
newToken().
'&id='.urlencode($numsondage).
'">'.$langs->trans(
"ReOpen").
'</a>';
 
  404  print 
dolGetButtonAction($langs->trans(
"Delete"), 
'', 
'delete', $_SERVER[
"PHP_SELF"].
'?suppressionsondage=1&id='.urlencode($numsondage).
'&action=delete&token='.
newToken(), 
'delete', $permissiontodelete);
 
  409if ($action == 
'delete') {
 
  410  print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?&id='.urlencode($numsondage), $langs->trans(
"RemovePoll"), $langs->trans(
"ConfirmRemovalOfPoll", $id), 
'delete_confirm', 
'', 
'', 1);
 
  416print 
'<form name="formulaire5" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
 
  417print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  418print 
'<input type="hidden" name="action" value="addcomment">';
 
  419print 
'<input type="hidden" name="id" value="'.urlencode($numsondage).
'">';
 
  420print 
'<input type="hidden" name="page_y" value="">';
 
  425$comments = 
$object->getComments();
 
  427if (!empty($comments)) {
 
  428  foreach ($comments as $comment) {
 
  429    if ($user->hasRight(
'opensurvey', 
'write')) {
 
  430      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> ';
 
  436  print 
'<span class="opacitymedium">'.$langs->trans(
"NoCommentYet").
'</span><br>';
 
  443  print $langs->trans(
"AddACommentForPoll").
'<br>';
 
  444  print 
'<textarea name="comment" rows="2" class="quatrevingtpercent"></textarea><br>'.
"\n";
 
  445  print $langs->trans(
"Name").
': <input type="text" class="minwidth300" name="commentuser" value="'.
dol_escape_htmltag($user->getFullName($langs)).
'"> '.
"\n";
 
  446  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
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_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.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
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.