959 if (empty($elementtype)) {
963 if ($elementtype ==
'thirdparty') {
964 $elementtype =
'societe';
966 if ($elementtype ==
'contact') {
967 $elementtype =
'socpeople';
969 if ($elementtype ==
'order_supplier') {
970 $elementtype =
'commande_fournisseur';
976 $array_name_label = array();
979 $sql =
"SELECT rowid, name, label, type, size, elementtype, fieldunique, fieldrequired, param, pos, alwayseditable, perms, langs, list, printable, totalizable, fielddefault, fieldcomputed, entity, enabled, help,";
980 $sql .=
" css, cssview, csslist";
981 $sql .=
" FROM ".$this->db->prefix().
"extrafields";
983 if ($elementtype && $elementtype !=
'all') {
984 $sql .=
" WHERE elementtype = '".$this->db->escape($elementtype).
"'";
986 if ($attrname && $elementtype && $elementtype !=
'all') {
987 $sql .=
" AND name = '".$this->db->escape($attrname).
"'";
989 $sql .=
" ORDER BY pos";
991 $resql = $this->db->query($sql);
994 if ($this->db->num_rows($resql)) {
995 while ($tab = $this->db->fetch_object($resql)) {
996 if ($tab->entity != 0 && $tab->entity != $conf->entity) {
998 if ($tab->fieldrequired && is_null($tab->fielddefault)) {
999 $this->attributes[$tab->elementtype][
'mandatoryfieldsofotherentities'][$tab->name] = $tab->type;
1005 if ($tab->type !=
'separate') {
1006 $array_name_label[$tab->name] = $tab->label;
1010 $this->attributes[$tab->elementtype][
'type'][$tab->name] = $tab->type;
1011 $this->attributes[$tab->elementtype][
'label'][$tab->name] = $tab->label;
1012 $this->attributes[$tab->elementtype][
'size'][$tab->name] = $tab->size;
1013 $this->attributes[$tab->elementtype][
'elementtype'][$tab->name] = $tab->elementtype;
1014 $this->attributes[$tab->elementtype][
'default'][$tab->name] = $tab->fielddefault;
1015 $this->attributes[$tab->elementtype][
'computed'][$tab->name] = $tab->fieldcomputed;
1016 $this->attributes[$tab->elementtype][
'unique'][$tab->name] = $tab->fieldunique;
1017 $this->attributes[$tab->elementtype][
'required'][$tab->name] = $tab->fieldrequired;
1018 $this->attributes[$tab->elementtype][
'param'][$tab->name] = ($tab->param ?
jsonOrUnserialize($tab->param) :
'');
1019 $this->attributes[$tab->elementtype][
'pos'][$tab->name] = $tab->pos;
1020 $this->attributes[$tab->elementtype][
'alwayseditable'][$tab->name] = $tab->alwayseditable;
1021 $this->attributes[$tab->elementtype][
'perms'][$tab->name] = ((is_null($tab->perms) || strlen($tab->perms) == 0) ? 1 : $tab->perms);
1022 $this->attributes[$tab->elementtype][
'langfile'][$tab->name] = $tab->langs;
1023 $this->attributes[$tab->elementtype][
'list'][$tab->name] = $tab->list;
1024 $this->attributes[$tab->elementtype][
'printable'][$tab->name] = $tab->printable;
1025 $this->attributes[$tab->elementtype][
'totalizable'][$tab->name] = ($tab->totalizable ? 1 : 0);
1026 $this->attributes[$tab->elementtype][
'entityid'][$tab->name] = $tab->entity;
1027 $this->attributes[$tab->elementtype][
'enabled'][$tab->name] = $tab->enabled;
1028 $this->attributes[$tab->elementtype][
'help'][$tab->name] = $tab->help;
1029 $this->attributes[$tab->elementtype][
'css'][$tab->name] = $tab->css;
1030 $this->attributes[$tab->elementtype][
'cssview'][$tab->name] = $tab->cssview;
1031 $this->attributes[$tab->elementtype][
'csslist'][$tab->name] = $tab->csslist;
1033 $this->attributes[$tab->elementtype][
'loaded'] = 1;
1038 $this->attributes[$elementtype][
'loaded'] = 1;
1039 $this->attributes[$elementtype][
'count'] = $count;
1042 $this->error = $this->db->lasterror();
1043 dol_syslog(get_class($this).
"::fetch_name_optionals_label ".$this->error, LOG_ERR);
1046 return $array_name_label;
1065 public function showInputField($key, $value, $moreparam =
'', $keysuffix =
'', $keyprefix =
'', $morecss =
'', $objectid = 0, $extrafieldsobjectkey =
'', $mode = 0)
1067 global $conf, $langs, $form;
1069 if (!is_object($form)) {
1070 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
1071 $form =
new Form($this->db);
1076 if (!preg_match(
'/options_$/', $keyprefix)) {
1077 $keyprefix = $keyprefix.
'options_';
1080 if (empty($extrafieldsobjectkey)) {
1081 dol_syslog(get_class($this).
'::showInputField extrafieldsobjectkey required', LOG_ERR);
1082 return 'BadValueForParamExtraFieldsObjectKey';
1085 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
1086 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1087 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
1088 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
1089 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
1090 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
1091 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
1092 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
1093 $perms = (int)
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
1094 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
1095 $list = (string)
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
1096 $totalizable = $this->attributes[$extrafieldsobjectkey][
'totalizable'][$key];
1097 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
1098 $hidden = (empty($list) ? 1 : 0);
1104 if (!preg_match(
'/^search_/', $keyprefix)) {
1105 return '<span class="opacitymedium">'.$langs->trans(
"AutomaticallyCalculated").
'</span>';
1113 if (empty($morecss)) {
1115 if ($type ==
'date') {
1116 $morecss =
'minwidth100imp';
1117 } elseif ($type ==
'datetime' || $type ==
'datetimegmt' || $type ==
'link') {
1118 $morecss =
'minwidth200imp';
1119 } elseif (in_array($type, array(
'int',
'integer',
'double',
'price'))) {
1120 $morecss =
'maxwidth75';
1121 } elseif ($type ==
'password') {
1122 $morecss =
'maxwidth100';
1123 } elseif ($type ==
'url') {
1124 $morecss =
'minwidth400';
1125 } elseif ($type ==
'boolean') {
1127 } elseif ($type ==
'radio') {
1128 $morecss =
'width25';
1130 if (empty($size) || round((
float) $size) < 12) {
1131 $morecss =
'minwidth100';
1132 } elseif (round((
float) $size) <= 48) {
1133 $morecss =
'minwidth200';
1135 $morecss =
'minwidth400';
1139 if (!empty($this->attributes[$extrafieldsobjectkey][
'css'][$key])) {
1140 $morecss = $this->attributes[$extrafieldsobjectkey][
'css'][$key];
1144 if (in_array($type, array(
'date'))) {
1145 $tmp = explode(
',', $size);
1150 if (!$required && $value ==
'') {
1157 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1158 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1160 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1161 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1162 $out .=
'</div><div class="nowrap">';
1163 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1164 $out .=
'</div></div>';
1167 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1);
1169 } elseif (in_array($type, array(
'datetime',
'datetimegmt'))) {
1170 $tmp = explode(
',', $size);
1175 if (!$required && $value ==
'') {
1182 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1183 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1185 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1186 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"),
'tzuserrel');
1187 $out .=
'</div><div class="nowrap">';
1188 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
1189 $out .=
'</div></div>';
1192 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1,
'',
'',
'', 1,
'',
'',
'tzuserrel');
1194 } elseif (in_array($type, array(
'int',
'integer'))) {
1195 $tmp = explode(
',', $size);
1197 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" maxlength="'.$newsize.
'" value="'.
dol_escape_htmltag($value).
'"'.($moreparam ? $moreparam :
'').
'>';
1198 } elseif (preg_match(
'/varchar/', $type)) {
1199 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" maxlength="'.$size.
'" value="'.
dol_escape_htmltag($value).
'"'.($moreparam ? $moreparam :
'').
'>';
1200 } elseif (in_array($type, array(
'mail',
'ip',
'phone',
'url'))) {
1201 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1202 } elseif ($type ==
'icon') {
1208 $out .=
'<input type="text" class="form-control icp icp-auto iconpicker-element iconpicker-input flat '.$morecss.
' maxwidthonsmartphone"';
1209 $out .=
' name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1212 $options =
"{ title: '<b>".$langs->trans(
"IconFieldSelector").
"</b>', placement: 'right', showFooter: false, templates: {";
1213 $options .=
"iconpicker: '<div class=\"iconpicker\"><div style=\"background-color:#EFEFEF;\" class=\"iconpicker-items\"></div></div>',";
1214 $options .=
"iconpickerItem: '<a role=\"button\" href=\"#\" class=\"iconpicker-item\" style=\"background-color:#DDDDDD;\"><i></i></a>',";
1217 $options .=
"footer: '<div class=\"popover-footer\" style=\"background-color:#EFEFEF;\"></div>',";
1218 $options .=
"search: '<input type=\"search\" class\"form-control iconpicker-search\" placeholder=\"".$langs->trans(
"TypeToFilter").
"\" />',";
1219 $options .=
"popover: '<div class=\"iconpicker-popover popover\">";
1220 $options .=
" <div class=\"arrow\" ></div>";
1221 $options .=
" <div class=\"popover-title\" style=\"text-align:center;background-color:#EFEFEF;\"></div>";
1222 $options .=
" <div class=\"popover-content \" ></div>";
1223 $options .=
"</div>'}}";
1224 $out .=
"$('#".$keyprefix.$key.$keysuffix.
"').iconpicker(".$options.
");";
1225 $out .=
'</script>';
1227 } elseif ($type ==
'text') {
1228 if (!preg_match(
'/search_/', $keyprefix)) {
1229 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1230 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false,
false, ROWS_5,
'90%');
1231 $out = (string) $doleditor->Create(1);
1233 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1235 } elseif ($type ==
'html') {
1236 if (!preg_match(
'/search_/', $keyprefix)) {
1237 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1238 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false, isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_5,
'90%');
1239 $out = (string) $doleditor->Create(1);
1241 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1243 } elseif ($type ==
'boolean') {
1246 if (!empty($value)) {
1247 $checked =
' checked value="1" ';
1249 $checked =
' value="1" ';
1251 $out =
'<input type="checkbox" class="flat valignmiddle'.($morecss ?
' '.$morecss :
'').
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.$checked.
' '.($moreparam ? $moreparam :
'').
'>';
1253 $out = $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1,
false, 1);
1255 $out .=
'<input type="hidden" name="'.$keyprefix.$key.$keysuffix.
'_boolean" value="1">';
1256 } elseif ($type ==
'price') {
1257 if (!empty($value)) {
1258 $value =
price($value);
1260 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone right" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
' placeholder="'.$langs->getCurrencySymbol($conf->currency).
'">';
1261 } elseif ($type ==
'pricecy') {
1262 $currency = $conf->currency;
1263 if (!empty($value)) {
1265 $pricetmp = explode(
':', $value);
1266 $currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
1267 $value =
price($pricetmp[0]);
1269 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1270 $out .= $form->selectCurrency($currency, $keyprefix.$key.$keysuffix.
'currency_id');
1271 } elseif ($type ==
'double') {
1272 if (!empty($value)) {
1273 $value =
price($value);
1275 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1276 } elseif ($type ==
'select') {
1280 foreach ($param[
'options'] as $okey => $val) {
1281 if ((
string) $okey ==
'') {
1285 $valarray = explode(
'|', $val);
1286 $val = $valarray[0];
1288 if ($langfile && $val) {
1289 $options[$okey] = $langs->trans($val);
1291 $options[$okey] = $val;
1294 $selected = array();
1295 if (!is_array($value)) {
1296 $selected = explode(
',', $value);
1299 $out .= $form->multiselectarray($keyprefix.$key.$keysuffix, $options, $selected, 0, 0, $morecss, 0, 0,
'',
'',
'', !empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2'));
1301 if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2')) {
1302 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1303 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1306 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1307 $out .=
'<option value="0"> </option>';
1308 foreach ($param[
'options'] as $key2 => $val2) {
1309 if ((
string) $key2 ==
'') {
1312 $valarray = explode(
'|', $val2);
1313 $val2 = $valarray[0];
1315 if (!empty($valarray[1])) {
1316 $parent = $valarray[1];
1318 $out .=
'<option value="'.$key2.
'"';
1319 $out .= (((string) $value == (
string) $key2) ?
' selected' :
'');
1320 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1322 if ($langfile && $val2) {
1323 $out .= $langs->trans($val2);
1327 $out .=
'</option>';
1329 $out .=
'</select>';
1331 } elseif ($type ==
'sellist') {
1333 if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2')) {
1334 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1335 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1338 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1339 if (is_array($param[
'options'])) {
1340 $tmpparamoptions = array_keys($param[
'options']);
1341 $paramoptions = preg_split(
'/[\r\n]+/', $tmpparamoptions[0]);
1343 $InfoFieldList = explode(
":", $paramoptions[0], 5);
1355 if (! empty($InfoFieldList[4])) {
1357 $parenthesisopen = 0;
1358 while (substr($InfoFieldList[4], $pos, 1) !==
'' && ($parenthesisopen || $pos == 0 || substr($InfoFieldList[4], $pos, 1) !=
':')) {
1359 if (substr($InfoFieldList[4], $pos, 1) ==
'(') {
1362 if (substr($InfoFieldList[4], $pos, 1) ==
')') {
1367 $tmpbefore = substr($InfoFieldList[4], 0, $pos);
1368 $tmpafter = substr($InfoFieldList[4], $pos + 1);
1370 $InfoFieldList[4] = $tmpbefore;
1371 if ($tmpafter !==
'') {
1372 $InfoFieldList = array_merge($InfoFieldList, explode(
':', $tmpafter));
1377 if (preg_match(
'/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) {
1378 $InfoFieldList[4] =
'('.$reg[1].
':'.$reg[2].
':'.$reg[3].
')';
1388 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1390 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1391 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1392 $keyList .=
', '.$parentField;
1394 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1395 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1396 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1398 $keyList = $InfoFieldList[2].
' as rowid';
1402 $filter_categorie =
false;
1403 if (count($InfoFieldList) > 5) {
1404 if ($InfoFieldList[0] ==
'categorie') {
1405 $filter_categorie =
true;
1409 if ($filter_categorie ===
false) {
1410 $fields_label = explode(
'|', $InfoFieldList[1]);
1411 if (is_array($fields_label)) {
1413 $keyList .= implode(
', ', $fields_label);
1417 $sql =
"SELECT ".$keyList;
1418 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1421 if (!empty($InfoFieldList[4])) {
1423 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1424 $InfoFieldList[4] = str_replace(
'$ENTITY$', (
string) $conf->entity, $InfoFieldList[4]);
1427 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1428 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1432 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1433 $InfoFieldList[4] = str_replace(
'$ID$', (
string) $objectid, $InfoFieldList[4]);
1435 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1440 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1441 $sql .=
' as main, '.$this->db->sanitize($this->db->prefix().$InfoFieldList[0]).
'_extrafields as extra';
1442 $sqlwhere .=
" WHERE extra.fk_object = main.".$this->db->sanitize($InfoFieldList[2]);
1448 $sqlwhere .=
' WHERE 1=1';
1465 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1466 $sqlwhere .=
' AND entity = '.((int) $conf->entity);
1471 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1473 dol_syslog(get_class($this).
'::showInputField type=sellist', LOG_DEBUG);
1474 $resql = $this->db->query($sql);
1476 $out .=
'<option value="0"> </option>';
1477 $num = $this->db->num_rows($resql);
1481 $obj = $this->db->fetch_object($resql);
1485 $fields_label = explode(
'|', $InfoFieldList[1]);
1486 if (is_array($fields_label) && count($fields_label) > 1) {
1488 foreach ($fields_label as $field_toshow) {
1489 $labeltoshow .= $obj->$field_toshow.
' ';
1492 $labeltoshow = $obj->{$InfoFieldList[1]};
1495 if ($value == $obj->rowid) {
1497 foreach ($fields_label as $field_toshow) {
1498 $translabel = $langs->trans($obj->$field_toshow);
1499 $labeltoshow = $translabel.
' ';
1502 $out .=
'<option value="'.$obj->rowid.
'" selected>'.$labeltoshow.
'</option>';
1505 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1506 $labeltoshow = $translabel;
1508 if (empty($labeltoshow)) {
1509 $labeltoshow =
'(not defined)';
1512 if (!empty($InfoFieldList[3]) && $parentField) {
1513 $parent = $parentName.
':'.$obj->{$parentField};
1516 $out .=
'<option value="'.$obj->rowid.
'"';
1517 $out .= ($value == $obj->rowid ?
' selected' :
'');
1518 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1519 $out .=
'>'.$labeltoshow.
'</option>';
1524 $this->db->free($resql);
1526 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1529 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1530 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1531 $out .=
'<option value="0"> </option>';
1532 if (is_array($data)) {
1533 foreach ($data as $data_key => $data_value) {
1534 $out .=
'<option value="'.$data_key.
'"';
1535 $out .= ($value == $data_key ?
' selected' :
'');
1536 $out .=
'>'.$data_value.
'</option>';
1541 $out .=
'</select>';
1542 } elseif ($type ==
'checkbox') {
1543 $value_arr = $value;
1544 if (!is_array($value)) {
1545 $value_arr = explode(
',', $value);
1547 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param[
'options']) ?
null : $param[
'options']), $value_arr,
'', 0,
'', 0,
'100%');
1548 } elseif ($type ==
'radio') {
1550 foreach ($param[
'options'] as $keyopt => $val) {
1551 $out .=
'<input class="flat '.$morecss.
'" type="radio" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'');
1552 $out .=
' value="'.$keyopt.
'"';
1553 $out .=
' id="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'"';
1554 $out .= ($value == $keyopt ?
'checked' :
'');
1555 $out .=
'/><label for="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'">'.$langs->trans($val).
'</label><br>';
1557 } elseif ($type ==
'chkbxlst') {
1558 if (is_array($value)) {
1559 $value_arr = $value;
1561 $value_arr = explode(
',', $value);
1564 if (is_array($param[
'options'])) {
1565 $tmpparamoptions = array_keys($param[
'options']);
1566 $paramoptions = preg_split(
'/[\r\n]+/', $tmpparamoptions[0]);
1568 $InfoFieldList = explode(
":", $paramoptions[0], 5);
1580 if (! empty($InfoFieldList[4])) {
1582 $parenthesisopen = 0;
1583 while (substr($InfoFieldList[4], $pos, 1) !==
'' && ($parenthesisopen || $pos == 0 || substr($InfoFieldList[4], $pos, 1) !=
':')) {
1584 if (substr($InfoFieldList[4], $pos, 1) ==
'(') {
1587 if (substr($InfoFieldList[4], $pos, 1) ==
')') {
1592 $tmpbefore = substr($InfoFieldList[4], 0, $pos);
1593 $tmpafter = substr($InfoFieldList[4], $pos + 1);
1595 $InfoFieldList[4] = $tmpbefore;
1596 if ($tmpafter !==
'') {
1597 $InfoFieldList = array_merge($InfoFieldList, explode(
':', $tmpafter));
1602 if (preg_match(
'/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) {
1603 $InfoFieldList[4] =
'('.$reg[1].
':'.$reg[2].
':'.$reg[3].
')';
1613 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1615 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1616 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1617 $keyList .=
', '.$parentField;
1619 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1620 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1621 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1623 $keyList = $InfoFieldList[2].
' as rowid';
1627 $filter_categorie =
false;
1628 if (count($InfoFieldList) > 5) {
1629 if ($InfoFieldList[0] ==
'categorie') {
1630 $filter_categorie =
true;
1634 if ($filter_categorie ===
false) {
1635 $fields_label = explode(
'|', $InfoFieldList[1]);
1636 if (is_array($fields_label)) {
1638 $keyList .= implode(
', ', $fields_label);
1642 $sql =
"SELECT ".$keyList;
1643 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1646 if (!empty($InfoFieldList[4])) {
1648 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1649 $InfoFieldList[4] = str_replace(
'$ENTITY$', (
string) $conf->entity, $InfoFieldList[4]);
1652 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1653 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1657 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1658 $InfoFieldList[4] = str_replace(
'$ID$', (
string) $objectid, $InfoFieldList[4]);
1659 } elseif (preg_match(
"#^.*list.php$#", $_SERVER[
"PHP_SELF"])) {
1661 $word =
'\b[a-zA-Z0-9-\.-_]+\b=\$ID\$';
1664 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1668 while ($nbPreg != 0) {
1670 $nbPregRepl = $nbPregSel = 0;
1672 $InfoFieldList[4] = preg_replace(
'#([^=])(\([^)^(]*('.$word.
')[^)^(]*\))#',
'$1 $3 ', $InfoFieldList[4], -1, $nbPregRepl);
1674 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1676 $InfoFieldList[4] = preg_replace(
'#\b[a-zA-Z0-9-\.-_]+\b=\([^)^(]*('.$word.
')[^)^(]*\)#',
'$1 ', $InfoFieldList[4], -1, $nbPregSel);
1678 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1681 $nbPreg = $nbPregRepl + $nbPregSel;
1685 $matchCondition = array();
1686 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1687 while (!empty($matchCondition[0])) {
1689 if (!empty($matchCondition[1]) && !empty($matchCondition[3]) && $matchCondition[1] != $matchCondition[3]) {
1691 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1693 if (!empty($matchCondition[1])) {
1694 $boolCond = (($matchCondition[1] ==
"AND") ?
' AND TRUE ' :
' OR FALSE ');
1695 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond.$matchCondition[3], $InfoFieldList[4]);
1696 } elseif (!empty($matchCondition[3])) {
1697 $boolCond = (($matchCondition[3] ==
"AND") ?
' TRUE AND ' :
' FALSE OR');
1698 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond, $InfoFieldList[4]);
1700 $InfoFieldList[4] =
" TRUE ";
1705 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1708 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1713 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1714 $sql .=
' as main, '.$this->db->sanitize($this->db->prefix().$InfoFieldList[0]).
'_extrafields as extra';
1715 $sqlwhere .=
" WHERE extra.fk_object = main.".$this->db->sanitize($InfoFieldList[2]);
1721 $sqlwhere .=
' WHERE 1=1';
1738 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1739 $sqlwhere .=
" AND entity = ".((int) $conf->entity);
1745 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1747 dol_syslog(get_class($this).
'::showInputField type=chkbxlst', LOG_DEBUG);
1748 $resql = $this->db->query($sql);
1750 $num = $this->db->num_rows($resql);
1757 $obj = $this->db->fetch_object($resql);
1761 $fields_label = explode(
'|', $InfoFieldList[1]);
1762 if (is_array($fields_label)) {
1764 foreach ($fields_label as $field_toshow) {
1765 $labeltoshow .= $obj->$field_toshow.
' ';
1768 $labeltoshow = $obj->{$InfoFieldList[1]};
1770 $labeltoshow =
dol_trunc($labeltoshow, 45);
1772 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1774 foreach ($fields_label as $field_toshow) {
1775 $translabel = $langs->trans($obj->$field_toshow);
1776 if ($translabel != $obj->$field_toshow) {
1777 $labeltoshow .=
' '.dol_trunc($translabel, 18).
' ';
1779 $labeltoshow .=
' '.dol_trunc($obj->$field_toshow, 18).
' ';
1782 $data[$obj->rowid] = $labeltoshow;
1785 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1786 if ($translabel != $obj->{$InfoFieldList[1]}) {
1787 $labeltoshow =
dol_trunc($translabel, 18);
1789 $labeltoshow =
dol_trunc($obj->{$InfoFieldList[1]}, 18);
1792 if (empty($labeltoshow)) {
1793 $labeltoshow =
'(not defined)';
1796 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1797 $data[$obj->rowid] = $labeltoshow;
1800 if (!empty($InfoFieldList[3]) && $parentField) {
1801 $parent = $parentName.
':'.$obj->{$parentField};
1804 $data[$obj->rowid] = $labeltoshow;
1809 $this->db->free($resql);
1811 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr,
'', 0,
'', 0,
'100%');
1813 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1816 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1817 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1818 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr,
'', 0,
'', 0,
'100%');
1821 } elseif ($type ==
'link') {
1822 $param_list = array_keys($param[
'options']);
1829 $showempty = (($required && $default !=
'') ? 0 : 1);
1831 $tmparray = explode(
':', $param_list[0]);
1833 $element = $extrafieldsobjectkey;
1834 if ($element ==
'socpeople') {
1835 $element =
'contact';
1836 } elseif ($element ==
'projet') {
1837 $element =
'project';
1841 $objectdesc = $tmparray[0];
1842 $objectfield = $element.
':options_'.$key;
1844 $out = $form->selectForForms($objectdesc, $keyprefix.$key.$keysuffix, $value, $showempty,
'',
'', $morecss,
'', 0, 0,
'', $objectfield);
1845 } elseif (in_array($type, [
'point',
'multipts',
'linestrg',
'polygon'])) {
1846 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeophp.class.php';
1850 if (!empty($value)) {
1851 $tmparray = $dolgeophp->parseGeoString($value);
1852 $geojson = $tmparray[
'geojson'];
1853 $centroidjson = $tmparray[
'centroidjson'];
1855 if (!preg_match(
'/search_/', $keyprefix)) {
1856 require_once DOL_DOCUMENT_ROOT.
'/core/class/geomapeditor.class.php';
1858 $out .= $geomapeditor->getHtml($keyprefix.$key.$keysuffix, $geojson, $centroidjson, $type);
1863 } elseif ($type ==
'password') {
1865 $out =
'<input style="display:none" type="text" name="fakeusernameremembered">';
1866 $out .=
'<input autocomplete="new-password" type="'.($keyprefix ==
'search_' ?
'text' :
'password').
'" class="flat '.$morecss.
'" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'>';
1868 if (!empty($hidden)) {
1869 $out =
'<input type="hidden" value="'.$value.
'" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'"/>';
1892 public function showOutputField($key, $value, $moreparam =
'', $extrafieldsobjectkey =
'', $outputlangs =
null)
1894 global $conf, $langs;
1896 if (is_null($outputlangs) || !is_object($outputlangs)) {
1897 $outputlangs = $langs;
1900 if (empty($extrafieldsobjectkey)) {
1901 dol_syslog(get_class($this).
'::showOutputField extrafieldsobjectkey required', LOG_ERR);
1902 return 'BadValueForParamExtraFieldsObjectKey';
1905 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
1906 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1907 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
1908 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
1909 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
1910 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
1911 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
1912 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
1913 $perms = (int)
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
1914 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
1915 $list = (string)
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
1916 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
1917 $cssview = $this->attributes[$extrafieldsobjectkey][
'cssview'][$key];
1919 $hidden = (empty($list) ? 1 : 0);
1928 if ($type ==
'date') {
1930 if ($value !==
'') {
1933 } elseif ($type ==
'datetime') {
1935 if ($value !==
'') {
1938 } elseif ($type ==
'datetimegmt') {
1940 if ($value !==
'') {
1943 } elseif ($type ==
'int') {
1945 } elseif ($type ==
'double') {
1946 if (!empty($value)) {
1948 $sizeparts = explode(
",", $size);
1949 $number_decimals = array_key_exists(1, $sizeparts) ? $sizeparts[1] : 0;
1950 $value =
price($value, 0, $outputlangs, 0, 0, $number_decimals,
'');
1952 } elseif ($type ==
'boolean') {
1954 if (!empty($value)) {
1955 $checked =
' checked ';
1958 $value =
'<input type="checkbox" '.$checked.
' '.($moreparam ? $moreparam :
'').
' readonly disabled>';
1960 $value =
yn($value ? 1 : 0);
1962 } elseif ($type ==
'mail') {
1964 } elseif ($type ==
'ip') {
1966 } elseif ($type ==
'icon') {
1967 $value =
'<span class="'.$value.
'"></span>';
1968 } elseif ($type ==
'url') {
1970 } elseif ($type ==
'phone') {
1972 } elseif ($type ==
'price') {
1974 if ($value || $value ==
'0') {
1975 $value =
price($value, 0, $outputlangs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1).
' '.$outputlangs->getCurrencySymbol($conf->currency);
1977 } elseif ($type ==
'pricecy') {
1978 $currency = $conf->currency;
1979 if (!empty($value)) {
1981 $pricetmp = explode(
':', $value);
1982 $currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
1983 $value = $pricetmp[0];
1985 if ($value || $value ==
'0') {
1986 $value =
price($value, 0, $outputlangs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1, $currency);
1988 } elseif ($type ==
'select') {
1989 $valstr = (!empty($param[
'options'][$value]) ? $param[
'options'][$value] :
'');
1990 if (($pos = strpos($valstr,
"|")) !==
false) {
1991 $valstr = substr($valstr, 0, $pos);
1993 if ($langfile && $valstr) {
1994 $value = $outputlangs->trans($valstr);
1998 } elseif ($type ==
'sellist') {
1999 $param_list = array_keys($param[
'options']);
2000 $InfoFieldList = explode(
":", $param_list[0]);
2002 $selectkey =
"rowid";
2005 if (count($InfoFieldList) >= 3) {
2006 $selectkey = $InfoFieldList[2];
2007 $keyList = $InfoFieldList[2].
' as rowid';
2010 $fields_label = explode(
'|', $InfoFieldList[1]);
2011 if (is_array($fields_label)) {
2013 $keyList .= implode(
', ', $fields_label);
2016 $filter_categorie =
false;
2017 if (count($InfoFieldList) > 5) {
2018 if ($InfoFieldList[0] ==
'categorie') {
2019 $filter_categorie =
true;
2023 $sql =
"SELECT ".$keyList;
2024 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
2025 if (!empty($InfoFieldList[4]) && strpos($InfoFieldList[4],
'extra.') !==
false) {
2028 if ($selectkey ==
'rowid' && empty($value)) {
2029 $sql .=
" WHERE ".$selectkey.
" = 0";
2030 } elseif ($selectkey ==
'rowid') {
2031 $sql .=
" WHERE ".$selectkey.
" = ".((int) $value);
2033 $sql .=
" WHERE ".$selectkey.
" = '".$this->db->escape($value).
"'";
2038 dol_syslog(get_class($this).
':showOutputField:$type=sellist', LOG_DEBUG);
2039 $resql = $this->db->query($sql);
2041 if ($filter_categorie ===
false) {
2044 $obj = $this->db->fetch_object($resql);
2047 $fields_label = explode(
'|', $InfoFieldList[1]);
2049 if (is_array($fields_label) && count($fields_label) > 1) {
2050 foreach ($fields_label as $field_toshow) {
2052 if (!empty($obj->$field_toshow)) {
2053 $translabel = $outputlangs->trans($obj->$field_toshow);
2055 if ($translabel != $obj->$field_toshow) {
2056 $value .=
dol_trunc($translabel, 24) .
' ';
2058 $value .= $obj->$field_toshow .
' ';
2064 $tmppropname = $InfoFieldList[1];
2066 if (!empty(isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
2067 $translabel = $outputlangs->trans($obj->$tmppropname);
2069 if ($translabel != (isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
2072 $value = isset($obj->$tmppropname) ? $obj->$tmppropname :
'';
2077 $obj = $this->db->fetch_object($resql);
2079 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
2081 $result = $c->fetch($obj->rowid);
2083 $ways = $c->print_all_ways();
2084 foreach ($ways as $way) {
2085 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ?
' style="background: #' . $c->color .
';"' :
' style="background: #bbb"') .
'>' .
img_object(
'',
'category') .
' ' . $way .
'</li>';
2089 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
2092 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
2094 } elseif ($type ==
'radio') {
2095 if (!isset($param[
'options'][$value])) {
2096 $outputlangs->load(
'errors');
2097 $value = $outputlangs->trans(
'ErrorNoValueForRadioType');
2099 $value = $outputlangs->trans($param[
'options'][$value]);
2101 } elseif ($type ==
'checkbox') {
2102 $value_arr = explode(
',', $value);
2105 if (is_array($value_arr)) {
2106 foreach ($value_arr as $keyval => $valueval) {
2107 if (!empty($valueval)) {
2108 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$param[
'options'][$valueval].
'</li>';
2112 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
2113 } elseif ($type ==
'chkbxlst') {
2114 $value_arr = explode(
',', $value);
2116 $param_list = array_keys($param[
'options']);
2117 $InfoFieldList = explode(
":", $param_list[0]);
2119 $selectkey =
"rowid";
2122 if (count($InfoFieldList) >= 3) {
2123 $selectkey = $InfoFieldList[2];
2124 $keyList = $InfoFieldList[2].
' as rowid';
2127 $fields_label = explode(
'|', $InfoFieldList[1]);
2128 if (is_array($fields_label)) {
2130 $keyList .= implode(
', ', $fields_label);
2133 $filter_categorie =
false;
2134 if (count($InfoFieldList) > 5) {
2135 if ($InfoFieldList[0] ==
'categorie') {
2136 $filter_categorie =
true;
2140 $sql =
"SELECT ".$keyList;
2141 $sql .=
" FROM ".$this->db->prefix().$InfoFieldList[0];
2142 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
2148 dol_syslog(get_class($this).
':showOutputField:$type=chkbxlst', LOG_DEBUG);
2149 $resql = $this->db->query($sql);
2151 if ($filter_categorie ===
false) {
2154 while ($obj = $this->db->fetch_object($resql)) {
2156 $fields_label = explode(
'|', $InfoFieldList[1]);
2157 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
2158 if (is_array($fields_label) && count($fields_label) > 1) {
2159 $label =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">';
2160 foreach ($fields_label as $field_toshow) {
2162 if (!empty($obj->$field_toshow)) {
2163 $translabel = $outputlangs->trans($obj->$field_toshow);
2165 if ($translabel != $field_toshow) {
2166 $label .=
' '.dol_trunc($translabel, 18);
2168 $label .=
' '.$obj->$field_toshow;
2172 $toprint[] = $label;
2175 if (!empty($obj->{$InfoFieldList[1]})) {
2176 $translabel = $outputlangs->trans($obj->{$InfoFieldList[1]});
2178 if ($translabel != $obj->{$InfoFieldList[1]}) {
2179 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).
'</li>';
2181 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->{$InfoFieldList[1]}.
'</li>';
2187 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2190 while ($obj = $this->db->fetch_object($resql)) {
2191 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
2193 $c->fetch($obj->rowid);
2194 $ways = $c->print_all_ways();
2195 foreach ($ways as $way) {
2196 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ?
' style="background: #'.$c->color.
';"' :
' style="background: #bbb"').
'>'.
img_object(
'',
'category').
' '.$way.
'</li>';
2201 if (!empty($toprint)) {
2202 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
2205 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
2207 } elseif ($type ==
'link') {
2212 $param_list = array_keys($param[
'options']);
2214 $InfoFieldList = explode(
":", $param_list[0]);
2215 $classname = $InfoFieldList[0];
2216 $classpath = $InfoFieldList[1];
2217 if (!empty($classpath)) {
2219 if ($classname && class_exists($classname)) {
2220 $object =
new $classname($this->db);
2222 $value =
$object->getNomUrl(3);
2225 dol_syslog(
'Error bad setup of extrafield', LOG_WARNING);
2226 return 'Error bad setup of extrafield';
2229 } elseif ($type ==
'point') {
2230 if (!empty($value)) {
2231 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeophp.class.php';
2233 $value = $dolgeophp->getXYString($value);
2237 } elseif (in_array($type, [
'multipts',
'linestrg',
'polygon'])) {
2238 if (!empty($value)) {
2239 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeophp.class.php';
2241 $value = $dolgeophp->getPointString($value);
2245 } elseif ($type ==
'text') {
2246 $value =
'<div class="'.($cssview ? $cssview :
'shortmessagecut').
'">'.
dol_htmlentitiesbr($value).
'</div>';
2247 } elseif ($type ==
'html') {
2249 } elseif ($type ==
'password') {
2250 $value =
dol_trunc(preg_replace(
'/./i',
'*', $value), 8,
'right',
'UTF-8', 1);
2252 $showsize = round((
float) $size);
2253 if ($showsize > 48) {