dolibarr 24.0.0-beta
html.formsetup.class.php
1<?php
2/* Copyright (C) 2021 John BOTELLA <john.botella@atm-consulting.fr>
3 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2026 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27{
31 public $db;
32
34 public $entity;
35
37 public $items = array();
38
42 public $setupNotEmpty = 0;
43
45 public $langs;
46
48 public $form;
49
51 protected $maxItemRank;
52
57 public $htmlBeforeOutputForm = '';
58
63 public $htmlAfterOutputForm = '';
64
69 public $htmlOutputMoreButton = '';
70
75 public $htmlButtonLabel = 'Save';
76
80 public $formAttributes = array(
81 'action' => '', // set in __construct
82 'method' => 'POST'
83 );
84
89 public $formHiddenInputs = array();
90
94 public $errors = array();
95
96
103 public function __construct($db, $outputLangs = null)
104 {
105 global $conf, $langs;
106
107 $this->db = $db;
108
109 $this->form = new Form($this->db);
110 $this->formAttributes['action'] = $_SERVER["PHP_SELF"];
111
112 $this->formHiddenInputs['token'] = newToken();
113 $this->formHiddenInputs['action'] = 'update';
114
115 $this->entity = (is_null($this->entity) ? $conf->entity : $this->entity);
116
117 if ($outputLangs) {
118 $this->langs = $outputLangs;
119 } else {
120 $this->langs = $langs;
121 }
122 }
123
130 public static function generateAttributesStringFromArray($attributes)
131 {
132 $Aattr = array();
133 if (is_array($attributes)) {
134 foreach ($attributes as $attribute => $value) {
135 if (is_array($value) || is_object($value)) {
136 continue;
137 }
138 $Aattr[] = $attribute.'="'.dol_escape_htmltag($value).'"';
139 }
140 }
141
142 return !empty($Aattr) ? implode(' ', $Aattr) : '';
143 }
144
145
155 public function generateOutput($editMode = false, $hideTitle = false, $title = '', $cssfirstcolumn = '')
156 {
157 global $hookmanager, $action;
158
159 require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
160
161 $parameters = array(
162 'editMode' => $editMode
163 );
164 $reshook = $hookmanager->executeHooks('formSetupBeforeGenerateOutput', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
165 if ($reshook < 0) {
166 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
167 }
168
169 if ($reshook > 0) {
170 return $hookmanager->resPrint;
171 } else {
172 $out = '<!-- Start generateOutput from FormSetup class -->';
173 $out .= $this->htmlBeforeOutputForm;
174
175 if ($editMode) {
176 $out .= '<form ' . self::generateAttributesStringFromArray($this->formAttributes) . ' >';
177 $out .= '<input type="hidden" name="page_y" value="">';
178
179 // generate hidden values from $this->formHiddenInputs
180 if (!empty($this->formHiddenInputs) && is_array($this->formHiddenInputs)) {
181 foreach ($this->formHiddenInputs as $hiddenKey => $hiddenValue) {
182 $out .= '<input type="hidden" name="'.dol_escape_htmltag($hiddenKey).'" value="' . dol_escape_htmltag($hiddenValue) . '">';
183 }
184 }
185 }
186
187 // generate output table
188 $out .= $this->generateTableOutput((bool) $editMode, $hideTitle, $title, $cssfirstcolumn);
189
190
191 $reshook = $hookmanager->executeHooks('formSetupBeforeGenerateOutputButton', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
192 if ($reshook < 0) {
193 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
194 }
195
196 if ($reshook > 0) {
197 return $hookmanager->resPrint;
198 } elseif ($editMode) {
199 $out .= '<div class="form-setup-button-container center">'; // Todo : remove .center by adding style to form-setup-button-container css class in all themes
200 $out .= $this->htmlOutputMoreButton;
201 if ($editMode !== 3) {
202 $out .= '<input class="button button-save reposition" type="submit" value="' . $this->langs->trans($this->htmlButtonLabel ?: "Save") . '" name="save">'; // Todo fix dolibarr style for <button and use <button instead of input
203 }
204 if ($editMode === 2) {
205 // Add also a cancel button
206 $out .= ' &nbsp;&nbsp; ';
207 $out .= '<input class="button button-cancel" type="submit" value="' . $this->langs->trans('Cancel') . '" name="cancel">';
208 }
209 $out .= '</div>';
210 }
211
212 if ($editMode) {
213 $out .= '</form>';
214 }
215
216 $out .= $this->htmlAfterOutputForm;
217
218 return $out;
219 }
220 }
221
231 public function generateTableOutput($editMode = false, $hideTitle = false, $title = '', $cssfirstcolumn = '')
232 {
233 global $hookmanager, $action;
234 require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
235
236 $parameters = array(
237 'editMode' => $editMode
238 );
239 $reshook = $hookmanager->executeHooks('formSetupBeforeGenerateTableOutput', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
240 if ($reshook < 0) {
241 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
242 }
243
244 if ($reshook > 0) {
245 return $hookmanager->resPrint;
246 } else {
247 $out = '<div class="div-table-responsive-no-min">';
248 $out .= '<table class="noborder centpercent">';
249 if (empty($hideTitle)) {
250 if (empty($title)) {
251 $title = $this->langs->transnoentitiesnoconv("Parameter");
252 }
253 $out .= '<thead>';
254 $out .= '<tr class="liste_titre">';
255 $out .= ' <td'.($cssfirstcolumn ? ' class="'.$cssfirstcolumn.'"' : '').'>' . dolPrintHTML($title) . '</td>';
256 $out .= ' <td></td>';
257 $out .= '</tr>';
258 $out .= '</thead>';
259 }
260
261 // Sort items before render
262 $this->sortingItems();
263
264 $out .= '<tbody>';
265 foreach ($this->items as $item) {
266 $out .= $this->generateLineOutput($item, $editMode);
267 }
268 $out .= '</tbody>';
269
270 $out .= '</table>';
271 $out .= '</div>';
272 return $out;
273 }
274 }
275
282 public function saveConfFromPost($noMessageInUpdate = false)
283 {
284 global $hookmanager, $conf;
285
286 $parameters = array();
287 $reshook = $hookmanager->executeHooks('formSetupBeforeSaveConfFromPost', $parameters, $this); // Note that $action and $object may have been modified by some hooks
288 if ($reshook < 0) {
289 $this->errors = $hookmanager->errors;
290 return -1;
291 }
292 if ($reshook > 0) {
293 return $reshook;
294 }
295
296 if (empty($this->items)) {
297 return null;
298 }
299
300 $this->db->begin();
301 $error = 0;
302 foreach ($this->items as $item) {
303 if ($item->getType() == 'yesno' && !empty($conf->use_javascript_ajax)) {
304 continue;
305 }
306
307 $res = $item->setValueFromPost();
308 if ($res > 0) {
309 $item->saveConfValue();
310 } elseif ($res < 0) {
311 $error++;
312 break;
313 }
314 }
315
316 if (!$error) {
317 $this->db->commit();
318 if (empty($noMessageInUpdate)) {
319 setEventMessages($this->langs->trans("SetupSaved"), null);
320 }
321 return 1;
322 } else {
323 $this->db->rollback();
324 if (empty($noMessageInUpdate)) {
325 setEventMessages($this->langs->trans("SetupNotSaved"), null, 'errors');
326 }
327 return -1;
328 }
329 }
330
338 public function generateLineOutput($item, $editMode = false)
339 {
340 $out = '';
341 if ($item->enabled == 1) {
342 $trClass = 'oddeven';
343 $tdOutputFieldClass = '';
344 if ($item->getType() == 'title') {
345 $trClass = 'liste_titre';
346 }
347 if (!empty($item->fieldParams['trClass'])) {
348 $trClass .= ' '.$item->fieldParams['trClass'];
349 }
350 if (!empty($item->fieldParams['tdOutputFieldClass'])) {
351 $tdOutputFieldClass .= ' class="'.$item->fieldParams['tdOutputFieldClass'].'"';
352 }
353
354 $this->setupNotEmpty++;
355
356 $tableLineAttr = [
357 'id' => 'setup-line-item_'. preg_replace('/[^a-zA-Z_]/', '', $item->confKey),
358 'class' => $trClass
359 ];
360
361 if ($item->getType() !== 'title') {
362 $tableLineAttr['data-conf-key'] = $item->confKey;
363 }
364
365 $tableLineAttrCompiled = commonHtmlAttributeBuilder($tableLineAttr);
366 $out .= '<tr '. implode(' ', $tableLineAttrCompiled).' >';
367
368 $out .= '<td class="col-setup-title'.(!empty($item->fieldParams['isMandatory']) ? ' fieldrequired' : '').'">';
369 $out .= '<span id="helplink'.$item->confKey.'" class="spanforparamtooltip">';
370 $out .= $this->form->textwithpicto($item->getNameText(), $item->getHelpText(), 1, 'info', '', 0, 3, empty($item->fieldParams['helpText']) ? 'tootips'.$item->confKey : ($item->fieldParams['helpText'] != 'noclick' ? $item->fieldParams['helpText'] : ''));
371 $out .= '</span>';
372 $out .= '</td>';
373
374 $out .= '<td'.$tdOutputFieldClass.'>';
375
376 if ($editMode) {
377 $out .= $item->generateInputField();
378 } else {
379 $out .= $item->generateOutputField();
380 }
381
382 if (!empty($item->errors)) {
383 // TODO : move set event message in a method to be called by cards not by this class
384 setEventMessages(null, $item->errors, 'errors');
385 }
386
387 $out .= '</td>';
388 $out .= '</tr>';
389 }
390
391 return $out;
392 }
393
394
401 public function addItemsFromParamsArray($params)
402 {
403 if (!is_array($params) || empty($params)) {
404 return false;
405 }
406 foreach ($params as $confKey => $param) {
407 $this->addItemFromParams($confKey, $param); // todo manage error
408 }
409 return true;
410 }
411
412
421 public function addItemFromParams($confKey, $params)
422 {
423 if (empty($confKey) || empty($params['type'])) {
424 return false;
425 }
426
427 /*
428 * Example from old module builder setup page
429 * // 'MYMODULE_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>1),
430 // 'MYMODULE_MYPARAM2'=>array('type'=>'textarea','enabled'=>1),
431 //'MYMODULE_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
432 //'MYMODULE_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1),
433 //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1),
434 //'MYMODULE_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1),
435 //'MYMODULE_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1),
436 //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1),
437 */
438
439 $item = new FormSetupItem($confKey);
440 // setTypeFromTypeString was created as deprecated to incite developer to use object oriented usage
442 $item->setTypeFromTypeString((string) $params['type']);
443
444 if (!empty($params['enabled']) && is_numeric($params['enabled'])) {
445 $item->enabled = (int) $params['enabled'];
446 }
447
448 if (!empty($params['css'])) {
449 $item->cssClass = (string) $params['css'];
450 }
451
452 $this->items[$item->confKey] = $item;
453
454 return true;
455 }
456
463 public function exportItemsAsParamsArray()
464 {
465 $arrayofparameters = array();
466 foreach ($this->items as $item) {
467 $arrayofparameters[$item->confKey] = array(
468 'type' => $item->getType(),
469 'enabled' => $item->enabled
470 );
471 }
472
473 return $arrayofparameters;
474 }
475
482 public function reloadConfs()
483 {
484 if (!array($this->items)) {
485 return false;
486 }
487 foreach ($this->items as $item) {
488 $item->loadValueFromConf();
489 }
490
491 return true;
492 }
493
494
504 public function newItem($confKey, $targetItemKey = '', $insertAfterTarget = false)
505 {
506 $item = new FormSetupItem($confKey);
507
508 $item->entity = $this->entity;
509
510 // set item rank if not defined as last item
511 if (empty($item->rank)) {
512 $item->rank = $this->getCurentItemMaxRank() + 1;
513 $this->setItemMaxRank($item->rank); // set new max rank if needed
514 }
515
516 // try to get rank from target column, this will override item->rank
517 if (!empty($targetItemKey)) {
518 if (isset($this->items[$targetItemKey])) {
519 $targetItem = $this->items[$targetItemKey];
520 $item->rank = $targetItem->rank; // $targetItem->rank will be increase after
521 if ($targetItem->rank >= 0 && $insertAfterTarget) {
522 $item->rank++;
523 }
524 }
525
526 // calc new rank for each item to make place for new item
527 foreach ($this->items as $fItem) {
528 if ($item->rank <= $fItem->rank) {
529 $fItem->rank += 1;
530 $this->setItemMaxRank($fItem->rank); // set new max rank if needed
531 }
532 }
533 }
534
535 $this->items[$item->confKey] = $item;
536 return $this->items[$item->confKey];
537 }
538
544 public function sortingItems()
545 {
546 // Sorting
547 return uasort($this->items, array($this, 'itemSort'));
548 }
549
556 public function getCurentItemMaxRank($cache = true)
557 {
558 if (empty($this->items)) {
559 return 0;
560 }
561
562 if ($cache && $this->maxItemRank > 0) {
563 return $this->maxItemRank;
564 }
565
566 $this->maxItemRank = 0;
567 foreach ($this->items as $item) {
568 $this->maxItemRank = max($this->maxItemRank, $item->rank);
569 }
570
571 return $this->maxItemRank;
572 }
573
574
581 public function setItemMaxRank($rank)
582 {
583 $this->maxItemRank = max($this->maxItemRank, $rank);
584 }
585
586
593 public function getLineRank($itemKey)
594 {
595 if (!isset($this->items[$itemKey]->rank)) {
596 return -1;
597 }
598 return $this->items[$itemKey]->rank;
599 }
600
601
609 public function itemSort(FormSetupItem $a, FormSetupItem $b)
610 {
611 if (empty($a->rank)) {
612 $a->rank = 0;
613 }
614 if (empty($b->rank)) {
615 $b->rank = 0;
616 }
617 if ($a->rank == $b->rank) {
618 return 0;
619 }
620 return ($a->rank < $b->rank) ? -1 : 1;
621 }
622}
623
624
629{
633 public $db;
634
636 public $langs;
637
639 public $entity;
640
642 public $form;
643
644
646 public $confKey;
647
649 public $nameText = false;
650
652 public $helpText = '';
653
655 public $picto = '';
656
658 public $fieldValue;
659
661 public $defaultFieldValue = null;
662
664 public $fieldAttr = array();
665
667 public $fieldOverride = false;
668
670 public $fieldInputOverride = false;
671
673 public $fieldInputCallBack;
674
676 public $fieldOutputOverride = false;
677
679 public $fieldOutputCallBack;
680
682 public $rank = 0;
683
685 public $fieldOptions = array();
686
688 public $fieldParams = array();
689
691 public $saveCallBack;
692
694 public $setValueFromPostCallBack;
695
699 public $errors = array();
700
707 protected $type = 'string';
708
709
711 public $enabled = 1;
712
716 public $cssClass = '';
717
718
724 public function __construct($confKey)
725 {
726 global $langs, $db, $conf, $form;
727 $this->db = $db;
728
729 if (!empty($form) && is_object($form) && get_class($form) == 'Form') { // the form class has a cache inside so I am using it to optimize
730 $this->form = $form;
731 } else {
732 $this->form = new Form($this->db);
733 }
734
735 $this->langs = $langs;
736 $this->entity = (is_null($this->entity) ? $conf->entity : ((int) $this->entity));
737
738 $this->confKey = $confKey;
739 $this->loadValueFromConf();
740 }
741
747 public function loadValueFromConf()
748 {
749 global $conf;
750 if (isset($conf->global->{$this->confKey})) {
751 $this->fieldValue = getDolGlobalString($this->confKey);
752 return true;
753 } else {
754 $this->fieldValue = null;
755 return false;
756 }
757 }
758
765 public function reloadValueFromConf()
766 {
767 return $this->loadValueFromConf();
768 }
769
770
776 public function saveConfValue()
777 {
778 global $hookmanager;
779
780 $parameters = array();
781 $reshook = $hookmanager->executeHooks('formSetupBeforeSaveConfValue', $parameters, $this); // Note that $action and $object may have been modified by some hooks
782 if ($reshook < 0) {
783 $this->setErrors($hookmanager->errors);
784 return -1;
785 }
786
787 if ($reshook > 0) {
788 return $reshook;
789 }
790
791 if ($this->saveCallBack !== null && is_callable($this->saveCallBack)) {
792 return call_user_func($this->saveCallBack, $this);
793 }
794
795 // Modify constant only if key was posted (avoid resetting key to the null value)
796 if ($this->type != 'title') {
797 $result = dolibarr_set_const($this->db, $this->confKey, $this->fieldValue, 'chaine', 0, '', $this->entity);
798 if ($result < 0) {
799 return -1;
800 } else {
801 return 1;
802 }
803 }
804
805 return 0;
806 }
807
814 public function setSaveCallBack(callable $callBack)
815 {
816 $this->saveCallBack = $callBack;
817 }
818
825 public function setValueFromPostCallBack(callable $callBack)
826 {
827 $this->setValueFromPostCallBack = $callBack;
828 }
829
835 public function setValueFromPost()
836 {
837 if ($this->setValueFromPostCallBack !== null && is_callable($this->setValueFromPostCallBack)) {
838 return call_user_func($this->setValueFromPostCallBack);
839 }
840
841 // Modify constant only if key was posted (avoid resetting key to the null value)
842 if ($this->type != 'title') {
843 if (preg_match('/category:/', $this->type)) {
844 if (GETPOSTINT($this->confKey) == '-1') {
845 $val_const = '';
846 } else {
847 $val_const = GETPOSTINT($this->confKey);
848 }
849 } elseif ($this->type == 'multiselect') {
850 $val = GETPOST($this->confKey, 'array');
851 if ($val && is_array($val)) {
852 $val_const = implode(',', $val);
853 } else {
854 $val_const = '';
855 }
856 } elseif ($this->type == 'html') {
857 $val_const = GETPOST($this->confKey, 'restricthtml');
858 } elseif ($this->type == 'email') {
859 $val_const = GETPOST($this->confKey, 'alphawithlgt');
860 } elseif ($this->type == 'number') {
861 $val_const = GETPOSTINT($this->confKey);
862 } else {
863 $val_const = GETPOST($this->confKey, 'alphanohtml');
864 }
865
866 // TODO add value check with class validate
867 $this->fieldValue = $val_const;
868
869 return 1;
870 }
871
872 return 0;
873 }
874
880 public function getHelpText()
881 {
882 if (!empty($this->helpText)) {
883 return $this->helpText;
884 }
885 return (($this->langs->trans($this->confKey . 'Tooltip') != $this->confKey . 'Tooltip') ? $this->langs->trans($this->confKey . 'Tooltip') : '');
886 }
887
893 public function getNameText()
894 {
895 if (!empty($this->nameText)) {
896 return $this->nameText;
897 }
898 $out = (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey', $this->confKey));
899
900 // if conf defined on entity 0, prepend a picto to indicate it will apply across all entities
901 if (isModEnabled('multicompany') && $this->entity == 0) {
902 $out = img_picto($this->langs->trans('AllEntities'), 'fa-globe-americas em088 opacityhigh') . '&nbsp;' . $out;
903 }
904
905 return $out;
906 }
907
913 public function generateInputField()
914 {
915 global $conf;
916
917 if ($this->fieldInputCallBack !== null && is_callable($this->fieldInputCallBack)) {
918 // can be used to populate fieldInputOverride, fieldOverride or change stuff
919 $resCallback = call_user_func($this->fieldInputCallBack, $this);
920 if (!empty($resCallback)) {
921 return $resCallback;
922 }
923 }
924
925 if (!empty($this->fieldOverride)) {
926 return $this->fieldOverride;
927 }
928
929 if (!empty($this->fieldInputOverride)) {
930 return $this->fieldInputOverride;
931 }
932
933 // Set default value
934 if (is_null($this->fieldValue)) {
935 $this->fieldValue = $this->defaultFieldValue;
936 }
937
938
939 $this->fieldAttr['name'] = $this->confKey;
940 $this->fieldAttr['id'] = 'setup-'.$this->confKey;
941 $this->fieldAttr['value'] = $this->fieldValue;
942
943 $out = '';
944
945 if ($this->type == 'title') {
946 $out .= $this->generateOutputField(); // title have no input
947 } elseif ($this->type == 'multiselect') {
948 $out .= $this->generateInputFieldMultiSelect();
949 } elseif ($this->type == 'select') {
950 $out .= $this->generateInputFieldSelect();
951 } elseif ($this->type == 'radio') {
952 $out .= $this->generateInputFieldRadio();
953 } elseif ($this->type == 'selectUser') {
954 $out .= $this->generateInputFieldSelectUser();
955 } elseif ($this->type == 'textarea') {
956 $out .= $this->generateInputFieldTextarea();
957 } elseif ($this->type == 'html') {
958 $out .= $this->generateInputFieldHtml();
959 } elseif ($this->type == 'color') {
960 $out .= $this->generateInputFieldColor();
961 } elseif ($this->type == 'yesno') {
962 if (!empty($conf->use_javascript_ajax)) {
963 $input = $this->fieldParams['input'] ?? array();
964 $revertonoff = empty($this->fieldParams['revertonoff']) ? 0 : 1;
965 $forcereload = empty($this->fieldParams['forcereload']) ? 0 : 1;
966 $suffixarray = array(
967 'ifoff' => '',
968 'ifon' => '',
969 );
970 if (!empty($this->fieldParams['alertifoff'])) {
971 $suffixarray['ifoff'] = '_red';
972 } elseif (!empty($this->fieldParams['warningifoff'])) {
973 $suffixarray['ifoff'] = '_warning';
974 }
975 if (!empty($this->fieldParams['alertifon'])) {
976 $suffixarray['ifon'] = '_red';
977 } elseif (!empty($this->fieldParams['warningifon'])) {
978 $suffixarray['ifon'] = '_warning';
979 }
980
981 $out .= ajax_constantonoff($this->confKey, $input, $this->entity, $revertonoff, 0, $forcereload, 2, 0, 0, $suffixarray, '', $this->cssClass);
982 } else {
983 $out .= $this->form->selectyesno($this->confKey, $this->fieldValue, 1, false, 0, 0, $this->cssClass);
984 }
985 } elseif (preg_match('/emailtemplate:/', $this->type)) {
986 $out .= $this->generateInputFieldEmailTemplate();
987 } elseif (preg_match('/category:/', $this->type)) {
988 $out .= $this->generateInputFieldCategories();
989 } elseif (preg_match('/thirdparty_type/', $this->type)) {
990 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
991 $formcompany = new FormCompany($this->db);
992 $out .= $formcompany->selectProspectCustomerType($this->fieldValue, $this->confKey);
993 } elseif ($this->type == 'securekey') {
994 $out .= $this->generateInputFieldSecureKey();
995 } elseif ($this->type == 'product') {
996 if (isModEnabled("product") || isModEnabled("service")) {
997 $selected = (empty($this->fieldValue) ? '' : $this->fieldValue);
998 $out .= img_picto('', 'product', 'class="pictofixedwidth"');
999 $out .= $this->form->select_produits((int) $selected, $this->confKey, '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, $this->cssClass, 0, '', null, 1);
1000 }
1001 } elseif ($this->type == 'selectBankAccount') {
1002 if (isModEnabled("bank")) {
1003 $selected = (empty($this->fieldValue) ? '' : $this->fieldValue);
1004 $out .= img_picto('', 'bank', 'class="pictofixedwidth"').$this->form->select_comptes($selected, $this->confKey, 0, '', 0, '', 0, '', 1);
1005 }
1006 } elseif ($this->type == 'password') {
1007 $out .= $this->generateInputFieldPassword('dolibarr');
1008 } elseif ($this->type == 'genericpassword') {
1009 $out .= $this->generateInputFieldPassword('generic', 0, 0);
1010 } elseif ($this->type == 'price') {
1011 $out .= $this->generateInputFieldPrice();
1012 } elseif ($this->type == 'email') {
1013 $out .= $this->generateInputFieldEmail();
1014 } elseif ($this->type == 'url') {
1015 $out .= $this->generateInputFieldUrl();
1016 } else {
1017 $out .= $this->generateInputFieldText();
1018 }
1019
1020 return $out;
1021 }
1022
1028 public function generateInputFieldText()
1029 {
1030 if (empty($this->fieldAttr) || empty($this->fieldAttr['class'])) {
1031 $this->fieldAttr['class'] = 'flat '.(empty($this->cssClass) ? 'minwidth200' : $this->cssClass);
1032 }
1033 return '<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).' spellcheck="false">';
1034 }
1035
1041 public function generateInputFieldPrice()
1042 {
1043 global $langs, $mysoc;
1044
1045 if (empty($this->fieldAttr) || empty($this->fieldAttr['class'])) {
1046 $this->fieldAttr['class'] = 'flat '.(empty($this->cssClass) ? 'minwidth40 maxwidth75' : $this->cssClass);
1047 }
1048 //return img_picto('', 'currency', 'class="pictofixedwidth"').'<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).' /> '.$langs->getCurrencySymbol($mysoc->currency_code);
1049 return '<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).' spellcheck="false"> '.$langs->getCurrencySymbol($mysoc->currency_code);
1050 }
1051
1057 public function generateInputFieldEmail()
1058 {
1059 if (empty($this->fieldAttr) || empty($this->fieldAttr['class'])) {
1060 $this->fieldAttr['class'] = 'flat '.(empty($this->cssClass) ? 'minwidth100 maxwidth500' : $this->cssClass);
1061 }
1062 return img_picto('', 'email', 'class="pictofixedwidth"').'<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).' spellcheck="false">';
1063 }
1064
1070 public function generateInputFieldUrl()
1071 {
1072 if (empty($this->fieldAttr) || empty($this->fieldAttr['class'])) {
1073 $this->fieldAttr['class'] = 'flat '.(empty($this->cssClass) ? 'minwidth100 maxwidth500' : $this->cssClass);
1074 }
1075 return img_picto('', 'url', 'class="pictofixedwidth"').'<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).' spellcheck="false">';
1076 }
1077
1084 {
1085 $out = '<textarea class="flat" name="'.$this->confKey.'" id="'.$this->confKey.'" cols="50" rows="5" wrap="soft" spellcheck="false">' . "\n";
1086 $out .= dol_htmlentities($this->fieldValue);
1087 $out .= "</textarea>\n";
1088 return $out;
1089 }
1090
1096 public function generateInputFieldHtml()
1097 {
1098 require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
1099 $doleditor = new DolEditor($this->confKey, $this->fieldValue, '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%');
1100 return $doleditor->Create(1);
1101 }
1102
1109 {
1110 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1111 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
1112 $formother = new FormOther($this->db);
1113
1114 $tmp = explode(':', $this->type);
1115 $out = img_picto('', 'category', 'class="pictofixedwidth"');
1116
1117 $label = 'Categories';
1118 if ($this->type == 'customer') {
1119 $label = 'CustomersProspectsCategoriesShort';
1120 }
1121 $out .= $formother->select_categories($tmp[1], (int) $this->fieldValue, $this->confKey, 0, $this->langs->trans($label));
1122
1123 return $out;
1124 }
1125
1131 {
1132 global $user;
1133
1134 $out = '';
1135 if (preg_match('/emailtemplate:/', $this->type)) {
1136 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
1137 $formmail = new FormMail($this->db);
1138
1139 $tmp = explode(':', $this->type);
1140 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
1141 $arrayOfMessageName = array();
1142 if (is_array($formmail->lines_model)) {
1143 foreach ($formmail->lines_model as $modelMail) {
1144 $moreonlabel = '';
1145 if (!empty($arrayOfMessageName[$modelMail->label])) {
1146 $moreonlabel = ' <span class="opacitymedium">(' . $this->langs->trans("SeveralLangugeVariatFound") . ')</span>';
1147 }
1148 // The 'label' is the key that is unique if we exclude the language
1149 $arrayOfMessageName[$modelMail->id] = $this->langs->trans(preg_replace('/\‍(|\‍)/', '', $modelMail->label)) . $moreonlabel;
1150 }
1151 }
1152 $out .= $this->form->selectarray($this->confKey, $arrayOfMessageName, $this->fieldValue, 'None', 0, 0, '', 0, 0, 0, '', '', 1);
1153 }
1154
1155 return $out;
1156 }
1157
1158
1165 {
1166 global $conf;
1167 $out = '<input type="text" class="flat minwidth150'.($this->cssClass ? ' '.$this->cssClass : '').'" id="'.$this->confKey.'" name="'.$this->confKey.'" value="'.(GETPOST($this->confKey, 'alpha') ? GETPOST($this->confKey, 'alpha') : $this->fieldValue).'">';
1168
1169 if (!empty($conf->use_javascript_ajax) && empty($this->fieldParams['hideGenerateButton'])) {
1170 $out .= '&nbsp;'.img_picto($this->langs->trans('Generate'), 'refresh', 'id="generate_token'.$this->confKey.'" class="linkobject"');
1171
1172 // Add button to autosuggest a key
1173 include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
1174 $out .= dolJSToSetRandomPassword($this->confKey, 'generate_token'.$this->confKey);
1175 }
1176
1177 return $out;
1178 }
1179
1180
1189 public function generateInputFieldPassword($type = 'generic', $defaultmin = 6, $defaultmax = 50)
1190 {
1191 global $conf, $langs, $user;
1192
1193 $min = $defaultmin;
1194 $max = $defaultmax;
1195 if ($type == 'dolibarr') {
1196 $gen = getDolGlobalString('USER_PASSWORD_GENERATED', 'standard');
1197 if ($gen == 'none') {
1198 $gen = 'standard';
1199 }
1200 $nomclass = "modGeneratePass".ucfirst($gen);
1201 $nomfichier = $nomclass.".class.php";
1202 require_once DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomfichier;
1203 $genhandler = new $nomclass($this->db, $conf, $langs, $user);
1204 $min = $genhandler->length;
1205 $max = $genhandler->length2;
1206 }
1207 $out = '<input required="required" type="password" class="flat minwidth150'.($this->cssClass ? ' '.$this->cssClass : '').'" id="'.$this->confKey.'" name="'.$this->confKey.'" value="'.(GETPOST($this->confKey, 'alpha') ? GETPOST($this->confKey, 'alpha') : $this->fieldValue).'"';
1208 if ($min) {
1209 $out .= ' minlength="' . $min . '"';
1210 }
1211 if ($max) {
1212 $out .= ' maxlength="' . $max . '"';
1213 }
1214 $out .= '>';
1215
1216 $out .= '<span class="fa fa-eye paddingleft paddingright" onclick="javascript: console.log(\'click on show-hide pass\'); newtype = (jQuery(\'#'.trim($this->confKey).'\').attr(\'type\') == \'text\' ? \'password\' : \'text\'); jQuery(\'#'.trim($this->confKey).'\').attr(\'type\', newtype);"></span>';
1217
1218 return $out;
1219 }
1220
1221
1222
1229 {
1230 $TSelected = array();
1231 if ($this->fieldValue) {
1232 $TSelected = explode(',', $this->fieldValue);
1233 }
1234
1235 return $this->form->multiselectarray($this->confKey, $this->fieldOptions, $TSelected, 0, 0, '', 0, 0, 'style="min-width:100px"');
1236 }
1237
1244 {
1245 $s = '';
1246 if ($this->picto) {
1247 $s .= img_picto('', $this->picto, 'class="pictofixedwidth"');
1248 }
1249
1250 $s .= $this->form->selectarray($this->confKey, $this->fieldOptions, $this->fieldValue, 0, 0, 0, '', 0, 0, 0, '', $this->cssClass);
1251
1252 return $s;
1253 }
1254
1260 public function generateInputFieldRadio()
1261 {
1262 $s = '';
1263 if ($this->picto) {
1264 $s .= img_picto('', $this->picto, 'class="pictofixedwidth"');
1265 }
1266
1267 $s .= $this->form->radio($this->confKey, $this->fieldOptions, $this->fieldValue, ['attrLabel' => ['class' => $this->cssClass]]);
1268
1269 return $s;
1270 }
1271
1276 {
1277 return $this->form->select_dolusers($this->fieldValue, $this->confKey);
1278 }
1279
1287 public function getType()
1288 {
1289 return $this->type;
1290 }
1291
1301 public function setTypeFromTypeString($type)
1302 {
1303 $this->type = $type;
1304
1305 return true;
1306 }
1307
1314 public function setErrors($errors)
1315 {
1316 if (is_array($errors)) {
1317 if (!empty($errors)) {
1318 foreach ($errors as $error) {
1319 $this->setErrors($error);
1320 }
1321 }
1322 } elseif (!empty($errors)) {
1323 $this->errors[] = $errors;
1324 }
1325 return null;
1326 }
1327
1333 public function generateOutputField()
1334 {
1335 global $conf, $user, $langs;
1336
1337 if ($this->fieldOutputCallBack !== null && is_callable($this->fieldOutputCallBack)) {
1338 // can be used to populate fieldOutputOverride, fieldOverride or change stuff
1339 $resCallback = call_user_func($this->fieldOutputCallBack, $this);
1340 if (!empty($resCallback)) {
1341 return $resCallback;
1342 }
1343 }
1344
1345 if (!empty($this->fieldOverride)) {
1346 return $this->fieldOverride;
1347 }
1348
1349 if (!empty($this->fieldOutputOverride)) {
1350 return $this->fieldOutputOverride;
1351 }
1352
1353 $out = '';
1354
1355 if ($this->type == 'title') {
1356 // nothing to do
1357 } elseif ($this->type == 'textarea') {
1358 $out .= dol_nl2br($this->fieldValue);
1359 } elseif ($this->type == 'multiselect') {
1360 $out .= $this->generateOutputFieldMultiSelect();
1361 } elseif ($this->type == 'select') {
1362 $out .= $this->generateOutputFieldSelect();
1363 } elseif ($this->type == 'selectUser') {
1364 $out .= $this->generateOutputFieldSelectUser();
1365 } elseif ($this->type == 'html') {
1366 $out .= $this->fieldValue;
1367 } elseif ($this->type == 'color') {
1368 $out .= $this->generateOutputFieldColor();
1369 } elseif ($this->type == 'yesno') {
1370 if (!empty($conf->use_javascript_ajax)) {
1371 $revertonoff = empty($this->fieldParams['revertonoff']) ? 0 : 1;
1372 $forcereload = empty($this->fieldParams['forcereload']) ? 0 : 1;
1373
1374 $out .= ajax_constantonoff($this->confKey, array(), $this->entity, $revertonoff, 0, $forcereload, 2, 0, 0, '', '', $this->cssClass); // TODO possibility to add $input parameter
1375 } else {
1376 if ($this->fieldValue == 1) {
1377 $out .= $langs->trans('yes');
1378 } else {
1379 $out .= $langs->trans('no');
1380 }
1381 }
1382 } elseif (preg_match('/emailtemplate:/', $this->type)) {
1383 if ($this->fieldValue > 0) {
1384 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
1385 $formmail = new FormMail($this->db);
1386
1387 $tmp = explode(':', $this->type);
1388
1389 $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, (int) $this->fieldValue);
1390 if (is_numeric($template) && $template < 0) {
1391 $this->setErrors($formmail->errors);
1392 }
1393 $out .= $this->langs->trans($template->label);
1394 }
1395 } elseif (preg_match('/category:/', $this->type)) {
1396 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1397 $c = new Categorie($this->db);
1398 $result = $c->fetch((int) $this->fieldValue);
1399 if ($result < 0) {
1400 $this->setErrors($c->errors);
1401 }
1402 $ways = $c->print_all_ways('auto', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
1403 $toprint = array();
1404 foreach ($ways as $way) {
1405 $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
1406 }
1407 $out .= '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
1408 } elseif (preg_match('/thirdparty_type/', $this->type)) {
1409 if ($this->fieldValue == 2) {
1410 $out .= $this->langs->trans("Prospect");
1411 } elseif ($this->fieldValue == 3) {
1412 $out .= $this->langs->trans("ProspectCustomer");
1413 } elseif ($this->fieldValue == 1) {
1414 $out .= $this->langs->trans("Customer");
1415 } elseif ($this->fieldValue == 0) {
1416 $out .= $this->langs->trans("NorProspectNorCustomer");
1417 }
1418 } elseif ($this->type == 'product') {
1419 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
1420
1421 $product = new Product($this->db);
1422 $resprod = $product->fetch((int) $this->fieldValue);
1423 if ($resprod > 0) {
1424 $out .= $product->getNomUrl(1, '', 0, -1, 0, '', 1);
1425 } elseif ($resprod < 0) {
1426 $this->setErrors($product->errors);
1427 }
1428 } elseif ($this->type == 'selectBankAccount') {
1429 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
1430
1431 $bankaccount = new Account($this->db);
1432 $resbank = $bankaccount->fetch((int) $this->fieldValue);
1433 if ($resbank > 0) {
1434 $out .= $bankaccount->label;
1435 } elseif ($resbank < 0) {
1436 $this->setErrors($bankaccount->errors);
1437 }
1438 } elseif ($this->type == 'password' || $this->type == 'genericpassword') {
1439 $out .= str_repeat('*', strlen($this->fieldValue));
1440 } else {
1441 $out .= dolPrintHTML($this->fieldValue);
1442 }
1443
1444 return $out;
1445 }
1446
1447
1454 {
1455 $outPut = '';
1456 $TSelected = array();
1457 if (!empty($this->fieldValue)) {
1458 $TSelected = explode(',', $this->fieldValue);
1459 }
1460
1461 if (!empty($TSelected)) {
1462 foreach ($TSelected as $selected) {
1463 if (!empty($this->fieldOptions[$selected])) {
1464 $outPut .= dolGetBadge('', $this->fieldOptions[$selected], 'info').' ';
1465 }
1466 }
1467 }
1468 return $outPut;
1469 }
1470
1477 {
1478 global $langs;
1479 $out = '';
1480 $this->fieldAttr['disabled'] = null;
1481 $color = colorArrayToHex(colorStringToArray($this->fieldValue, array()), '');
1482 $useDefaultColor = false;
1483 if (!$color && !empty($this->defaultFieldValue)) {
1484 $color = $this->defaultFieldValue;
1485 $useDefaultColor = true;
1486 }
1487 if ($color) {
1488 $out .= '<input type="color" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; " value="#'.$color.'">';
1489 }
1490
1491 if ($useDefaultColor) {
1492 $out .= ' '.$langs->trans("Default");
1493 } else {
1494 $out .= ' #'.$color;
1495 }
1496
1497 return $out;
1498 }
1504 public function generateInputFieldColor()
1505 {
1506 $this->fieldAttr['type'] = 'color';
1507 $default = $this->defaultFieldValue;
1508 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
1509 $formother = new FormOther($this->db);
1510 return $formother->selectColor(colorArrayToHex(colorStringToArray((string) $this->fieldAttr['value'], array()), ''), $this->fieldAttr['name'], '', 1, array(), '', '', (string) $default).' ';
1511 }
1512
1519 {
1520 $outPut = '';
1521 if (!empty($this->fieldOptions[$this->fieldValue])) {
1522 $outPut = $this->fieldOptions[$this->fieldValue];
1523 }
1524
1525 return $outPut;
1526 }
1527
1534 {
1535 $outPut = '';
1536 $user = new User($this->db);
1537 $user->fetch((int) $this->fieldValue);
1538 $outPut = $user->firstname . " " . $user->lastname;
1539 return $outPut;
1540 }
1541
1542 /*
1543 * METHODS FOR SETTING DISPLAY TYPE
1544 */
1545
1551 public function setAsString()
1552 {
1553 $this->type = 'string';
1554 return $this;
1555 }
1556
1565 public function setAsNumber($min = null, $max = null, $step = null)
1566 {
1567 $this->type = 'number'; //for GETPOSTINT
1568 $this->fieldAttr['type'] = 'number'; //generic thanks to generateAttributesStringFromArray
1569 if (!is_null($min)) {
1570 $this->fieldAttr['min'] = $min;
1571 }
1572 if (!is_null($max)) {
1573 $this->fieldAttr['max'] = $max;
1574 }
1575 if (!is_null($step)) {
1576 $this->fieldAttr['step'] = $step;
1577 }
1578 return $this;
1579 }
1580
1581
1587 public function setAsEmail()
1588 {
1589 $this->type = 'email';
1590 return $this;
1591 }
1592
1598 public function setAsUrl()
1599 {
1600 $this->type = 'url';
1601 return $this;
1602 }
1603
1609 public function setAsColor()
1610 {
1611 $this->type = 'color';
1612 return $this;
1613 }
1614
1620 public function setAsTextarea()
1621 {
1622 $this->type = 'textarea';
1623 return $this;
1624 }
1625
1631 public function setAsHtml()
1632 {
1633 $this->type = 'html';
1634 return $this;
1635 }
1636
1643 public function setAsEmailTemplate($templateType)
1644 {
1645 $this->type = 'emailtemplate:'.$templateType;
1646 return $this;
1647 }
1648
1654 public function setAsThirdpartyType()
1655 {
1656 $this->type = 'thirdparty_type';
1657 return $this;
1658 }
1659
1665 public function setAsYesNo()
1666 {
1667 $this->type = 'yesno';
1668 return $this;
1669 }
1670
1676 public function setAsSecureKey()
1677 {
1678 $this->type = 'securekey';
1679 return $this;
1680 }
1681
1687 public function setAsProduct()
1688 {
1689 $this->type = 'product';
1690 return $this;
1691 }
1692
1698 public function setAsPrice()
1699 {
1700 $this->type = 'price';
1701 return $this;
1702 }
1703
1711 public function setAsCategory($catType)
1712 {
1713 $this->type = 'category:'.$catType;
1714 return $this;
1715 }
1716
1722 public function setAsTitle()
1723 {
1724 $this->type = 'title';
1725 return $this;
1726 }
1727
1728
1735 public function setAsMultiSelect($fieldOptions)
1736 {
1737 if (is_array($fieldOptions)) {
1738 $this->fieldOptions = $fieldOptions;
1739 }
1740
1741 $this->type = 'multiselect';
1742 return $this;
1743 }
1744
1751 public function setAsSelect($fieldOptions)
1752 {
1753 if (is_array($fieldOptions)) {
1754 $this->fieldOptions = $fieldOptions;
1755 }
1756
1757 $this->type = 'select';
1758 return $this;
1759 }
1760
1761
1768 public function setAsRadio($fieldOptions)
1769 {
1770 if (is_array($fieldOptions)) {
1771 $this->fieldOptions = $fieldOptions;
1772 }
1773
1774 $this->type = 'radio';
1775 return $this;
1776 }
1777
1783 public function setAsSelectUser()
1784 {
1785 $this->type = 'selectUser';
1786 return $this;
1787 }
1788
1794 public function setAsSelectBankAccount()
1795 {
1796 $this->type = 'selectBankAccount';
1797 return $this;
1798 }
1799
1807 public function setAsPassword()
1808 {
1809 $this->type = 'password';
1810 return $this;
1811 }
1812
1820 public function setAsGenericPassword()
1821 {
1822 $this->type = 'genericpassword';
1823 return $this;
1824 }
1825}
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
$c
Definition line.php:334
Class to manage bank accounts.
Class to manage categories.
Class to manage a WYSIWYG editor.
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
Class to manage a HTML form to send a unitary email Usage: $formail = new FormMail($db) $formmail->pr...
Class to help generate other html components Only common components are here.
This class help you create setup render.
sortingItems()
Sort items according to rank.
saveConfFromPost($noMessageInUpdate=false)
saveConfFromPost
generateOutput($editMode=false, $hideTitle=false, $title='', $cssfirstcolumn='')
Generate the form (in read or edit mode depending on $editMode)
itemSort(FormSetupItem $a, FormSetupItem $b)
uasort callback function to Sort params items
newItem($confKey, $targetItemKey='', $insertAfterTarget=false)
Create a new item The target is useful with hooks : that allow externals modules to add setup items o...
__construct($db, $outputLangs=null)
Constructor.
setItemMaxRank($rank)
set new max rank if needed
exportItemsAsParamsArray()
Used to export param array for /core/actions_setmoduleoptions.inc.php template Method exists only for...
getLineRank($itemKey)
get item position rank from item key
addItemsFromParamsArray($params)
Method used to test module builder conversion to this form usage.
addItemFromParams($confKey, $params)
From old Method was used to test module builder conversion to this form usage.
static generateAttributesStringFromArray($attributes)
Generate an attributes string form an input array.
generateTableOutput($editMode=false, $hideTitle=false, $title='', $cssfirstcolumn='')
generateTableOutput
reloadConfs()
Reload for each item default conf note: this will override custom configuration.
generateLineOutput($item, $editMode=false)
generateLineOutput
getCurentItemMaxRank($cache=true)
getCurentItemMaxRank
This class help to create item for class formSetup.
reloadValueFromConf()
Reload conf value from databases is an alias of loadValueFromConf.
setSaveCallBack(callable $callBack)
Set an override function for saving data.
generateInputFieldTextarea()
generate input field for textarea
setAsString()
Set type of input as string.
setValueFromPostCallBack(callable $callBack)
Set an override function for get data from post.
setAsSecureKey()
Set type of input as secure key.
generateInputFieldMultiSelect()
generateInputFieldMultiSelect
generateOutputFieldColor()
generateOutputFieldColor
generateOutputField()
generateOutputField
saveConfValue()
Save const value based on htdocs/core/actions_setmoduleoptions.inc.php.
loadValueFromConf()
load conf value from databases
setAsHtml()
Set type of input as html editor.
generateInputField()
generate input field
generateOutputFieldMultiSelect()
generateOutputFieldMultiSelect
setAsColor()
Set type of input as color.
generateInputFieldRadio()
generateInputFieldSelect
generateInputFieldEmail()
Generate default input field.
generateOutputFieldSelectUser()
generateOutputFieldSelectUser
generateOutputFieldSelect()
generateOutputFieldSelect
setAsPrice()
Set type of input as product.
setErrors($errors)
Add error.
getType()
get the type : used for old module builder setup conf style conversion and tests because this two cla...
setAsTitle()
Set type of input as a simple title.
generateInputFieldText()
Generate default input field.
setAsCategory($catType)
Set type of input as a category selector TODO add default value.
setAsSelect($fieldOptions)
Set type of input as a select list.
setAsRadio($fieldOptions)
Set type of input as a radio button.
generateInputFieldUrl()
Generate default input field.
setAsSelectUser()
Set type of input as a selection of a user from dolibarr users list.
setAsSelectBankAccount()
Set type of input as a bank account selection from dolibarr bank accounts list.
generateInputFieldPrice()
Generate default input field.
setValueFromPost()
Save const value based on htdocs/core/actions_setmoduleoptions.inc.php.
setAsMultiSelect($fieldOptions)
Set type of input as a multiselect list.
generateInputFieldCategories()
generate input field for categories
setAsProduct()
Set type of input as product.
setAsThirdpartyType()
Set type of input as thirdparty_type selector.
setAsPassword()
Set type of input as a password with dolibarr password rules apply.
generateInputFieldEmailTemplate()
generate input field for email template selector
setTypeFromTypeString($type)
set the type from string : used for old module builder setup conf style conversion and tests because ...
generateInputFieldColor()
generateInputFieldColor
generateInputFieldHtml()
generate input field for html
setAsEmail()
Set type of input as string.
__construct($confKey)
Constructor.
setAsNumber($min=null, $max=null, $step=null)
Set type of input as number.
setAsGenericPassword()
Set type of input as a generic password without dolibarr password rules (for external passwords for e...
setAsUrl()
Set type of input as string.
getNameText()
Get field name text or generate it.
generateInputFieldPassword($type='generic', $defaultmin=6, $defaultmax=50)
generate input field for a password
setAsYesNo()
Set type of input as Yes.
generateInputFieldSecureKey()
generate input field for secure key
generateInputFieldSelect()
generateInputFieldSelect
setAsEmailTemplate($templateType)
Set type of input as emailtemplate selector.
getHelpText()
Get help text or generate it.
setAsTextarea()
Set type of input as textarea.
Class to manage products or services.
Class to manage Dolibarr users.
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
colorArrayToHex($arraycolor, $colorifnotfound='888888')
Convert an array with RGB value into hex RGB value.
colorStringToArray($stringcolor, $colorifnotfound=array(88, 88, 88))
Convert a string RGB value ('FFFFFF', '255,255,255') into an array RGB array(255,255,...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
$item fieldInputCallBack
Callback used to generate the custom HTML input field.
Definition setup.php:82
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:130
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Output javascript to autoset a generated password using default module into a HTML element.