26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
28require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
29require_once DOL_DOCUMENT_ROOT.
"/opensurvey/class/opensurveysondage.class.php";
32$langs->load(
"opensurvey");
34$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
35$massaction =
GETPOST(
'massaction',
'alpha');
36$show_files =
GETPOST(
'show_files',
'int');
37$confirm =
GETPOST(
'confirm',
'alpha');
38$cancel =
GETPOST(
'cancel',
'alpha');
39$toselect =
GETPOST(
'toselect',
'array');
40$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'opensurveylist';
41$backtopage =
GETPOST(
'backtopage',
'alpha');
42$optioncss =
GETPOST(
'optioncss',
'aZ');
43$sall = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
46$search_ref =
GETPOST(
'search_ref',
'alpha');
47$search_title =
GETPOST(
'search_title',
'alpha');
48$search_status =
GETPOST(
'search_status',
'alpha');
51$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
52$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
53$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
54$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
55if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
58$offset = $limit * $page;
67$diroutputmassaction = $conf->opensurvey->dir_output.
'/temp/massgeneration/'.$user->id;
68$hookmanager->initHooks(array(
'surveylist'));
70$extrafields->fetch_name_optionals_label($object->table_element);
71$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
75 $sortfield =
"p.date_fin";
82if (!$user->rights->opensurvey->read) {
87$arrayfields = array();
88foreach ($arrayfields as $key => $val) {
90 if (!empty($val[
'visible'])) {
91 $arrayfields[
't.'.$key] = array(
'label'=>$val[
'label'],
'checked'=>(($val[
'visible'] < 0) ? 0 : 1),
'enabled'=>$val[
'enabled'],
'position'=>$val[
'position']);
95if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label']) > 0) {
96 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
97 if (!empty($extrafields->attributes[$object->table_element][
'list'][$key])) {
98 $arrayfields[
"ef.".$key] = array(
99 'label'=>$extrafields->attributes[$object->table_element][
'label'][$key],
100 'checked'=>(($extrafields->attributes[$object->table_element][
'list'][$key] < 0) ? 0 : 1),
101 'position'=>$extrafields->attributes[$object->table_element][
'pos'][$key],
102 'enabled'=>(abs($extrafields->attributes[$object->table_element][
'list'][$key]) != 3 && $extrafields->attributes[$object->table_element][
'perms'][$key])
110$permissiontoread = $user->rights->opensurvey->read;
111$permissiontoadd = $user->rights->opensurvey->write;
113$permissiontodelete = $user->rights->opensurvey->write;
120if (
GETPOST(
'cancel',
'alpha')) {
121 $action =
'list'; $massaction =
'';
123if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
127$parameters = array();
128$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
133if (empty($reshook)) {
135 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
138 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
143 $search_array_options = array();
145 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
146 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
151 $objectclass =
'Opensurveysondage';
152 $objectlabel =
'Opensurveysondage';
153 $uploaddir = $conf->opensurvey->dir_output;
154 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
162$form =
new Form($db);
168$title = $langs->trans(
'OpenSurveyArea');
171$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,";
172$sql .=
" u.login, u.firstname, u.lastname";
173$sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_sondage as p";
174$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user u ON u.rowid = p.fk_user_creat";
175$sql .=
" WHERE p.entity IN (".getEntity(
'survey').
")";
176if ($search_status !=
'-1' && $search_status !=
'') {
179if (!empty($search_expired) && $search_expired ==
'expired') {
180 $sql .=
" AND p.date_fin < '".$db->idate($now).
"'";
182if (!empty($search_expired) && $search_expired ==
'opened') {
183 $sql .=
" AND p.date_fin >= '".$db->idate($now).
"'";
185if (!empty($search_ref)) {
188if (!empty($search_title)) {
192include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
194$parameters = array();
195$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
196$sql .= $hookmanager->resPrint;
198$sql .= $db->order($sortfield, $sortorder);
201$nbtotalofrecords =
'';
203 $resql = $db->query($sql);
204 $nbtotalofrecords = $db->num_rows($resql);
205 if (($page * $limit) > $nbtotalofrecords) {
211if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
212 $num = $nbtotalofrecords;
214 $sql .= $db->plimit($limit + 1, $offset);
216 $resql = $db->query($sql);
222 $num = $db->num_rows($resql);
226if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
227 $obj = $db->fetch_object($resql);
229 header(
"Location: ".
dol_buildpath(
'/opensurvey/card.php', 1).
'?id='.$id);
239$arrayofselected = is_array($toselect) ? $toselect : array();
242if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
243 $param .=
'&contextpage='.urlencode($contextpage);
245if ($limit > 0 && $limit != $conf->liste_limit) {
246 $param .=
'&limit='.((int) $limit);
248$fieldtosortuser = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ?
'firstname' :
'lastname';
250if ($optioncss !=
'') {
251 $param .=
'&optioncss='.urlencode($optioncss);
254include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
257$arrayofmassactions = array(
261if ($permissiontodelete) {
262 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
264if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
265 $arrayofmassactions = array();
267$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
272print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
273if ($optioncss !=
'') {
274 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
276print
'<input type="hidden" name="token" value="'.newToken().
'">';
277print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
278print
'<input type="hidden" name="action" value="list">';
279print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
280print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
281print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
283$newcardbutton =
dolGetButtonTitle($langs->trans(
'NewSurvey'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/opensurvey/wizard/index.php',
'', $user->rights->opensurvey->write);
285print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'poll', 0, $newcardbutton,
'', $limit, 0, 0, 1);
288$topicmail =
"SendOpenSurveyRef";
289$modelmail =
"opensurvey";
291$trackid =
'surv'.$object->id;
292include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
295 foreach ($fieldstosearchall as $key => $val) {
296 $fieldstosearchall[$key] = $langs->trans($val);
298 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
306$parameters = array();
307$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object);
308if (empty($reshook)) {
309 $moreforfilter .= $hookmanager->resPrint;
311 $moreforfilter = $hookmanager->resPrint;
314if (!empty($moreforfilter)) {
315 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
316 print $moreforfilter;
320$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
323$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
325print
'<div class="div-table-responsive">';
326print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
330print
'<tr class="liste_titre_filter">';
333 print
'<td class="liste_titre maxwidthsearch">';
334 $searchpicto = $form->showFilterButtons(
'left');
338print
'<td class="liste_titre"><input type="text" class="maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'"></td>';
339print
'<td class="liste_titre"><input type="text" class="maxwidth100onsmartphone" name="search_title" value="'.dol_escape_htmltag($search_title).
'"></td>';
340print
'<td class="liste_titre"></td>';
341print
'<td class="liste_titre"></td>';
342print
'<td class="liste_titre"></td>';
343print
'<td class="liste_titre"></td>';
344print
'<td class="liste_titre"></td>';
345$arraystatus = array(
'-1'=>
' ',
'0'=>$langs->trans(
"Draft"),
'1'=>$langs->trans(
"Opened"),
'2'=>$langs->trans(
"Closed"));
346print
'<td class="liste_titre" align="center">'.$form->selectarray(
'search_status', $arraystatus, $search_status, 0, 0, 0,
'', 0, 0, 0,
'',
'onroghtofpage').
'</td>';
348include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
351$parameters = array(
'arrayfields'=>$arrayfields);
352$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object);
353print $hookmanager->resPrint;
356 print
'<td class="liste_titre maxwidthsearch">';
357 $searchpicto = $form->showFilterButtons();
366print
'<tr class="liste_titre">';
369 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ').
"\n";
374print_liste_field_titre(
"Author", $_SERVER[
"PHP_SELF"],
"u.".$fieldtosortuser, $param,
"",
"", $sortfield, $sortorder);
375print_liste_field_titre(
"NbOfVoters", $_SERVER[
"PHP_SELF"],
"", $param,
"",
'align="right"', $sortfield, $sortorder);
376print_liste_field_titre(
"ExpireDate", $_SERVER[
"PHP_SELF"],
"p.date_fin", $param,
"",
'align="center"', $sortfield, $sortorder);
377print_liste_field_titre(
"DateLastModification", $_SERVER[
"PHP_SELF"],
"p.tms", $param,
"",
'align="center"', $sortfield, $sortorder);
378print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"p.status", $param,
"",
'align="center"', $sortfield, $sortorder);
380include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
382$parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
383$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
384print $hookmanager->resPrint;
387 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ').
"\n";
396$totalarray = array();
397$totalarray[
'nbfield'] = 0;
398while ($i < min($num, $limit)) {
399 $obj = $db->fetch_object($resql);
404 $sql2 =
'select COUNT(*) as nb from '.MAIN_DB_PREFIX.
"opensurvey_user_studs where id_sondage='".$db->escape($obj->rowid).
"'";
405 $resql2 = $db->query($sql2);
407 $obj2 = $db->fetch_object($resql2);
413 $opensurvey_static->id = $obj->rowid;
414 $opensurvey_static->ref = $obj->rowid;
415 $opensurvey_static->title = $obj->title;
416 $opensurvey_static->status = $obj->status;
417 $opensurvey_static->date_fin = $db->jdate($obj->date_fin);
420 print
'<tr class="oddeven">';
423 print
'<td class="nowrap center">';
424 if ($massactionbutton || $massaction) {
426 if (in_array($obj->rowid, $arrayofselected)) {
429 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
435 print $opensurvey_static->getNomUrl(1);
438 $totalarray[
'nbfield']++;
442 print
'<td>'.dol_htmlentities($obj->title).
'</td>';
444 $totalarray[
'nbfield']++;
449 $type = ($obj->format ==
'A') ?
'classic' :
'date';
450 print
img_picto(
'',
dol_buildpath(
'/opensurvey/img/'.($type ==
'classic' ?
'chart-32.png' :
'calendar-32.png'), 1),
'width="16"', 1);
451 print
' '.$langs->trans($type ==
'classic' ?
"TypeClassic" :
"TypeDate");
454 $totalarray[
'nbfield']++;
459 if ($obj->fk_user_creat) {
460 $userstatic =
new User($db);
461 $userstatic->id = $obj->fk_user_creat;
462 $userstatic->firstname = $obj->firstname;
463 $userstatic->lastname = $obj->lastname;
464 $userstatic->login = $userstatic->getFullName($langs, 0, -1, 48);
466 print $userstatic->getLoginUrl(1);
472 $totalarray[
'nbfield']++;
476 print
'<td class="right">'.$nbuser.
'</td>'.
"\n";
478 $totalarray[
'nbfield']++;
481 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_fin),
'day');
487 $totalarray[
'nbfield']++;
490 print
'<td class="center">'.dol_print_date($db->jdate($obj->tms),
'dayhour');
493 $totalarray[
'nbfield']++;
496 print
'<td class="center">'.$opensurvey_static->getLibStatut(5).
'</td>'.
"\n";
498 $totalarray[
'nbfield']++;
502 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
504 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
505 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
506 print $hookmanager->resPrint;
509 print
'<td class="nowrap center">';
510 if ($massactionbutton || $massaction) {
512 if (in_array($obj->rowid, $arrayofselected)) {
515 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
520 $totalarray[
'nbfield']++;
528include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
534 foreach ($arrayfields as $key => $val) {
535 if (!empty($val[
'checked'])) {
539 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
545$parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
546$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
547print $hookmanager->resPrint;
549print
'</table>'.
"\n";
554if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
555 $hidegeneratedfilelistifempty = 1;
556 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
557 $hidegeneratedfilelistifempty = 0;
560 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
564 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
565 $urlsource .= str_replace(
'&',
'&', $param);
567 $filedir = $diroutputmassaction;
568 $genallowed = $permissiontoread;
569 $delallowed = $permissiontoadd;
571 print $formfile->showdocuments(
'massfilesarea_mymodule',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Put here description of your class.
const STATUS_VALIDATED
Validated/Opened status.
Class to manage Dolibarr users.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.