27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
29require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
30require_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');
49$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'opensurveylist';
50$backtopage =
GETPOST(
'backtopage',
'alpha');
51$optioncss =
GETPOST(
'optioncss',
'aZ');
52$sall = trim(
GETPOST(
'search_all',
'alphanohtml'));
55$search_ref =
GETPOST(
'search_ref',
'alpha');
56$search_title =
GETPOST(
'search_title',
'alpha');
57$search_status =
GETPOST(
'search_status',
'alpha');
61$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
62$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
64if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
67$offset = $limit * $page;
76$diroutputmassaction =
$conf->opensurvey->dir_output.
'/temp/massgeneration/'.$user->id;
77$hookmanager->initHooks(array(
'surveylist'));
79$extrafields->fetch_name_optionals_label(
$object->table_element);
80$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
84 $sortfield =
"p.date_fin";
91if (!$user->hasRight(
'opensurvey',
'read')) {
96$arrayfields = array();
97foreach ($arrayfields as $key => $val) {
99 if (!empty($val[
'visible'])) {
100 $arrayfields[
't.'.$key] = array(
'label' => $val[
'label'],
'checked' => (($val[
'visible'] < 0) ? 0 : 1),
'enabled' => $val[
'enabled'],
'position' => $val[
'position']);
104if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label']) > 0) {
105 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
106 if (!empty($extrafields->attributes[
$object->table_element][
'list'][$key])) {
107 $arrayfields[
"ef.".$key] = array(
108 'label' => $extrafields->attributes[
$object->table_element][
'label'][$key],
109 'checked' => (($extrafields->attributes[
$object->table_element][
'list'][$key] < 0) ? 0 : 1),
110 'position' => $extrafields->attributes[
$object->table_element][
'pos'][$key],
111 'enabled' => (abs($extrafields->attributes[
$object->table_element][
'list'][$key]) != 3 && $extrafields->attributes[
$object->table_element][
'perms'][$key])
119$permissiontoread = $user->hasRight(
'opensurvey',
'read');
120$permissiontoadd = $user->hasRight(
'opensurvey',
'write');
122$permissiontodelete = $user->hasRight(
'opensurvey',
'write');
129if (
GETPOST(
'cancel',
'alpha')) {
133if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
137$parameters = array();
138$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
143if (empty($reshook)) {
145 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
148 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
153 $search_array_options = array();
155 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
156 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
161 $objectclass =
'Opensurveysondage';
162 $objectlabel =
'Opensurveysondage';
163 $uploaddir =
$conf->opensurvey->dir_output;
164 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
172$form =
new Form($db);
178$title = $langs->trans(
'OpenSurveyArea');
181$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,";
182$sql .=
" u.login, u.firstname, u.lastname";
183$sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_sondage as p";
184$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user u ON u.rowid = p.fk_user_creat";
185$sql .=
" WHERE p.entity IN (".getEntity(
'survey').
")";
186if ($search_status !=
'-1' && $search_status !=
'') {
189if (!empty($search_expired) && $search_expired ==
'expired') {
190 $sql .=
" AND p.date_fin < '".$db->idate($now).
"'";
192if (!empty($search_expired) && $search_expired ==
'opened') {
193 $sql .=
" AND p.date_fin >= '".$db->idate($now).
"'";
195if (!empty($search_ref)) {
198if (!empty($search_title)) {
202include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
204$parameters = array();
205$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
206$sql .= $hookmanager->resPrint;
208$sql .= $db->order($sortfield, $sortorder);
211$nbtotalofrecords =
'';
213 $resql = $db->query($sql);
214 $nbtotalofrecords = $db->num_rows($resql);
215 if (($page * $limit) > $nbtotalofrecords) {
221if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
222 $num = $nbtotalofrecords;
224 $sql .= $db->plimit($limit + 1, $offset);
226 $resql = $db->query($sql);
232 $num = $db->num_rows($resql);
236if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
237 $obj = $db->fetch_object($resql);
247llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist');
249$arrayofselected = is_array($toselect) ? $toselect : array();
252if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
253 $param .=
'&contextpage='.urlencode($contextpage);
255if ($limit > 0 && $limit !=
$conf->liste_limit) {
256 $param .=
'&limit='.((int) $limit);
258$fieldtosortuser = !
getDolGlobalString(
'MAIN_FIRSTNAME_NAME_POSITION') ?
'firstname' :
'lastname';
260if ($optioncss !=
'') {
261 $param .=
'&optioncss='.urlencode($optioncss);
264include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
267$arrayofmassactions = array(
271if ($permissiontodelete) {
272 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
274if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
275 $arrayofmassactions = array();
277$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
282print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
283if ($optioncss !=
'') {
284 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
286print
'<input type="hidden" name="token" value="'.newToken().
'">';
287print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
288print
'<input type="hidden" name="action" value="list">';
289print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
290print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
291print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
294$newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewSurvey'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/opensurvey/wizard/index.php',
'', $user->hasRight(
'opensurvey',
'write'));
296print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'poll', 0, $newcardbutton,
'', $limit, 0, 0, 1);
299$topicmail =
"SendOpenSurveyRef";
300$modelmail =
"opensurvey";
302$trackid =
'surv'.$object->id;
303include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
308 if (!isset($fieldstosearchall) || !is_array($fieldstosearchall)) {
309 $fieldstosearchall = array();
311 foreach ($fieldstosearchall as $key => $val) {
312 $fieldstosearchall[$key] = $langs->trans($val);
314 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).implode(
', ', $fieldstosearchall).
'</div>';
322$parameters = array();
323$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
324if (empty($reshook)) {
325 $moreforfilter .= $hookmanager->resPrint;
327 $moreforfilter = $hookmanager->resPrint;
330if (!empty($moreforfilter)) {
331 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
332 print $moreforfilter;
336$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
339$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
341print
'<div class="div-table-responsive">';
342print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
346print
'<tr class="liste_titre_filter">';
349 print
'<td class="liste_titre maxwidthsearch">';
350 $searchpicto = $form->showFilterButtons(
'left');
354print
'<td class="liste_titre"><input type="text" class="maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'"></td>';
355print
'<td class="liste_titre"><input type="text" class="maxwidth100" name="search_title" value="'.dol_escape_htmltag($search_title).
'"></td>';
356print
'<td class="liste_titre"></td>';
357print
'<td class="liste_titre"></td>';
358print
'<td class="liste_titre"></td>';
359print
'<td class="liste_titre"></td>';
360print
'<td class="liste_titre"></td>';
361$arraystatus = array(
'-1' =>
' ',
'0' => $langs->trans(
"Draft"),
'1' => $langs->trans(
"Opened"),
'2' => $langs->trans(
"Closed"));
362print
'<td class="liste_titre" align="center">'.$form->selectarray(
'search_status', $arraystatus, $search_status, 0, 0, 0,
'', 0, 0, 0,
'',
'onroghtofpage').
'</td>';
364include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
367$parameters = array(
'arrayfields' => $arrayfields);
368$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object);
369print $hookmanager->resPrint;
372 print
'<td class="liste_titre maxwidthsearch">';
373 $searchpicto = $form->showFilterButtons();
382print
'<tr class="liste_titre">';
385 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ').
"\n";
390print_liste_field_titre(
"Author", $_SERVER[
"PHP_SELF"],
"u.".$fieldtosortuser, $param,
"",
"", $sortfield, $sortorder);
391print_liste_field_titre(
"NbOfVoters", $_SERVER[
"PHP_SELF"],
"", $param,
"",
'align="right"', $sortfield, $sortorder);
392print_liste_field_titre(
"ExpireDate", $_SERVER[
"PHP_SELF"],
"p.date_fin", $param,
"",
'align="center"', $sortfield, $sortorder);
393print_liste_field_titre(
"DateLastModification", $_SERVER[
"PHP_SELF"],
"p.tms", $param,
"",
'align="center"', $sortfield, $sortorder);
394print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"p.status", $param,
"",
'align="center"', $sortfield, $sortorder);
396include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
398$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
399$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
400print $hookmanager->resPrint;
403 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ').
"\n";
412$totalarray = array();
413$totalarray[
'nbfield'] = 0;
414while ($i < min($num, $limit)) {
415 $obj = $db->fetch_object($resql);
420 $sql2 =
'select COUNT(*) as nb from '.MAIN_DB_PREFIX.
"opensurvey_user_studs where id_sondage='".$db->escape($obj->rowid).
"'";
421 $resql2 = $db->query($sql2);
423 $obj2 = $db->fetch_object($resql2);
429 $opensurvey_static->id = $obj->rowid;
430 $opensurvey_static->ref = $obj->rowid;
431 $opensurvey_static->title = $obj->title;
432 $opensurvey_static->status = $obj->status;
433 $opensurvey_static->date_fin = $db->jdate($obj->date_fin);
436 print
'<tr class="oddeven">';
439 print
'<td class="nowrap center">';
440 if ($massactionbutton || $massaction) {
442 if (in_array($obj->rowid, $arrayofselected)) {
445 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
451 print
'<td class="tdoverflowmax150">';
452 print $opensurvey_static->getNomUrl(1);
455 $totalarray[
'nbfield']++;
459 print
'<td class="tdoverflowmax125">'.dol_htmlentities($obj->title).
'</td>';
461 $totalarray[
'nbfield']++;
465 print
'<td class="tdoverflowmax100">';
466 $type = ($obj->format ==
'A') ?
'classic' :
'date';
467 print
img_picto(
'',
dol_buildpath(
'/opensurvey/img/'.($type ==
'classic' ?
'chart-32.png' :
'calendar-32.png'), 1),
'width="16"', 1);
468 print
' '.$langs->trans($type ==
'classic' ?
"TypeClassic" :
"TypeDate");
471 $totalarray[
'nbfield']++;
474 print
'<td class="tdoverflowmax100">';
476 if ($obj->fk_user_creat) {
477 $userstatic =
new User($db);
478 $userstatic->id = $obj->fk_user_creat;
479 $userstatic->firstname = $obj->firstname;
480 $userstatic->lastname = $obj->lastname;
481 $userstatic->login = $userstatic->getFullName($langs, 0, -1, 48);
483 print $userstatic->getLoginUrl(1);
489 $totalarray[
'nbfield']++;
493 print
'<td class="right">'.$nbuser.
'</td>'.
"\n";
495 $totalarray[
'nbfield']++;
498 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_fin),
'day');
504 $totalarray[
'nbfield']++;
507 print
'<td class="center">'.dol_print_date($db->jdate($obj->tms),
'dayhour');
510 $totalarray[
'nbfield']++;
513 print
'<td class="center">'.$opensurvey_static->getLibStatut(5).
'</td>'.
"\n";
515 $totalarray[
'nbfield']++;
519 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
521 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
522 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
523 print $hookmanager->resPrint;
526 print
'<td class="nowrap center">';
527 if ($massactionbutton || $massaction) {
529 if (in_array($obj->rowid, $arrayofselected)) {
532 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
537 $totalarray[
'nbfield']++;
545include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
551 foreach ($arrayfields as $key => $val) {
552 if (!empty($val[
'checked'])) {
556 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
562$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
563$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
564print $hookmanager->resPrint;
566print
'</table>'.
"\n";
571if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
572 $hidegeneratedfilelistifempty = 1;
573 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
574 $hidegeneratedfilelistifempty = 0;
577 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
581 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
582 $urlsource .= str_replace(
'&',
'&', $param);
584 $filedir = $diroutputmassaction;
585 $genallowed = $permissiontoread;
586 $delallowed = $permissiontoadd;
588 print $formfile->showdocuments(
'massfilesarea_mymodule',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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_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.
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 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...
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.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.