dolibarr 23.0.3
fieldsmanager.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
4 * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
5 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
6 * Copyright (C) 2009-2012 Laurent Destailleur <eldy@users.sourceforge.net>
7 * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
8 * Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro>
9 * Copyright (C) 2015 Charles-Fr BENKE <charles.fr@benke.fr>
10 * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
11 * Copyright (C) 2017 Nicolas ZABOURI <info@inovea-conseil.com>
12 * Copyright (C) 2018-2022 Frédéric France <frederic.france@netlogic.fr>
13 * Copyright (C) 2022 Antonin MARCHAL <antonin@letempledujeu.fr>
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <https://www.gnu.org/licenses/>.
27 */
28
35require_once DOL_DOCUMENT_ROOT . '/core/class/fieldinfos.class.php';
36require_once DOL_DOCUMENT_ROOT . '/core/class/fields/commonfield.class.php';
37
38
43{
47 public $db;
48
52 public $error = '';
53
57 public $errors = array();
58
62 public $validateFieldsErrors = array();
63
67 public $fieldsPath = '/core/class/fields/';
68
72 public static $fieldClasses = array();
73
77 public static $fieldInfos = array();
78
82 public $expand_display = array();
83
85 // * @var array<string,string> Array of type to label
86 // */
87 //public static $type2label = array(
88 // 'varchar' => 'String1Line',
89 // 'text' => 'TextLongNLines',
90 // 'html' => 'HtmlText',
91 // 'int' => 'Int',
92 // 'double' => 'Float',
93 // 'date' => 'Date',
94 // 'datetime' => 'DateAndTime',
95 // 'duration' => 'Duration',
96 // //'datetimegmt'=>'DateAndTimeUTC',
97 // 'boolean' => 'Boolean',
98 // 'price' => 'ExtrafieldPrice',
99 // 'pricecy' => 'ExtrafieldPriceWithCurrency',
100 // 'phone' => 'ExtrafieldPhone',
101 // 'email' => 'ExtrafieldMail',
102 // 'url' => 'ExtrafieldUrl',
103 // 'ip' => 'ExtrafieldIP',
104 // 'icon' => 'Icon',
105 // 'password' => 'ExtrafieldPassword',
106 // 'radio' => 'ExtrafieldRadio',
107 // 'select' => 'ExtrafieldSelect',
108 // 'sellist' => 'ExtrafieldSelectList',
109 // 'checkbox' => 'ExtrafieldCheckBox',
110 // 'chkbxlst' => 'ExtrafieldCheckBoxFromList',
111 // 'link' => 'ExtrafieldLink',
112 // 'point' => 'ExtrafieldPointGeo',
113 // 'multipts' => 'ExtrafieldMultiPointGeo',
114 // 'linestrg' => 'ExtrafieldLinestringGeo',
115 // 'polygon' => 'ExtrafieldPolygonGeo',
116 // 'separate' => 'ExtrafieldSeparator',
117 // 'stars' => 'ExtrafieldStars',
118 // //'real' => 'ExtrafieldReal',
119 //);
120
121
128 public function __construct($db, $form = null)
129 {
130 $this->db = $db;
131 $this->error = '';
132 $this->errors = array();
133
134 if (isset($form)) {
136 }
137 }
138
145 public function getFieldClass($type)
146 {
147 global $hookmanager, $langs;
148
149 $type = trim($type);
150
151 if (!isset(self::$fieldClasses[$type])) {
152 $field = null;
153 $parameters = array(
154 'type' => $type,
155 // @phan-suppress-next-line PhanPluginConstantVariableNull
156 'field' => &$field,
157 );
158
159 $hookmanager->executeHooks('getFieldClass', $parameters, $this); // Note that $object may have been modified by hook
160 // @phpstan-ignore-next-line @phan-suppress-next-line PhanPluginConstantVariableNull
161 if (isset($field) && is_object($field)) {
162 self::$fieldClasses[$type] = $field;
163 } else {
164 $filename = strtolower($type) . 'field.class.php';
165 $classname = ucfirst($type) . 'Field';
166
167 // Load class file
168 dol_include_once(rtrim($this->fieldsPath, '/') . '/' . $filename);
169 if (!class_exists($classname)) {
170 @include_once DOL_DOCUMENT_ROOT . '/core/class/fields/' . $filename;
171 }
172
173 if (class_exists($classname)) {
174 self::$fieldClasses[$type] = new $classname($this->db);
175 } else {
176 $langs->load("errors");
177 $this->errors[] = $langs->trans('ErrorFieldClassNotFoundForClassName', $classname, $type);
178 return null;
179 }
180 }
181 }
182
183 $field = self::$fieldClasses[$type];
184 $field->clearErrors();
185
186 return $field;
187 }
188
194 public function getAllFields()
195 {
196 // Todo to make
197 return self::$fieldClasses;
198 }
199
205 public function clearErrors()
206 {
207 $this->error = '';
208 $this->errors = array();
209 }
210
217 public function errorsToString($separator = ', ')
218 {
219 return $this->error . (is_array($this->errors) ? (!empty($this->error) ? $separator : '') . implode($separator, $this->errors) : '');
220 }
221
228 public function clearFieldError($fieldKey)
229 {
230 $this->error = '';
231 unset($this->validateFieldsErrors[$fieldKey]);
232 }
233
241 public function setFieldError($fieldKey, $msg = '')
242 {
243 global $langs;
244 if (empty($msg)) {
245 $msg = $langs->trans("UnknownError");
246 }
247
248 $this->error = $this->validateFieldsErrors[$fieldKey] = $msg;
249 }
250
257 public function getFieldError($fieldKey)
258 {
259 if (!empty($this->validateFieldsErrors[$fieldKey])) {
260 return $this->validateFieldsErrors[$fieldKey];
261 }
262 return '';
263 }
264
271 public function getFieldErrorIcon($fieldValidationErrorMsg)
272 {
273 $out = '';
274
275 if (!empty($fieldValidationErrorMsg) && function_exists('getFieldErrorIcon')) {
276 $out .= ' ' . getFieldErrorIcon($fieldValidationErrorMsg);
277 }
278
279 return $out;
280 }
281
293 public function getAllFieldsInfos(&$object, &$extrafields = null, $mode = 'view', $nbColumn = 2, $breakKeys = array(), $params = array())
294 {
295 global $hookmanager, $langs;
296
297 // Get object fields
298 $fields = $this->getAllObjectFieldsInfos($object, $mode, $params);
299
300 // Old sort
301 if (!getDolGlobalInt('MAIN_FIELDS_SORT_WITH_EXTRA_FIELDS')) {
302 $fields = dol_sort_array($fields, 'position');
303 }
304
305 // Get extra fields
306 $fields2 = $this->getAllExtraFieldsInfos($object, $extrafields, $mode, $params);
307 $fields = array_merge($fields, $fields2);
308
309 // New sort
310 if (getDolGlobalInt('MAIN_FIELDS_SORT_WITH_EXTRA_FIELDS')) {
311 $fields = dol_sort_array($fields, 'position');
312 }
313
314 // Split in columns
315 $idxColumn = 1;
316 $columns = array();
317 $hiddenFields = array();
318 $columns[$idxColumn] = array();
319 $nbVisibleFields = 0;
320 foreach ($fields as $field) {
321 if ($field->visible) {
322 $nbVisibleFields++;
323 }
324 }
325 $nbFieldsByColumn = ceil($nbVisibleFields / $nbColumn);
326 $breakKey = $breakKeys[$idxColumn] ?? '';
327 $idxField = 0;
328 foreach ($fields as $key => $field) {
329 if ($idxColumn < $nbColumn && ((!empty($breakKey) && $key == $breakKey) || (empty($breakKey) && $idxField == $nbFieldsByColumn))) {
330 $idxColumn++;
331 $idxField = 0;
332 $columns[$idxColumn] = array();
333 }
334
335 if ($field->visible) {
336 if ($field->type != 'separate') {
337 $idxField++;
338 }
339
340 // Add field into column
341 $columns[$idxColumn][$key] = $field;
342 } else {
343 $hiddenFields[$key] = $field;
344 }
345 }
346
347 // Add column not created
348 for ($idxColumn = 1; $idxColumn <= $nbColumn; $idxColumn++) {
349 if (!isset($columns[$idxColumn])) {
350 $columns[$idxColumn] = array();
351 }
352 }
353
354 $parameters = array(
355 'object' => &$object,
356 'extrafields' => &$extrafields,
357 'mode' => $mode,
358 'nbColumn' => $nbColumn,
359 'breakKeys' => $breakKeys,
360 'params' => $params,
361 'columns' => &$columns,
362 'hiddenFields' => &$hiddenFields,
363 );
364
365 $hookmanager->executeHooks('getFieldInfosFromObjectField', $parameters, $this); // Note that $object may have been modified by hook
366
367 return array(
368 'columns' => $columns,
369 'hiddenFields' => $hiddenFields,
370 );
371 }
372
381 public function getAllObjectFieldsInfos(&$object, $mode = 'view', $params = array())
382 {
383 global $hookmanager;
384
385 // Get object fields
386 $fields = array();
387 // @phpstan-ignore-next-line
388 if (isset($object->fields) && is_array($object->fields)) {
389 $keyPrefix = getDolGlobalInt('MAIN_FIELDS_NEW_OBJECT_KEY_PREFIX') ? 'object_' : '';
390 foreach ($object->fields as $key => $field) {
391 $fieldInfos = $this->getFieldInfosFromObjectField($object, $key, $mode, $params);
392 $fields[$keyPrefix . $key] = $fieldInfos;
393 }
394 }
395
396 $parameters = array(
397 'object' => &$object,
398 'mode' => $mode,
399 'params' => $params,
400 'fields' => &$fields,
401 );
402
403 $hookmanager->executeHooks('getAllObjectFieldsInfos', $parameters, $this); // Note that $object may have been modified by hook
404
405 return $fields;
406 }
407
417 public function getAllExtraFieldsInfos(&$object, &$extrafields = null, $mode = 'view', $params = array())
418 {
419 global $hookmanager;
420
421 // Get extra fields
422 $fields = array();
423 if (isset($extrafields->attributes[$object->table_element]) && is_array($extrafields->attributes[$object->table_element])) {
424 if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label'])) {
425 $keyPrefix = 'options_';
426 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) {
427 $fieldInfos = $this->getFieldInfosFromExtraField($object, $extrafields, $key, $mode, $params);
428 $fields[$keyPrefix . $key] = $fieldInfos;
429 }
430 }
431 }
432
433 $parameters = array(
434 'object' => &$object,
435 'extrafields' => &$extrafields,
436 'mode' => $mode,
437 'params' => $params,
438 'fields' => &$fields,
439 );
440
441 $hookmanager->executeHooks('getAllExtraFieldsInfos', $parameters, $this); // Note that $object may have been modified by hook
442
443 return $fields;
444 }
445
456 public function getFieldsInfos($key, &$object, &$extrafields = null, $mode = 'view', $params = array())
457 {
458 $fieldInfos = null;
459
460 $patternObjectPrefix = getDolGlobalInt('MAIN_FIELDS_NEW_OBJECT_KEY_PREFIX') ? 'object_' : '';
461 $matches = array();
462 if (preg_match('/^options_(.*)/i', $key, $matches)) {
463 $fieldKey = $matches[1];
464 $fieldInfos = $this->getFieldInfosFromExtraField($object, $extrafields, $fieldKey, $mode, $params);
465 } elseif (preg_match('/^' . $patternObjectPrefix . '(.*)/i', $key, $matches)) {
466 $fieldKey = $matches[2];
467 $fieldInfos = $this->getFieldInfosFromObjectField($object, $fieldKey, $mode, $params);
468 }
469
470 return $fieldInfos;
471 }
472
482 public function getFieldInfosFromObjectField(&$object, $key, $mode = 'view', $params = array())
483 {
484 global $hookmanager;
485
486 if (!isset($object->fields[$key])) {
487 return null;
488 }
489
490 if (isset(self::$fieldInfos[$object->element][$mode]['object'][$key])) {
491 return self::$fieldInfos[$object->element][$mode]['object'][$key];
492 }
493
494 $attributes = $object->fields[$key];
495
496 $fieldInfos = new FieldInfos();
497 $fieldInfos->fieldType = FieldInfos::FIELD_TYPE_OBJECT;
498 $fieldInfos->originType = $attributes['type'] ?? '';
499 $fieldInfos->size = $attributes['length'] ?? '';
500 $fieldInfos->label = $attributes['label'] ?? '';
501 $fieldInfos->langFile = $attributes['langfile'] ?? '';
502 $fieldInfos->sqlAlias = $attributes['alias'] ?? null;
503 $fieldInfos->picto = $attributes['picto'] ?? '';
504 $fieldInfos->position = $attributes['position'] ?? 0;
505 $fieldInfos->required = ($attributes['notnull'] ?? 0) > 0;
506 $fieldInfos->alwaysEditable = !empty($attributes['alwayseditable']);
507 $fieldInfos->defaultValue = $attributes['default'] ?? '';
508 $fieldInfos->css = $attributes['css'] ?? '';
509 $fieldInfos->viewCss = $attributes['cssview'] ?? '';
510 $fieldInfos->listCss = $attributes['csslist'] ?? '';
511 $fieldInfos->inputPlaceholder = $attributes['placeholder'] ?? '';
512 $fieldInfos->help = $attributes['help'] ?? '';
513 $fieldInfos->listHelp = $attributes['helplist'] ?? '';
514 $fieldInfos->showOnComboBox = !empty($attributes['showoncombobox']);
515 $fieldInfos->inputDisabled = !empty($attributes['disabled']);
516 $fieldInfos->inputAutofocus = !empty($attributes['autofocusoncreate']) && $mode == 'create';
517 $fieldInfos->comment = $attributes['comment'] ?? '';
518 $fieldInfos->listTotalizable = !empty($attributes['isameasure']) && $attributes['isameasure'] == 1;
519 $fieldInfos->validateField = !empty($attributes['validate']);
520 $fieldInfos->copyToClipboard = $attributes['copytoclipboard'] ?? 0;
521 $fieldInfos->tdCss = $attributes['tdcss'] ?? '';
522 $fieldInfos->multiInput = !empty($attributes['multiinput']);
523 $fieldInfos->nameInClass = $attributes['nameinclass'] ?? $key;
524 $fieldInfos->nameInTable = $attributes['nameintable'] ?? $key;
525 $fieldInfos->getNameUrlParams = $attributes['get_name_url_params'] ?? null;
526 $fieldInfos->showOnHeader = !empty($attributes['showonheader']);
527
528 // TODO set nameinclass = "id" in fields "rowid"
529 if ($fieldInfos->nameInClass == 'rowid') {
530 $fieldInfos->nameInClass = 'id';
531 }
532
533 $enabled = $attributes['enabled'] ?? '1';
534 $visibility = $attributes['visible'] ?? '1';
535 $perms = empty($attributes['noteditable']) ? '1' : '0';
536
537 $this->setCommonFieldInfos($fieldInfos, $object, $extrafields, $key, $mode, $enabled, $visibility, $perms, $params);
538
539 // Special case that force options and type ($type can be integer, varchar, ...)
540 if (!empty($attributes['arrayofkeyval']) && is_array($attributes['arrayofkeyval'])) {
541 $fieldInfos->options = $attributes['arrayofkeyval'];
542 // Special case that prevent to force $type to have multiple input @phan-suppress-next-line PhanTypeMismatchProperty
543 if (!$fieldInfos->multiInput) {
544 $fieldInfos->type = (($fieldInfos->type == 'checkbox') ? $fieldInfos->type : 'select');
545 }
546 }
547
548 $parameters = array(
549 'object' => &$object,
550 'key' => $key,
551 'mode' => $mode,
552 'fieldInfos' => &$fieldInfos,
553 );
554
555 $hookmanager->executeHooks('getFieldInfosFromObjectField', $parameters, $this); // Note that $object may have been modified by hook
556
557 self::$fieldInfos[$object->element][$mode]['object'][$key] = $fieldInfos;
558 return $fieldInfos;
559 }
560
571 public function getFieldInfosFromExtraField(&$object, &$extrafields, $key, $mode = 'view', $params = array())
572 {
573 global $hookmanager;
574
575 if (!isset($extrafields->attributes[$object->table_element]['label'][$key])) {
576 return null;
577 }
578
579 if (isset(self::$fieldInfos[$object->element][$mode]['extraField'][$key])) {
580 return self::$fieldInfos[$object->element][$mode]['extraField'][$key];
581 }
582
583 $attributes = $extrafields->attributes[$object->table_element];
584
585 $fieldInfos = new FieldInfos();
586 $fieldInfos->fieldType = FieldInfos::FIELD_TYPE_EXTRA_FIELD;
587 $fieldInfos->originType = $attributes['type'][$key] ?? '';
588 $fieldInfos->label = $attributes['label'][$key] ?? '';
589 $fieldInfos->position = $attributes['pos'][$key] ?? 0;
590 $fieldInfos->required = !empty($attributes['required'][$key]);
591 $fieldInfos->defaultValue = $attributes['default'][$key] ?? '';
592 $fieldInfos->css = $attributes['css'][$key] ?? '';
593 $fieldInfos->help = $attributes['help'][$key] ?? '';
594 $fieldInfos->size = $attributes['size'][$key] ?? '';
595 $fieldInfos->computed = $attributes['computed'][$key] ?? '';
596 $fieldInfos->unique = !empty($attributes['unique'][$key]);
597 $fieldInfos->alwaysEditable = !empty($attributes['alwayseditable'][$key]);
598 $fieldInfos->emptyOnClone = !empty($attributes['emptyonclone'][$key]);
599 $fieldInfos->langFile = $attributes['langfile'][$key] ?? '';
600 $fieldInfos->printable = !empty($attributes['printable'][$key]);
601 $fieldInfos->aiPrompt = $attributes['aiprompt'][$key] ?? '';
602 $fieldInfos->viewCss = $attributes['cssview'][$key] ?? '';
603 $fieldInfos->listCss = $attributes['csslist'][$key] ?? '';
604 $fieldInfos->listTotalizable = !empty($attributes['totalizable'][$key]);
605 $fieldInfos->options = array_diff_assoc($attributes['param'][$key]['options'] ?? array(), array('' => null)); // For remove case when not defined
606 $fieldInfos->nameInClass = $key;
607 $fieldInfos->nameInTable = $key;
608
609 $enabled = $attributes['enabled'][$key] ?? '1';
610 $visibility = $attributes['list'][$key] ?? '1';
611 $perms = $attributes['perms'][$key] ?? null;
612
613 $this->setCommonFieldInfos($fieldInfos, $object, $extrafields, $key, $mode, $enabled, $visibility, $perms, $params);
614
615 $parameters = array(
616 'object' => &$object,
617 'extraFields' => &$extrafields,
618 'key' => $key,
619 'mode' => $mode,
620 'fieldInfos' => &$fieldInfos,
621 );
622
623 $hookmanager->executeHooks('getFieldInfosFromExtraField', $parameters, $this); // Note that $object may have been modified by hook
624
625 self::$fieldInfos[$object->element][$mode]['extraField'][$key] = $fieldInfos;
626 return $fieldInfos;
627 }
628
643 public function setCommonFieldInfos(&$fieldInfos, &$object, &$extrafields, $key, $mode = 'view', $enabled = '1', $visibility = '', $perms = null, $params = array())
644 {
645 global $user;
646
647 $fieldInfos->object = &$object;
648 $fieldInfos->mode = preg_replace('/[^a-z0-9_]/i', '', $mode);
649 $fieldInfos->type = $fieldInfos->originType;
650 $fieldInfos->key = $key;
651 $fieldInfos->otherParams = $params;
652
653 if (preg_match('/^(integer|link):(.*):(.*):(.*):(.*)/i', $fieldInfos->originType, $reg)) {
654 $fieldInfos->options = array($reg[2] . ':' . $reg[3] . ':' . $reg[4] . ':' . $reg[5] => 'N');
655 $fieldInfos->type = 'link';
656 } elseif (preg_match('/^(integer|link):(.*):(.*):(.*)/i', $fieldInfos->originType, $reg)) {
657 $fieldInfos->options = array($reg[2] . ':' . $reg[3] . ':' . $reg[4] => 'N');
658 $fieldInfos->type = 'link';
659 } elseif (preg_match('/^(integer|link):(.*):(.*)/i', $fieldInfos->originType, $reg)) {
660 $fieldInfos->options = array($reg[2] . ':' . $reg[3] . ($reg[1] == 'User' ? ':#getnomurlparam1=-1' : '') => 'N');
661 $fieldInfos->type = 'link';
662 } elseif (preg_match('/^(sellist):(.*):(.*):(.*):(.*)/i', $fieldInfos->originType, $reg)) {
663 $fieldInfos->options = array($reg[2] . ':' . $reg[3] . ':' . $reg[4] . ':' . $reg[5] => 'N');
664 $fieldInfos->type = 'sellist';
665 } elseif (preg_match('/^(sellist):(.*):(.*):(.*)/i', $fieldInfos->originType, $reg)) {
666 $fieldInfos->options = array($reg[2] . ':' . $reg[3] . ':' . $reg[4] => 'N');
667 $fieldInfos->type = 'sellist';
668 } elseif (preg_match('/^(sellist):(.*):(.*)/i', $fieldInfos->originType, $reg)) {
669 $fieldInfos->options = array($reg[2] . ':' . $reg[3] => 'N');
670 $fieldInfos->type = 'sellist';
671 } elseif (preg_match('/^chkbxlst:(.*)/i', $fieldInfos->originType, $reg)) {
672 $fieldInfos->options = array($reg[1] => 'N');
673 $fieldInfos->type = 'chkbxlst';
674 } elseif (preg_match('/varchar\‍((\d+)\‍)/', $fieldInfos->originType, $reg)) {
675 $fieldInfos->options = array();
676 $fieldInfos->type = 'varchar';
677 $fieldInfos->size = $reg[1];
678 $fieldInfos->maxLength = (int) $reg[1];
679 } elseif (preg_match('/varchar/', $fieldInfos->originType)) {
680 $fieldInfos->options = array();
681 $fieldInfos->type = 'varchar';
682 } elseif (preg_match('/stars\‍((\d+)\‍)/', $fieldInfos->originType, $reg)) {
683 $fieldInfos->options = array();
684 $fieldInfos->type = 'stars';
685 $fieldInfos->size = $reg[1];
686 } elseif (preg_match('/integer/', $fieldInfos->originType)) {
687 $fieldInfos->type = 'int';
688 } elseif ($fieldInfos->originType == 'mail') {
689 $fieldInfos->type = 'email';
690 } elseif (preg_match('/^(text):(.*)/i', $fieldInfos->originType, $reg)) {
691 $fieldInfos->type = 'text';
692 $fieldInfos->getPostCheck = $reg[2];
693 } elseif (preg_match('/^(html):(.*)/i', $fieldInfos->originType, $reg)) {
694 $fieldInfos->type = 'html';
695 $fieldInfos->getPostCheck = $reg[2];
696 } elseif (preg_match('/^double\‍(([0-9]+,[0-9]+)\‍)/', $fieldInfos->originType, $reg)) {
697 $fieldInfos->type = 'double';
698 $fieldInfos->size = $reg[1];
699 }
700
701 // Set visibility
702 $visibility = (int) dol_eval((string) $visibility, 1, 1, '2');
703 $absVisibility = abs($visibility);
704 $enabled = (int) dol_eval((string) $enabled, 1, 1, '2');
705 $fieldInfos->visible = true;
706 if (empty($visibility) ||
707 empty($enabled) ||
708 ($mode == 'create' && !in_array($absVisibility, array(1, 3, 6))) ||
709 ($mode == 'edit' && !in_array($absVisibility, array(1, 3, 4))) ||
710 ($mode == 'view' && (!in_array($absVisibility, array(1, 3, 4, 5)) || $fieldInfos->showOnHeader)) ||
711 ($mode == 'list' && $absVisibility == 3)
712 ) {
713 $fieldInfos->visible = false;
714 }
715
716 // Set edit perms
717 if (isset($perms)) {
718 $perms = (int) dol_eval((string) $perms, 1, 1, '2');
719 } else {
720 //TODO Improve element and rights detection
721 $mappingKeyForPerm = array(
722 'fichinter' => 'ficheinter',
723 'product' => 'produit',
724 'project' => 'projet',
725 'order_supplier' => 'supplier_order',
726 'invoice_supplier' => 'supplier_invoice',
727 'shipping' => 'expedition',
728 'productlot' => 'stock',
729 'facturerec' => 'facture',
730 'mo' => 'mrp',
731 'salary' => 'salaries',
732 'member' => 'adherent',
733 );
734 $keyForPerm = $mappingKeyForPerm[$object->element] ?? $object->element;
735
736 $perms = false;
737 if (isset($user->rights->$keyForPerm)) {
738 $perms = $user->hasRight($keyForPerm, 'creer') || $user->hasRight($keyForPerm, 'create') || $user->hasRight($keyForPerm, 'write');
739 }
740 if ($object->element == 'order_supplier' && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) {
741 $perms = $user->hasRight('fournisseur', 'commande', 'creer');
742 } elseif ($object->element == 'invoice_supplier' && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) {
743 $perms = $user->hasRight('fournisseur', 'facture', 'creer');
744 } elseif ($object->element == 'delivery') {
745 $perms = $user->hasRight('expedition', 'delivery', 'creer');
746 } elseif ($object->element == 'contact') {
747 $perms = $user->hasRight('societe', 'contact', 'creer');
748 }
749 }
750 // Manage always editable of extra field
751 $isDraft = ((isset($object->statut) && $object->statut == 0) || (isset($object->status) && $object->status == 0));
752 if ($mode == 'view' && !$isDraft && !$fieldInfos->alwaysEditable) {
753 $perms = false;
754 }
755 // Case visible only in view so not editable
756 if ($mode == 'view' && $absVisibility == 5) {
757 $perms = false;
758 }
759 // Case field computed
760 if (!empty($fieldInfos->computed)) {
761 $perms = false;
762 }
763 $fieldInfos->editable = !empty($perms);
764
765 // Set list info 'checked'
766 $fieldInfos->listChecked = $mode == 'list' && $visibility > 0;
767 }
768
780 public function setFieldValuesFromPost(&$object, &$extrafields, $keyPrefix = '', $keySuffix = '', $mode = 'view', $params = array())
781 {
782 $result = $this->setObjectFieldValuesFromPost($object, $keyPrefix, $keySuffix, $mode, $params);
783 $result2 = $this->setExtraFieldValuesFromPost($object, $extrafields, $keyPrefix, $keySuffix, $mode, $params);
784
785 return $result > 0 && $result2 > 0 ? 1 : -1;
786 }
787
798 public function setObjectFieldValuesFromPost(&$object, $keyPrefix = '', $keySuffix = '', $mode = 'view', $params = array())
799 {
800 $fields = $this->getAllObjectFieldsInfos($object, $mode, $params);
801
802 $error = 0;
803 foreach ($fields as $fieldKey => $fieldInfos) {
804 $check = true;
805 $key = $fieldInfos->nameInClass ?? $fieldInfos->key;
806 if ($fieldInfos->visible) {
807 $check = $this->verifyPostFieldValue($fieldInfos, $fieldKey, $keyPrefix, $keySuffix);
808 }
809 if ($check) {
810 $object->$key = $this->getPostFieldValue($fieldInfos, $fieldKey, $object->$key, $keyPrefix, $keySuffix);
811 }
812 if (!$fieldInfos->visible) {
813 $check = $this->verifyFieldValue($fieldInfos, $fieldKey, $object->$key);
814 }
815 if (!$check) {
816 $error++;
817 }
818 }
819
820 return $error ? -1 : 1;
821 }
822
834 public function setExtraFieldValuesFromPost(&$object, &$extrafields, $keyPrefix = '', $keySuffix = '', $mode = 'view', $params = array())
835 {
836 $fields = $this->getAllExtraFieldsInfos($object, $extrafields, $mode, $params);
837
838 $error = 0;
839 foreach ($fields as $fieldKey => $fieldInfos) {
840 $check = true;
841 $key = 'options_' . ($fieldInfos->nameInClass ?? $fieldInfos->key);
842 if ($fieldInfos->visible) {
843 $check = $this->verifyPostFieldValue($fieldInfos, $fieldKey, $keyPrefix, $keySuffix);
844 }
845 if ($check) {
846 $object->array_options[$key] = $this->getPostFieldValue($fieldInfos, $fieldKey, $object->array_options[$key], $keyPrefix, $keySuffix);
847 }
848 if (!$fieldInfos->visible) {
849 $check = $this->verifyFieldValue($fieldInfos, $fieldKey, $object->array_options[$key]);
850 }
851 if (!$check) {
852 $error++;
853 }
854 }
855
856 return $error ? -1 : 1;
857 }
858
868 public function verifyPostFieldValue($fieldInfos, $key, $keyPrefix = '', $keySuffix = '')
869 {
870 global $hookmanager;
871
872 $result = true;
873 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1 || getDolGlobalString('MAIN_ACTIVATE_VALIDATION_RESULT')) {
874 $parameters = array(
875 'fieldInfos' => &$fieldInfos,
876 'key' => $key,
877 'keyPrefix' => $keyPrefix,
878 'keySuffix' => $keySuffix,
879 );
880
881 $reshook = $hookmanager->executeHooks('verifyPostFieldValue', $parameters, $this); // Note that $object may have been modified by hook
882 if ($reshook > 0) {
883 return (bool) $hookmanager->resPrint;
884 }
885
886 $this->clearErrors();
887 $field = $this->getFieldClass($fieldInfos->type);
888 if (isset($field)) {
889 $this->clearFieldError($key);
890 $result = $field->verifyPostFieldValue($fieldInfos, $key, $keyPrefix, $keySuffix);
891 if (!$result) {
892 $this->setFieldError($key, CommonField::$validator->error);
893 }
894 }
895 }
896
897 return $result;
898 }
899
908 public function verifyFieldValue($fieldInfos, $key, $value)
909 {
910 global $hookmanager;
911
912 $result = true;
913 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1 || getDolGlobalString('MAIN_ACTIVATE_VALIDATION_RESULT')) {
914 $parameters = array(
915 'fieldInfos' => &$fieldInfos,
916 'key' => $key,
917 'value' => $value,
918 );
919
920 $reshook = $hookmanager->executeHooks('verifyFieldValue', $parameters, $this); // Note that $object may have been modified by hook
921 if ($reshook > 0) {
922 return (bool) $hookmanager->resPrint;
923 }
924
925 $this->clearErrors();
926 $field = $this->getFieldClass($fieldInfos->type);
927 if (isset($field)) {
928 $this->clearFieldError($key);
929 $result = $field->verifyFieldValue($fieldInfos, $key, $value);
930 if (!$result) {
931 $this->setFieldError($key, CommonField::$validator->error);
932 }
933 }
934 }
935
936 return $result;
937 }
938
949 public function getPostFieldValue($fieldInfos, $key, $defaultValue = null, $keyPrefix = '', $keySuffix = '')
950 {
951 global $hookmanager;
952
953 $value = '';
954 $parameters = array(
955 'fieldInfos' => &$fieldInfos,
956 'key' => $key,
957 'value' => &$value,
958 'keyPrefix' => $keyPrefix,
959 'keySuffix' => $keySuffix,
960 );
961
962 $reshook = $hookmanager->executeHooks('getPostFieldValue', $parameters, $this); // Note that $object may have been modified by hook
963 if ($reshook > 0) {
964 return $value;
965 }
966
967 $this->clearErrors();
968 $field = $this->getFieldClass($fieldInfos->type);
969 if (isset($field)) {
970 $value = $field->getPostFieldValue($fieldInfos, $key, $defaultValue, $keyPrefix, $keySuffix);
971 } else {
972 $value = $defaultValue;
973 }
974
975 return $value;
976 }
977
988 public function getPostSearchFieldValue($fieldInfos, $key, $defaultValue = null, $keyPrefix = '', $keySuffix = '')
989 {
990 global $hookmanager;
991
992 $value = '';
993 $parameters = array(
994 'fieldInfos' => &$fieldInfos,
995 'key' => $key,
996 'value' => &$value,
997 'keyPrefix' => $keyPrefix,
998 'keySuffix' => $keySuffix,
999 );
1000
1001 $reshook = $hookmanager->executeHooks('getPostSearchFieldValue', $parameters, $this); // Note that $object may have been modified by hook
1002 if ($reshook > 0) {
1003 return $value;
1004 }
1005
1006 $this->clearErrors();
1007 $field = $this->getFieldClass($fieldInfos->type);
1008 if (isset($field)) {
1009 $value = $field->getPostSearchFieldValue($fieldInfos, $key, $defaultValue, $keyPrefix, $keySuffix);
1010 } else {
1011 $value = $defaultValue;
1012 }
1013
1014 return $value;
1015 }
1016
1030 public function printInputSearchField($fieldInfos, $key, $value, $keyPrefix = '', $keySuffix = '', $moreCss = '', $moreAttrib = '', $noNewButton = 0)
1031 {
1032 global $hookmanager;
1033
1034 $overwrite_before = '';
1035 $overwrite_content = '';
1036 $overwrite_after = '';
1037
1038 $parameters = array(
1039 'fieldInfos' => &$fieldInfos,
1040 'key' => $key,
1041 'value' => &$value,
1042 'keyPrefix' => $keyPrefix,
1043 'keySuffix' => $keySuffix,
1044 'moreCss' => $moreCss,
1045 'moreAttrib' => $moreAttrib,
1046 'noNewButton' => $noNewButton,
1047 'overwrite_before' => &$overwrite_before,
1048 'overwrite_content' => &$overwrite_content,
1049 'overwrite_after' => &$overwrite_after,
1050 );
1051
1052 $hookmanager->executeHooks('printInputSearchField', $parameters, $this); // Note that $this may have been modified by hook
1053
1054 if (!empty($fieldInfos->computed)) {
1055 return '';
1056 }
1057
1058 $out = $overwrite_before;
1059 if (empty($overwrite_content)) {
1060 $this->clearErrors();
1061 $field = $this->getFieldClass($fieldInfos->type);
1062 if (isset($field)) {
1063 $moreCss = $field->getInputCss($fieldInfos, $moreCss);
1064
1065 $out .= $field->printInputSearchField($fieldInfos, $key, $value, $keyPrefix, $keySuffix, $moreCss, $moreAttrib);
1066 } else {
1067 $out .= $this->errorsToString();
1068 }
1069 } else {
1070 $out .= $overwrite_content;
1071 }
1072 $out .= $overwrite_after;
1073
1074 return $out;
1075 }
1076
1090 public function printInputField($fieldInfos, $key, $value, $keyPrefix = '', $keySuffix = '', $moreCss = '', $moreAttrib = '', $noNewButton = 0)
1091 {
1092 global $hookmanager, $langs;
1093
1094 $overwrite_before = '';
1095 $overwrite_content = '';
1096 $overwrite_after = '';
1097
1098 $parameters = array(
1099 'fieldInfos' => &$fieldInfos,
1100 'key' => $key,
1101 'value' => &$value,
1102 'keyPrefix' => $keyPrefix,
1103 'keySuffix' => $keySuffix,
1104 'moreCss' => $moreCss,
1105 'moreAttrib' => $moreAttrib,
1106 'noNewButton' => $noNewButton,
1107 'overwrite_before' => &$overwrite_before,
1108 'overwrite_content' => &$overwrite_content,
1109 'overwrite_after' => &$overwrite_after,
1110 );
1111
1112 $hookmanager->executeHooks('printInputField', $parameters, $this); // Note that $this may have been modified by hook
1113
1114 if (!empty($fieldInfos->computed)) {
1115 return '<span class="opacitymedium">' . $langs->trans("AutomaticallyCalculated") . '</span>';
1116 }
1117
1118 if (!$fieldInfos->editable) {
1119 return $this->printOutputField($fieldInfos, $key, $value, $keyPrefix, $keySuffix, $moreCss, $moreAttrib);
1120 }
1121
1122 // Get validation error
1123 $fieldValidationErrorMsg = $this->getFieldError($key);
1124
1125 $out = $overwrite_before;
1126 if (empty($overwrite_content)) {
1127 $this->clearErrors();
1128 $field = $this->getFieldClass($fieldInfos->type);
1129 if (isset($field)) {
1130 $moreCss = $field->getInputCss($fieldInfos, $moreCss);
1131
1132 // Add validation state class
1133 if (!empty($fieldValidationErrorMsg)) {
1134 $moreCss .= ' --error'; // the -- is use as class state in css : .--error can't be be defined alone it must be define with another class like .my-class.--error or input.--error
1135 } else {
1136 $moreCss .= ' --success'; // the -- is use as class state in css : .--success can't be be defined alone it must be define with another class like .my-class.--success or input.--success
1137 }
1138
1139 $out .= $field->printInputField($fieldInfos, $key, $value, $keyPrefix, $keySuffix, $moreCss, $moreAttrib);
1140 } else {
1141 $out .= $this->errorsToString();
1142 }
1143 } else {
1144 $out .= $overwrite_content;
1145 }
1146 if (empty($overwrite_after)) {
1147 // Display error message for field
1148 $out .= $this->getFieldErrorIcon($fieldValidationErrorMsg);
1149 } else {
1150 $out .= $overwrite_after;
1151 }
1152
1153 return $out;
1154 }
1155
1168 public function printOutputField($fieldInfos, $key, $value, $keyPrefix = '', $keySuffix = '', $moreCss = '', $moreAttrib = '')
1169 {
1170 global $hookmanager;
1171
1172 $overwrite_before = '';
1173 $overwrite_content = '';
1174 $overwrite_after = '';
1175
1176 $parameters = array(
1177 'fieldInfos' => &$fieldInfos,
1178 'key' => $key,
1179 'value' => &$value,
1180 'keyPrefix' => $keyPrefix,
1181 'keySuffix' => $keySuffix,
1182 'moreCss' => $moreCss,
1183 'moreAttrib' => $moreAttrib,
1184 'overwrite_before' => &$overwrite_before,
1185 'overwrite_content' => &$overwrite_content,
1186 'overwrite_after' => &$overwrite_after,
1187 );
1188
1189 $hookmanager->executeHooks('printOutputField', $parameters, $this); // Note that $object may have been modified by hook
1190
1191 $out = $overwrite_before;
1192 if (empty($overwrite_content)) {
1193 $this->clearErrors();
1194 $field = $this->getFieldClass($fieldInfos->type);
1195 if (isset($field)) {
1196 $moreCss = $field->getInputCss($fieldInfos, $moreCss);
1197
1198 $out .= $field->printOutputField($fieldInfos, $key, $value, $keyPrefix, $keySuffix, $moreCss, $moreAttrib);
1199 } else {
1200 $out .= $this->errorsToString();
1201 }
1202 } else {
1203 $out .= $overwrite_content;
1204 }
1205 $out .= $overwrite_after;
1206
1207 return $out;
1208 }
1209
1220 public function printSeparator($key, &$object, $colspan = 2, $display_type = 'card', $mode = 'view')
1221 {
1222 global $conf, $langs;
1223
1224 // TODO to adapt for field and not extra fields only
1225 $out = '';
1226
1227 /*$tagtype = 'tr';
1228 $tagtype_dyn = 'td';
1229
1230 if ($display_type == 'line') {
1231 $tagtype = 'div';
1232 $tagtype_dyn = 'span';
1233 $colspan = 0;
1234 }
1235
1236 $extrafield_param = $this->attributes[$object->table_element]['param'][$key];
1237 $extrafield_param_list = array();
1238 if (!empty($extrafield_param) && is_array($extrafield_param)) {
1239 $extrafield_param_list = array_keys($extrafield_param['options']);
1240 }
1241
1242 // Set $extrafield_collapse_display_value (do we have to collapse/expand the group after the separator)
1243 $extrafield_collapse_display_value = -1;
1244 $expand_display = false;
1245 if (is_array($extrafield_param_list) && count($extrafield_param_list) > 0) {
1246 $extrafield_collapse_display_value = intval($extrafield_param_list[0]);
1247 $expand_display = ((isset($_COOKIE['DOLUSER_COLLAPSE_' . $object->table_element . '_extrafields_' . $key]) || GETPOSTINT('ignorecollapsesetup')) ? (!empty($_COOKIE['DOLUSER_COLLAPSE_' . $object->table_element . '_extrafields_' . $key])) : !($extrafield_collapse_display_value == 2));
1248 }
1249 $disabledcookiewrite = 0;
1250 if ($mode == 'create') {
1251 // On create mode, force separator group to not be collapsible
1252 $extrafield_collapse_display_value = 1;
1253 $expand_display = true; // We force group to be shown expanded
1254 $disabledcookiewrite = 1; // We keep status of group unchanged into the cookie
1255 }
1256
1257 $out = '<' . $tagtype . ' id="trextrafieldseparator' . $key . (!empty($object->id) ? '_' . $object->id : '') . '" class="trextrafieldseparator trextrafieldseparator' . $key . (!empty($object->id) ? '_' . $object->id : '') . '">';
1258 $out .= '<' . $tagtype_dyn . ' ' . (!empty($colspan) ? 'colspan="' . $colspan . '"' : '') . '>';
1259 // Some js code will be injected here to manage the collapsing of fields
1260 // Output the picto
1261 $out .= '<span class="' . ($extrafield_collapse_display_value ? 'cursorpointer ' : '') . ($extrafield_collapse_display_value == 0 ? 'fas fa-square opacitymedium' : 'far fa-' . (($expand_display ? 'minus' : 'plus') . '-square')) . '"></span>';
1262 $out .= '&nbsp;';
1263 $out .= '<strong>';
1264 $out .= $langs->trans($this->attributes[$object->table_element]['label'][$key]);
1265 $out .= '</strong>';
1266 $out .= '</' . $tagtype_dyn . '>';
1267 $out .= '</' . $tagtype . '>';
1268
1269 $collapse_group = $key . (!empty($object->id) ? '_' . $object->id : '');
1270 //$extrafields_collapse_num = $this->attributes[$object->table_element]['pos'][$key].(!empty($object->id)?'_'.$object->id:'');
1271
1272 if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) {
1273 // Set the collapse_display status to cookie in priority or if ignorecollapsesetup is 1, if cookie and ignorecollapsesetup not defined, use the setup.
1274 $this->expand_display[$collapse_group] = $expand_display;
1275
1276 if (!empty($conf->use_javascript_ajax)) {
1277 $out .= '<!-- Add js script to manage the collapse/uncollapse of extrafields separators ' . $key . ' -->' . "\n";
1278 $out .= '<script nonce="' . getNonce() . '" type="text/javascript">' . "\n";
1279 $out .= 'jQuery(document).ready(function(){' . "\n";
1280 if (empty($disabledcookiewrite)) {
1281 if (!$expand_display) {
1282 $out .= ' console.log("Inject js for the collapsing of extrafield ' . $key . ' - hide");' . "\n";
1283 $out .= ' jQuery(".trextrafields_collapse' . $collapse_group . '").hide();' . "\n";
1284 } else {
1285 $out .= ' console.log("Inject js for collapsing of extrafield ' . $key . ' - keep visible and set cookie");' . "\n";
1286 $out .= ' document.cookie = "DOLUSER_COLLAPSE_' . $object->table_element . '_extrafields_' . $key . '=1; path=' . $_SERVER["PHP_SELF"] . '"' . "\n";
1287 }
1288 }
1289 $out .= ' jQuery("#trextrafieldseparator' . $key . (!empty($object->id) ? '_' . $object->id : '') . '").click(function(){' . "\n";
1290 $out .= ' console.log("We click on collapse/uncollapse to hide/show .trextrafields_collapse' . $collapse_group . '");' . "\n";
1291 $out .= ' jQuery(".trextrafields_collapse' . $collapse_group . '").toggle(100, function(){' . "\n";
1292 $out .= ' if (jQuery(".trextrafields_collapse' . $collapse_group . '").is(":hidden")) {' . "\n";
1293 $out .= ' jQuery("#trextrafieldseparator' . $key . (!empty($object->id) ? '_' . $object->id : '') . ' ' . $tagtype_dyn . ' span").addClass("fa-plus-square").removeClass("fa-minus-square");' . "\n";
1294 $out .= ' document.cookie = "DOLUSER_COLLAPSE_' . $object->table_element . '_extrafields_' . $key . '=0; path=' . $_SERVER["PHP_SELF"] . '"' . "\n";
1295 $out .= ' } else {' . "\n";
1296 $out .= ' jQuery("#trextrafieldseparator' . $key . (!empty($object->id) ? '_' . $object->id : '') . ' ' . $tagtype_dyn . ' span").addClass("fa-minus-square").removeClass("fa-plus-square");' . "\n";
1297 $out .= ' document.cookie = "DOLUSER_COLLAPSE_' . $object->table_element . '_extrafields_' . $key . '=1; path=' . $_SERVER["PHP_SELF"] . '"' . "\n";
1298 $out .= ' }' . "\n";
1299 $out .= ' });' . "\n";
1300 $out .= ' });' . "\n";
1301 $out .= '});' . "\n";
1302 $out .= '</script>' . "\n";
1303 }
1304 } else {
1305 $this->expand_display[$collapse_group] = 1;
1306 }*/
1307
1308 return $out;
1309 }
1310}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
static setForm(&$form)
Set form used for print the field.
Class to stock field infos.
Class to manage fields.
getAllFields()
Get all fields handler available.
getFieldsInfos($key, &$object, &$extrafields=null, $mode='view', $params=array())
Get list of fields infos for the provided mode into X columns.
setObjectFieldValuesFromPost(&$object, $keyPrefix='', $keySuffix='', $mode='view', $params=array())
Set all object values of the object from POST.
verifyPostFieldValue($fieldInfos, $key, $keyPrefix='', $keySuffix='')
Verify if the field value is valid.
getAllExtraFieldsInfos(&$object, &$extrafields=null, $mode='view', $params=array())
Get list of extra fields infos.
getAllFieldsInfos(&$object, &$extrafields=null, $mode='view', $nbColumn=2, $breakKeys=array(), $params=array())
Get list of fields infos for the provided mode into X columns.
getFieldInfosFromObjectField(&$object, $key, $mode='view', $params=array())
Get field infos from object field infos.
errorsToString($separator=', ')
Method to output saved errors.
getFieldClass($type)
Get field handler for the provided type.
getPostSearchFieldValue($fieldInfos, $key, $defaultValue=null, $keyPrefix='', $keySuffix='')
Get search field value from GET/POST.
setExtraFieldValuesFromPost(&$object, &$extrafields, $keyPrefix='', $keySuffix='', $mode='view', $params=array())
Set all extra field values of the object from POST.
getAllObjectFieldsInfos(&$object, $mode='view', $params=array())
Get list of object fields infos.
printOutputField($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='')
Return HTML string to show a field into a page.
verifyFieldValue($fieldInfos, $key, $value)
Verify if the field value is valid.
getFieldInfosFromExtraField(&$object, &$extrafields, $key, $mode='view', $params=array())
Get field infos from extra field infos.
setFieldError($fieldKey, $msg='')
set validation error message a field
setCommonFieldInfos(&$fieldInfos, &$object, &$extrafields, $key, $mode='view', $enabled='1', $visibility='', $perms=null, $params=array())
Set common field infos.
setFieldValuesFromPost(&$object, &$extrafields, $keyPrefix='', $keySuffix='', $mode='view', $params=array())
Set all values of the object (with extra field) from POST.
clearErrors()
clear errors
printSeparator($key, &$object, $colspan=2, $display_type='card', $mode='view')
Return HTML string to print separator field.
getPostFieldValue($fieldInfos, $key, $defaultValue=null, $keyPrefix='', $keySuffix='')
Get field value from GET/POST.
getFieldErrorIcon($fieldValidationErrorMsg)
get field error icon
__construct($db, $form=null)
Constructor.
printInputField($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='', $noNewButton=0)
Return HTML string to put an input field into a page.
clearFieldError($fieldKey)
clear validation message result for a field
printInputSearchField($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='', $noNewButton=0)
Return HTML string to put an input search field into a page.
getFieldError($fieldKey)
get field error message
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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...
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.