25 require
'../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
27 require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
28 require_once DOL_DOCUMENT_ROOT.
"/opensurvey/class/opensurveysondage.class.php";
31 $langs->load(
"opensurvey");
33 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
34 $massaction =
GETPOST(
'massaction',
'alpha');
35 $show_files =
GETPOST(
'show_files',
'int');
36 $confirm =
GETPOST(
'confirm',
'alpha');
37 $cancel =
GETPOST(
'cancel',
'alpha');
38 $toselect =
GETPOST(
'toselect',
'array');
39 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'opensurveylist';
40 $backtopage =
GETPOST(
'backtopage',
'alpha');
41 $optioncss =
GETPOST(
'optioncss',
'aZ');
44 $search_ref =
GETPOST(
'search_ref',
'alpha');
45 $search_title =
GETPOST(
'search_title',
'alpha');
46 $search_status =
GETPOST(
'search_status',
'alpha');
49 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
50 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
51 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
53 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) { $page = 0; }
54 $offset = $limit * $page;
55 $pageprev = $page - 1;
56 $pagenext = $page + 1;
63 $diroutputmassaction = $conf->opensurvey->dir_output.
'/temp/massgeneration/'.$user->id;
64 $hookmanager->initHooks(array(
'surveylist'));
66 $extrafields->fetch_name_optionals_label($object->table_element);
67 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
70 if (!$sortfield) $sortfield =
"p.date_fin";
71 if (!$sortorder) $sortorder =
"DESC";
77 $arrayfields = array();
78 foreach ($arrayfields as $key => $val)
81 if (!empty($val[
'visible'])) $arrayfields[
't.'.$key] = array(
'label'=>$val[
'label'],
'checked'=>(($val[
'visible'] < 0) ? 0 : 1),
'enabled'=>$val[
'enabled'],
'position'=>$val[
'position']);
84 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label']) > 0)
86 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val)
88 if (!empty($extrafields->attributes[$object->table_element][
'list'][$key])) {
89 $arrayfields[
"ef.".$key] = array(
90 'label'=>$extrafields->attributes[$object->table_element][
'label'][$key],
91 'checked'=>(($extrafields->attributes[$object->table_element][
'list'][$key] < 0) ? 0 : 1),
92 'position'=>$extrafields->attributes[$object->table_element][
'pos'][$key],
93 'enabled'=>(abs($extrafields->attributes[$object->table_element][
'list'][$key]) != 3 && $extrafields->attributes[$object->table_element][
'perms'][$key])
101 $permissiontoread = $user->rights->opensurvey->read;
102 $permissiontoadd = $user->rights->opensurvey->write;
103 $permissiontodelete = $user->rights->opensurvey->delete;
110 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
111 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') { $massaction =
''; }
113 $parameters = array();
114 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
115 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
120 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
123 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
129 $search_array_options = array();
131 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
132 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha'))
138 $objectclass =
'Opensurveysondage';
139 $objectlabel =
'Opensurveysondage';
140 $uploaddir = $conf->opensurvey->dir_output;
141 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
149 $form =
new Form($db);
155 $title = $langs->trans(
'OpenSurveyArea');
158 $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,";
159 $sql .=
" u.login, u.firstname, u.lastname";
160 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_sondage as p";
161 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user u ON u.rowid = p.fk_user_creat";
162 $sql .=
" WHERE p.entity IN (".getEntity(
'survey').
")";
163 if ($search_status !=
'-1' && $search_status !=
'') $sql .=
natural_search(
"p.status", $search_status, 2);
164 if ($search_expired ==
'expired') $sql .=
" AND p.date_fin < '".$db->idate($now).
"'";
165 if ($search_expired ==
'opened') $sql .=
" AND p.date_fin >= '".$db->idate($now).
"'";
166 if ($search_ref) $sql .=
natural_search(
"p.id_sondage", $search_ref);
167 if ($search_title) $sql .=
natural_search(
"p.titre", $search_title);
169 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
171 $parameters = array();
172 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
173 $sql .= $hookmanager->resPrint;
175 $sql .= $db->order($sortfield, $sortorder);
178 $nbtotalofrecords =
'';
179 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
181 $resql = $db->query($sql);
182 $nbtotalofrecords = $db->num_rows(
$resql);
183 if (($page * $limit) > $nbtotalofrecords)
190 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
192 $num = $nbtotalofrecords;
194 $sql .= $db->plimit($limit + 1, $offset);
196 $resql = $db->query($sql);
203 $num = $db->num_rows(
$resql);
207 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
209 $obj = $db->fetch_object(
$resql);
211 header(
"Location: ".
dol_buildpath(
'/opensurvey/card.php', 1).
'?id='.$id);
221 $arrayofselected = is_array($toselect) ? $toselect : array();
224 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
225 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
226 $fieldtosortuser = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ?
'firstname' :
'lastname';
228 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
230 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
233 $arrayofmassactions = array(
237 if ($permissiontodelete) $arrayofmassactions[
'predelete'] =
'<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans(
"Delete");
238 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) $arrayofmassactions = array();
239 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
244 print '<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
245 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
246 print '<input type="hidden" name="token" value="'.newToken().
'">';
247 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
248 print '<input type="hidden" name="action" value="list">';
249 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
250 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
251 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
253 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewSurvey'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/opensurvey/wizard/index.php',
'', $user->rights->opensurvey->write);
255 print_barre_liste($title, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'poll', 0, $newcardbutton,
'', $limit, 0, 0, 1);
258 $topicmail =
"SendOpenSurveyRef";
259 $modelmail =
"opensurvey";
261 $trackid =
'surv'.$object->id;
262 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
266 foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
267 print '<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
275 $parameters = array();
276 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object);
277 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
278 else $moreforfilter = $hookmanager->resPrint;
280 if (!empty($moreforfilter))
282 print '<div class="liste_titre liste_titre_bydiv centpercent">';
283 print $moreforfilter;
287 $varpage = empty($contextpage) ?
$_SERVER[
"PHP_SELF"] : $contextpage;
289 $selectedfields =
'';
290 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
292 print '<div class="div-table-responsive">';
293 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
297 print '<tr class="liste_titre_filter">';
298 print
'<td class="liste_titre"><input type="text" class="maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'"></td>';
299 print
'<td class="liste_titre"><input type="text" class="maxwidth100onsmartphone" name="search_title" value="'.dol_escape_htmltag($search_title).
'"></td>';
300 print
'<td class="liste_titre"></td>';
301 print
'<td class="liste_titre"></td>';
302 print
'<td class="liste_titre"></td>';
303 print
'<td class="liste_titre"></td>';
304 print
'<td class="liste_titre"></td>';
305 $arraystatus = array(
'-1'=>
' ',
'0'=>$langs->trans(
"Draft"),
'1'=>$langs->trans(
"Opened"),
'2'=>$langs->trans(
"Closed"));
306 print
'<td class="liste_titre" align="center">'.$form->selectarray(
'search_status', $arraystatus, $search_status).
'</td>';
308 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
311 $parameters = array(
'arrayfields'=>$arrayfields);
312 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object);
313 print $hookmanager->resPrint;
315 print
'<td class="liste_titre maxwidthsearch">';
316 $searchpicto = $form->showFilterButtons();
324 print
'<tr class="liste_titre">';
334 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
336 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
337 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
338 print $hookmanager->resPrint;
340 print
getTitleFieldOfList($selectedfields, 0,
$_SERVER[
"PHP_SELF"],
'',
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ').
"\n";
348 $totalarray = array();
349 while ($i < min($num, $limit))
351 $obj = $db->fetch_object(
$resql);
352 if (empty($obj))
break;
354 $sql2 =
'select COUNT(*) as nb from '.MAIN_DB_PREFIX.
"opensurvey_user_studs where id_sondage='".$db->escape($obj->rowid).
"'";
355 $resql2 = $db->query($sql2);
358 $obj2 = $db->fetch_object($resql2);
362 $opensurvey_static->id = $obj->rowid;
363 $opensurvey_static->ref = $obj->rowid;
364 $opensurvey_static->title = $obj->title;
365 $opensurvey_static->status = $obj->status;
366 $opensurvey_static->date_fin = $db->jdate($obj->date_fin);
369 print
'<tr class="oddeven">';
373 print $opensurvey_static->getNomUrl(1);
375 if (!$i) $totalarray[
'nbfield']++;
378 print
'<td>'.dol_htmlentities($obj->title).
'</td>';
379 if (!$i) $totalarray[
'nbfield']++;
383 $type = ($obj->format ==
'A') ?
'classic' :
'date';
384 print
img_picto(
'',
dol_buildpath(
'/opensurvey/img/'.($type ==
'classic' ?
'chart-32.png' :
'calendar-32.png'), 1),
'width="16"', 1);
385 print
' '.$langs->trans($type ==
'classic' ?
"TypeClassic" :
"TypeDate");
387 if (!$i) $totalarray[
'nbfield']++;
391 if ($obj->fk_user_creat) {
392 $userstatic =
new User($db);
393 $userstatic->id = $obj->fk_user_creat;
394 $userstatic->firstname = $obj->firstname;
395 $userstatic->lastname = $obj->lastname;
396 $userstatic->login = $userstatic->getFullName($langs, 0, -1, 48);
398 print $userstatic->getLoginUrl(1);
403 if (!$i) $totalarray[
'nbfield']++;
406 print
'<td class="right">'.$nbuser.
'</td>'.
"\n";
407 if (!$i) $totalarray[
'nbfield']++;
409 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_fin),
'day');
412 if (!$i) $totalarray[
'nbfield']++;
414 print
'<td class="center">'.dol_print_date($db->jdate($obj->tms),
'dayhour');
416 if (!$i) $totalarray[
'nbfield']++;
418 print
'<td class="center">'.$opensurvey_static->getLibStatut(5).
'</td>'.
"\n";
419 if (!$i) $totalarray[
'nbfield']++;
422 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
424 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
425 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
426 print $hookmanager->resPrint;
428 print
'<td class="nowrap center">';
429 if ($massactionbutton || $massaction)
432 if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
433 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
436 if (!$i) $totalarray[
'nbfield']++;
443 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
450 foreach ($arrayfields as $key => $val) {
if (!empty($val[
'checked'])) $colspan++; }
451 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
457 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
458 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
459 print $hookmanager->resPrint;
461 print
'</table>'.
"\n";
464 print
'</form>'.
"\n";
466 if (in_array(
'builddoc', $arrayofmassactions) && ($nbtotalofrecords ===
'' || $nbtotalofrecords))
468 $hidegeneratedfilelistifempty = 1;
469 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
471 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
475 $urlsource =
$_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
476 $urlsource .= str_replace(
'&',
'&', $param);
478 $filedir = $diroutputmassaction;
479 $genallowed = $permissiontoread;
480 $delallowed = $permissiontoadd;
482 print $formfile->showdocuments(
'massfilesarea_mymodule',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'', null, $hidegeneratedfilelistifempty);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
dol_htmlentities($string, $flags=null, $encoding= 'UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
const STATUS_VALIDATED
Validated/Opened status.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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...
Put here description of your class.
print $_SERVER["PHP_SELF"]
Edit parameters.
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
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.