37 public $items = array();
42 public $setupNotEmpty = 0;
51 protected $maxItemRank;
57 public $htmlBeforeOutputForm =
'';
63 public $htmlAfterOutputForm =
'';
69 public $htmlOutputMoreButton =
'';
75 public $htmlButtonLabel =
'Save';
80 public $formAttributes = array(
89 public $formHiddenInputs = array();
94 public $errors = array();
105 global
$conf, $langs;
109 $this->form =
new Form($this->db);
110 $this->formAttributes[
'action'] = $_SERVER[
"PHP_SELF"];
112 $this->formHiddenInputs[
'token'] = newToken();
113 $this->formHiddenInputs[
'action'] =
'update';
115 $this->entity = (is_null($this->entity) ?
$conf->entity : $this->entity);
118 $this->langs = $outputLangs;
120 $this->langs = $langs;
133 if (is_array($attributes)) {
134 foreach ($attributes as $attribute => $value) {
135 if (is_array($value) || is_object($value)) {
142 return !empty($Aattr) ? implode(
' ', $Aattr) :
'';
155 public function generateOutput($editMode =
false, $hideTitle =
false, $title =
'', $cssfirstcolumn =
'')
157 global $hookmanager, $action;
159 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
162 'editMode' => $editMode
164 $reshook = $hookmanager->executeHooks(
'formSetupBeforeGenerateOutput', $parameters, $this, $action);
170 return $hookmanager->resPrint;
172 $out =
'<!-- Start generateOutput from FormSetup class -->';
173 $out .= $this->htmlBeforeOutputForm;
177 $out .=
'<input type="hidden" name="page_y" value="">';
180 if (!empty($this->formHiddenInputs) && is_array($this->formHiddenInputs)) {
181 foreach ($this->formHiddenInputs as $hiddenKey => $hiddenValue) {
182 $out .=
'<input type="hidden" name="'.dol_escape_htmltag($hiddenKey).
'" value="' .
dol_escape_htmltag($hiddenValue) .
'">';
191 $reshook = $hookmanager->executeHooks(
'formSetupBeforeGenerateOutputButton', $parameters, $this, $action);
197 return $hookmanager->resPrint;
198 } elseif ($editMode) {
199 $out .=
'<div class="form-setup-button-container center">';
200 $out .= $this->htmlOutputMoreButton;
201 if ($editMode !== 3) {
202 $out .=
'<input class="button button-save reposition" type="submit" value="' . $this->langs->trans($this->htmlButtonLabel ?:
"Save") .
'" name="save">';
204 if ($editMode === 2) {
206 $out .=
' ';
207 $out .=
'<input class="button button-cancel" type="submit" value="' . $this->langs->trans(
'Cancel') .
'" name="cancel">';
216 $out .= $this->htmlAfterOutputForm;
231 public function generateTableOutput($editMode =
false, $hideTitle =
false, $title =
'', $cssfirstcolumn =
'')
233 global $hookmanager, $action;
234 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
237 'editMode' => $editMode
239 $reshook = $hookmanager->executeHooks(
'formSetupBeforeGenerateTableOutput', $parameters, $this, $action);
245 return $hookmanager->resPrint;
247 $out =
'<div class="div-table-responsive-no-min">';
248 $out .=
'<table class="noborder centpercent">';
249 if (empty($hideTitle)) {
251 $title = $this->langs->transnoentitiesnoconv(
"Parameter");
254 $out .=
'<tr class="liste_titre">';
255 $out .=
' <td'.($cssfirstcolumn ?
' class="'.$cssfirstcolumn.
'"' :
'').
'>' .
dolPrintHTML($title) .
'</td>';
256 $out .=
' <td></td>';
265 foreach ($this->items as $item) {
284 global $hookmanager,
$conf;
286 $parameters = array();
287 $reshook = $hookmanager->executeHooks(
'formSetupBeforeSaveConfFromPost', $parameters, $this);
289 $this->errors = $hookmanager->errors;
296 if (empty($this->items)) {
302 foreach ($this->items as $item) {
303 if ($item->getType() ==
'yesno' && !empty(
$conf->use_javascript_ajax)) {
307 $res = $item->setValueFromPost();
309 $item->saveConfValue();
310 } elseif ($res < 0) {
318 if (empty($noMessageInUpdate)) {
323 $this->db->rollback();
324 if (empty($noMessageInUpdate)) {
341 if ($item->enabled == 1) {
342 $trClass =
'oddeven';
343 $tdOutputFieldClass =
'';
344 if ($item->getType() ==
'title') {
345 $trClass =
'liste_titre';
347 if (!empty($item->fieldParams[
'trClass'])) {
348 $trClass .=
' '.$item->fieldParams[
'trClass'];
350 if (!empty($item->fieldParams[
'tdOutputFieldClass'])) {
351 $tdOutputFieldClass .=
' class="'.$item->fieldParams[
'tdOutputFieldClass'].
'"';
354 $this->setupNotEmpty++;
357 'id' =>
'setup-line-item_'. preg_replace(
'/[^a-zA-Z_]/',
'', $item->confKey),
361 if ($item->getType() !==
'title') {
362 $tableLineAttr[
'data-conf-key'] = $item->confKey;
365 $tableLineAttrCompiled = commonHtmlAttributeBuilder($tableLineAttr);
366 $out .=
'<tr '. implode(
' ', $tableLineAttrCompiled).
' >';
368 $out .=
'<td class="col-setup-title'.(!empty($item->fieldParams[
'isMandatory']) ?
' fieldrequired' :
'').
'">';
369 $out .=
'<span id="helplink'.$item->confKey.
'" class="spanforparamtooltip">';
370 $out .= $this->form->textwithpicto($item->getNameText(), $item->getHelpText(), 1,
'info',
'', 0, 3, empty($item->fieldParams[
'helpText']) ?
'tootips'.$item->confKey : ($item->fieldParams[
'helpText'] !=
'noclick' ? $item->fieldParams[
'helpText'] :
''));
374 $out .=
'<td'.$tdOutputFieldClass.
'>';
377 $out .= $item->generateInputField();
379 $out .= $item->generateOutputField();
382 if (!empty($item->errors)) {
403 if (!is_array($params) || empty($params)) {
406 foreach ($params as $confKey => $param) {
423 if (empty($confKey) || empty($params[
'type'])) {
442 $item->setTypeFromTypeString((
string) $params[
'type']);
444 if (!empty($params[
'enabled']) && is_numeric($params[
'enabled'])) {
445 $item->enabled = (int) $params[
'enabled'];
448 if (!empty($params[
'css'])) {
449 $item->cssClass = (
string) $params[
'css'];
452 $this->items[$item->confKey] = $item;
465 $arrayofparameters = array();
466 foreach ($this->items as $item) {
467 $arrayofparameters[$item->confKey] = array(
468 'type' => $item->getType(),
469 'enabled' => $item->enabled
473 return $arrayofparameters;
484 if (!array($this->items)) {
487 foreach ($this->items as $item) {
488 $item->loadValueFromConf();
504 public function newItem($confKey, $targetItemKey =
'', $insertAfterTarget =
false)
508 $item->entity = $this->entity;
511 if (empty($item->rank)) {
517 if (!empty($targetItemKey)) {
518 if (isset($this->items[$targetItemKey])) {
519 $targetItem = $this->items[$targetItemKey];
520 $item->rank = $targetItem->rank;
521 if ($targetItem->rank >= 0 && $insertAfterTarget) {
527 foreach ($this->items as $fItem) {
528 if ($item->rank <= $fItem->rank) {
535 $this->items[$item->confKey] = $item;
536 return $this->items[$item->confKey];
547 return uasort($this->items, array($this,
'itemSort'));
558 if (empty($this->items)) {
562 if ($cache && $this->maxItemRank > 0) {
563 return $this->maxItemRank;
566 $this->maxItemRank = 0;
567 foreach ($this->items as $item) {
568 $this->maxItemRank = max($this->maxItemRank, $item->rank);
571 return $this->maxItemRank;
583 $this->maxItemRank = max($this->maxItemRank, $rank);
595 if (!isset($this->items[$itemKey]->rank)) {
598 return $this->items[$itemKey]->rank;
611 if (empty($a->rank)) {
614 if (empty($b->rank)) {
617 if ($a->rank == $b->rank) {
620 return ($a->rank < $b->rank) ? -1 : 1;
649 public $nameText =
false;
652 public $helpText =
'';
661 public $defaultFieldValue =
null;
664 public $fieldAttr = array();
667 public $fieldOverride =
false;
670 public $fieldInputOverride =
false;
673 public $fieldInputCallBack;
676 public $fieldOutputOverride =
false;
679 public $fieldOutputCallBack;
685 public $fieldOptions = array();
688 public $fieldParams = array();
691 public $saveCallBack;
694 public $setValueFromPostCallBack;
699 public $errors = array();
707 protected $type =
'string';
716 public $cssClass =
'';
726 global $langs, $db,
$conf, $form;
729 if (!empty($form) && is_object($form) && get_class($form) ==
'Form') {
732 $this->form =
new Form($this->db);
735 $this->langs = $langs;
736 $this->entity = (is_null($this->entity) ?
$conf->entity : ((int) $this->entity));
738 $this->confKey = $confKey;
750 if (isset(
$conf->global->{$this->confKey})) {
754 $this->fieldValue =
null;
767 return $this->loadValueFromConf();
780 $parameters = array();
781 $reshook = $hookmanager->executeHooks(
'formSetupBeforeSaveConfValue', $parameters, $this);
783 $this->setErrors($hookmanager->errors);
791 if ($this->saveCallBack !==
null && is_callable($this->saveCallBack)) {
792 return call_user_func($this->saveCallBack, $this);
796 if ($this->
type !=
'title') {
797 $result =
dolibarr_set_const($this->db, $this->confKey, $this->fieldValue,
'chaine', 0,
'', $this->entity);
816 $this->saveCallBack = $callBack;
827 $this->setValueFromPostCallBack = $callBack;
837 if ($this->setValueFromPostCallBack !==
null && is_callable($this->setValueFromPostCallBack)) {
838 return call_user_func($this->setValueFromPostCallBack);
842 if ($this->
type !=
'title') {
843 if (preg_match(
'/category:/', $this->
type)) {
849 } elseif ($this->
type ==
'multiselect') {
850 $val =
GETPOST($this->confKey,
'array');
851 if ($val && is_array($val)) {
852 $val_const = implode(
',', $val);
856 } elseif ($this->
type ==
'html') {
857 $val_const =
GETPOST($this->confKey,
'restricthtml');
858 } elseif ($this->
type ==
'email') {
859 $val_const =
GETPOST($this->confKey,
'alphawithlgt');
860 } elseif ($this->
type ==
'number') {
863 $val_const =
GETPOST($this->confKey,
'alphanohtml');
867 $this->fieldValue = $val_const;
882 if (!empty($this->helpText)) {
883 return $this->helpText;
885 return (($this->langs->trans($this->confKey .
'Tooltip') != $this->confKey .
'Tooltip') ? $this->langs->trans($this->confKey .
'Tooltip') :
'');
895 if (!empty($this->nameText)) {
896 return $this->nameText;
898 $out = (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans(
'MissingTranslationForConfKey', $this->confKey));
901 if (
isModEnabled(
'multicompany') && $this->entity == 0) {
902 $out =
img_picto($this->langs->trans(
'AllEntities'),
'fa-globe-americas em088 opacityhigh') .
' ' . $out;
920 if (!empty($resCallback)) {
925 if (!empty($this->fieldOverride)) {
926 return $this->fieldOverride;
929 if (!empty($this->fieldInputOverride)) {
930 return $this->fieldInputOverride;
934 if (is_null($this->fieldValue)) {
935 $this->fieldValue = $this->defaultFieldValue;
939 $this->fieldAttr[
'name'] = $this->confKey;
940 $this->fieldAttr[
'id'] =
'setup-'.$this->confKey;
941 $this->fieldAttr[
'value'] = $this->fieldValue;
945 if ($this->
type ==
'title') {
946 $out .= $this->generateOutputField();
947 } elseif ($this->
type ==
'multiselect') {
948 $out .= $this->generateInputFieldMultiSelect();
949 } elseif ($this->
type ==
'select') {
950 $out .= $this->generateInputFieldSelect();
951 } elseif ($this->
type ==
'radio') {
952 $out .= $this->generateInputFieldRadio();
953 } elseif ($this->
type ==
'selectUser') {
954 $out .= $this->generateInputFieldSelectUser();
955 } elseif ($this->
type ==
'textarea') {
956 $out .= $this->generateInputFieldTextarea();
957 } elseif ($this->
type ==
'html') {
958 $out .= $this->generateInputFieldHtml();
959 } elseif ($this->
type ==
'color') {
960 $out .= $this->generateInputFieldColor();
961 } elseif ($this->
type ==
'yesno') {
962 if (!empty(
$conf->use_javascript_ajax)) {
963 $input = $this->fieldParams[
'input'] ?? array();
964 $revertonoff = empty($this->fieldParams[
'revertonoff']) ? 0 : 1;
965 $forcereload = empty($this->fieldParams[
'forcereload']) ? 0 : 1;
966 $suffixarray = array(
970 if (!empty($this->fieldParams[
'alertifoff'])) {
971 $suffixarray[
'ifoff'] =
'_red';
972 } elseif (!empty($this->fieldParams[
'warningifoff'])) {
973 $suffixarray[
'ifoff'] =
'_warning';
975 if (!empty($this->fieldParams[
'alertifon'])) {
976 $suffixarray[
'ifon'] =
'_red';
977 } elseif (!empty($this->fieldParams[
'warningifon'])) {
978 $suffixarray[
'ifon'] =
'_warning';
981 $out .= ajax_constantonoff($this->confKey, $input, $this->entity, $revertonoff, 0, $forcereload, 2, 0, 0, $suffixarray,
'', $this->cssClass);
983 $out .= $this->form->selectyesno($this->confKey, $this->fieldValue, 1,
false, 0, 0, $this->cssClass);
985 } elseif (preg_match(
'/emailtemplate:/', $this->
type)) {
986 $out .= $this->generateInputFieldEmailTemplate();
987 } elseif (preg_match(
'/category:/', $this->
type)) {
988 $out .= $this->generateInputFieldCategories();
989 } elseif (preg_match(
'/thirdparty_type/', $this->
type)) {
990 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
992 $out .= $formcompany->selectProspectCustomerType($this->fieldValue, $this->confKey);
993 } elseif ($this->
type ==
'securekey') {
994 $out .= $this->generateInputFieldSecureKey();
995 } elseif ($this->
type ==
'product') {
997 $selected = (empty($this->fieldValue) ?
'' : $this->fieldValue);
998 $out .=
img_picto(
'',
'product',
'class="pictofixedwidth"');
999 $out .= $this->form->select_produits((
int) $selected, $this->confKey,
'', 0, 0, 1, 2,
'', 0, array(), 0,
'1', 0, $this->cssClass, 0,
'',
null, 1);
1001 } elseif ($this->
type ==
'selectBankAccount') {
1003 $selected = (empty($this->fieldValue) ?
'' : $this->fieldValue);
1004 $out .=
img_picto(
'',
'bank',
'class="pictofixedwidth"').$this->form->select_comptes($selected, $this->confKey, 0,
'', 0,
'', 0,
'', 1);
1006 } elseif ($this->
type ==
'password') {
1007 $out .= $this->generateInputFieldPassword(
'dolibarr');
1008 } elseif ($this->
type ==
'genericpassword') {
1009 $out .= $this->generateInputFieldPassword(
'generic', 0, 0);
1010 } elseif ($this->
type ==
'price') {
1011 $out .= $this->generateInputFieldPrice();
1012 } elseif ($this->
type ==
'email') {
1013 $out .= $this->generateInputFieldEmail();
1014 } elseif ($this->
type ==
'url') {
1015 $out .= $this->generateInputFieldUrl();
1017 $out .= $this->generateInputFieldText();
1030 if (empty($this->fieldAttr) || empty($this->fieldAttr[
'class'])) {
1031 $this->fieldAttr[
'class'] =
'flat '.(empty($this->cssClass) ?
'minwidth200' : $this->cssClass);
1033 return '<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).
' spellcheck="false">';
1045 if (empty($this->fieldAttr) || empty($this->fieldAttr[
'class'])) {
1046 $this->fieldAttr[
'class'] =
'flat '.(empty($this->cssClass) ?
'minwidth40 maxwidth75' : $this->cssClass);
1049 return '<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).
' spellcheck="false"> '.$langs->getCurrencySymbol(
$mysoc->currency_code);
1059 if (empty($this->fieldAttr) || empty($this->fieldAttr[
'class'])) {
1060 $this->fieldAttr[
'class'] =
'flat '.(empty($this->cssClass) ?
'minwidth100 maxwidth500' : $this->cssClass);
1072 if (empty($this->fieldAttr) || empty($this->fieldAttr[
'class'])) {
1073 $this->fieldAttr[
'class'] =
'flat '.(empty($this->cssClass) ?
'minwidth100 maxwidth500' : $this->cssClass);
1085 $out =
'<textarea class="flat" name="'.$this->confKey.
'" id="'.$this->confKey.
'" cols="50" rows="5" wrap="soft" spellcheck="false">' .
"\n";
1087 $out .=
"</textarea>\n";
1098 require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
1099 $doleditor =
new DolEditor($this->confKey, $this->fieldValue,
'', 160,
'dolibarr_notes',
'',
false,
false,
isModEnabled(
'fckeditor'), ROWS_5,
'90%');
1100 return $doleditor->Create(1);
1110 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1111 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
1114 $tmp = explode(
':', $this->
type);
1115 $out =
img_picto(
'',
'category',
'class="pictofixedwidth"');
1117 $label =
'Categories';
1118 if ($this->
type ==
'customer') {
1119 $label =
'CustomersProspectsCategoriesShort';
1121 $out .= $formother->select_categories($tmp[1], (
int) $this->fieldValue, $this->confKey, 0, $this->langs->trans($label));
1135 if (preg_match(
'/emailtemplate:/', $this->
type)) {
1136 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
1137 $formmail =
new FormMail($this->db);
1139 $tmp = explode(
':', $this->
type);
1140 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, 1);
1141 $arrayOfMessageName = array();
1142 if (is_array($formmail->lines_model)) {
1143 foreach ($formmail->lines_model as $modelMail) {
1145 if (!empty($arrayOfMessageName[$modelMail->label])) {
1146 $moreonlabel =
' <span class="opacitymedium">(' . $this->langs->trans(
"SeveralLangugeVariatFound") .
')</span>';
1149 $arrayOfMessageName[$modelMail->id] = $this->langs->trans(preg_replace(
'/\(|\)/',
'', $modelMail->label)) . $moreonlabel;
1152 $out .= $this->form->selectarray($this->confKey, $arrayOfMessageName, $this->fieldValue,
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
1167 $out =
'<input type="text" class="flat minwidth150'.($this->cssClass ?
' '.$this->cssClass :
'').
'" id="'.$this->confKey.
'" name="'.$this->confKey.
'" value="'.(
GETPOST($this->confKey,
'alpha') ?
GETPOST($this->confKey,
'alpha') : $this->fieldValue).
'">';
1169 if (!empty(
$conf->use_javascript_ajax) && empty($this->fieldParams[
'hideGenerateButton'])) {
1170 $out .=
' '.img_picto($this->langs->trans(
'Generate'),
'refresh',
'id="generate_token'.$this->confKey.
'" class="linkobject"');
1173 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1191 global
$conf, $langs, $user;
1195 if ($type ==
'dolibarr') {
1197 if ($gen ==
'none') {
1200 $nomclass =
"modGeneratePass".ucfirst($gen);
1201 $nomfichier = $nomclass.
".class.php";
1202 require_once DOL_DOCUMENT_ROOT.
"/core/modules/security/generate/".$nomfichier;
1203 $genhandler =
new $nomclass($this->db,
$conf, $langs, $user);
1204 $min = $genhandler->length;
1205 $max = $genhandler->length2;
1207 $out =
'<input required="required" type="password" class="flat minwidth150'.($this->cssClass ?
' '.$this->cssClass :
'').
'" id="'.$this->confKey.
'" name="'.$this->confKey.
'" value="'.(
GETPOST($this->confKey,
'alpha') ?
GETPOST($this->confKey,
'alpha') : $this->fieldValue).
'"';
1209 $out .=
' minlength="' . $min .
'"';
1212 $out .=
' maxlength="' . $max .
'"';
1216 $out .=
'<span class="fa fa-eye paddingleft paddingright" onclick="javascript: console.log(\'click on show-hide pass\'); newtype = (jQuery(\'#'.trim($this->confKey).
'\').attr(\
'type\') == \'text\' ? \'password\' : \'text\'); jQuery(\'#'.trim($this->confKey).
'\').attr(\
'type\', newtype);"></span>';
1230 $TSelected = array();
1231 if ($this->fieldValue) {
1232 $TSelected = explode(
',', $this->fieldValue);
1235 return $this->form->multiselectarray($this->confKey, $this->fieldOptions, $TSelected, 0, 0,
'', 0, 0,
'style="min-width:100px"');
1247 $s .=
img_picto(
'', $this->picto,
'class="pictofixedwidth"');
1250 $s .= $this->form->selectarray($this->confKey, $this->fieldOptions, $this->fieldValue, 0, 0, 0,
'', 0, 0, 0,
'', $this->cssClass);
1264 $s .=
img_picto(
'', $this->picto,
'class="pictofixedwidth"');
1267 $s .= $this->form->radio($this->confKey, $this->fieldOptions, $this->fieldValue, [
'attrLabel' => [
'class' => $this->cssClass]]);
1277 return $this->form->select_dolusers($this->fieldValue, $this->confKey);
1303 $this->
type = $type;
1316 if (is_array($errors)) {
1317 if (!empty($errors)) {
1318 foreach ($errors as $error) {
1319 $this->setErrors($error);
1322 } elseif (!empty($errors)) {
1323 $this->errors[] = $errors;
1335 global
$conf, $user, $langs;
1337 if ($this->fieldOutputCallBack !==
null && is_callable($this->fieldOutputCallBack)) {
1339 $resCallback = call_user_func($this->fieldOutputCallBack, $this);
1340 if (!empty($resCallback)) {
1341 return $resCallback;
1345 if (!empty($this->fieldOverride)) {
1346 return $this->fieldOverride;
1349 if (!empty($this->fieldOutputOverride)) {
1350 return $this->fieldOutputOverride;
1355 if ($this->
type ==
'title') {
1357 } elseif ($this->
type ==
'textarea') {
1359 } elseif ($this->
type ==
'multiselect') {
1360 $out .= $this->generateOutputFieldMultiSelect();
1361 } elseif ($this->
type ==
'select') {
1362 $out .= $this->generateOutputFieldSelect();
1363 } elseif ($this->
type ==
'selectUser') {
1364 $out .= $this->generateOutputFieldSelectUser();
1365 } elseif ($this->
type ==
'html') {
1366 $out .= $this->fieldValue;
1367 } elseif ($this->
type ==
'color') {
1368 $out .= $this->generateOutputFieldColor();
1369 } elseif ($this->
type ==
'yesno') {
1370 if (!empty(
$conf->use_javascript_ajax)) {
1371 $revertonoff = empty($this->fieldParams[
'revertonoff']) ? 0 : 1;
1372 $forcereload = empty($this->fieldParams[
'forcereload']) ? 0 : 1;
1374 $out .= ajax_constantonoff($this->confKey, array(), $this->entity, $revertonoff, 0, $forcereload, 2, 0, 0,
'',
'', $this->cssClass);
1376 if ($this->fieldValue == 1) {
1377 $out .= $langs->trans(
'yes');
1379 $out .= $langs->trans(
'no');
1382 } elseif (preg_match(
'/emailtemplate:/', $this->
type)) {
1383 if ($this->fieldValue > 0) {
1384 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
1385 $formmail =
new FormMail($this->db);
1387 $tmp = explode(
':', $this->
type);
1389 $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, (
int) $this->fieldValue);
1390 if (is_numeric($template) && $template < 0) {
1391 $this->setErrors($formmail->errors);
1393 $out .= $this->langs->trans($template->label);
1395 } elseif (preg_match(
'/category:/', $this->
type)) {
1396 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1398 $result =
$c->fetch((
int) $this->fieldValue);
1400 $this->setErrors(
$c->errors);
1402 $ways =
$c->print_all_ways(
'auto',
'none', 0, 1);
1404 foreach ($ways as $way) {
1405 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . (
$c->color ?
' style="background: #' .
$c->color .
';"' :
' style="background: #bbb"') .
'>' . $way .
'</li>';
1407 $out .=
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
1408 } elseif (preg_match(
'/thirdparty_type/', $this->
type)) {
1409 if ($this->fieldValue == 2) {
1410 $out .= $this->langs->trans(
"Prospect");
1411 } elseif ($this->fieldValue == 3) {
1412 $out .= $this->langs->trans(
"ProspectCustomer");
1413 } elseif ($this->fieldValue == 1) {
1414 $out .= $this->langs->trans(
"Customer");
1415 } elseif ($this->fieldValue == 0) {
1416 $out .= $this->langs->trans(
"NorProspectNorCustomer");
1418 } elseif ($this->
type ==
'product') {
1419 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1421 $product =
new Product($this->db);
1422 $resprod = $product->fetch((
int) $this->fieldValue);
1424 $out .= $product->getNomUrl(1,
'', 0, -1, 0,
'', 1);
1425 } elseif ($resprod < 0) {
1426 $this->setErrors($product->errors);
1428 } elseif ($this->
type ==
'selectBankAccount') {
1429 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1431 $bankaccount =
new Account($this->db);
1432 $resbank = $bankaccount->fetch((
int) $this->fieldValue);
1434 $out .= $bankaccount->label;
1435 } elseif ($resbank < 0) {
1436 $this->setErrors($bankaccount->errors);
1438 } elseif ($this->
type ==
'password' || $this->
type ==
'genericpassword') {
1439 $out .= str_repeat(
'*', strlen($this->fieldValue));
1456 $TSelected = array();
1457 if (!empty($this->fieldValue)) {
1458 $TSelected = explode(
',', $this->fieldValue);
1461 if (!empty($TSelected)) {
1462 foreach ($TSelected as $selected) {
1463 if (!empty($this->fieldOptions[$selected])) {
1464 $outPut .= dolGetBadge(
'', $this->fieldOptions[$selected],
'info').
' ';
1480 $this->fieldAttr[
'disabled'] =
null;
1482 $useDefaultColor =
false;
1483 if (!$color && !empty($this->defaultFieldValue)) {
1484 $color = $this->defaultFieldValue;
1485 $useDefaultColor =
true;
1488 $out .=
'<input type="color" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; " value="#'.$color.
'">';
1491 if ($useDefaultColor) {
1492 $out .=
' '.$langs->trans(
"Default");
1494 $out .=
' #'.$color;
1506 $this->fieldAttr[
'type'] =
'color';
1507 $default = $this->defaultFieldValue;
1508 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
1510 return $formother->selectColor(
colorArrayToHex(
colorStringToArray((
string) $this->fieldAttr[
'value'], array()),
''), $this->fieldAttr[
'name'],
'', 1, array(),
'',
'', (
string) $default).
' ';
1521 if (!empty($this->fieldOptions[$this->fieldValue])) {
1522 $outPut = $this->fieldOptions[$this->fieldValue];
1536 $user =
new User($this->db);
1537 $user->fetch((
int) $this->fieldValue);
1538 $outPut = $user->firstname .
" " . $user->lastname;
1553 $this->
type =
'string';
1567 $this->
type =
'number';
1568 $this->fieldAttr[
'type'] =
'number';
1569 if (!is_null($min)) {
1570 $this->fieldAttr[
'min'] = $min;
1572 if (!is_null($max)) {
1573 $this->fieldAttr[
'max'] = $max;
1575 if (!is_null($step)) {
1576 $this->fieldAttr[
'step'] = $step;
1589 $this->
type =
'email';
1600 $this->
type =
'url';
1611 $this->
type =
'color';
1622 $this->
type =
'textarea';
1633 $this->
type =
'html';
1645 $this->
type =
'emailtemplate:'.$templateType;
1656 $this->
type =
'thirdparty_type';
1667 $this->
type =
'yesno';
1678 $this->
type =
'securekey';
1689 $this->
type =
'product';
1700 $this->
type =
'price';
1713 $this->
type =
'category:'.$catType;
1724 $this->
type =
'title';
1737 if (is_array($fieldOptions)) {
1738 $this->fieldOptions = $fieldOptions;
1741 $this->
type =
'multiselect';
1753 if (is_array($fieldOptions)) {
1754 $this->fieldOptions = $fieldOptions;
1757 $this->
type =
'select';
1770 if (is_array($fieldOptions)) {
1771 $this->fieldOptions = $fieldOptions;
1774 $this->
type =
'radio';
1785 $this->
type =
'selectUser';
1796 $this->
type =
'selectBankAccount';
1809 $this->
type =
'password';
1822 $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, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
$item fieldInputCallBack
Callback used to generate the custom HTML input field.
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.