dolibarr  17.0.4
knowledgerecord_list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
4  * Copyright (C) 2023 Anthony Berton <anthony.berton@bb2a.fr>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 // Load Dolibarr environment
27 require '../main.inc.php';
28 
29 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
33 
34 // load knowledgemanagement libraries
35 require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class.php';
36 
37 // for other modules
38 if (isModEnabled('categorie')) {
39  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
40 }
41 //dol_include_once('/othermodule/class/otherobject.class.php');
42 
43 // Load translation files required by the page
44 $langs->loadLangs(array("knowledgemanagement", "other"));
45 
46 $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
47 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
48 $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
49 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
50 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
51 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
52 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'knowledgerecordlist'; // To manage different context of search
53 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
54 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
55 $mode = GETPOST('mode', 'aZ09');
56 
57 $id = GETPOST('id', 'int');
58 
59 $searchCategoryKnowledgemanagementList = GETPOST('search_category_knowledgemanagement_list', 'array');
60 $searchCategoryKnowledgemanagementOperator = 0;
61 if (GETPOSTISSET('formfilteraction')) {
62  $searchCategoryKnowledgemanagementOperator = GETPOST('search_category_knowledgemanagement_operator', 'int');
63 } elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) {
64  $searchCategoryKnowledgemanagementOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
65 }
66 // Load variable for pagination
67 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
68 $sortfield = GETPOST('sortfield', 'aZ09comma');
69 $sortorder = GETPOST('sortorder', 'aZ09comma');
70 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
71 if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
72  // If $page is not defined, or '' or -1 or if we click on clear filters
73  $page = 0;
74 }
75 $offset = $limit * $page;
76 $pageprev = $page - 1;
77 $pagenext = $page + 1;
78 
79 // Initialize technical objects
80 $object = new KnowledgeRecord($db);
81 $extrafields = new ExtraFields($db);
82 $diroutputmassaction = $conf->knowledgemanagement->dir_output.'/temp/massgeneration/'.$user->id;
83 $hookmanager->initHooks(array('knowledgerecordlist')); // Note that conf->hooks_modules contains array
84 
85 // Fetch optionals attributes and labels
86 $extrafields->fetch_name_optionals_label($object->table_element);
87 //$extrafields->fetch_name_optionals_label($object->table_element_line);
88 
89 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
90 
91 // Default sort order (if not yet defined by previous GETPOST)
92 if (!$sortfield) {
93  reset($object->fields); // Reset is required to avoid key() to return null.
94  $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
95 }
96 if (!$sortorder) {
97  $sortorder = "ASC";
98 }
99 
100 // Initialize array of search criterias
101 $search_all = GETPOST('search_all', 'alphanohtml');
102 $search = array();
103 foreach ($object->fields as $key => $val) {
104  if ($key == "lang") {
105  $search[$key] = GETPOST('search_'.$key, 'alpha')!='0' ? GETPOST('search_'.$key, 'alpha') : '';
106  } else {
107  $search[$key] = GETPOST('search_'.$key, 'alpha');
108  }
109 
110  if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
111  $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
112  $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
113  }
114 }
115 
116 // List of fields to search into when doing a "search in all"
117 $fieldstosearchall = array();
118 foreach ($object->fields as $key => $val) {
119  if (!empty($val['searchall'])) {
120  $fieldstosearchall['t.'.$key] = $val['label'];
121  }
122 }
123 
124 // Definition of array of fields for columns
125 $arrayfields = array();
126 foreach ($object->fields as $key => $val) {
127  // If $val['visible']==0, then we never show the field
128  if (!empty($val['visible'])) {
129  $visible = (int) dol_eval($val['visible'], 1);
130  $arrayfields['t.'.$key] = array(
131  'label'=>$val['label'],
132  'checked'=>(($visible < 0) ? 0 : 1),
133  'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)),
134  'position'=>$val['position'],
135  'help'=> isset($val['help']) ? $val['help'] : ''
136  );
137  }
138 }
139 // Extra fields
140 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
141 
142 $object->fields = dol_sort_array($object->fields, 'position');
143 $arrayfields = dol_sort_array($arrayfields, 'position');
144 
145 $permissiontoread = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read');
146 $permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write');
147 $permissiontodelete = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'delete');
148 
149 // Security check
150 if (empty($conf->knowledgemanagement->enabled)) {
151  accessforbidden('Module not enabled');
152 }
153 $socid = 0;
154 if ($user->socid > 0) { // Protection if external user
155  //$socid = $user->socid;
156  accessforbidden();
157 }
158 $result = restrictedArea($user, 'knowledgemanagement', 0, '', 'knowledgerecord');
159 //if (!$permissiontoread) accessforbidden();
160 
161 
162 
163 /*
164  * Actions
165  */
166 
167 if (GETPOST('cancel', 'alpha')) {
168  $action = 'list';
169  $massaction = '';
170 }
171 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
172  $massaction = '';
173 }
174 
175 $parameters = array();
176 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
177 if ($reshook < 0) {
178  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
179 }
180 
181 if (empty($reshook)) {
182  // Selection of new fields
183  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
184 
185  // Purge search criteria
186  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
187  foreach ($object->fields as $key => $val) {
188  $search[$key] = '';
189  if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
190  $search[$key.'_dtstart'] = '';
191  $search[$key.'_dtend'] = '';
192  }
193  }
194  $toselect = array();
195  $search_array_options = array();
196  }
197  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
198  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
199  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
200  }
201  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
202  $searchCategoryKnowledgemanagementOperator = 0;
203  $searchCategoryKnowledgemanagementList = array();
204  }
205 
206  // Mass actions
207  $objectclass = 'KnowledgeRecord';
208  $objectlabel = 'KnowledgeRecord';
209  $uploaddir = $conf->knowledgemanagement->dir_output;
210  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
211 }
212 
213 
214 
215 /*
216  * View
217  */
218 
219 $form = new Form($db);
220 $user_temp = new User($db);
221 $formadmin = new FormAdmin($db);
222 
223 $now = dol_now();
224 
225 //$help_url="EN:Module_KnowledgeRecord|FR:Module_KnowledgeRecord_FR|ES:Módulo_KnowledgeRecord";
226 $help_url = '';
227 $title = $langs->trans('KnowledgeRecords');
228 $morejs = array();
229 $morecss = array();
230 
231 
232 // Build and execute select
233 // --------------------------------------------------------------------
234 $sql = 'SELECT ';
235 $sql .= $object->getFieldList('t');
236 // Add fields from extrafields
237 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
238  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
239  $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
240  }
241 }
242 // Add fields from hooks
243 $parameters = array();
244 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
245 $sql .= $hookmanager->resPrint;
246 $sql = preg_replace('/,\s*$/', '', $sql);
247 
248 $sqlfields = $sql; // $sql fields to remove for count total
249 
250 $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
251 if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
252  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
253 }
254 // Add table from hooks
255 $parameters = array();
256 $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
257 $sql .= $hookmanager->resPrint;
258 if ($object->ismultientitymanaged == 1) {
259  $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
260 } else {
261  $sql .= " WHERE 1 = 1";
262 }
263 foreach ($search as $key => $val) {
264  if (array_key_exists($key, $object->fields)) {
265  if ($key == 'status' && $search[$key] == -1) {
266  continue;
267  }
268  $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
269  if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
270  if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
271  $search[$key] = '';
272  }
273  $mode_search = 2;
274  }
275  if ($search[$key] != '') {
276  $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
277  }
278  } else {
279  if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
280  $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
281  if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
282  if (preg_match('/_dtstart$/', $key)) {
283  $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'";
284  }
285  if (preg_match('/_dtend$/', $key)) {
286  $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'";
287  }
288  }
289  }
290  }
291 }
292 
293 // Search for tag/category ($searchCategoryKnowledgemanagementList is an array of ID)
294 if (!empty($searchCategoryKnowledgemanagementList)) {
295  $searchCategoryKnowledgemanagementSqlList = array();
296  $listofcategoryid = '';
297  foreach ($searchCategoryKnowledgemanagementList as $searchCategoryKnowledgemanagement) {
298  if (intval($searchCategoryKnowledgemanagement) == -2) {
299  $searchCategoryKnowledgemanagementSqlList[] = "NOT EXISTS (SELECT ck.fk_knowledgemanagement FROM ".MAIN_DB_PREFIX."categorie_knowledgemanagement as ck WHERE t.rowid = ck.fk_knowledgemanagement)";
300  } elseif (intval($searchCategoryKnowledgemanagement) > 0) {
301  if (empty($searchCategoryKnowledgemanagementOperator)) {
302  $searchCategoryKnowledgemanagementSqlList[] = " EXISTS (SELECT ck.fk_knowledgemanagement FROM ".MAIN_DB_PREFIX."categorie_knowledgemanagement as ck WHERE t.rowid = ck.fk_knowledgemanagement AND ck.fk_categorie = ".((int) $searchCategoryKnowledgemanagement).")";
303  } else {
304  $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryKnowledgemanagement);
305  }
306  }
307  }
308  if ($listofcategoryid) {
309  $searchCategoryKnowledgemanagementSqlList[] = " EXISTS (SELECT ck.fk_knowledgemanagement FROM ".MAIN_DB_PREFIX."categorie_knowledgemanagement as ck WHERE t.rowid = ck.fk_knowledgemanagement AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
310  }
311  if ($searchCategoryKnowledgemanagementOperator == 1) {
312  if (!empty($searchCategoryKnowledgemanagementSqlList)) {
313  $sql .= " AND (".implode(' OR ', $searchCategoryKnowledgemanagementSqlList).")";
314  }
315  } else {
316  if (!empty($searchCategoryKnowledgemanagementSqlList)) {
317  $sql .= " AND (".implode(' AND ', $searchCategoryKnowledgemanagementSqlList).")";
318  }
319  }
320 }
321 
322 if ($search_all) {
323  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
324 }
325 //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
326 // Add where from extra fields
327 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
328 // Add where from hooks
329 $parameters = array();
330 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
331 $sql .= $hookmanager->resPrint;
332 
333 /* If a group by is required
334 $sql.= " GROUP BY ";
335 foreach($object->fields as $key => $val) {
336  $sql .= "t.".$key.", ";
337 }
338 // Add fields from extrafields
339 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
340  foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
341 }
342 // Add where from hooks
343 $parameters=array();
344 $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters, $object); // Note that $action and $object may have been modified by hook
345 $sql.=$hookmanager->resPrint;
346 $sql=preg_replace('/,\s*$/','', $sql);
347 */
348 
349 // Count total nb of records
350 $nbtotalofrecords = '';
351 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
352  /* The fast and low memory method to get and count full list converts the sql into a sql count */
353  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
354  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
355  $resql = $db->query($sqlforcount);
356  if ($resql) {
357  $objforcount = $db->fetch_object($resql);
358  $nbtotalofrecords = $objforcount->nbtotalofrecords;
359  } else {
360  dol_print_error($db);
361  }
362 
363  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
364  $page = 0;
365  $offset = 0;
366  }
367  $db->free($resql);
368 }
369 
370 // Complete request and execute it with limit
371 $sql .= $db->order($sortfield, $sortorder);
372 if ($limit) {
373  $sql .= $db->plimit($limit + 1, $offset);
374 }
375 
376 $resql = $db->query($sql);
377 if (!$resql) {
378  dol_print_error($db);
379  exit;
380 }
381 
382 $num = $db->num_rows($resql);
383 
384 
385 // Direct jump if only one record found
386 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
387  $obj = $db->fetch_object($resql);
388  $id = $obj->rowid;
389  header("Location: ".dol_buildpath('/knowledgemanagement/knowledgerecord_card.php', 1).'?id='.$id);
390  exit;
391 }
392 
393 
394 // Output page
395 // --------------------------------------------------------------------
396 
397 llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist');
398 
399 
400 $arrayofselected = is_array($toselect) ? $toselect : array();
401 
402 $param = '';
403 if (!empty($mode)) {
404  $param .= '&mode='.urlencode($mode);
405 }
406 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
407  $param .= '&contextpage='.urlencode($contextpage);
408 }
409 if ($limit > 0 && $limit != $conf->liste_limit) {
410  $param .= '&limit='.((int) $limit);
411 }
412 foreach ($search as $key => $val) {
413  if (is_array($search[$key])) {
414  foreach ($search[$key] as $skey) {
415  if ($skey != '') {
416  $param .= '&search_'.$key.'[]='.urlencode($skey);
417  }
418  }
419  } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
420  $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int'));
421  $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int'));
422  $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int'));
423  } elseif ($search[$key] != '') {
424  $param .= '&search_'.$key.'='.urlencode($search[$key]);
425  }
426 }
427 if ($optioncss != '') {
428  $param .= '&optioncss='.urlencode($optioncss);
429 }
430 // Add $param from extra fields
431 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
432 // Add $param from hooks
433 $parameters = array();
434 $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
435 $param .= $hookmanager->resPrint;
436 
437 // List of mass actions available
438 $arrayofmassactions = array(
439  'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
440  //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
441  //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
442  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
443 );
444 if (isModEnabled('category') && $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write')) {
445  $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
446 }
447 if (!empty($permissiontodelete)) {
448  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
449 }
450 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
451  $arrayofmassactions = array();
452 }
453 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
454 
455 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
456 if ($optioncss != '') {
457  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
458 }
459 print '<input type="hidden" name="token" value="'.newToken().'">';
460 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
461 print '<input type="hidden" name="action" value="list">';
462 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
463 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
464 print '<input type="hidden" name="page" value="'.$page.'">';
465 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
466 print '<input type="hidden" name="page_y" value="">';
467 print '<input type="hidden" name="mode" value="'.$mode.'">';
468 
469 $newcardbutton = '';
470 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
471 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
472 $newcardbutton .= dolGetButtonTitleSeparator();
473 $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/knowledgemanagement/knowledgerecord_card.php', 1).'?action=create', '', $permissiontoadd);
474 
475 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
476 
477 // Add code for pre mass action (confirmation or email presend form)
478 $topicmail = "SendKnowledgeRecordRef";
479 $modelmail = "knowledgerecord";
480 $objecttmp = new KnowledgeRecord($db);
481 $trackid = 'xxxx'.$object->id;
482 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
483 
484 if ($search_all) {
485  $setupstring = '';
486  foreach ($fieldstosearchall as $key => $val) {
487  $fieldstosearchall[$key] = $langs->trans($val);
488  $setupstring .= $key."=".$val.";";
489  }
490  print '<!-- Search done like if KNOWLEDGEMANAGEMENT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
491  print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'."\n";
492 }
493 
494 $moreforfilter = '';
495 /*$moreforfilter.='<div class="divsearchfield">';
496 $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
497 $moreforfilter.= '</div>';*/
498 
499 // Filter on categories
500 $moreforfilter = '';
501 if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) {
502  $moreforfilter .= '<div class="divsearchfield">';
503  $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"');
504  $categoriesKnowledgeArr = $form->select_all_categories(Categorie::TYPE_KNOWLEDGEMANAGEMENT, '', '', 64, 0, 1);
505  $categoriesKnowledgeArr[-2] = '- '.$langs->trans('NotCategorized').' -';
506  $moreforfilter .= Form::multiselectarray('search_category_knowledgemanagement_list', $categoriesKnowledgeArr, $searchCategoryKnowledgemanagementList, 0, 0, 'minwidth300');
507  $moreforfilter .= ' <input type="checkbox" class="valignmiddle" id="search_category_knowledgemanagement_operator" name="search_category_knowledgemanagement_operator" value="1"'.($searchCategoryKnowledgemanagementOperator == 1 ? ' checked="checked"' : '').'/><label class="none valignmiddle" for="search_category_knowledgemanagement_operator">'.$langs->trans('UseOrOperatorForCategories').'</label>';
508  $moreforfilter .= '</div>';
509 }
510 
511 $parameters = array();
512 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
513 if (empty($reshook)) {
514  $moreforfilter .= $hookmanager->resPrint;
515 } else {
516  $moreforfilter = $hookmanager->resPrint;
517 }
518 
519 if (!empty($moreforfilter)) {
520  print '<div class="liste_titre liste_titre_bydiv centpercent">';
521  print $moreforfilter;
522  $parameters = array();
523  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
524  print $hookmanager->resPrint;
525  print '</div>';
526 }
527 
528 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
529 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
530 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
531 
532 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
533 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
534 
535 
536 // Fields title search
537 // --------------------------------------------------------------------
538 print '<tr class="liste_titre_filter">';
539 // Action column
540 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
541  print '<td class="liste_titre maxwidthsearch center">';
542  $searchpicto = $form->showFilterButtons('left');
543  print $searchpicto;
544  print '</td>';
545 }
546 foreach ($object->fields as $key => $val) {
547  $searchkey = empty($search[$key]) ? '' : $search[$key];
548  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
549  if ($key == 'status') {
550  $cssforfield .= ($cssforfield ? ' ' : '').'center';
551  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
552  $cssforfield .= ($cssforfield ? ' ' : '').'center';
553  } elseif (in_array($val['type'], array('timestamp'))) {
554  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
555  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
556  $cssforfield .= ($cssforfield ? ' ' : '').'right';
557  }
558  if (!empty($arrayfields['t.'.$key]['checked'])) {
559  print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
560  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
561  print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
562  } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) {
563  print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
564  } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
565  print '<div class="nowrap">';
566  print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
567  print '</div>';
568  print '<div class="nowrap">';
569  print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
570  print '</div>';
571  } elseif ($key == 'lang') {
572  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
573  $formadmin = new FormAdmin($db);
574  print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
575  } else {
576  print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
577  }
578  print '</td>';
579  }
580 }
581 // Extra fields
582 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
583 
584 // Fields from hook
585 $parameters = array('arrayfields'=>$arrayfields);
586 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
587 print $hookmanager->resPrint;
588 // Action column
589 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
590  print '<td class="liste_titre center maxwidthsearch">';
591  $searchpicto = $form->showFilterButtons();
592  print $searchpicto;
593  print '</td>';
594 }
595 print '</tr>'."\n";
596 
597 $totalarray = array();
598 $totalarray['nbfield'] = 0;
599 
600 // Fields title label
601 // --------------------------------------------------------------------
602 print '<tr class="liste_titre">';
603 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
604  print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
605  $totalarray['nbfield']++;
606 }
607 foreach ($object->fields as $key => $val) {
608  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
609  if ($key == 'status') {
610  $cssforfield .= ($cssforfield ? ' ' : '').'center';
611  } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
612  $cssforfield .= ($cssforfield ? ' ' : '').'center';
613  } elseif (in_array($val['type'], array('timestamp'))) {
614  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
615  } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
616  $cssforfield .= ($cssforfield ? ' ' : '').'right';
617  }
618  $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
619  if (!empty($arrayfields['t.'.$key]['checked'])) {
620  print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n";
621  $totalarray['nbfield']++;
622  }
623 }
624 // Extra fields
625 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
626 // Hook fields
627 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
628 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
629 print $hookmanager->resPrint;
630 // Action column
631 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
632  print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
633  $totalarray['nbfield']++;
634 }
635 print '</tr>'."\n";
636 
637 // Detect if we need a fetch on each output line
638 $needToFetchEachLine = 0;
639 if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
640  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
641  if ($val && preg_match('/\$object/', $val)) {
642  $needToFetchEachLine++; // There is at least one compute field that use $object
643  }
644  }
645 }
646 
647 
648 // Loop on record
649 // --------------------------------------------------------------------
650 $i = 0;
651 $savnbfield = $totalarray['nbfield'];
652 $totalarray = array();
653 $totalarray['nbfield'] = 0;
654 $imaxinloop = ($limit ? min($num, $limit) : $num);
655 while ($i < $imaxinloop) {
656  $obj = $db->fetch_object($resql);
657  if (empty($obj)) {
658  break; // Should not happen
659  }
660 
661  // Store properties in $object
662  $object->setVarsFromFetchObj($obj);
663 
664  if ($mode == 'kanban') {
665  if ($i == 0) {
666  print '<tr><td colspan="'.$savnbfield.'">';
667  print '<div class="box-flex-container kanban">';
668  }
669  // Output Kanban
670  print $object->getKanbanView('');
671  if ($i == ($imaxinloop - 1)) {
672  print '</div>';
673  print '</td></tr>';
674  }
675  } else {
676  // Show here line of result
677  $j = 0;
678  print '<tr data-rowid="'.$object->id.'" class="oddeven">';
679  // Action column
680  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
681  print '<td class="nowrap center">';
682  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
683  $selected = 0;
684  if (in_array($object->id, $arrayofselected)) {
685  $selected = 1;
686  }
687  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
688  }
689  print '</td>';
690  if (!$i) {
691  $totalarray['nbfield']++;
692  }
693  }
694  foreach ($object->fields as $key => $val) {
695  $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
696  if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
697  $cssforfield .= ($cssforfield ? ' ' : '').'center';
698  } elseif ($key == 'status') {
699  $cssforfield .= ($cssforfield ? ' ' : '').'center';
700  }
701 
702  if (in_array($val['type'], array('timestamp'))) {
703  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
704  } elseif ($key == 'ref') {
705  $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
706  }
707 
708  if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
709  $cssforfield .= ($cssforfield ? ' ' : '').'right';
710  }
711  //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
712  if (!empty($arrayfields['t.'.$key]['checked'])) {
713  print '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
714  if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
715  print ' title="'.dol_escape_htmltag(dol_nl2br($object->$key, 1)).'"'; // We add dol_nl2br for the question and answer fields
716  }
717  print '>';
718  if ($key == 'status') {
719  print $object->getLibStatut(5);
720  } elseif ($key == 'rowid') {
721  print $object->showOutputField($val, $key, $object->id, '');
722  } elseif ($key == 'fk_user_creat') {
723  if ($object->fk_user_creat > 0) {
724  if (isset($conf->cache['user'][$object->fk_user_creat])) {
725  $user_temp = $conf->cache['user'][$object->fk_user_creat];
726  } else {
727  $user_temp = new User($db);
728  $user_temp->fetch($object->fk_user_creat);
729  $conf->cache['user'][$object->fk_user_creat] = $user_temp;
730  }
731  print $user_temp->getNomUrl(-1);
732  }
733  } elseif ($key == 'fk_user_modif') {
734  if ($object->fk_user_modif > 0) {
735  if (isset($conf->cache['user'][$object->fk_user_modif])) {
736  $user_temp = $conf->cache['user'][$object->fk_user_modif];
737  } else {
738  $user_temp = new User($db);
739  $user_temp->fetch($object->fk_user_modif);
740  $conf->cache['user'][$object->fk_user_modif] = $user_temp;
741  }
742  print $user_temp->getNomUrl(-1);
743  }
744  } elseif ($key == 'fk_user_valid') {
745  if ($object->fk_user_valid > 0) {
746  if (isset($conf->cache['user'][$object->fk_user_valid])) {
747  $user_temp = $conf->cache['user'][$object->fk_user_valid];
748  } else {
749  $user_temp = new User($db);
750  $user_temp->fetch($object->fk_user_valid);
751  $conf->cache['user'][$object->fk_user_valid] = $user_temp;
752  }
753  print $user_temp->getNomUrl(-1);
754  }
755  } elseif ($key == 'lang') {
756  $labellang = ($object->lang ? $langs->trans('Language_'.$object->lang) : '');
757  print picto_from_langcode($object->lang, 'class="paddingrightonly saturatemedium opacitylow"');
758  print $labellang;
759  } elseif ($key == 'question') {
760  print dolGetFirstLineOfText($object->$key);
761  } else {
762  print $object->showOutputField($val, $key, $object->$key, '');
763  }
764  print '</td>';
765  if (!$i) {
766  $totalarray['nbfield']++;
767  }
768  if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
769  if (!$i) {
770  $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
771  }
772  if (!isset($totalarray['val'])) {
773  $totalarray['val'] = array();
774  }
775  if (!isset($totalarray['val']['t.'.$key])) {
776  $totalarray['val']['t.'.$key] = 0;
777  }
778  $totalarray['val']['t.'.$key] += $object->$key;
779  }
780  }
781  }
782  // Extra fields
783  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
784  // Fields from hook
785  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
786  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
787  print $hookmanager->resPrint;
788  // Action column
789  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
790  print '<td class="nowrap center">';
791  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
792  $selected = 0;
793  if (in_array($object->id, $arrayofselected)) {
794  $selected = 1;
795  }
796  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
797  }
798  print '</td>';
799  if (!$i) {
800  $totalarray['nbfield']++;
801  }
802  }
803 
804  print '</tr>'."\n";
805  }
806  $i++;
807 }
808 
809 // Show total line
810 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
811 
812 // If no record found
813 if ($num == 0) {
814  $colspan = 1;
815  foreach ($arrayfields as $key => $val) {
816  if (!empty($val['checked'])) {
817  $colspan++;
818  }
819  }
820  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
821 }
822 
823 
824 $db->free($resql);
825 
826 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
827 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
828 print $hookmanager->resPrint;
829 
830 print '</table>'."\n";
831 print '</div>'."\n";
832 
833 print '</form>'."\n";
834 
835 if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
836  $hidegeneratedfilelistifempty = 1;
837  if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
838  $hidegeneratedfilelistifempty = 0;
839  }
840 
841  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
842  $formfile = new FormFile($db);
843 
844  // Show list of available documents
845  $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
846  $urlsource .= str_replace('&amp;', '&', $param);
847 
848  $filedir = $diroutputmassaction;
849  $genallowed = $permissiontoread;
850  $delallowed = $permissiontoadd;
851 
852  print $formfile->showdocuments('massfilesarea_knowledgemanagement', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
853 }
854 
855 // End of page
856 llxFooter();
857 $db->close();
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.
Definition: agenda.php:118
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage standard extra fields.
Class to generate html code for admin pages.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
static multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $morecss='', $translate=0, $width=0, $moreattrib='', $elemtype='', $placeholder='', $addjscombo=-1)
Show a multiselect form from an array.
Class for KnowledgeRecord.
Class to manage Dolibarr users.
Definition: user.class.php:47
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
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.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_now($mode='auto')
Return date for now.
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...
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
Definition: list.php:329
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.