38 public $items = array();
43 public $setupNotEmpty = 0;
52 protected $maxItemRank;
58 public $htmlBeforeOutputForm =
'';
64 public $htmlAfterOutputForm =
'';
70 public $htmlOutputMoreButton =
'';
76 public $htmlButtonLabel =
'Save';
81 public $formAttributes = array(
90 public $formHiddenInputs = array();
95 public $errors = array();
106 global
$conf, $langs;
110 $this->form =
new Form($this->db);
111 $this->formAttributes[
'action'] = $_SERVER[
"PHP_SELF"];
113 $this->formHiddenInputs[
'token'] =
newToken();
114 $this->formHiddenInputs[
'action'] =
'update';
116 $this->entity = (is_null($this->entity) ?
$conf->entity : $this->entity);
119 $this->langs = $outputLangs;
121 $this->langs = $langs;
134 if (is_array($attributes)) {
135 foreach ($attributes as $attribute => $value) {
136 if (is_array($value) || is_object($value)) {
143 return !empty($Aattr) ? implode(
' ', $Aattr) :
'';
156 public function generateOutput($editMode =
false, $hideTitle =
false, $title =
'', $cssfirstcolumn =
'')
158 global $hookmanager, $action;
160 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
163 'editMode' => $editMode
165 $reshook = $hookmanager->executeHooks(
'formSetupBeforeGenerateOutput', $parameters, $this, $action);
167 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
171 return $hookmanager->resPrint;
173 $out =
'<!-- Start generateOutput from FormSetup class -->';
174 $out .= $this->htmlBeforeOutputForm;
178 $out .=
'<input type="hidden" name="page_y" value="">';
181 if (!empty($this->formHiddenInputs) && is_array($this->formHiddenInputs)) {
182 foreach ($this->formHiddenInputs as $hiddenKey => $hiddenValue) {
183 $out .=
'<input type="hidden" name="'.dol_escape_htmltag($hiddenKey).
'" value="' .
dol_escape_htmltag($hiddenValue) .
'">';
192 $reshook = $hookmanager->executeHooks(
'formSetupBeforeGenerateOutputButton', $parameters, $this, $action);
194 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
198 return $hookmanager->resPrint;
199 } elseif ($editMode) {
200 $out .=
'<div class="form-setup-button-container center">';
201 $out .= $this->htmlOutputMoreButton;
202 if ($editMode !== 3) {
203 $out .=
'<input class="button button-save reposition" type="submit" value="' . $this->langs->trans($this->htmlButtonLabel ?:
"Save") .
'" name="save">';
205 if ($editMode === 2) {
207 $out .=
' ';
208 $out .=
'<input class="button button-cancel" type="submit" value="' . $this->langs->trans(
'Cancel') .
'" name="cancel">';
217 $out .= $this->htmlAfterOutputForm;
232 public function generateTableOutput($editMode =
false, $hideTitle =
false, $title =
'', $cssfirstcolumn =
'')
234 global $hookmanager, $action;
235 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
238 'editMode' => $editMode
240 $reshook = $hookmanager->executeHooks(
'formSetupBeforeGenerateTableOutput', $parameters, $this, $action);
242 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
246 return $hookmanager->resPrint;
248 $out =
'<div class="div-table-responsive-no-min">';
249 $out .=
'<table class="noborder centpercent">';
250 if (empty($hideTitle)) {
252 $title = $this->langs->transnoentitiesnoconv(
"Parameter");
255 $out .=
'<tr class="liste_titre">';
256 $out .=
' <td'.($cssfirstcolumn ?
' class="'.$cssfirstcolumn.
'"' :
'').
'>' . dolPrintHTML($title) .
'</td>';
257 $out .=
' <td></td>';
266 foreach ($this->items as $item) {
285 global $hookmanager,
$conf;
287 $parameters = array();
288 $reshook = $hookmanager->executeHooks(
'formSetupBeforeSaveConfFromPost', $parameters, $this);
290 $this->errors = $hookmanager->errors;
297 if (empty($this->items)) {
303 foreach ($this->items as $item) {
304 if ($item->getType() ==
'yesno' && !empty(
$conf->use_javascript_ajax)) {
308 $res = $item->setValueFromPost();
310 $item->saveConfValue();
311 } elseif ($res < 0) {
319 if (empty($noMessageInUpdate)) {
320 setEventMessages($this->langs->trans(
"SetupSaved"),
null);
324 $this->db->rollback();
325 if (empty($noMessageInUpdate)) {
326 setEventMessages($this->langs->trans(
"SetupNotSaved"),
null,
'errors');
342 if ($item->enabled == 1) {
343 $trClass =
'oddeven';
344 $tdOutputFieldClass =
'';
345 if ($item->getType() ==
'title') {
346 $trClass =
'liste_titre';
348 if (!empty($item->fieldParams[
'trClass'])) {
349 $trClass .=
' '.$item->fieldParams[
'trClass'];
351 if (!empty($item->fieldParams[
'tdOutputFieldClass'])) {
352 $tdOutputFieldClass .=
' class="'.$item->fieldParams[
'tdOutputFieldClass'].
'"';
355 $this->setupNotEmpty++;
358 'id' =>
'setup-line-item_'. preg_replace(
'/[^a-zA-Z_]/',
'', $item->confKey),
362 if ($item->getType() !==
'title') {
363 $tableLineAttr[
'data-conf-key'] = $item->confKey;
367 $out .=
'<tr '. implode(
' ', $tableLineAttrCompiled).
' >';
369 $out .=
'<td class="col-setup-title'.(!empty($item->fieldParams[
'isMandatory']) ?
' fieldrequired' :
'').
'">';
370 $out .=
'<span id="helplink'.$item->confKey.
'" class="spanforparamtooltip">';
371 $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'] :
''));
375 $out .=
'<td'.$tdOutputFieldClass.
'>';
378 $out .= $item->generateInputField();
380 $out .= $item->generateOutputField();
383 if (!empty($item->errors)) {
385 setEventMessages(
null, $item->errors,
'errors');
404 if (!is_array($params) || empty($params)) {
407 foreach ($params as $confKey => $param) {
424 if (empty($confKey) || empty($params[
'type'])) {
443 $item->setTypeFromTypeString((
string) $params[
'type']);
445 if (!empty($params[
'enabled']) && is_numeric($params[
'enabled'])) {
446 $item->enabled = (int) $params[
'enabled'];
449 if (!empty($params[
'css'])) {
450 $item->cssClass = (string) $params[
'css'];
453 $this->items[$item->confKey] = $item;
466 $arrayofparameters = array();
467 foreach ($this->items as $item) {
468 $arrayofparameters[$item->confKey] = array(
469 'type' => $item->getType(),
470 'enabled' => $item->enabled
474 return $arrayofparameters;
485 if (!array($this->items)) {
488 foreach ($this->items as $item) {
489 $item->loadValueFromConf();
505 public function newItem($confKey, $targetItemKey =
'', $insertAfterTarget =
false)
509 $item->entity = $this->entity;
512 if (empty($item->rank)) {
518 if (!empty($targetItemKey)) {
519 if (isset($this->items[$targetItemKey])) {
520 $targetItem = $this->items[$targetItemKey];
521 $item->rank = $targetItem->rank;
522 if ($targetItem->rank >= 0 && $insertAfterTarget) {
528 foreach ($this->items as $fItem) {
529 if ($item->rank <= $fItem->rank) {
536 $this->items[$item->confKey] = $item;
537 return $this->items[$item->confKey];
548 return uasort($this->items, array($this,
'itemSort'));
559 if (empty($this->items)) {
563 if ($cache && $this->maxItemRank > 0) {
564 return $this->maxItemRank;
567 $this->maxItemRank = 0;
568 foreach ($this->items as $item) {
569 $this->maxItemRank = max($this->maxItemRank, $item->rank);
572 return $this->maxItemRank;
584 $this->maxItemRank = max($this->maxItemRank, $rank);
596 if (!isset($this->items[$itemKey]->rank)) {
599 return $this->items[$itemKey]->rank;
612 if (empty($a->rank)) {
615 if (empty($b->rank)) {
618 if ($a->rank == $b->rank) {
621 return ($a->rank < $b->rank) ? -1 : 1;
650 public $nameText =
false;
653 public $helpText =
'';
662 public $defaultFieldValue =
null;
665 public $fieldAttr = array();
668 public $fieldOverride =
false;
671 public $fieldInputOverride =
false;
674 public $fieldInputCallBack;
677 public $fieldOutputOverride =
false;
680 public $fieldOutputCallBack;
686 public $fieldOptions = array();
689 public $fieldParams = array();
692 public $saveCallBack;
695 public $setValueFromPostCallBack;
700 public $errors = array();
708 protected $type =
'string';
717 public $cssClass =
'';
727 global $langs, $db,
$conf, $form;
730 if (!empty($form) && is_object($form) && get_class($form) ==
'Form') {
733 $this->form =
new Form($this->db);
736 $this->langs = $langs;
737 $this->entity = (is_null($this->entity) ?
$conf->entity : ((int) $this->entity));
739 $this->confKey = $confKey;
751 if (isset(
$conf->global->{$this->confKey})) {
755 $this->fieldValue =
null;
768 return $this->loadValueFromConf();
781 $parameters = array();
782 $reshook = $hookmanager->executeHooks(
'formSetupBeforeSaveConfValue', $parameters, $this);
784 $this->setErrors($hookmanager->errors);
792 if ($this->saveCallBack !==
null && is_callable($this->saveCallBack)) {
793 return call_user_func($this->saveCallBack, $this);
797 if ($this->
type !=
'title') {
798 $result =
dolibarr_set_const($this->db, $this->confKey, $this->fieldValue,
'chaine', 0,
'', $this->entity);
817 $this->saveCallBack = $callBack;
828 $this->setValueFromPostCallBack = $callBack;
838 if ($this->setValueFromPostCallBack !==
null && is_callable($this->setValueFromPostCallBack)) {
839 return call_user_func($this->setValueFromPostCallBack);
848 if ($this->
type !=
'title') {
849 if (preg_match(
'/category:/', $this->
type)) {
855 } elseif ($this->
type ==
'multiselect') {
856 $val =
GETPOST($this->confKey,
'array');
857 if ($val && is_array($val)) {
858 $val_const = implode(
',', $val);
862 } elseif ($this->
type ==
'html') {
863 $val_const =
GETPOST($this->confKey,
'restricthtml');
864 } elseif ($this->
type ==
'email') {
865 $val_const =
GETPOST($this->confKey,
'alphawithlgt');
866 } elseif ($this->
type ==
'number') {
868 } elseif ($this->
type ==
'password' || $this->
type ==
'genericpassword') {
869 $val_const =
GETPOST($this->confKey,
'password');
871 $val_const =
GETPOST($this->confKey,
'alphanohtml');
875 $this->fieldValue = $val_const;
890 if (!empty($this->helpText)) {
891 return $this->helpText;
893 return (($this->langs->trans($this->confKey .
'Tooltip') != $this->confKey .
'Tooltip') ? $this->langs->trans($this->confKey .
'Tooltip') :
'');
903 if (!empty($this->nameText)) {
904 return $this->nameText;
906 $out = (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans(
'MissingTranslationForConfKey', $this->confKey));
909 if (
isModEnabled(
'multicompany') && $this->entity == 0) {
910 $out = img_picto($this->langs->trans(
'AllEntities'),
'fa-globe-americas em088 opacityhigh') .
' ' . $out;
928 if (!empty($resCallback)) {
933 if (!empty($this->fieldOverride)) {
934 return $this->fieldOverride;
937 if (!empty($this->fieldInputOverride)) {
938 return $this->fieldInputOverride;
942 if (is_null($this->fieldValue)) {
943 $this->fieldValue = $this->defaultFieldValue;
947 $this->fieldAttr[
'name'] = $this->confKey;
948 $this->fieldAttr[
'id'] =
'setup-'.$this->confKey;
949 $this->fieldAttr[
'value'] = $this->fieldValue;
953 if ($this->
type ==
'title') {
954 $out .= $this->generateOutputField();
955 } elseif ($this->
type ==
'multiselect') {
956 $out .= $this->generateInputFieldMultiSelect();
957 } elseif ($this->
type ==
'select') {
958 $out .= $this->generateInputFieldSelect();
959 } elseif ($this->
type ==
'radio') {
960 $out .= $this->generateInputFieldRadio();
961 } elseif ($this->
type ==
'selectUser') {
962 $out .= $this->generateInputFieldSelectUser();
963 } elseif ($this->
type ==
'textarea') {
964 $out .= $this->generateInputFieldTextarea();
965 } elseif ($this->
type ==
'html') {
966 $out .= $this->generateInputFieldHtml();
967 } elseif ($this->
type ==
'color') {
968 $out .= $this->generateInputFieldColor();
969 } elseif ($this->
type ==
'yesno') {
970 if (!empty(
$conf->use_javascript_ajax)) {
971 $input = $this->fieldParams[
'input'] ?? array();
972 $revertonoff = empty($this->fieldParams[
'revertonoff']) ? 0 : 1;
973 $forcereload = empty($this->fieldParams[
'forcereload']) ? 0 : 1;
974 $suffixarray = array(
978 if (!empty($this->fieldParams[
'alertifoff'])) {
979 $suffixarray[
'ifoff'] =
'_red';
980 } elseif (!empty($this->fieldParams[
'warningifoff'])) {
981 $suffixarray[
'ifoff'] =
'_warning';
983 if (!empty($this->fieldParams[
'alertifon'])) {
984 $suffixarray[
'ifon'] =
'_red';
985 } elseif (!empty($this->fieldParams[
'warningifon'])) {
986 $suffixarray[
'ifon'] =
'_warning';
989 $out .= ajax_constantonoff($this->confKey, $input, $this->entity, $revertonoff, 0, $forcereload, 2, 0, 0, $suffixarray,
'', $this->cssClass);
991 $out .= $this->form->selectyesno($this->confKey, $this->fieldValue, 1,
false, 0, 0, $this->cssClass);
993 } elseif (preg_match(
'/emailtemplate:/', $this->
type)) {
994 $out .= $this->generateInputFieldEmailTemplate();
995 } elseif (preg_match(
'/category:/', $this->
type)) {
996 $out .= $this->generateInputFieldCategories();
997 } elseif (preg_match(
'/thirdparty_type/', $this->
type)) {
998 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
1000 $out .= $formcompany->selectProspectCustomerType($this->fieldValue, $this->confKey);
1001 } elseif ($this->
type ==
'securekey') {
1002 $out .= $this->generateInputFieldSecureKey();
1003 } elseif ($this->
type ==
'product') {
1005 $selected = (empty($this->fieldValue) ?
'' : $this->fieldValue);
1006 $out .= img_picto(
'',
'product',
'class="pictofixedwidth"');
1007 $out .= $this->form->select_produits((
int) $selected, $this->confKey,
'', 0, 0, 1, 2,
'', 0, array(), 0,
'1', 0, $this->cssClass, 0,
'',
null, 1);
1009 } elseif ($this->
type ==
'selectBankAccount') {
1011 $selected = (empty($this->fieldValue) ?
'' : $this->fieldValue);
1012 $out .= img_picto(
'',
'bank',
'class="pictofixedwidth"').$this->form->select_comptes($selected, $this->confKey, 0,
'', 0,
'', 0,
'', 1);
1014 } elseif ($this->
type ==
'password') {
1015 $out .= $this->generateInputFieldPassword(
'dolibarr');
1016 } elseif ($this->
type ==
'genericpassword') {
1017 $out .= $this->generateInputFieldPassword(
'generic', 0, 0);
1018 } elseif ($this->
type ==
'price') {
1019 $out .= $this->generateInputFieldPrice();
1020 } elseif ($this->
type ==
'email') {
1021 $out .= $this->generateInputFieldEmail();
1022 } elseif ($this->
type ==
'url') {
1023 $out .= $this->generateInputFieldUrl();
1025 $out .= $this->generateInputFieldText();
1038 if (empty($this->fieldAttr) || empty($this->fieldAttr[
'class'])) {
1039 $this->fieldAttr[
'class'] =
'flat '.(empty($this->cssClass) ?
'minwidth200' : $this->cssClass);
1041 return '<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).
' spellcheck="false">';
1053 if (empty($this->fieldAttr) || empty($this->fieldAttr[
'class'])) {
1054 $this->fieldAttr[
'class'] =
'flat '.(empty($this->cssClass) ?
'minwidth40 maxwidth75' : $this->cssClass);
1057 return '<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).
' spellcheck="false"> '.$langs->getCurrencySymbol(
$mysoc->currency_code);
1067 if (empty($this->fieldAttr) || empty($this->fieldAttr[
'class'])) {
1068 $this->fieldAttr[
'class'] =
'flat '.(empty($this->cssClass) ?
'minwidth100 maxwidth500' : $this->cssClass);
1080 if (empty($this->fieldAttr) || empty($this->fieldAttr[
'class'])) {
1081 $this->fieldAttr[
'class'] =
'flat '.(empty($this->cssClass) ?
'minwidth100 maxwidth500' : $this->cssClass);
1093 $out =
'<textarea class="flat" name="'.$this->confKey.
'" id="'.$this->confKey.
'" cols="50" rows="5" wrap="soft" spellcheck="false">' .
"\n";
1095 $out .=
"</textarea>\n";
1106 require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
1107 $doleditor =
new DolEditor($this->confKey, $this->fieldValue,
'', 160,
'dolibarr_notes',
'',
false,
false,
isModEnabled(
'fckeditor'), ROWS_5,
'90%');
1108 return $doleditor->Create(1);
1118 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1119 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
1122 $tmp = explode(
':', $this->
type);
1123 $out = img_picto(
'',
'category',
'class="pictofixedwidth"');
1125 $label =
'Categories';
1126 if ($this->
type ==
'customer') {
1127 $label =
'CustomersProspectsCategoriesShort';
1129 $out .= $formother->select_categories($tmp[1], (
int) $this->fieldValue, $this->confKey, 0, $this->langs->trans($label));
1143 if (preg_match(
'/emailtemplate:/', $this->
type)) {
1144 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
1145 $formmail =
new FormMail($this->db);
1147 $tmp = explode(
':', $this->
type);
1148 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, 1);
1149 $arrayOfMessageName = array();
1150 if (is_array($formmail->lines_model)) {
1151 foreach ($formmail->lines_model as $modelMail) {
1153 if (!empty($arrayOfMessageName[$modelMail->label])) {
1154 $moreonlabel =
' <span class="opacitymedium">(' . $this->langs->trans(
"SeveralLangugeVariatFound") .
')</span>';
1157 $arrayOfMessageName[$modelMail->id] = $this->langs->trans(preg_replace(
'/\(|\)/',
'', $modelMail->label)) . $moreonlabel;
1160 $out .= $this->form->selectarray($this->confKey, $arrayOfMessageName, $this->fieldValue,
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
1175 $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).
'">';
1177 if (!empty(
$conf->use_javascript_ajax) && empty($this->fieldParams[
'hideGenerateButton'])) {
1178 $out .=
' '.img_picto($this->langs->trans(
'Generate'),
'refresh',
'id="generate_token'.$this->confKey.
'" class="linkobject"');
1181 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1186 if (!empty(
$conf->use_javascript_ajax) && !empty($this->fieldParams[
'showEyeButton'])) {
1187 $out .=
'<span class="fa fa-eye paddingleft paddingright cursorpointer pictofixedwidth" title="'.dolPrintHTMLForAttribute($this->langs->trans(
'Show')).
'" onclick="jQuery(\'#'.trim($this->confKey).
'\').toggleClass(\
'text-security\'); jQuery(this).toggleClass(\'fa-eye fa-eye-slash\');"></span>';
1204 global
$conf, $langs, $user;
1208 if ($type ==
'dolibarr') {
1210 if ($gen ==
'none') {
1213 require_once DOL_DOCUMENT_ROOT.
"/core/modules/security/generate/modules_genpassword.php";
1216 $min = $genhandler->length;
1217 $max = $genhandler->length2;
1220 $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).
'"';
1222 $out .=
' minlength="' . $min .
'"';
1225 $out .=
' maxlength="' . $max .
'"';
1229 $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>';
1243 $TSelected = array();
1244 if ($this->fieldValue) {
1245 $TSelected = explode(
',', $this->fieldValue);
1248 $out = $this->form->multiselectarray($this->confKey, $this->fieldOptions, $TSelected, 0, 0,
'', 0, 0,
'style="min-width:100px"');
1250 $out .=
'<input type="hidden" name="'.dol_escape_htmltag($this->confKey).
'_multiselect" value="1">';
1264 $s .= img_picto(
'', $this->picto,
'class="pictofixedwidth"');
1267 $s .= $this->form->selectarray($this->confKey, $this->fieldOptions, $this->fieldValue, 0, 0, 0,
'', 0, 0, 0,
'', $this->cssClass);
1281 $s .= img_picto(
'', $this->picto,
'class="pictofixedwidth"');
1284 $s .= $this->form->radio($this->confKey, $this->fieldOptions, $this->fieldValue, [
'attrLabel' => [
'class' => $this->cssClass]]);
1294 return $this->form->select_dolusers($this->fieldValue, $this->confKey);
1320 $this->
type = $type;
1333 if (is_array($errors)) {
1334 if (!empty($errors)) {
1335 foreach ($errors as $error) {
1336 $this->setErrors($error);
1339 } elseif (!empty($errors)) {
1340 $this->errors[] = $errors;
1352 global
$conf, $user, $langs;
1354 if ($this->fieldOutputCallBack !==
null && is_callable($this->fieldOutputCallBack)) {
1356 $resCallback = call_user_func($this->fieldOutputCallBack, $this);
1357 if (!empty($resCallback)) {
1358 return $resCallback;
1362 if (!empty($this->fieldOverride)) {
1363 return $this->fieldOverride;
1366 if (!empty($this->fieldOutputOverride)) {
1367 return $this->fieldOutputOverride;
1372 if ($this->
type ==
'title') {
1374 } elseif ($this->
type ==
'textarea') {
1376 } elseif ($this->
type ==
'multiselect') {
1377 $out .= $this->generateOutputFieldMultiSelect();
1378 } elseif ($this->
type ==
'select') {
1379 $out .= $this->generateOutputFieldSelect();
1380 } elseif ($this->
type ==
'selectUser') {
1381 $out .= $this->generateOutputFieldSelectUser();
1382 } elseif ($this->
type ==
'html') {
1383 $out .= $this->fieldValue;
1384 } elseif ($this->
type ==
'color') {
1385 $out .= $this->generateOutputFieldColor();
1386 } elseif ($this->
type ==
'yesno') {
1387 if (!empty(
$conf->use_javascript_ajax)) {
1388 $revertonoff = empty($this->fieldParams[
'revertonoff']) ? 0 : 1;
1389 $forcereload = empty($this->fieldParams[
'forcereload']) ? 0 : 1;
1391 $out .= ajax_constantonoff($this->confKey, array(), $this->entity, $revertonoff, 0, $forcereload, 2, 0, 0,
'',
'', $this->cssClass);
1393 if ($this->fieldValue == 1) {
1394 $out .= $langs->trans(
'yes');
1396 $out .= $langs->trans(
'no');
1399 } elseif (preg_match(
'/emailtemplate:/', $this->
type)) {
1400 if ($this->fieldValue > 0) {
1401 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
1402 $formmail =
new FormMail($this->db);
1404 $tmp = explode(
':', $this->
type);
1406 $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, (
int) $this->fieldValue);
1407 if (is_numeric($template) && $template < 0) {
1408 $this->setErrors($formmail->errors);
1410 $out .= $this->langs->trans($template->label);
1412 } elseif (preg_match(
'/category:/', $this->
type)) {
1413 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1415 $result =
$c->fetch((
int) $this->fieldValue);
1417 $this->setErrors(
$c->errors);
1419 $ways =
$c->print_all_ways(
'auto',
'none', 0, 1);
1421 foreach ($ways as $way) {
1422 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . (
$c->color ?
' style="background: #' .
$c->color .
';"' :
' style="background: #bbb"') .
'>' . $way .
'</li>';
1424 $out .=
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
1425 } elseif (preg_match(
'/thirdparty_type/', $this->
type)) {
1426 if ($this->fieldValue == 2) {
1427 $out .= $this->langs->trans(
"Prospect");
1428 } elseif ($this->fieldValue == 3) {
1429 $out .= $this->langs->trans(
"ProspectCustomer");
1430 } elseif ($this->fieldValue == 1) {
1431 $out .= $this->langs->trans(
"Customer");
1432 } elseif ($this->fieldValue == 0) {
1433 $out .= $this->langs->trans(
"NorProspectNorCustomer");
1435 } elseif ($this->
type ==
'product') {
1436 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1438 $product =
new Product($this->db);
1439 $resprod = $product->fetch((
int) $this->fieldValue);
1441 $out .= $product->getNomUrl(1,
'', 0, -1, 0,
'', 1);
1442 } elseif ($resprod < 0) {
1443 $this->setErrors($product->errors);
1445 } elseif ($this->
type ==
'selectBankAccount') {
1446 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1448 $bankaccount =
new Account($this->db);
1449 $resbank = $bankaccount->fetch((
int) $this->fieldValue);
1451 $out .= $bankaccount->label;
1452 } elseif ($resbank < 0) {
1453 $this->setErrors($bankaccount->errors);
1455 } elseif ($this->
type ==
'password' || $this->
type ==
'genericpassword') {
1456 $out .= str_repeat(
'*', strlen($this->fieldValue));
1458 $out .= dolPrintHTML($this->fieldValue);
1473 $TSelected = array();
1474 if (!empty($this->fieldValue)) {
1475 $TSelected = explode(
',', $this->fieldValue);
1478 if (!empty($TSelected)) {
1479 foreach ($TSelected as $selected) {
1480 if (!empty($this->fieldOptions[$selected])) {
1481 $outPut .= dolGetBadge(
'', $this->fieldOptions[$selected],
'info').
' ';
1497 $this->fieldAttr[
'disabled'] =
null;
1499 $useDefaultColor =
false;
1500 if (!$color && !empty($this->defaultFieldValue)) {
1501 $color = $this->defaultFieldValue;
1502 $useDefaultColor =
true;
1505 $out .=
'<input type="color" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; " value="#'.$color.
'">';
1508 if ($useDefaultColor) {
1509 $out .=
' '.$langs->trans(
"Default");
1511 $out .=
' #'.$color;
1523 $this->fieldAttr[
'type'] =
'color';
1524 $default = $this->defaultFieldValue;
1525 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
1527 return $formother->selectColor(
colorArrayToHex(
colorStringToArray((
string) $this->fieldAttr[
'value'], array()),
''), $this->fieldAttr[
'name'],
'', 1, array(),
'',
'', (
string) $default).
' ';
1538 if (!empty($this->fieldOptions[$this->fieldValue])) {
1539 $outPut = $this->fieldOptions[$this->fieldValue];
1553 $user =
new User($this->db);
1554 $user->fetch((
int) $this->fieldValue);
1555 $outPut = $user->firstname .
" " . $user->lastname;
1570 $this->
type =
'string';
1584 $this->
type =
'number';
1585 $this->fieldAttr[
'type'] =
'number';
1586 if (!is_null($min)) {
1587 $this->fieldAttr[
'min'] = $min;
1589 if (!is_null($max)) {
1590 $this->fieldAttr[
'max'] = $max;
1592 if (!is_null($step)) {
1593 $this->fieldAttr[
'step'] = $step;
1606 $this->
type =
'email';
1617 $this->
type =
'url';
1628 $this->
type =
'color';
1639 $this->
type =
'textarea';
1650 $this->
type =
'html';
1662 $this->
type =
'emailtemplate:'.$templateType;
1673 $this->
type =
'thirdparty_type';
1684 $this->
type =
'yesno';
1695 $this->
type =
'securekey';
1706 $this->
type =
'product';
1717 $this->
type =
'price';
1730 $this->
type =
'category:'.$catType;
1741 $this->
type =
'title';
1754 if (is_array($fieldOptions)) {
1755 $this->fieldOptions = $fieldOptions;
1758 $this->
type =
'multiselect';
1770 if (is_array($fieldOptions)) {
1771 $this->fieldOptions = $fieldOptions;
1774 $this->
type =
'select';
1787 if (is_array($fieldOptions)) {
1788 $this->fieldOptions = $fieldOptions;
1791 $this->
type =
'radio';
1802 $this->
type =
'selectUser';
1813 $this->
type =
'selectBankAccount';
1826 $this->
type =
'password';
1839 $this->
type =
'genericpassword';
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
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).
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage bank accounts.
Class to manage categories.
Class to manage a WYSIWYG editor.
static loadAndInstantiate($id, $db, $conf, $langs, $user)
Locate, load and instantiate a password generator/validator model by its id (the value stored in USER...
Class to manage products or services.
Class to manage Dolibarr users.
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,...
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
commonHtmlAttributeBuilder($attr, array $unescapedAttr=[])
Builds an array of safe and properly escaped HTML attributes from a key-value pair list.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
$item fieldInputCallBack
Callback used to generate the custom HTML input field.
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Output javascript to autoset a generated password using default module into a HTML element.