dolibarr 23.0.3
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 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25{
29 public $db;
30
32 public $entity;
33
35 public $items = array();
36
40 public $setupNotEmpty = 0;
41
43 public $langs;
44
46 public $form;
47
49 protected $maxItemRank;
50
55 public $htmlBeforeOutputForm = '';
56
61 public $htmlAfterOutputForm = '';
62
67 public $htmlOutputMoreButton = '';
68
73 public $htmlButtonLabel = 'Save';
74
78 public $formAttributes = array(
79 'action' => '', // set in __construct
80 'method' => 'POST'
81 );
82
87 public $formHiddenInputs = array();
88
92 public $errors = array();
93
94
101 public function __construct($db, $outputLangs = null)
102 {
103 global $conf, $langs;
104
105 $this->db = $db;
106
107 $this->form = new Form($this->db);
108 $this->formAttributes['action'] = $_SERVER["PHP_SELF"];
109
110 $this->formHiddenInputs['token'] = newToken();
111 $this->formHiddenInputs['action'] = 'update';
112
113 $this->entity = (is_null($this->entity) ? $conf->entity : $this->entity);
114
115 if ($outputLangs) {
116 $this->langs = $outputLangs;
117 } else {
118 $this->langs = $langs;
119 }
120 }
121
128 public static function generateAttributesStringFromArray($attributes)
129 {
130 $Aattr = array();
131 if (is_array($attributes)) {
132 foreach ($attributes as $attribute => $value) {
133 if (is_array($value) || is_object($value)) {
134 continue;
135 }
136 $Aattr[] = $attribute.'="'.dol_escape_htmltag($value).'"';
137 }
138 }
139
140 return !empty($Aattr) ? implode(' ', $Aattr) : '';
141 }
142
143
153 public function generateOutput($editMode = false, $hideTitle = false, $title = '', $cssfirstcolumn = '')
154 {
155 global $hookmanager, $action;
156
157 require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
158
159 $parameters = array(
160 'editMode' => $editMode
161 );
162 $reshook = $hookmanager->executeHooks('formSetupBeforeGenerateOutput', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
163 if ($reshook < 0) {
164 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
165 }
166
167 if ($reshook > 0) {
168 return $hookmanager->resPrint;
169 } else {
170 $out = '<!-- Start generateOutput from FormSetup class -->';
171 $out .= $this->htmlBeforeOutputForm;
172
173 if ($editMode) {
174 $out .= '<form ' . self::generateAttributesStringFromArray($this->formAttributes) . ' >';
175 $out .= '<input type="hidden" name="page_y" value="">';
176
177 // generate hidden values from $this->formHiddenInputs
178 if (!empty($this->formHiddenInputs) && is_array($this->formHiddenInputs)) {
179 foreach ($this->formHiddenInputs as $hiddenKey => $hiddenValue) {
180 $out .= '<input type="hidden" name="'.dol_escape_htmltag($hiddenKey).'" value="' . dol_escape_htmltag($hiddenValue) . '">';
181 }
182 }
183 }
184
185 // generate output table
186 $out .= $this->generateTableOutput($editMode, $hideTitle, $title, $cssfirstcolumn);
187
188
189 $reshook = $hookmanager->executeHooks('formSetupBeforeGenerateOutputButton', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
190 if ($reshook < 0) {
191 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
192 }
193
194 if ($reshook > 0) {
195 return $hookmanager->resPrint;
196 } elseif ($editMode) {
197 $out .= '<div class="form-setup-button-container center">'; // Todo : remove .center by adding style to form-setup-button-container css class in all themes
198 $out .= $this->htmlOutputMoreButton;
199 if ($editMode !== 3) {
200 $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
201 }
202 if ($editMode === 2) {
203 // Add also a cancel button
204 $out .= ' &nbsp;&nbsp; ';
205 $out .= '<input class="button button-cancel" type="submit" value="' . $this->langs->trans('Cancel') . '" name="cancel">';
206 }
207 $out .= '</div>';
208 }
209
210 if ($editMode) {
211 $out .= '</form>';
212 }
213
214 $out .= $this->htmlAfterOutputForm;
215
216 return $out;
217 }
218 }
219
229 public function generateTableOutput($editMode = false, $hideTitle = false, $title = '', $cssfirstcolumn = '')
230 {
231 global $hookmanager, $action;
232 require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
233
234 $parameters = array(
235 'editMode' => $editMode
236 );
237 $reshook = $hookmanager->executeHooks('formSetupBeforeGenerateTableOutput', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
238 if ($reshook < 0) {
239 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
240 }
241
242 if ($reshook > 0) {
243 return $hookmanager->resPrint;
244 } else {
245 $out = '<div class="div-table-responsive-no-min">';
246 $out .= '<table class="noborder centpercent">';
247 if (empty($hideTitle)) {
248 if (empty($title)) {
249 $title = $this->langs->transnoentitiesnoconv("Parameter");
250 }
251 $out .= '<thead>';
252 $out .= '<tr class="liste_titre">';
253 $out .= ' <td'.($cssfirstcolumn ? ' class="'.$cssfirstcolumn.'"' : '').'>' . dolPrintHTML($title) . '</td>';
254 $out .= ' <td></td>';
255 $out .= '</tr>';
256 $out .= '</thead>';
257 }
258
259 // Sort items before render
260 $this->sortingItems();
261
262 $out .= '<tbody>';
263 foreach ($this->items as $item) {
264 $out .= $this->generateLineOutput($item, $editMode);
265 }
266 $out .= '</tbody>';
267
268 $out .= '</table>';
269 $out .= '</div>';
270 return $out;
271 }
272 }
273
280 public function saveConfFromPost($noMessageInUpdate = false)
281 {
282 global $hookmanager, $conf;
283
284 $parameters = array();
285 $reshook = $hookmanager->executeHooks('formSetupBeforeSaveConfFromPost', $parameters, $this); // Note that $action and $object may have been modified by some hooks
286 if ($reshook < 0) {
287 $this->errors = $hookmanager->errors;
288 return -1;
289 }
290 if ($reshook > 0) {
291 return $reshook;
292 }
293
294 if (empty($this->items)) {
295 return null;
296 }
297
298 $this->db->begin();
299 $error = 0;
300 foreach ($this->items as $item) {
301 if ($item->getType() == 'yesno' && !empty($conf->use_javascript_ajax)) {
302 continue;
303 }
304
305 $res = $item->setValueFromPost();
306 if ($res > 0) {
307 $item->saveConfValue();
308 } elseif ($res < 0) {
309 $error++;
310 break;
311 }
312 }
313
314 if (!$error) {
315 $this->db->commit();
316 if (empty($noMessageInUpdate)) {
317 setEventMessages($this->langs->trans("SetupSaved"), null);
318 }
319 return 1;
320 } else {
321 $this->db->rollback();
322 if (empty($noMessageInUpdate)) {
323 setEventMessages($this->langs->trans("SetupNotSaved"), null, 'errors');
324 }
325 return -1;
326 }
327 }
328
336 public function generateLineOutput($item, $editMode = false)
337 {
338 $out = '';
339 if ($item->enabled == 1) {
340 $trClass = 'oddeven';
341 if ($item->getType() == 'title') {
342 $trClass = 'liste_titre';
343 }
344 if (!empty($item->fieldParams['trClass'])) {
345 $trClass .= ' '.$item->fieldParams['trClass'];
346 }
347
348 $this->setupNotEmpty++;
349 $out .= '<tr class="'.$trClass.'">';
350
351 $out .= '<td class="col-setup-title'.(!empty($item->fieldParams['isMandatory']) ? ' fieldrequired' : '').'">';
352 $out .= '<span id="helplink'.$item->confKey.'" class="spanforparamtooltip">';
353 $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'] : ''));
354 $out .= '</span>';
355 $out .= '</td>';
356
357 $out .= '<td>';
358
359 if ($editMode) {
360 $out .= $item->generateInputField();
361 } else {
362 $out .= $item->generateOutputField();
363 }
364
365 if (!empty($item->errors)) {
366 // TODO : move set event message in a methode to be called by cards not by this class
367 setEventMessages(null, $item->errors, 'errors');
368 }
369
370 $out .= '</td>';
371 $out .= '</tr>';
372 }
373
374 return $out;
375 }
376
377
384 public function addItemsFromParamsArray($params)
385 {
386 if (!is_array($params) || empty($params)) {
387 return false;
388 }
389 foreach ($params as $confKey => $param) {
390 $this->addItemFromParams($confKey, $param); // todo manage error
391 }
392 return true;
393 }
394
395
404 public function addItemFromParams($confKey, $params)
405 {
406 if (empty($confKey) || empty($params['type'])) {
407 return false;
408 }
409
410 /*
411 * Example from old module builder setup page
412 * // 'MYMODULE_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>1),
413 // 'MYMODULE_MYPARAM2'=>array('type'=>'textarea','enabled'=>1),
414 //'MYMODULE_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
415 //'MYMODULE_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1),
416 //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1),
417 //'MYMODULE_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1),
418 //'MYMODULE_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1),
419 //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1),
420 */
421
422 $item = new FormSetupItem($confKey);
423 // setTypeFromTypeString was created as deprecated to incite developer to use object oriented usage
425 $item->setTypeFromTypeString((string) $params['type']);
426
427 if (!empty($params['enabled']) && is_numeric($params['enabled'])) {
428 $item->enabled = (int) $params['enabled'];
429 }
430
431 if (!empty($params['css'])) {
432 $item->cssClass = (string) $params['css'];
433 }
434
435 $this->items[$item->confKey] = $item;
436
437 return true;
438 }
439
446 public function exportItemsAsParamsArray()
447 {
448 $arrayofparameters = array();
449 foreach ($this->items as $item) {
450 $arrayofparameters[$item->confKey] = array(
451 'type' => $item->getType(),
452 'enabled' => $item->enabled
453 );
454 }
455
456 return $arrayofparameters;
457 }
458
465 public function reloadConfs()
466 {
467 if (!array($this->items)) {
468 return false;
469 }
470 foreach ($this->items as $item) {
471 $item->loadValueFromConf();
472 }
473
474 return true;
475 }
476
477
487 public function newItem($confKey, $targetItemKey = '', $insertAfterTarget = false)
488 {
489 $item = new FormSetupItem($confKey);
490
491 $item->entity = $this->entity;
492
493 // set item rank if not defined as last item
494 if (empty($item->rank)) {
495 $item->rank = $this->getCurentItemMaxRank() + 1;
496 $this->setItemMaxRank($item->rank); // set new max rank if needed
497 }
498
499 // try to get rank from target column, this will override item->rank
500 if (!empty($targetItemKey)) {
501 if (isset($this->items[$targetItemKey])) {
502 $targetItem = $this->items[$targetItemKey];
503 $item->rank = $targetItem->rank; // $targetItem->rank will be increase after
504 if ($targetItem->rank >= 0 && $insertAfterTarget) {
505 $item->rank++;
506 }
507 }
508
509 // calc new rank for each item to make place for new item
510 foreach ($this->items as $fItem) {
511 if ($item->rank <= $fItem->rank) {
512 $fItem->rank += 1;
513 $this->setItemMaxRank($fItem->rank); // set new max rank if needed
514 }
515 }
516 }
517
518 $this->items[$item->confKey] = $item;
519 return $this->items[$item->confKey];
520 }
521
527 public function sortingItems()
528 {
529 // Sorting
530 return uasort($this->items, array($this, 'itemSort'));
531 }
532
539 public function getCurentItemMaxRank($cache = true)
540 {
541 if (empty($this->items)) {
542 return 0;
543 }
544
545 if ($cache && $this->maxItemRank > 0) {
546 return $this->maxItemRank;
547 }
548
549 $this->maxItemRank = 0;
550 foreach ($this->items as $item) {
551 $this->maxItemRank = max($this->maxItemRank, $item->rank);
552 }
553
554 return $this->maxItemRank;
555 }
556
557
564 public function setItemMaxRank($rank)
565 {
566 $this->maxItemRank = max($this->maxItemRank, $rank);
567 }
568
569
576 public function getLineRank($itemKey)
577 {
578 if (!isset($this->items[$itemKey]->rank)) {
579 return -1;
580 }
581 return $this->items[$itemKey]->rank;
582 }
583
584
592 public function itemSort(FormSetupItem $a, FormSetupItem $b)
593 {
594 if (empty($a->rank)) {
595 $a->rank = 0;
596 }
597 if (empty($b->rank)) {
598 $b->rank = 0;
599 }
600 if ($a->rank == $b->rank) {
601 return 0;
602 }
603 return ($a->rank < $b->rank) ? -1 : 1;
604 }
605}
606
607
612{
616 public $db;
617
619 public $langs;
620
622 public $entity;
623
625 public $form;
626
627
629 public $confKey;
630
632 public $nameText = false;
633
635 public $helpText = '';
636
638 public $picto = '';
639
641 public $fieldValue;
642
644 public $defaultFieldValue = null;
645
647 public $fieldAttr = array();
648
650 public $fieldOverride = false;
651
653 public $fieldInputOverride = false;
654
656 public $fieldOutputOverride = false;
657
659 public $rank = 0;
660
662 public $fieldOptions = array();
663
665 public $fieldParams = array();
666
668 public $saveCallBack;
669
671 public $setValueFromPostCallBack;
672
676 public $errors = array();
677
684 protected $type = 'string';
685
686
688 public $enabled = 1;
689
693 public $cssClass = '';
694
695
701 public function __construct($confKey)
702 {
703 global $langs, $db, $conf, $form;
704 $this->db = $db;
705
706 if (!empty($form) && is_object($form) && get_class($form) == 'Form') { // the form class has a cache inside so I am using it to optimize
707 $this->form = $form;
708 } else {
709 $this->form = new Form($this->db);
710 }
711
712 $this->langs = $langs;
713 $this->entity = (is_null($this->entity) ? $conf->entity : ((int) $this->entity));
714
715 $this->confKey = $confKey;
716 $this->loadValueFromConf();
717 }
718
724 public function loadValueFromConf()
725 {
726 global $conf;
727 if (isset($conf->global->{$this->confKey})) {
728 $this->fieldValue = getDolGlobalString($this->confKey);
729 return true;
730 } else {
731 $this->fieldValue = null;
732 return false;
733 }
734 }
735
742 public function reloadValueFromConf()
743 {
744 return $this->loadValueFromConf();
745 }
746
747
753 public function saveConfValue()
754 {
755 global $hookmanager;
756
757 $parameters = array();
758 $reshook = $hookmanager->executeHooks('formSetupBeforeSaveConfValue', $parameters, $this); // Note that $action and $object may have been modified by some hooks
759 if ($reshook < 0) {
760 $this->setErrors($hookmanager->errors);
761 return -1;
762 }
763
764 if ($reshook > 0) {
765 return $reshook;
766 }
767
768
769 if (!empty($this->saveCallBack) && is_callable($this->saveCallBack)) {
770 return call_user_func($this->saveCallBack, $this);
771 }
772
773 // Modify constant only if key was posted (avoid resetting key to the null value)
774 if ($this->type != 'title') {
775 $result = dolibarr_set_const($this->db, $this->confKey, $this->fieldValue, 'chaine', 0, '', $this->entity);
776 if ($result < 0) {
777 return -1;
778 } else {
779 return 1;
780 }
781 }
782
783 return 0;
784 }
785
792 public function setSaveCallBack(callable $callBack)
793 {
794 $this->saveCallBack = $callBack;
795 }
796
803 public function setValueFromPostCallBack(callable $callBack)
804 {
805 $this->setValueFromPostCallBack = $callBack;
806 }
807
813 public function setValueFromPost()
814 {
815 if (!empty($this->setValueFromPostCallBack) && is_callable($this->setValueFromPostCallBack)) {
816 return call_user_func($this->setValueFromPostCallBack);
817 }
818
819 // Modify constant only if key was posted (avoid resetting key to the null value)
820 if ($this->type != 'title') {
821 if (preg_match('/category:/', $this->type)) {
822 if (GETPOSTINT($this->confKey) == '-1') {
823 $val_const = '';
824 } else {
825 $val_const = GETPOSTINT($this->confKey);
826 }
827 } elseif ($this->type == 'multiselect') {
828 $val = GETPOST($this->confKey, 'array');
829 if ($val && is_array($val)) {
830 $val_const = implode(',', $val);
831 } else {
832 $val_const = '';
833 }
834 } elseif ($this->type == 'html') {
835 $val_const = GETPOST($this->confKey, 'restricthtml');
836 } elseif ($this->type == 'email') {
837 $val_const = GETPOST($this->confKey, 'alphawithlgt');
838 } elseif ($this->type == 'number') {
839 $val_const = GETPOSTINT($this->confKey);
840 } else {
841 $val_const = GETPOST($this->confKey, 'alphanohtml');
842 }
843
844 // TODO add value check with class validate
845 $this->fieldValue = $val_const;
846
847 return 1;
848 }
849
850 return 0;
851 }
852
858 public function getHelpText()
859 {
860 if (!empty($this->helpText)) {
861 return $this->helpText;
862 }
863 return (($this->langs->trans($this->confKey . 'Tooltip') != $this->confKey . 'Tooltip') ? $this->langs->trans($this->confKey . 'Tooltip') : '');
864 }
865
871 public function getNameText()
872 {
873 if (!empty($this->nameText)) {
874 return $this->nameText;
875 }
876 $out = (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey', $this->confKey));
877
878 // if conf defined on entity 0, prepend a picto to indicate it will apply across all entities
879 if (isModEnabled('multicompany') && $this->entity == 0) {
880 $out = img_picto($this->langs->trans('AllEntities'), 'fa-globe-americas em088 opacityhigh') . '&nbsp;' . $out;
881 }
882
883 return $out;
884 }
885
891 public function generateInputField()
892 {
893 global $conf;
894
895 if (!empty($this->fieldOverride)) {
896 return $this->fieldOverride;
897 }
898
899 if (!empty($this->fieldInputOverride)) {
900 return $this->fieldInputOverride;
901 }
902
903 // Set default value
904 if (is_null($this->fieldValue)) {
905 $this->fieldValue = $this->defaultFieldValue;
906 }
907
908
909 $this->fieldAttr['name'] = $this->confKey;
910 $this->fieldAttr['id'] = 'setup-'.$this->confKey;
911 $this->fieldAttr['value'] = $this->fieldValue;
912
913 $out = '';
914
915 if ($this->type == 'title') {
916 $out .= $this->generateOutputField(); // title have no input
917 } elseif ($this->type == 'multiselect') {
918 $out .= $this->generateInputFieldMultiSelect();
919 } elseif ($this->type == 'select') {
920 $out .= $this->generateInputFieldSelect();
921 } elseif ($this->type == 'radio') {
922 $out .= $this->generateInputFieldRadio();
923 } elseif ($this->type == 'selectUser') {
924 $out .= $this->generateInputFieldSelectUser();
925 } elseif ($this->type == 'textarea') {
926 $out .= $this->generateInputFieldTextarea();
927 } elseif ($this->type == 'html') {
928 $out .= $this->generateInputFieldHtml();
929 } elseif ($this->type == 'color') {
930 $out .= $this->generateInputFieldColor();
931 } elseif ($this->type == 'yesno') {
932 if (!empty($conf->use_javascript_ajax)) {
933 $input = $this->fieldParams['input'] ?? array();
934 $revertonoff = empty($this->fieldParams['revertonoff']) ? 0 : 1;
935 $forcereload = empty($this->fieldParams['forcereload']) ? 0 : 1;
936 $suffixarray = array('ifoff' => empty($this->fieldParams['alertifoff']) ? '' : '_red', 'ifon' => empty($this->fieldParams['alertifon']) ? '' : '_red');
937
938 $out .= ajax_constantonoff($this->confKey, $input, $this->entity, $revertonoff, 0, $forcereload, 2, 0, 0, $suffixarray, '', $this->cssClass);
939 } else {
940 $out .= $this->form->selectyesno($this->confKey, $this->fieldValue, 1, false, 0, 0, $this->cssClass);
941 }
942 } elseif (preg_match('/emailtemplate:/', $this->type)) {
943 $out .= $this->generateInputFieldEmailTemplate();
944 } elseif (preg_match('/category:/', $this->type)) {
945 $out .= $this->generateInputFieldCategories();
946 } elseif (preg_match('/thirdparty_type/', $this->type)) {
947 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
948 $formcompany = new FormCompany($this->db);
949 $out .= $formcompany->selectProspectCustomerType($this->fieldValue, $this->confKey);
950 } elseif ($this->type == 'securekey') {
951 $out .= $this->generateInputFieldSecureKey();
952 } elseif ($this->type == 'product') {
953 if (isModEnabled("product") || isModEnabled("service")) {
954 $selected = (empty($this->fieldValue) ? '' : $this->fieldValue);
955 $out .= img_picto('', 'product', 'class="pictofixedwidth"');
956 $out .= $this->form->select_produits((int) $selected, $this->confKey, '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, $this->cssClass, 0, '', null, 1);
957 }
958 } elseif ($this->type == 'selectBankAccount') {
959 if (isModEnabled("bank")) {
960 $selected = (empty($this->fieldValue) ? '' : $this->fieldValue);
961 $out .= img_picto('', 'bank', 'class="pictofixedwidth"').$this->form->select_comptes($selected, $this->confKey, 0, '', 0, '', 0, '', 1);
962 }
963 } elseif ($this->type == 'password') {
964 $out .= $this->generateInputFieldPassword('dolibarr');
965 } elseif ($this->type == 'genericpassword') {
966 $out .= $this->generateInputFieldPassword('generic', 0, 0);
967 } elseif ($this->type == 'price') {
968 $out .= $this->generateInputFieldPrice();
969 } elseif ($this->type == 'email') {
970 $out .= $this->generateInputFieldEmail();
971 } elseif ($this->type == 'url') {
972 $out .= $this->generateInputFieldUrl();
973 } else {
974 $out .= $this->generateInputFieldText();
975 }
976
977 return $out;
978 }
979
985 public function generateInputFieldText()
986 {
987 if (empty($this->fieldAttr) || empty($this->fieldAttr['class'])) {
988 $this->fieldAttr['class'] = 'flat '.(empty($this->cssClass) ? 'minwidth200' : $this->cssClass);
989 }
990 return '<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).' />';
991 }
992
998 public function generateInputFieldPrice()
999 {
1000 global $langs, $mysoc;
1001
1002 if (empty($this->fieldAttr) || empty($this->fieldAttr['class'])) {
1003 $this->fieldAttr['class'] = 'flat '.(empty($this->cssClass) ? 'minwidth40 maxwidth75' : $this->cssClass);
1004 }
1005 //return img_picto('', 'currency', 'class="pictofixedwidth"').'<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).' /> '.$langs->getCurrencySymbol($mysoc->currency_code);
1006 return '<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).' /> '.$langs->getCurrencySymbol($mysoc->currency_code);
1007 }
1008
1014 public function generateInputFieldEmail()
1015 {
1016 if (empty($this->fieldAttr) || empty($this->fieldAttr['class'])) {
1017 $this->fieldAttr['class'] = 'flat '.(empty($this->cssClass) ? 'minwidth100 maxwidth500' : $this->cssClass);
1018 }
1019 return img_picto('', 'email', 'class="pictofixedwidth"').'<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).' />';
1020 }
1021
1027 public function generateInputFieldUrl()
1028 {
1029 if (empty($this->fieldAttr) || empty($this->fieldAttr['class'])) {
1030 $this->fieldAttr['class'] = 'flat '.(empty($this->cssClass) ? 'minwidth100 maxwidth500' : $this->cssClass);
1031 }
1032 return img_picto('', 'url', 'class="pictofixedwidth"').'<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).' />';
1033 }
1034
1041 {
1042 $out = '<textarea class="flat" name="'.$this->confKey.'" id="'.$this->confKey.'" cols="50" rows="5" wrap="soft">' . "\n";
1043 $out .= dol_htmlentities($this->fieldValue);
1044 $out .= "</textarea>\n";
1045 return $out;
1046 }
1047
1053 public function generateInputFieldHtml()
1054 {
1055 require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
1056 $doleditor = new DolEditor($this->confKey, $this->fieldValue, '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%');
1057 return $doleditor->Create(1);
1058 }
1059
1066 {
1067 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1068 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
1069 $formother = new FormOther($this->db);
1070
1071 $tmp = explode(':', $this->type);
1072 $out = img_picto('', 'category', 'class="pictofixedwidth"');
1073
1074 $label = 'Categories';
1075 if ($this->type == 'customer') {
1076 $label = 'CustomersProspectsCategoriesShort';
1077 }
1078 $out .= $formother->select_categories($tmp[1], (int) $this->fieldValue, $this->confKey, 0, $this->langs->trans($label));
1079
1080 return $out;
1081 }
1082
1088 {
1089 global $user;
1090
1091 $out = '';
1092 if (preg_match('/emailtemplate:/', $this->type)) {
1093 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
1094 $formmail = new FormMail($this->db);
1095
1096 $tmp = explode(':', $this->type);
1097 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang
1098 $arrayOfMessageName = array();
1099 if (is_array($formmail->lines_model)) {
1100 foreach ($formmail->lines_model as $modelMail) {
1101 $moreonlabel = '';
1102 if (!empty($arrayOfMessageName[$modelMail->label])) {
1103 $moreonlabel = ' <span class="opacitymedium">(' . $this->langs->trans("SeveralLangugeVariatFound") . ')</span>';
1104 }
1105 // The 'label' is the key that is unique if we exclude the language
1106 $arrayOfMessageName[$modelMail->id] = $this->langs->trans(preg_replace('/\‍(|\‍)/', '', $modelMail->label)) . $moreonlabel;
1107 }
1108 }
1109 $out .= $this->form->selectarray($this->confKey, $arrayOfMessageName, $this->fieldValue, 'None', 0, 0, '', 0, 0, 0, '', '', 1);
1110 }
1111
1112 return $out;
1113 }
1114
1115
1122 {
1123 global $conf;
1124 $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).'">';
1125
1126 if (!empty($conf->use_javascript_ajax) && empty($this->fieldParams['hideGenerateButton'])) {
1127 $out .= '&nbsp;'.img_picto($this->langs->trans('Generate'), 'refresh', 'id="generate_token'.$this->confKey.'" class="linkobject"');
1128
1129 // Add button to autosuggest a key
1130 include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
1131 $out .= dolJSToSetRandomPassword($this->confKey, 'generate_token'.$this->confKey);
1132 }
1133
1134 return $out;
1135 }
1136
1137
1146 public function generateInputFieldPassword($type = 'generic', $defaultmin = 6, $defaultmax = 50)
1147 {
1148 global $conf, $langs, $user;
1149
1150 $min = $defaultmin;
1151 $max = $defaultmax;
1152 if ($type == 'dolibarr') {
1153 $gen = getDolGlobalString('USER_PASSWORD_GENERATED', 'standard');
1154 if ($gen == 'none') {
1155 $gen = 'standard';
1156 }
1157 $nomclass = "modGeneratePass".ucfirst($gen);
1158 $nomfichier = $nomclass.".class.php";
1159 require_once DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomfichier;
1160 $genhandler = new $nomclass($this->db, $conf, $langs, $user);
1161 $min = $genhandler->length;
1162 $max = $genhandler->length2;
1163 }
1164 $out = '<input required="required" type="password" class="flat" id="'.$this->confKey.'" name="'.$this->confKey.'" value="'.(GETPOST($this->confKey, 'alpha') ? GETPOST($this->confKey, 'alpha') : $this->fieldValue).'"';
1165 if ($min) {
1166 $out .= ' minlength="' . $min . '"';
1167 }
1168 if ($max) {
1169 $out .= ' maxlength="' . $max . '"';
1170 }
1171 $out .= '>';
1172
1173 $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>';
1174
1175 return $out;
1176 }
1177
1178
1179
1186 {
1187 $TSelected = array();
1188 if ($this->fieldValue) {
1189 $TSelected = explode(',', $this->fieldValue);
1190 }
1191
1192 return $this->form->multiselectarray($this->confKey, $this->fieldOptions, $TSelected, 0, 0, '', 0, 0, 'style="min-width:100px"');
1193 }
1194
1201 {
1202 $s = '';
1203 if ($this->picto) {
1204 $s .= img_picto('', $this->picto, 'class="pictofixedwidth"');
1205 }
1206
1207 $s .= $this->form->selectarray($this->confKey, $this->fieldOptions, $this->fieldValue, 0, 0, 0, '', 0, 0, 0, '', $this->cssClass);
1208
1209 return $s;
1210 }
1211
1217 public function generateInputFieldRadio()
1218 {
1219 $s = '';
1220 if ($this->picto) {
1221 $s .= img_picto('', $this->picto, 'class="pictofixedwidth"');
1222 }
1223
1224 $s .= $this->form->radio($this->confKey, $this->fieldOptions, $this->fieldValue, ['attrLabel' => ['class' => $this->cssClass]]);
1225
1226 return $s;
1227 }
1228
1233 {
1234 return $this->form->select_dolusers($this->fieldValue, $this->confKey);
1235 }
1236
1244 public function getType()
1245 {
1246 return $this->type;
1247 }
1248
1258 public function setTypeFromTypeString($type)
1259 {
1260 $this->type = $type;
1261
1262 return true;
1263 }
1264
1271 public function setErrors($errors)
1272 {
1273 if (is_array($errors)) {
1274 if (!empty($errors)) {
1275 foreach ($errors as $error) {
1276 $this->setErrors($error);
1277 }
1278 }
1279 } elseif (!empty($errors)) {
1280 $this->errors[] = $errors;
1281 }
1282 return null;
1283 }
1284
1290 public function generateOutputField()
1291 {
1292 global $conf, $user, $langs;
1293
1294 if (!empty($this->fieldOverride)) {
1295 return $this->fieldOverride;
1296 }
1297
1298 if (!empty($this->fieldOutputOverride)) {
1299 return $this->fieldOutputOverride;
1300 }
1301
1302 $out = '';
1303
1304 if ($this->type == 'title') {
1305 // nothing to do
1306 } elseif ($this->type == 'textarea') {
1307 $out .= dol_nl2br($this->fieldValue);
1308 } elseif ($this->type == 'multiselect') {
1309 $out .= $this->generateOutputFieldMultiSelect();
1310 } elseif ($this->type == 'select') {
1311 $out .= $this->generateOutputFieldSelect();
1312 } elseif ($this->type == 'selectUser') {
1313 $out .= $this->generateOutputFieldSelectUser();
1314 } elseif ($this->type == 'html') {
1315 $out .= $this->fieldValue;
1316 } elseif ($this->type == 'color') {
1317 $out .= $this->generateOutputFieldColor();
1318 } elseif ($this->type == 'yesno') {
1319 if (!empty($conf->use_javascript_ajax)) {
1320 $revertonoff = empty($this->fieldParams['revertonoff']) ? 0 : 1;
1321 $forcereload = empty($this->fieldParams['forcereload']) ? 0 : 1;
1322
1323 $out .= ajax_constantonoff($this->confKey, array(), $this->entity, $revertonoff, 0, $forcereload, 2, 0, 0, '', '', $this->cssClass); // TODO possibility to add $input parameter
1324 } else {
1325 if ($this->fieldValue == 1) {
1326 $out .= $langs->trans('yes');
1327 } else {
1328 $out .= $langs->trans('no');
1329 }
1330 }
1331 } elseif (preg_match('/emailtemplate:/', $this->type)) {
1332 if ($this->fieldValue > 0) {
1333 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
1334 $formmail = new FormMail($this->db);
1335
1336 $tmp = explode(':', $this->type);
1337
1338 $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, (int) $this->fieldValue);
1339 if (is_numeric($template) && $template < 0) {
1340 $this->setErrors($formmail->errors);
1341 }
1342 $out .= $this->langs->trans($template->label);
1343 }
1344 } elseif (preg_match('/category:/', $this->type)) {
1345 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1346 $c = new Categorie($this->db);
1347 $result = $c->fetch((int) $this->fieldValue);
1348 if ($result < 0) {
1349 $this->setErrors($c->errors);
1350 }
1351 $ways = $c->print_all_ways('auto', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
1352 $toprint = array();
1353 foreach ($ways as $way) {
1354 $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '</li>';
1355 }
1356 $out .= '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
1357 } elseif (preg_match('/thirdparty_type/', $this->type)) {
1358 if ($this->fieldValue == 2) {
1359 $out .= $this->langs->trans("Prospect");
1360 } elseif ($this->fieldValue == 3) {
1361 $out .= $this->langs->trans("ProspectCustomer");
1362 } elseif ($this->fieldValue == 1) {
1363 $out .= $this->langs->trans("Customer");
1364 } elseif ($this->fieldValue == 0) {
1365 $out .= $this->langs->trans("NorProspectNorCustomer");
1366 }
1367 } elseif ($this->type == 'product') {
1368 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
1369
1370 $product = new Product($this->db);
1371 $resprod = $product->fetch((int) $this->fieldValue);
1372 if ($resprod > 0) {
1373 $out .= $product->getNomUrl(1, '', 0, -1, 0, '', 1);
1374 } elseif ($resprod < 0) {
1375 $this->setErrors($product->errors);
1376 }
1377 } elseif ($this->type == 'selectBankAccount') {
1378 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
1379
1380 $bankaccount = new Account($this->db);
1381 $resbank = $bankaccount->fetch((int) $this->fieldValue);
1382 if ($resbank > 0) {
1383 $out .= $bankaccount->label;
1384 } elseif ($resbank < 0) {
1385 $this->setErrors($bankaccount->errors);
1386 }
1387 } elseif ($this->type == 'password' || $this->type == 'genericpassword') {
1388 $out .= str_repeat('*', strlen($this->fieldValue));
1389 } else {
1390 $out .= dolPrintHTML($this->fieldValue);
1391 }
1392
1393 return $out;
1394 }
1395
1396
1403 {
1404 $outPut = '';
1405 $TSelected = array();
1406 if (!empty($this->fieldValue)) {
1407 $TSelected = explode(',', $this->fieldValue);
1408 }
1409
1410 if (!empty($TSelected)) {
1411 foreach ($TSelected as $selected) {
1412 if (!empty($this->fieldOptions[$selected])) {
1413 $outPut .= dolGetBadge('', $this->fieldOptions[$selected], 'info').' ';
1414 }
1415 }
1416 }
1417 return $outPut;
1418 }
1419
1426 {
1427 global $langs;
1428 $out = '';
1429 $this->fieldAttr['disabled'] = null;
1430 $color = colorArrayToHex(colorStringToArray($this->fieldValue, array()), '');
1431 $useDefaultColor = false;
1432 if (!$color && !empty($this->defaultFieldValue)) {
1433 $color = $this->defaultFieldValue;
1434 $useDefaultColor = true;
1435 }
1436 if ($color) {
1437 $out .= '<input type="color" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; " value="#'.$color.'">';
1438 }
1439
1440 if ($useDefaultColor) {
1441 $out .= ' '.$langs->trans("Default");
1442 } else {
1443 $out .= ' #'.$color;
1444 }
1445
1446 return $out;
1447 }
1453 public function generateInputFieldColor()
1454 {
1455 $this->fieldAttr['type'] = 'color';
1456 $default = $this->defaultFieldValue;
1457 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
1458 $formother = new FormOther($this->db);
1459 return $formother->selectColor(colorArrayToHex(colorStringToArray((string) $this->fieldAttr['value'], array()), ''), $this->fieldAttr['name'], '', 1, array(), '', '', (string) $default).' ';
1460 }
1461
1468 {
1469 $outPut = '';
1470 if (!empty($this->fieldOptions[$this->fieldValue])) {
1471 $outPut = $this->fieldOptions[$this->fieldValue];
1472 }
1473
1474 return $outPut;
1475 }
1476
1483 {
1484 $outPut = '';
1485 $user = new User($this->db);
1486 $user->fetch((int) $this->fieldValue);
1487 $outPut = $user->firstname . " " . $user->lastname;
1488 return $outPut;
1489 }
1490
1491 /*
1492 * METHODS FOR SETTING DISPLAY TYPE
1493 */
1494
1500 public function setAsString()
1501 {
1502 $this->type = 'string';
1503 return $this;
1504 }
1505
1514 public function setAsNumber($min = null, $max = null, $step = null)
1515 {
1516 $this->type = 'number'; //for GETPOSTINT
1517 $this->fieldAttr['type'] = 'number'; //generic thanks to generateAttributesStringFromArray
1518 if (!is_null($min)) {
1519 $this->fieldAttr['min'] = $min;
1520 }
1521 if (!is_null($max)) {
1522 $this->fieldAttr['max'] = $max;
1523 }
1524 if (!is_null($step)) {
1525 $this->fieldAttr['step'] = $step;
1526 }
1527 return $this;
1528 }
1529
1530
1536 public function setAsEmail()
1537 {
1538 $this->type = 'email';
1539 return $this;
1540 }
1541
1547 public function setAsUrl()
1548 {
1549 $this->type = 'url';
1550 return $this;
1551 }
1552
1558 public function setAsColor()
1559 {
1560 $this->type = 'color';
1561 return $this;
1562 }
1563
1569 public function setAsTextarea()
1570 {
1571 $this->type = 'textarea';
1572 return $this;
1573 }
1574
1580 public function setAsHtml()
1581 {
1582 $this->type = 'html';
1583 return $this;
1584 }
1585
1592 public function setAsEmailTemplate($templateType)
1593 {
1594 $this->type = 'emailtemplate:'.$templateType;
1595 return $this;
1596 }
1597
1603 public function setAsThirdpartyType()
1604 {
1605 $this->type = 'thirdparty_type';
1606 return $this;
1607 }
1608
1614 public function setAsYesNo()
1615 {
1616 $this->type = 'yesno';
1617 return $this;
1618 }
1619
1625 public function setAsSecureKey()
1626 {
1627 $this->type = 'securekey';
1628 return $this;
1629 }
1630
1636 public function setAsProduct()
1637 {
1638 $this->type = 'product';
1639 return $this;
1640 }
1641
1647 public function setAsPrice()
1648 {
1649 $this->type = 'price';
1650 return $this;
1651 }
1652
1660 public function setAsCategory($catType)
1661 {
1662 $this->type = 'category:'.$catType;
1663 return $this;
1664 }
1665
1671 public function setAsTitle()
1672 {
1673 $this->type = 'title';
1674 return $this;
1675 }
1676
1677
1684 public function setAsMultiSelect($fieldOptions)
1685 {
1686 if (is_array($fieldOptions)) {
1687 $this->fieldOptions = $fieldOptions;
1688 }
1689
1690 $this->type = 'multiselect';
1691 return $this;
1692 }
1693
1700 public function setAsSelect($fieldOptions)
1701 {
1702 if (is_array($fieldOptions)) {
1703 $this->fieldOptions = $fieldOptions;
1704 }
1705
1706 $this->type = 'select';
1707 return $this;
1708 }
1709
1710
1717 public function setAsRadio($fieldOptions)
1718 {
1719 if (is_array($fieldOptions)) {
1720 $this->fieldOptions = $fieldOptions;
1721 }
1722
1723 $this->type = 'radio';
1724 return $this;
1725 }
1726
1732 public function setAsSelectUser()
1733 {
1734 $this->type = 'selectUser';
1735 return $this;
1736 }
1737
1743 public function setAsSelectBankAccount()
1744 {
1745 $this->type = 'selectBankAccount';
1746 return $this;
1747 }
1748
1756 public function setAsPassword()
1757 {
1758 $this->type = 'password';
1759 return $this;
1760 }
1761
1769 public function setAsGenericPassword()
1770 {
1771 $this->type = 'genericpassword';
1772 return $this;
1773 }
1774}
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:331
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 permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new Form...
Class permettant la generation de composants html autre 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
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)
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.
dolGetBadge($label, $html='', $type='primary', $mode='', $url='', $params=array())
Function dolGetBadge.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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...
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:125
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Output javascript to autoset a generated password using default module into a HTML element.