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')) {
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
65 $diroutputmassaction = $conf->opensurvey->dir_output.
'/temp/massgeneration/'.$user->id;
66 $hookmanager->initHooks(array(
'surveylist'));
68 $extrafields->fetch_name_optionals_label($object->table_element);
69 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
73 $sortfield =
"p.date_fin";
80 if (!$user->rights->opensurvey->read) {
85 $arrayfields = array();
86 foreach ($arrayfields as $key => $val) {
88 if (!empty($val[
'visible'])) {
89 $arrayfields[
't.'.$key] = array(
'label'=>$val[
'label'],
'checked'=>(($val[
'visible'] < 0) ? 0 : 1),
'enabled'=>$val[
'enabled'],
'position'=>$val[
'position']);
93 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label']) > 0) {
94 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
95 if (!empty($extrafields->attributes[$object->table_element][
'list'][$key])) {
96 $arrayfields[
"ef.".$key] = array(
97 'label'=>$extrafields->attributes[$object->table_element][
'label'][$key],
98 'checked'=>(($extrafields->attributes[$object->table_element][
'list'][$key] < 0) ? 0 : 1),
99 'position'=>$extrafields->attributes[$object->table_element][
'pos'][$key],
100 'enabled'=>(abs($extrafields->attributes[$object->table_element][
'list'][$key]) != 3 && $extrafields->attributes[$object->table_element][
'perms'][$key])
108 $permissiontoread = $user->rights->opensurvey->read;
109 $permissiontoadd = $user->rights->opensurvey->write;
111 $permissiontodelete = $user->rights->opensurvey->write;
118 if (
GETPOST(
'cancel',
'alpha')) {
119 $action =
'list'; $massaction =
'';
121 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
125 $parameters = array();
126 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
131 if (empty($reshook)) {
133 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
136 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
141 $search_array_options = array();
143 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
144 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
149 $objectclass =
'Opensurveysondage';
150 $objectlabel =
'Opensurveysondage';
151 $uploaddir = $conf->opensurvey->dir_output;
152 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
166 $title = $langs->trans(
'OpenSurveyArea');
169 $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,";
170 $sql .=
" u.login, u.firstname, u.lastname";
171 $sql .=
" FROM ".MAIN_DB_PREFIX.
"opensurvey_sondage as p";
172 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user u ON u.rowid = p.fk_user_creat";
173 $sql .=
" WHERE p.entity IN (".getEntity(
'survey').
")";
174 if ($search_status !=
'-1' && $search_status !=
'') {
177 if ($search_expired ==
'expired') {
178 $sql .=
" AND p.date_fin < '".$db->idate($now).
"'";
180 if ($search_expired ==
'opened') {
181 $sql .=
" AND p.date_fin >= '".$db->idate($now).
"'";
190 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
192 $parameters = array();
193 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
194 $sql .= $hookmanager->resPrint;
196 $sql .= $db->order($sortfield, $sortorder);
199 $nbtotalofrecords =
'';
200 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
201 $resql = $db->query($sql);
202 $nbtotalofrecords = $db->num_rows(
$resql);
203 if (($page * $limit) > $nbtotalofrecords) {
209 if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
210 $num = $nbtotalofrecords;
212 $sql .= $db->plimit($limit + 1, $offset);
214 $resql = $db->query($sql);
220 $num = $db->num_rows(
$resql);
224 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
225 $obj = $db->fetch_object(
$resql);
227 header(
"Location: ".
dol_buildpath(
'/opensurvey/card.php', 1).
'?id='.$id);
237 $arrayofselected = is_array($toselect) ? $toselect : array();
240 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
241 $param .=
'&contextpage='.urlencode($contextpage);
243 if ($limit > 0 && $limit != $conf->liste_limit) {
244 $param .=
'&limit='.urlencode($limit);
246 $fieldtosortuser = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ?
'firstname' :
'lastname';
248 if ($optioncss !=
'') {
249 $param .=
'&optioncss='.urlencode($optioncss);
252 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
255 $arrayofmassactions = array(
259 if ($permissiontodelete) {
260 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
262 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
263 $arrayofmassactions = array();
265 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
270 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
271 if ($optioncss !=
'') {
272 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
274 print
'<input type="hidden" name="token" value="'.newToken().
'">';
275 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
276 print
'<input type="hidden" name="action" value="list">';
277 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
278 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
279 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
281 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewSurvey'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/opensurvey/wizard/index.php',
'', $user->rights->opensurvey->write);
283 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'poll', 0, $newcardbutton,
'', $limit, 0, 0, 1);
286 $topicmail =
"SendOpenSurveyRef";
287 $modelmail =
"opensurvey";
289 $trackid =
'surv'.$object->id;
290 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
293 foreach ($fieldstosearchall as $key => $val) {
294 $fieldstosearchall[$key] = $langs->trans($val);
296 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
304 $parameters = array();
305 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object);
306 if (empty($reshook)) {
307 $moreforfilter .= $hookmanager->resPrint;
309 $moreforfilter = $hookmanager->resPrint;
312 if (!empty($moreforfilter)) {
313 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
314 print $moreforfilter;
318 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
320 $selectedfields =
'';
321 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
323 print
'<div class="div-table-responsive">';
324 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
328 print
'<tr class="liste_titre_filter">';
329 print
'<td class="liste_titre"><input type="text" class="maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'"></td>';
330 print
'<td class="liste_titre"><input type="text" class="maxwidth100onsmartphone" name="search_title" value="'.dol_escape_htmltag($search_title).
'"></td>';
331 print
'<td class="liste_titre"></td>';
332 print
'<td class="liste_titre"></td>';
333 print
'<td class="liste_titre"></td>';
334 print
'<td class="liste_titre"></td>';
335 print
'<td class="liste_titre"></td>';
336 $arraystatus = array(
'-1'=>
' ',
'0'=>$langs->trans(
"Draft"),
'1'=>$langs->trans(
"Opened"),
'2'=>$langs->trans(
"Closed"));
337 print
'<td class="liste_titre" align="center">'.$form->selectarray(
'search_status', $arraystatus, $search_status).
'</td>';
339 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
342 $parameters = array(
'arrayfields'=>$arrayfields);
343 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object);
344 print $hookmanager->resPrint;
346 print
'<td class="liste_titre maxwidthsearch">';
347 $searchpicto =
$form->showFilterButtons();
355 print
'<tr class="liste_titre">';
359 print_liste_field_titre(
"Author", $_SERVER[
"PHP_SELF"],
"u.".$fieldtosortuser, $param,
"",
"", $sortfield, $sortorder);
360 print_liste_field_titre(
"NbOfVoters", $_SERVER[
"PHP_SELF"],
"", $param,
"",
'align="right"', $sortfield, $sortorder);
361 print_liste_field_titre(
"ExpireDate", $_SERVER[
"PHP_SELF"],
"p.date_fin", $param,
"",
'align="center"', $sortfield, $sortorder);
362 print_liste_field_titre(
"DateLastModification", $_SERVER[
"PHP_SELF"],
"p.tms", $param,
"",
'align="center"', $sortfield, $sortorder);
363 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"p.status", $param,
"",
'align="center"', $sortfield, $sortorder);
365 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
367 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
368 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
369 print $hookmanager->resPrint;
371 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ').
"\n";
379 $totalarray = array();
380 $totalarray[
'nbfield'] = 0;
381 while ($i < min($num, $limit)) {
382 $obj = $db->fetch_object(
$resql);
387 $sql2 =
'select COUNT(*) as nb from '.MAIN_DB_PREFIX.
"opensurvey_user_studs where id_sondage='".$db->escape($obj->rowid).
"'";
388 $resql2 = $db->query($sql2);
390 $obj2 = $db->fetch_object($resql2);
396 $opensurvey_static->id = $obj->rowid;
397 $opensurvey_static->ref = $obj->rowid;
398 $opensurvey_static->title = $obj->title;
399 $opensurvey_static->status = $obj->status;
400 $opensurvey_static->date_fin = $db->jdate($obj->date_fin);
403 print
'<tr class="oddeven">';
407 print $opensurvey_static->getNomUrl(1);
410 $totalarray[
'nbfield']++;
414 print
'<td>'.dol_htmlentities($obj->title).
'</td>';
416 $totalarray[
'nbfield']++;
421 $type = ($obj->format ==
'A') ?
'classic' :
'date';
422 print
img_picto(
'',
dol_buildpath(
'/opensurvey/img/'.($type ==
'classic' ?
'chart-32.png' :
'calendar-32.png'), 1),
'width="16"', 1);
423 print
' '.$langs->trans($type ==
'classic' ?
"TypeClassic" :
"TypeDate");
426 $totalarray[
'nbfield']++;
431 if ($obj->fk_user_creat) {
432 $userstatic =
new User($db);
433 $userstatic->id = $obj->fk_user_creat;
434 $userstatic->firstname = $obj->firstname;
435 $userstatic->lastname = $obj->lastname;
436 $userstatic->login = $userstatic->getFullName($langs, 0, -1, 48);
438 print $userstatic->getLoginUrl(1);
444 $totalarray[
'nbfield']++;
448 print
'<td class="right">'.$nbuser.
'</td>'.
"\n";
450 $totalarray[
'nbfield']++;
453 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_fin),
'day');
459 $totalarray[
'nbfield']++;
462 print
'<td class="center">'.dol_print_date($db->jdate($obj->tms),
'dayhour');
465 $totalarray[
'nbfield']++;
468 print
'<td class="center">'.$opensurvey_static->getLibStatut(5).
'</td>'.
"\n";
470 $totalarray[
'nbfield']++;
474 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
476 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
477 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
478 print $hookmanager->resPrint;
480 print
'<td class="nowrap center">';
481 if ($massactionbutton || $massaction) {
483 if (in_array($obj->rowid, $arrayofselected)) {
486 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
490 $totalarray[
'nbfield']++;
498 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
504 foreach ($arrayfields as $key => $val) {
505 if (!empty($val[
'checked'])) {
509 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
515 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
516 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
517 print $hookmanager->resPrint;
519 print
'</table>'.
"\n";
522 print
'</form>'.
"\n";
524 if (in_array(
'builddoc', $arrayofmassactions) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
525 $hidegeneratedfilelistifempty = 1;
526 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
527 $hidegeneratedfilelistifempty = 0;
530 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
534 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
535 $urlsource .= str_replace(
'&',
'&', $param);
537 $filedir = $diroutputmassaction;
538 $genallowed = $permissiontoread;
539 $delallowed = $permissiontoadd;
541 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.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding= 'UTF-8', $double_encode=false)
Replace htmlentities functions.
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.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
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 from a POST of a form...
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.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
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...
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.