28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
30require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
31require_once DOL_DOCUMENT_ROOT.
"/opensurvey/class/opensurveysondage.class.php";
42$langs->load(
"opensurvey");
44$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
45$massaction =
GETPOST(
'massaction',
'alpha');
47$confirm =
GETPOST(
'confirm',
'alpha');
48$cancel =
GETPOST(
'cancel',
'alpha');
49$toselect =
GETPOST(
'toselect',
'array:int');
50$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'opensurveylist';
51$backtopage =
GETPOST(
'backtopage',
'alpha');
52$optioncss =
GETPOST(
'optioncss',
'aZ');
55$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
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';
109$permissiontoread = $user->hasRight(
'opensurvey',
'read');
110$permissiontoadd = $user->hasRight(
'opensurvey',
'write');
112$permissiontodelete = $user->hasRight(
'opensurvey',
'write');
119if (
GETPOST(
'cancel',
'alpha')) {
123if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
127$parameters = array(
'arrayfields' => &$arrayfields);
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');
172$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,";
173$sql .=
" u.login, u.firstname, u.lastname";
174$sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_sondage as p";
175$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user u ON u.rowid = p.fk_user_creat";
176$sql .=
" WHERE p.entity IN (".getEntity(
'survey').
")";
177if ($search_status !=
'-1' && $search_status !=
'') {
180if (!empty($search_expired) && $search_expired ==
'expired') {
181 $sql .=
" AND p.date_fin < '".$db->idate($now).
"'";
183if (!empty($search_expired) && $search_expired ==
'opened') {
184 $sql .=
" AND p.date_fin >= '".$db->idate($now).
"'";
186if (!empty($search_ref)) {
189if (!empty($search_title)) {
193include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
195$parameters = array();
196$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
197$sql .= $hookmanager->resPrint;
199$sql .= $db->order($sortfield, $sortorder);
202$nbtotalofrecords =
'';
204 $resql = $db->query($sql);
205 $nbtotalofrecords = $db->num_rows($resql);
206 if (($page * $limit) > (
int) $nbtotalofrecords) {
212if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
213 $num = $nbtotalofrecords;
215 $sql .= $db->plimit($limit + 1, $offset);
217 $resql = $db->query($sql);
223 $num = $db->num_rows($resql);
227if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
228 $obj = $db->fetch_object($resql);
230 header(
"Location: ".
dol_buildpath(
'/opensurvey/card.php', 1).
'?id='.((
int)
$id));
238llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist');
240$arrayofselected = is_array($toselect) ? $toselect : array();
243if ( $contextpage != $_SERVER[
"PHP_SELF"]) {
244 $param .=
'&contextpage='.urlencode($contextpage);
246if ($limit > 0 && $limit != $conf->liste_limit) {
247 $param .=
'&limit='.((int) $limit);
249if ($optioncss !=
'') {
250 $param .=
'&optioncss='.urlencode($optioncss);
252$fieldtosortuser =
getDolGlobalString(
'MAIN_FIRSTNAME_NAME_POSITION') ?
'lastname' :
'firstname';
255include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
258$arrayofmassactions = array(
262if (!empty($permissiontodelete)) {
263 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
265if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
266 $arrayofmassactions = array();
268$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
270print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
271if ($optioncss !=
'') {
272 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
274print
'<input type="hidden" name="token" value="'.newToken().
'">';
275print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
276print
'<input type="hidden" name="action" value="list">';
277print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
278print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
279print
'<input type="hidden" name="page" value="'.$page.
'">';
280print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
281print
'<input type="hidden" name="page_y" value="">';
282print
'<input type="hidden" name="mode" value="'.$mode.
'">';
285$newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewSurvey'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/opensurvey/wizard/index.php',
'', $user->hasRight(
'opensurvey',
'write'));
287print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'poll', 0, $newcardbutton,
'', $limit, 0, 0, 1);
290$topicmail =
"SendOpenSurveyRef";
291$modelmail =
"opensurvey";
293$trackid =
'surv'.$object->id;
294include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
300 foreach ($fieldstosearchall as $key => $val) {
301 $fieldstosearchall[$key] = $langs->trans($val);
302 $setupstring .= $key.
"=".$val.
";";
304 print
'<!-- Search done like if OPENSURVEY_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
305 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
313$parameters = array();
314$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
315if (empty($reshook)) {
316 $moreforfilter .= $hookmanager->resPrint;
318 $moreforfilter = $hookmanager->resPrint;
321 'arrayfields' => &$arrayfields,
324if (!empty($moreforfilter)) {
325 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
326 print $moreforfilter;
330$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
331$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage, $conf->main_checkbox_left_column);
332$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
333$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
335print
'<div class="div-table-responsive">';
336print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
340print
'<tr class="liste_titre_filter">';
343 print
'<td class="liste_titre center maxwidthsearch">';
344 $searchpicto = $form->showFilterButtons(
'left');
348print
'<td class="liste_titre"><input type="text" class="maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'"></td>';
349print
'<td class="liste_titre"><input type="text" class="maxwidth100" name="search_title" value="'.dol_escape_htmltag($search_title).
'"></td>';
350print
'<td class="liste_titre"></td>';
351print
'<td class="liste_titre"></td>';
352print
'<td class="liste_titre"></td>';
353print
'<td class="liste_titre"></td>';
354print
'<td class="liste_titre"></td>';
355$arraystatus = array(
'-1' =>
' ',
'0' => $langs->trans(
"Draft"),
'1' => $langs->trans(
"Opened"),
'2' => $langs->trans(
"Closed"));
356print
'<td class="liste_titre center parentonrightofpage">'.$form->selectarray(
'search_status', $arraystatus, $search_status, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth100 onrightofpage').
'</td>';
358include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
361$parameters = array(
'arrayfields' => $arrayfields);
362$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
363print $hookmanager->resPrint;
366 print
'<td class="liste_titre center maxwidthsearch">';
367 $searchpicto = $form->showFilterButtons();
378print
'<tr class="liste_titre">';
381 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
390print_liste_field_titre(
"Author", $_SERVER[
"PHP_SELF"],
"u.".$fieldtosortuser,
"", $param,
"", $sortfield, $sortorder);
392print_liste_field_titre(
"NbOfVoters", $_SERVER[
"PHP_SELF"],
"",
"", $param,
'align="right"', $sortfield, $sortorder);
394print_liste_field_titre(
"ExpireDate", $_SERVER[
"PHP_SELF"],
"p.date_fin",
"", $param,
'align="center"', $sortfield, $sortorder);
396print_liste_field_titre(
"DateLastModification", $_SERVER[
"PHP_SELF"],
"p.tms",
"", $param,
'align="center"', $sortfield, $sortorder);
398print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"p.status",
"", $param,
'align="center"', $sortfield, $sortorder);
401include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
403$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
404$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
405print $hookmanager->resPrint;
408 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ').
"\n";
421$imaxinloop = ($limit ? min($num, $limit) : $num);
422while ($i < $imaxinloop) {
423 $obj = $db->fetch_object($resql);
429 $sql2 =
'select COUNT(*) as nb from '.MAIN_DB_PREFIX.
"opensurvey_user_studs where id_sondage='".$db->escape($obj->rowid).
"'";
430 $resql2 = $db->query($sql2);
432 $obj2 = $db->fetch_object($resql2);
438 $opensurvey_static->id = $obj->rowid;
439 $opensurvey_static->ref = $obj->rowid;
440 $opensurvey_static->title = $obj->title;
441 $opensurvey_static->status = $obj->status;
442 $opensurvey_static->date_fin = $db->jdate($obj->date_fin);
445 print
'<tr data-rowid="'.$opensurvey_static->id.
'" class="oddeven">';
448 print
'<td class="nowrap center">';
449 if ($massactionbutton || $massaction) {
451 if (in_array($obj->rowid, $arrayofselected)) {
454 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
463 print
'<td class="tdoverflowmax150">';
464 print $opensurvey_static->getNomUrl(1);
471 print
'<td class="tdoverflowmax200">'.dol_htmlentities($obj->title).
'</td>';
477 print
'<td class="tdoverflowmax125">';
478 $type = ($obj->format ==
'A') ?
'classic' :
'date';
479 print
img_picto(
'',
dol_buildpath(
'/opensurvey/img/'.($type ==
'classic' ?
'chart-32.png' :
'calendar-32.png'), 1),
'width="16"', 1);
480 print
' '.$langs->trans($type ==
'classic' ?
"TypeClassic" :
"TypeDate");
486 print
'<td class="tdoverflowmax125">';
488 if ($obj->fk_user_creat) {
489 $userstatic =
new User($db);
490 $userstatic->id = $obj->fk_user_creat;
491 $userstatic->firstname = $obj->firstname;
492 $userstatic->lastname = $obj->lastname;
493 $userstatic->login = $userstatic->getFullName($langs, 0, -1, 48);
495 print $userstatic->getLoginUrl(1);
505 print
'<td class="right">'.$nbuser.
'</td>'.
"\n";
510 print
'<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_fin),
'day');
519 print
'<td class="center nowraponall">'.dol_print_date($db->jdate($obj->tms),
'dayhour');
525 print
'<td class="center">'.$opensurvey_static->getLibStatut(5).
'</td>'.
"\n";
531 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
533 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
534 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
535 print $hookmanager->resPrint;
538 print
'<td class="nowrap center">';
539 if ($massactionbutton || $massaction) {
541 if (in_array($obj->rowid, $arrayofselected)) {
544 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
557include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
562 $colspan = $savnbfield;
563 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
569$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
570$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
571print $hookmanager->resPrint;
573print
'</table>'.
"\n";
578if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
579 $hidegeneratedfilelistifempty = 1;
580 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
581 $hidegeneratedfilelistifempty = 0;
584 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
588 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
589 $urlsource .= str_replace(
'&',
'&', $param);
591 $filedir = $diroutputmassaction;
592 $genallowed = $permissiontoread;
593 $delallowed = $permissiontoadd;
595 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.
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.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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, $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...
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.
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...
getDolGlobalString($key, $default='')
Return a 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.