28require
'../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
37require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
38require_once DOL_DOCUMENT_ROOT.
"/opensurvey/class/opensurveysondage.class.php";
41$langs->load(
"opensurvey");
43$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
44$massaction =
GETPOST(
'massaction',
'alpha');
46$confirm =
GETPOST(
'confirm',
'alpha');
47$cancel =
GETPOST(
'cancel',
'alpha');
48$toselect =
GETPOST(
'toselect',
'array:int');
49$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'opensurveylist';
50$backtopage =
GETPOST(
'backtopage',
'alpha');
51$optioncss =
GETPOST(
'optioncss',
'aZ');
54$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
55$search_expired =
GETPOST(
'search_expired');
58$search_ref =
GETPOST(
'search_ref',
'alpha');
59$search_title =
GETPOST(
'search_title',
'alpha');
60$search_status =
GETPOST(
'search_status',
'alpha');
64$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
65$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
67if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
70$offset = $limit * $page;
79$diroutputmassaction =
$conf->opensurvey->dir_output.
'/temp/massgeneration/'.$user->id;
80$hookmanager->initHooks(array(
'surveylist'));
82$extrafields->fetch_name_optionals_label(
$object->table_element);
83$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
87 $sortfield =
"p.date_fin";
94if (!$user->hasRight(
'opensurvey',
'read')) {
98$fieldstosearchall = array();
101$arrayfields = array();
103include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
105$parameters = array(
'arrayfields' => &$arrayfields);
106$reshook = $hookmanager->executeHooks(
'completeArrayFields', $parameters, $object, $action);
112$permissiontoread = $user->hasRight(
'opensurvey',
'read');
113$permissiontoadd = $user->hasRight(
'opensurvey',
'write');
115$permissiontodelete = $user->hasRight(
'opensurvey',
'write');
122if (
GETPOST(
'cancel',
'alpha')) {
126if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
130$parameters = array(
'arrayfields' => &$arrayfields);
131$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
136if (empty($reshook)) {
138 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
141 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
146 $search_array_options = array();
148 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
149 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
154 $objectclass =
'Opensurveysondage';
155 $objectlabel =
'Opensurveysondage';
156 $uploaddir =
$conf->opensurvey->dir_output;
157 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
171$title = $langs->trans(
'OpenSurveyArea');
175$sql =
"SELECT p.id_sondage as rowid, p.fk_user_creat, p.format, p.date_fin, p.status, p.titre as title, p.nom_admin, p.tms,";
176$sql .=
" u.login, u.firstname, u.lastname";
180$sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_sondage as p";
181$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user u ON u.rowid = p.fk_user_creat";
182$sql .=
" WHERE p.entity IN (".getEntity(
'survey').
")";
183if ($search_status !=
'-1' && $search_status !=
'') {
186if (!empty($search_expired) && $search_expired ==
'expired') {
187 $sql .=
" AND p.date_fin < '".$db->idate($now).
"'";
189if (!empty($search_expired) && $search_expired ==
'opened') {
190 $sql .=
" AND p.date_fin >= '".$db->idate($now).
"'";
192if (!empty($search_ref)) {
195if (!empty($search_title)) {
199include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
201$parameters = array();
202$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
203$sql .= $hookmanager->resPrint;
206$nbtotalofrecords =
'';
209 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
210 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
212 $resql =
$db->query($sqlforcount);
214 $objforcount =
$db->fetch_object($resql);
215 $nbtotalofrecords = $objforcount->nbtotalofrecords;
220 if (($page * $limit) > (
int) $nbtotalofrecords) {
228$sql .=
$db->order($sortfield, $sortorder);
230 $sql .=
$db->plimit($limit + 1, $offset);
233$resql =
$db->query($sql);
239$num =
$db->num_rows($resql);
243if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
244 $obj =
$db->fetch_object($resql);
246 header(
"Location: ".
dol_buildpath(
'/opensurvey/card.php', 1).
'?id='.((
int)
$id));
254llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist');
256$arrayofselected = is_array($toselect) ? $toselect : array();
259if ( $contextpage != $_SERVER[
"PHP_SELF"]) {
260 $param .=
'&contextpage='.urlencode($contextpage);
262if ($limit > 0 && $limit !=
$conf->liste_limit) {
263 $param .=
'&limit='.((int) $limit);
265if ($optioncss !=
'') {
266 $param .=
'&optioncss='.urlencode($optioncss);
268$fieldtosortuser =
getDolGlobalString(
'MAIN_FIRSTNAME_NAME_POSITION') ?
'lastname' :
'firstname';
271include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
274$arrayofmassactions = array(
278if (!empty($permissiontodelete)) {
279 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
281if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
282 $arrayofmassactions = array();
284$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
286print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
287if ($optioncss !=
'') {
288 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
290print
'<input type="hidden" name="token" value="'.newToken().
'">';
291print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
292print
'<input type="hidden" name="action" value="list">';
293print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
294print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
295print
'<input type="hidden" name="page" value="'.$page.
'">';
296print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
297print
'<input type="hidden" name="page_y" value="">';
298print
'<input type="hidden" name="mode" value="'.$mode.
'">';
301$newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewSurvey'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/opensurvey/wizard/index.php',
'', $user->hasRight(
'opensurvey',
'write'));
303print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'poll', 0, $newcardbutton,
'', $limit, 0, 0, 1);
306$topicmail =
"SendOpenSurveyRef";
307$modelmail =
"opensurvey";
309$trackid =
'surv'.$object->id;
310include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
316 foreach ($fieldstosearchall as $key => $val) {
317 $fieldstosearchall[$key] = $langs->trans($val);
318 $setupstring .= $key.
"=".$val.
";";
320 print
'<!-- Search done like if OPENSURVEY_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
321 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
329$parameters = array();
330$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
331if (empty($reshook)) {
332 $moreforfilter .= $hookmanager->resPrint;
334 $moreforfilter = $hookmanager->resPrint;
337 'arrayfields' => &$arrayfields,
340if (!empty($moreforfilter)) {
341 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
342 print $moreforfilter;
346$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
347$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
348$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
349$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
351print
'<div class="div-table-responsive">';
352print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
356print
'<tr class="liste_titre_filter">';
358if (
$conf->main_checkbox_left_column) {
359 print
'<td class="liste_titre center maxwidthsearch">';
360 $searchpicto = $form->showFilterButtons(
'left');
364print
'<td class="liste_titre"><input type="text" class="maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'"></td>';
365print
'<td class="liste_titre"><input type="text" class="maxwidth100" name="search_title" value="'.dol_escape_htmltag($search_title).
'"></td>';
366print
'<td class="liste_titre"></td>';
367print
'<td class="liste_titre"></td>';
368print
'<td class="liste_titre"></td>';
369print
'<td class="liste_titre"></td>';
370print
'<td class="liste_titre"></td>';
371$arraystatus = array(
'-1' =>
' ',
'0' => $langs->trans(
"Draft"),
'1' => $langs->trans(
"Opened"),
'2' => $langs->trans(
"Closed"));
372print
'<td class="liste_titre center parentonrightofpage">'.$form->selectarray(
'search_status', $arraystatus, $search_status, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth100 onrightofpage').
'</td>';
374include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
377$parameters = array(
'arrayfields' => $arrayfields);
378$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
379print $hookmanager->resPrint;
381if (!
$conf->main_checkbox_left_column) {
382 print
'<td class="liste_titre center maxwidthsearch">';
383 $searchpicto = $form->showFilterButtons();
394print
'<tr class="liste_titre">';
396if (
$conf->main_checkbox_left_column) {
397 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
406print_liste_field_titre(
"Author", $_SERVER[
"PHP_SELF"],
"u.".$fieldtosortuser,
"", $param,
"", $sortfield, $sortorder);
408print_liste_field_titre(
"NbOfVoters", $_SERVER[
"PHP_SELF"],
"",
"", $param,
'align="right"', $sortfield, $sortorder);
410print_liste_field_titre(
"ExpireDate", $_SERVER[
"PHP_SELF"],
"p.date_fin",
"", $param,
'align="center"', $sortfield, $sortorder);
412print_liste_field_titre(
"DateLastModification", $_SERVER[
"PHP_SELF"],
"p.tms",
"", $param,
'align="center"', $sortfield, $sortorder);
414print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"p.status",
"", $param,
'align="center"', $sortfield, $sortorder);
417include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
419$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
420$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
421print $hookmanager->resPrint;
423if (!
$conf->main_checkbox_left_column) {
424 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ').
"\n";
437$imaxinloop = ($limit ? min($num, $limit) : $num);
438while ($i < $imaxinloop) {
439 $obj =
$db->fetch_object($resql);
445 $sql2 =
'select COUNT(*) as nb from '.MAIN_DB_PREFIX.
"opensurvey_user_studs where id_sondage='".
$db->escape($obj->rowid).
"'";
446 $resql2 =
$db->query($sql2);
448 $obj2 =
$db->fetch_object($resql2);
454 $opensurvey_static->id = $obj->rowid;
455 $opensurvey_static->ref = $obj->rowid;
456 $opensurvey_static->title = $obj->title;
457 $opensurvey_static->status = $obj->status;
458 $opensurvey_static->date_fin =
$db->jdate($obj->date_fin);
461 print
'<tr data-rowid="'.$opensurvey_static->id.
'" class="oddeven row-with-select">';
463 if (
$conf->main_checkbox_left_column) {
464 print
'<td class="nowrap center">';
465 if ($massactionbutton || $massaction) {
467 if (in_array($obj->rowid, $arrayofselected)) {
470 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
479 print
'<td class="tdoverflowmax150">';
480 print $opensurvey_static->getNomUrl(1);
487 print
'<td class="tdoverflowmax200">'.dol_htmlentities($obj->title).
'</td>';
493 print
'<td class="tdoverflowmax125">';
494 $type = ($obj->format ==
'A') ?
'classic' :
'date';
495 print
img_picto(
'',
dol_buildpath(
'/opensurvey/img/'.($type ==
'classic' ?
'chart-32.png' :
'calendar-32.png'), 1),
'width="16"', 1);
496 print
' '.$langs->trans($type ==
'classic' ?
"TypeClassic" :
"TypeDate");
502 print
'<td class="tdoverflowmax125">';
504 if ($obj->fk_user_creat) {
506 $userstatic->id = $obj->fk_user_creat;
507 $userstatic->firstname = $obj->firstname;
508 $userstatic->lastname = $obj->lastname;
509 $userstatic->login = $userstatic->getFullName($langs, 0, -1, 48);
511 print $userstatic->getLoginUrl(1);
521 print
'<td class="right">'.$nbuser.
'</td>'.
"\n";
526 print
'<td class="center nowraponall">'.dol_print_date(
$db->jdate($obj->date_fin),
'day');
535 print
'<td class="center nowraponall">'.dol_print_date(
$db->jdate($obj->tms),
'dayhour');
541 print
'<td class="center">'.$opensurvey_static->getLibStatut(5).
'</td>'.
"\n";
547 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
549 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &
$totalarray);
550 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
551 print $hookmanager->resPrint;
553 if (!
$conf->main_checkbox_left_column) {
554 print
'<td class="nowrap center">';
555 if ($massactionbutton || $massaction) {
557 if (in_array($obj->rowid, $arrayofselected)) {
560 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
573include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
578 $colspan = $savnbfield;
579 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
585$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
586$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
587print $hookmanager->resPrint;
589print
'</table>'.
"\n";
594if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
595 $hidegeneratedfilelistifempty = 1;
596 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
597 $hidegeneratedfilelistifempty = 0;
600 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
604 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
605 $urlsource .= str_replace(
'&',
'&', $param);
607 $filedir = $diroutputmassaction;
608 $genallowed = $permissiontoread;
609 $delallowed = $permissiontoadd;
611 print $formfile->showdocuments(
'massfilesarea_mymodule',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $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.
Put here description of your class.
const STATUS_VALIDATED
Validated/Opened status.
Class to manage Dolibarr users.
dol_now($mode='gmt')
Return date for now.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.