35 public $items = array();
40 public $setupNotEmpty = 0;
49 protected $maxItemRank;
55 public $htmlBeforeOutputForm =
'';
61 public $htmlAfterOutputForm =
'';
67 public $htmlOutputMoreButton =
'';
73 public $htmlButtonLabel =
'Save';
78 public $formAttributes = array(
87 public $formHiddenInputs = array();
92 public $errors = array();
103 global $conf, $langs;
107 $this->form =
new Form($this->db);
108 $this->formAttributes[
'action'] = $_SERVER[
"PHP_SELF"];
110 $this->formHiddenInputs[
'token'] =
newToken();
111 $this->formHiddenInputs[
'action'] =
'update';
113 $this->entity = (is_null($this->entity) ? $conf->entity : $this->entity);
116 $this->langs = $outputLangs;
118 $this->langs = $langs;
131 if (is_array($attributes)) {
132 foreach ($attributes as $attribute => $value) {
133 if (is_array($value) || is_object($value)) {
140 return !empty($Aattr) ? implode(
' ', $Aattr) :
'';
153 public function generateOutput($editMode =
false, $hideTitle =
false, $title =
'', $cssfirstcolumn =
'')
155 global $hookmanager, $action;
157 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
160 'editMode' => $editMode
162 $reshook = $hookmanager->executeHooks(
'formSetupBeforeGenerateOutput', $parameters, $this, $action);
168 return $hookmanager->resPrint;
170 $out =
'<!-- Start generateOutput from FormSetup class -->';
171 $out .= $this->htmlBeforeOutputForm;
175 $out .=
'<input type="hidden" name="page_y" value="">';
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) .
'">';
189 $reshook = $hookmanager->executeHooks(
'formSetupBeforeGenerateOutputButton', $parameters, $this, $action);
195 return $hookmanager->resPrint;
196 } elseif ($editMode) {
197 $out .=
'<div class="form-setup-button-container center">';
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">';
202 if ($editMode === 2) {
204 $out .=
' ';
205 $out .=
'<input class="button button-cancel" type="submit" value="' . $this->langs->trans(
'Cancel') .
'" name="cancel">';
214 $out .= $this->htmlAfterOutputForm;
229 public function generateTableOutput($editMode =
false, $hideTitle =
false, $title =
'', $cssfirstcolumn =
'')
231 global $hookmanager, $action;
232 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
235 'editMode' => $editMode
237 $reshook = $hookmanager->executeHooks(
'formSetupBeforeGenerateTableOutput', $parameters, $this, $action);
243 return $hookmanager->resPrint;
245 $out =
'<div class="div-table-responsive-no-min">';
246 $out .=
'<table class="noborder centpercent">';
247 if (empty($hideTitle)) {
249 $title = $this->langs->transnoentitiesnoconv(
"Parameter");
252 $out .=
'<tr class="liste_titre">';
253 $out .=
' <td'.($cssfirstcolumn ?
' class="'.$cssfirstcolumn.
'"' :
'').
'>' .
dolPrintHTML($title) .
'</td>';
254 $out .=
' <td></td>';
263 foreach ($this->items as $item) {
282 global $hookmanager, $conf;
284 $parameters = array();
285 $reshook = $hookmanager->executeHooks(
'formSetupBeforeSaveConfFromPost', $parameters, $this);
287 $this->errors = $hookmanager->errors;
294 if (empty($this->items)) {
300 foreach ($this->items as $item) {
301 if ($item->getType() ==
'yesno' && !empty($conf->use_javascript_ajax)) {
305 $res = $item->setValueFromPost();
307 $item->saveConfValue();
308 } elseif ($res < 0) {
316 if (empty($noMessageInUpdate)) {
321 $this->db->rollback();
322 if (empty($noMessageInUpdate)) {
339 if ($item->enabled == 1) {
340 $trClass =
'oddeven';
341 if ($item->getType() ==
'title') {
342 $trClass =
'liste_titre';
344 if (!empty($item->fieldParams[
'trClass'])) {
345 $trClass .=
' '.$item->fieldParams[
'trClass'];
348 $this->setupNotEmpty++;
349 $out .=
'<tr class="'.$trClass.
'">';
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'] :
''));
360 $out .= $item->generateInputField();
362 $out .= $item->generateOutputField();
365 if (!empty($item->errors)) {
386 if (!is_array($params) || empty($params)) {
389 foreach ($params as $confKey => $param) {
406 if (empty($confKey) || empty($params[
'type'])) {
425 $item->setTypeFromTypeString((
string) $params[
'type']);
427 if (!empty($params[
'enabled']) && is_numeric($params[
'enabled'])) {
428 $item->enabled = (int) $params[
'enabled'];
431 if (!empty($params[
'css'])) {
432 $item->cssClass = (string) $params[
'css'];
435 $this->items[$item->confKey] = $item;
448 $arrayofparameters = array();
449 foreach ($this->items as $item) {
450 $arrayofparameters[$item->confKey] = array(
451 'type' => $item->getType(),
452 'enabled' => $item->enabled
456 return $arrayofparameters;
467 if (!array($this->items)) {
470 foreach ($this->items as $item) {
471 $item->loadValueFromConf();
487 public function newItem($confKey, $targetItemKey =
'', $insertAfterTarget =
false)
491 $item->entity = $this->entity;
494 if (empty($item->rank)) {
500 if (!empty($targetItemKey)) {
501 if (isset($this->items[$targetItemKey])) {
502 $targetItem = $this->items[$targetItemKey];
503 $item->rank = $targetItem->rank;
504 if ($targetItem->rank >= 0 && $insertAfterTarget) {
510 foreach ($this->items as $fItem) {
511 if ($item->rank <= $fItem->rank) {
518 $this->items[$item->confKey] = $item;
519 return $this->items[$item->confKey];
530 return uasort($this->items, array($this,
'itemSort'));
541 if (empty($this->items)) {
545 if ($cache && $this->maxItemRank > 0) {
546 return $this->maxItemRank;
549 $this->maxItemRank = 0;
550 foreach ($this->items as $item) {
551 $this->maxItemRank = max($this->maxItemRank, $item->rank);
554 return $this->maxItemRank;
566 $this->maxItemRank = max($this->maxItemRank, $rank);
578 if (!isset($this->items[$itemKey]->rank)) {
581 return $this->items[$itemKey]->rank;
594 if (empty($a->rank)) {
597 if (empty($b->rank)) {
600 if ($a->rank == $b->rank) {
603 return ($a->rank < $b->rank) ? -1 : 1;
632 public $nameText =
false;
635 public $helpText =
'';
644 public $defaultFieldValue =
null;
647 public $fieldAttr = array();
650 public $fieldOverride =
false;
653 public $fieldInputOverride =
false;
656 public $fieldOutputOverride =
false;
662 public $fieldOptions = array();
665 public $fieldParams = array();
668 public $saveCallBack;
671 public $setValueFromPostCallBack;
676 public $errors = array();
684 protected $type =
'string';
693 public $cssClass =
'';
703 global $langs, $db, $conf, $form;
706 if (!empty($form) && is_object($form) && get_class($form) ==
'Form') {
709 $this->form =
new Form($this->db);
712 $this->langs = $langs;
713 $this->entity = (is_null($this->entity) ? $conf->entity : ((int) $this->entity));
715 $this->confKey = $confKey;
727 if (isset($conf->global->{$this->confKey})) {
731 $this->fieldValue =
null;
744 return $this->loadValueFromConf();
757 $parameters = array();
758 $reshook = $hookmanager->executeHooks(
'formSetupBeforeSaveConfValue', $parameters, $this);
760 $this->setErrors($hookmanager->errors);
769 if (!empty($this->saveCallBack) && is_callable($this->saveCallBack)) {
770 return call_user_func($this->saveCallBack, $this);
774 if ($this->
type !=
'title') {
775 $result =
dolibarr_set_const($this->db, $this->confKey, $this->fieldValue,
'chaine', 0,
'', $this->entity);
794 $this->saveCallBack = $callBack;
805 $this->setValueFromPostCallBack = $callBack;
815 if (!empty($this->setValueFromPostCallBack) && is_callable($this->setValueFromPostCallBack)) {
816 return call_user_func($this->setValueFromPostCallBack);
820 if ($this->
type !=
'title') {
821 if (preg_match(
'/category:/', $this->
type)) {
827 } elseif ($this->
type ==
'multiselect') {
828 $val =
GETPOST($this->confKey,
'array');
829 if ($val && is_array($val)) {
830 $val_const = implode(
',', $val);
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') {
841 $val_const =
GETPOST($this->confKey,
'alphanohtml');
845 $this->fieldValue = $val_const;
860 if (!empty($this->helpText)) {
861 return $this->helpText;
863 return (($this->langs->trans($this->confKey .
'Tooltip') != $this->confKey .
'Tooltip') ? $this->langs->trans($this->confKey .
'Tooltip') :
'');
873 if (!empty($this->nameText)) {
874 return $this->nameText;
876 $out = (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans(
'MissingTranslationForConfKey', $this->confKey));
879 if (
isModEnabled(
'multicompany') && $this->entity == 0) {
880 $out =
img_picto($this->langs->trans(
'AllEntities'),
'fa-globe-americas em088 opacityhigh') .
' ' . $out;
895 if (!empty($this->fieldOverride)) {
896 return $this->fieldOverride;
899 if (!empty($this->fieldInputOverride)) {
900 return $this->fieldInputOverride;
904 if (is_null($this->fieldValue)) {
905 $this->fieldValue = $this->defaultFieldValue;
909 $this->fieldAttr[
'name'] = $this->confKey;
910 $this->fieldAttr[
'id'] =
'setup-'.$this->confKey;
911 $this->fieldAttr[
'value'] = $this->fieldValue;
915 if ($this->
type ==
'title') {
916 $out .= $this->generateOutputField();
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');
938 $out .= ajax_constantonoff($this->confKey, $input, $this->entity, $revertonoff, 0, $forcereload, 2, 0, 0, $suffixarray,
'', $this->cssClass);
940 $out .= $this->form->selectyesno($this->confKey, $this->fieldValue, 1,
false, 0, 0, $this->cssClass);
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';
949 $out .= $formcompany->selectProspectCustomerType($this->fieldValue, $this->confKey);
950 } elseif ($this->
type ==
'securekey') {
951 $out .= $this->generateInputFieldSecureKey();
952 } elseif ($this->
type ==
'product') {
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);
958 } elseif ($this->
type ==
'selectBankAccount') {
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);
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();
974 $out .= $this->generateInputFieldText();
987 if (empty($this->fieldAttr) || empty($this->fieldAttr[
'class'])) {
988 $this->fieldAttr[
'class'] =
'flat '.(empty($this->cssClass) ?
'minwidth200' : $this->cssClass);
990 return '<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).
' />';
1002 if (empty($this->fieldAttr) || empty($this->fieldAttr[
'class'])) {
1003 $this->fieldAttr[
'class'] =
'flat '.(empty($this->cssClass) ?
'minwidth40 maxwidth75' : $this->cssClass);
1006 return '<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).
' /> '.$langs->getCurrencySymbol(
$mysoc->currency_code);
1016 if (empty($this->fieldAttr) || empty($this->fieldAttr[
'class'])) {
1017 $this->fieldAttr[
'class'] =
'flat '.(empty($this->cssClass) ?
'minwidth100 maxwidth500' : $this->cssClass);
1029 if (empty($this->fieldAttr) || empty($this->fieldAttr[
'class'])) {
1030 $this->fieldAttr[
'class'] =
'flat '.(empty($this->cssClass) ?
'minwidth100 maxwidth500' : $this->cssClass);
1042 $out =
'<textarea class="flat" name="'.$this->confKey.
'" id="'.$this->confKey.
'" cols="50" rows="5" wrap="soft">' .
"\n";
1044 $out .=
"</textarea>\n";
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);
1067 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1068 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
1071 $tmp = explode(
':', $this->
type);
1072 $out =
img_picto(
'',
'category',
'class="pictofixedwidth"');
1074 $label =
'Categories';
1075 if ($this->
type ==
'customer') {
1076 $label =
'CustomersProspectsCategoriesShort';
1078 $out .= $formother->select_categories($tmp[1], (
int) $this->fieldValue, $this->confKey, 0, $this->langs->trans($label));
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);
1096 $tmp = explode(
':', $this->
type);
1097 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, 1);
1098 $arrayOfMessageName = array();
1099 if (is_array($formmail->lines_model)) {
1100 foreach ($formmail->lines_model as $modelMail) {
1102 if (!empty($arrayOfMessageName[$modelMail->label])) {
1103 $moreonlabel =
' <span class="opacitymedium">(' . $this->langs->trans(
"SeveralLangugeVariatFound") .
')</span>';
1106 $arrayOfMessageName[$modelMail->id] = $this->langs->trans(preg_replace(
'/\(|\)/',
'', $modelMail->label)) . $moreonlabel;
1109 $out .= $this->form->selectarray($this->confKey, $arrayOfMessageName, $this->fieldValue,
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
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).
'">';
1126 if (!empty($conf->use_javascript_ajax) && empty($this->fieldParams[
'hideGenerateButton'])) {
1127 $out .=
' '.img_picto($this->langs->trans(
'Generate'),
'refresh',
'id="generate_token'.$this->confKey.
'" class="linkobject"');
1130 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1148 global $conf, $langs, $user;
1152 if ($type ==
'dolibarr') {
1154 if ($gen ==
'none') {
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;
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).
'"';
1166 $out .=
' minlength="' . $min .
'"';
1169 $out .=
' maxlength="' . $max .
'"';
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>';
1187 $TSelected = array();
1188 if ($this->fieldValue) {
1189 $TSelected = explode(
',', $this->fieldValue);
1192 return $this->form->multiselectarray($this->confKey, $this->fieldOptions, $TSelected, 0, 0,
'', 0, 0,
'style="min-width:100px"');
1204 $s .=
img_picto(
'', $this->picto,
'class="pictofixedwidth"');
1207 $s .= $this->form->selectarray($this->confKey, $this->fieldOptions, $this->fieldValue, 0, 0, 0,
'', 0, 0, 0,
'', $this->cssClass);
1221 $s .=
img_picto(
'', $this->picto,
'class="pictofixedwidth"');
1224 $s .= $this->form->radio($this->confKey, $this->fieldOptions, $this->fieldValue, [
'attrLabel' => [
'class' => $this->cssClass]]);
1234 return $this->form->select_dolusers($this->fieldValue, $this->confKey);
1260 $this->
type = $type;
1273 if (is_array($errors)) {
1274 if (!empty($errors)) {
1275 foreach ($errors as $error) {
1276 $this->setErrors($error);
1279 } elseif (!empty($errors)) {
1280 $this->errors[] = $errors;
1292 global $conf, $user, $langs;
1294 if (!empty($this->fieldOverride)) {
1295 return $this->fieldOverride;
1298 if (!empty($this->fieldOutputOverride)) {
1299 return $this->fieldOutputOverride;
1304 if ($this->
type ==
'title') {
1306 } elseif ($this->
type ==
'textarea') {
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;
1323 $out .= ajax_constantonoff($this->confKey, array(), $this->entity, $revertonoff, 0, $forcereload, 2, 0, 0,
'',
'', $this->cssClass);
1325 if ($this->fieldValue == 1) {
1326 $out .= $langs->trans(
'yes');
1328 $out .= $langs->trans(
'no');
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);
1336 $tmp = explode(
':', $this->
type);
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);
1342 $out .= $this->langs->trans($template->label);
1344 } elseif (preg_match(
'/category:/', $this->
type)) {
1345 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1347 $result =
$c->fetch((
int) $this->fieldValue);
1349 $this->setErrors(
$c->errors);
1351 $ways =
$c->print_all_ways(
'auto',
'none', 0, 1);
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>';
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");
1367 } elseif ($this->
type ==
'product') {
1368 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1370 $product =
new Product($this->db);
1371 $resprod = $product->fetch((
int) $this->fieldValue);
1373 $out .= $product->getNomUrl(1,
'', 0, -1, 0,
'', 1);
1374 } elseif ($resprod < 0) {
1375 $this->setErrors($product->errors);
1377 } elseif ($this->
type ==
'selectBankAccount') {
1378 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1380 $bankaccount =
new Account($this->db);
1381 $resbank = $bankaccount->fetch((
int) $this->fieldValue);
1383 $out .= $bankaccount->label;
1384 } elseif ($resbank < 0) {
1385 $this->setErrors($bankaccount->errors);
1387 } elseif ($this->
type ==
'password' || $this->
type ==
'genericpassword') {
1388 $out .= str_repeat(
'*', strlen($this->fieldValue));
1405 $TSelected = array();
1406 if (!empty($this->fieldValue)) {
1407 $TSelected = explode(
',', $this->fieldValue);
1410 if (!empty($TSelected)) {
1411 foreach ($TSelected as $selected) {
1412 if (!empty($this->fieldOptions[$selected])) {
1413 $outPut .=
dolGetBadge(
'', $this->fieldOptions[$selected],
'info').
' ';
1429 $this->fieldAttr[
'disabled'] =
null;
1431 $useDefaultColor =
false;
1432 if (!$color && !empty($this->defaultFieldValue)) {
1433 $color = $this->defaultFieldValue;
1434 $useDefaultColor =
true;
1437 $out .=
'<input type="color" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; " value="#'.$color.
'">';
1440 if ($useDefaultColor) {
1441 $out .=
' '.$langs->trans(
"Default");
1443 $out .=
' #'.$color;
1455 $this->fieldAttr[
'type'] =
'color';
1456 $default = $this->defaultFieldValue;
1457 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
1459 return $formother->selectColor(
colorArrayToHex(
colorStringToArray((
string) $this->fieldAttr[
'value'], array()),
''), $this->fieldAttr[
'name'],
'', 1, array(),
'',
'', (
string) $default).
' ';
1470 if (!empty($this->fieldOptions[$this->fieldValue])) {
1471 $outPut = $this->fieldOptions[$this->fieldValue];
1485 $user =
new User($this->db);
1486 $user->fetch((
int) $this->fieldValue);
1487 $outPut = $user->firstname .
" " . $user->lastname;
1502 $this->
type =
'string';
1516 $this->
type =
'number';
1517 $this->fieldAttr[
'type'] =
'number';
1518 if (!is_null($min)) {
1519 $this->fieldAttr[
'min'] = $min;
1521 if (!is_null($max)) {
1522 $this->fieldAttr[
'max'] = $max;
1524 if (!is_null($step)) {
1525 $this->fieldAttr[
'step'] = $step;
1538 $this->
type =
'email';
1549 $this->
type =
'url';
1560 $this->
type =
'color';
1571 $this->
type =
'textarea';
1582 $this->
type =
'html';
1594 $this->
type =
'emailtemplate:'.$templateType;
1605 $this->
type =
'thirdparty_type';
1616 $this->
type =
'yesno';
1627 $this->
type =
'securekey';
1638 $this->
type =
'product';
1649 $this->
type =
'price';
1662 $this->
type =
'category:'.$catType;
1673 $this->
type =
'title';
1686 if (is_array($fieldOptions)) {
1687 $this->fieldOptions = $fieldOptions;
1690 $this->
type =
'multiselect';
1702 if (is_array($fieldOptions)) {
1703 $this->fieldOptions = $fieldOptions;
1706 $this->
type =
'select';
1719 if (is_array($fieldOptions)) {
1720 $this->fieldOptions = $fieldOptions;
1723 $this->
type =
'radio';
1734 $this->
type =
'selectUser';
1745 $this->
type =
'selectBankAccount';
1758 $this->
type =
'password';
1771 $this->
type =
'genericpassword';
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).
Class to manage bank accounts.
Class to manage categories.
Class to manage a WYSIWYG editor.
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,...
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]]]',...
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Output javascript to autoset a generated password using default module into a HTML element.