962 if (empty($elementtype)) {
966 if ($elementtype ==
'thirdparty') {
967 $elementtype =
'societe';
969 if ($elementtype ==
'contact') {
970 $elementtype =
'socpeople';
972 if ($elementtype ==
'order_supplier') {
973 $elementtype =
'commande_fournisseur';
979 $array_name_label = array();
982 $sql =
"SELECT rowid, name, label, type, size, elementtype, fieldunique, fieldrequired, param, pos, alwayseditable, perms, langs, list, printable, totalizable, fielddefault, fieldcomputed, entity, enabled, help,";
983 $sql .=
" css, cssview, csslist";
984 $sql .=
" FROM ".$this->db->prefix().
"extrafields";
986 if ($elementtype && $elementtype !=
'all') {
987 $sql .=
" WHERE elementtype = '".$this->db->escape($elementtype).
"'";
989 if ($attrname && $elementtype && $elementtype !=
'all') {
990 $sql .=
" AND name = '".$this->db->escape($attrname).
"'";
992 $sql .=
" ORDER BY pos";
994 $resql = $this->db->query($sql);
997 if ($this->db->num_rows($resql)) {
998 while ($tab = $this->db->fetch_object($resql)) {
999 if ($tab->entity != 0 && $tab->entity != $conf->entity) {
1001 if ($tab->fieldrequired && is_null($tab->fielddefault)) {
1002 $this->attributes[$tab->elementtype][
'mandatoryfieldsofotherentities'][$tab->name] = $tab->type;
1008 if ($tab->type !=
'separate') {
1009 $array_name_label[$tab->name] = $tab->label;
1013 $this->attributes[$tab->elementtype][
'type'][$tab->name] = $tab->type;
1014 $this->attributes[$tab->elementtype][
'label'][$tab->name] = $tab->label;
1015 $this->attributes[$tab->elementtype][
'size'][$tab->name] = $tab->size;
1016 $this->attributes[$tab->elementtype][
'elementtype'][$tab->name] = $tab->elementtype;
1017 $this->attributes[$tab->elementtype][
'default'][$tab->name] = $tab->fielddefault;
1018 $this->attributes[$tab->elementtype][
'computed'][$tab->name] = $tab->fieldcomputed;
1019 $this->attributes[$tab->elementtype][
'unique'][$tab->name] = $tab->fieldunique;
1020 $this->attributes[$tab->elementtype][
'required'][$tab->name] = $tab->fieldrequired;
1021 $this->attributes[$tab->elementtype][
'param'][$tab->name] = ($tab->param ?
jsonOrUnserialize($tab->param) :
'');
1022 $this->attributes[$tab->elementtype][
'pos'][$tab->name] = $tab->pos;
1023 $this->attributes[$tab->elementtype][
'alwayseditable'][$tab->name] = $tab->alwayseditable;
1024 $this->attributes[$tab->elementtype][
'perms'][$tab->name] = ((is_null($tab->perms) || strlen($tab->perms) == 0) ? 1 : $tab->perms);
1025 $this->attributes[$tab->elementtype][
'langfile'][$tab->name] = $tab->langs;
1026 $this->attributes[$tab->elementtype][
'list'][$tab->name] = $tab->list;
1027 $this->attributes[$tab->elementtype][
'printable'][$tab->name] = $tab->printable;
1028 $this->attributes[$tab->elementtype][
'totalizable'][$tab->name] = ($tab->totalizable ? 1 : 0);
1029 $this->attributes[$tab->elementtype][
'entityid'][$tab->name] = $tab->entity;
1030 $this->attributes[$tab->elementtype][
'enabled'][$tab->name] = $tab->enabled;
1031 $this->attributes[$tab->elementtype][
'help'][$tab->name] = $tab->help;
1032 $this->attributes[$tab->elementtype][
'css'][$tab->name] = $tab->css;
1033 $this->attributes[$tab->elementtype][
'cssview'][$tab->name] = $tab->cssview;
1034 $this->attributes[$tab->elementtype][
'csslist'][$tab->name] = $tab->csslist;
1036 $this->attributes[$tab->elementtype][
'loaded'] = 1;
1041 $this->attributes[$elementtype][
'loaded'] = 1;
1042 $this->attributes[$elementtype][
'count'] = $count;
1045 $this->error = $this->db->lasterror();
1046 dol_syslog(get_class($this).
"::fetch_name_optionals_label ".$this->error, LOG_ERR);
1049 return $array_name_label;
1068 public function showInputField($key, $value, $moreparam =
'', $keysuffix =
'', $keyprefix =
'', $morecss =
'', $objectid = 0, $extrafieldsobjectkey =
'', $mode = 0)
1070 global $conf, $langs, $form;
1072 if (!is_object($form)) {
1073 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
1074 $form =
new Form($this->db);
1079 if (!preg_match(
'/options_$/', $keyprefix)) {
1080 $keyprefix = $keyprefix.
'options_';
1083 if (empty($extrafieldsobjectkey)) {
1084 dol_syslog(get_class($this).
'::showInputField extrafieldsobjectkey required', LOG_ERR);
1085 return 'BadValueForParamExtraFieldsObjectKey';
1088 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
1089 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1090 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
1091 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
1092 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
1093 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
1094 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
1095 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
1096 $perms = (int)
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
1097 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
1098 $list = (string)
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
1099 $totalizable = $this->attributes[$extrafieldsobjectkey][
'totalizable'][$key];
1100 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
1101 $hidden = (empty($list) ? 1 : 0);
1107 if (!preg_match(
'/^search_/', $keyprefix)) {
1108 return '<span class="opacitymedium">'.$langs->trans(
"AutomaticallyCalculated").
'</span>';
1116 if (empty($morecss)) {
1118 if ($type ==
'date') {
1119 $morecss =
'minwidth100imp';
1120 } elseif ($type ==
'datetime' || $type ==
'datetimegmt' || $type ==
'link') {
1121 $morecss =
'minwidth200imp';
1122 } elseif (in_array($type, array(
'int',
'integer',
'double',
'price'))) {
1123 $morecss =
'maxwidth75';
1124 } elseif ($type ==
'password') {
1125 $morecss =
'maxwidth100';
1126 } elseif ($type ==
'url') {
1127 $morecss =
'minwidth400';
1128 } elseif ($type ==
'boolean') {
1130 } elseif ($type ==
'radio') {
1131 $morecss =
'width25';
1133 if (empty($size) || round((
float) $size) < 12) {
1134 $morecss =
'minwidth100';
1135 } elseif (round((
float) $size) <= 48) {
1136 $morecss =
'minwidth200';
1138 $morecss =
'minwidth400';
1142 if (!empty($this->attributes[$extrafieldsobjectkey][
'css'][$key])) {
1143 $morecss = $this->attributes[$extrafieldsobjectkey][
'css'][$key];
1147 if (in_array($type, array(
'date'))) {
1148 $tmp = explode(
',', $size);
1153 if (!$required && $value ==
'') {
1160 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1161 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1163 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1164 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1165 $out .=
'</div><div class="nowrap">';
1166 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1167 $out .=
'</div></div>';
1170 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1);
1172 } elseif (in_array($type, array(
'datetime',
'datetimegmt'))) {
1173 $tmp = explode(
',', $size);
1178 if (!$required && $value ==
'') {
1185 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1186 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1188 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1189 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"),
'tzuserrel');
1190 $out .=
'</div><div class="nowrap">';
1191 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
1192 $out .=
'</div></div>';
1195 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1,
'',
'',
'', 1,
'',
'',
'tzuserrel');
1197 } elseif (in_array($type, array(
'int',
'integer'))) {
1198 $tmp = explode(
',', $size);
1200 $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 :
'').
'>';
1201 } elseif (preg_match(
'/varchar/', $type)) {
1202 $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 :
'').
'>';
1203 } elseif (in_array($type, array(
'mail',
'ip',
'phone',
'url'))) {
1204 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1205 } elseif ($type ==
'icon') {
1211 $out .=
'<input type="text" class="form-control icp icp-auto iconpicker-element iconpicker-input flat '.$morecss.
' maxwidthonsmartphone"';
1212 $out .=
' name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1215 $options =
"{ title: '<b>".$langs->trans(
"IconFieldSelector").
"</b>', placement: 'right', showFooter: false, templates: {";
1216 $options .=
"iconpicker: '<div class=\"iconpicker\"><div style=\"background-color:#EFEFEF;\" class=\"iconpicker-items\"></div></div>',";
1217 $options .=
"iconpickerItem: '<a role=\"button\" href=\"#\" class=\"iconpicker-item\" style=\"background-color:#DDDDDD;\"><i></i></a>',";
1220 $options .=
"footer: '<div class=\"popover-footer\" style=\"background-color:#EFEFEF;\"></div>',";
1221 $options .=
"search: '<input type=\"search\" class\"form-control iconpicker-search\" placeholder=\"".$langs->trans(
"TypeToFilter").
"\" />',";
1222 $options .=
"popover: '<div class=\"iconpicker-popover popover\">";
1223 $options .=
" <div class=\"arrow\" ></div>";
1224 $options .=
" <div class=\"popover-title\" style=\"text-align:center;background-color:#EFEFEF;\"></div>";
1225 $options .=
" <div class=\"popover-content \" ></div>";
1226 $options .=
"</div>'}}";
1227 $out .=
"$('#".$keyprefix.$key.$keysuffix.
"').iconpicker(".$options.
");";
1228 $out .=
'</script>';
1230 } elseif ($type ==
'text') {
1231 if (!preg_match(
'/search_/', $keyprefix)) {
1232 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1233 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false,
false, ROWS_5,
'90%');
1234 $out = (string) $doleditor->Create(1);
1236 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1238 } elseif ($type ==
'html') {
1239 if (!preg_match(
'/search_/', $keyprefix)) {
1240 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1241 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false, isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_5,
'90%');
1242 $out = (string) $doleditor->Create(1);
1244 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1246 } elseif ($type ==
'boolean') {
1249 if (!empty($value)) {
1250 $checked =
' checked value="1" ';
1252 $checked =
' value="1" ';
1254 $out =
'<input type="checkbox" class="flat valignmiddle'.($morecss ?
' '.$morecss :
'').
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.$checked.
' '.($moreparam ? $moreparam :
'').
'>';
1256 $out = $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1,
false, 1);
1258 $out .=
'<input type="hidden" name="'.$keyprefix.$key.$keysuffix.
'_boolean" value="1">';
1259 } elseif ($type ==
'price') {
1260 if (!empty($value)) {
1261 $value =
price($value);
1263 $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).
'">';
1264 } elseif ($type ==
'pricecy') {
1265 $currency = $conf->currency;
1266 if (!empty($value)) {
1268 $pricetmp = explode(
':', $value);
1269 $currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
1270 $value =
price($pricetmp[0]);
1272 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1273 $out .= $form->selectCurrency($currency, $keyprefix.$key.$keysuffix.
'currency_id');
1274 } elseif ($type ==
'double') {
1275 if (!empty($value)) {
1276 $value =
price($value);
1278 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1279 } elseif ($type ==
'select') {
1283 foreach ($param[
'options'] as $okey => $val) {
1284 if ((
string) $okey ==
'') {
1288 $valarray = explode(
'|', $val);
1289 $val = $valarray[0];
1291 if ($langfile && $val) {
1292 $options[$okey] = $langs->trans($val);
1294 $options[$okey] = $val;
1297 $selected = array();
1298 if (!is_array($value)) {
1299 $selected = explode(
',', $value);
1302 $out .= $form->multiselectarray($keyprefix.$key.$keysuffix, $options, $selected, 0, 0, $morecss, 0, 0,
'',
'',
'', !empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2'));
1304 if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2')) {
1305 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1306 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1309 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1310 $out .=
'<option value="0"> </option>';
1311 foreach ($param[
'options'] as $key2 => $val2) {
1312 if ((
string) $key2 ==
'') {
1315 $valarray = explode(
'|', $val2);
1316 $val2 = $valarray[0];
1318 if (!empty($valarray[1])) {
1319 $parent = $valarray[1];
1321 $out .=
'<option value="'.$key2.
'"';
1322 $out .= (((string) $value == (
string) $key2) ?
' selected' :
'');
1323 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1325 if ($langfile && $val2) {
1326 $out .= $langs->trans($val2);
1330 $out .=
'</option>';
1332 $out .=
'</select>';
1334 } elseif ($type ==
'sellist') {
1336 if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2')) {
1337 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1338 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1341 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1342 if (is_array($param[
'options'])) {
1343 $tmpparamoptions = array_keys($param[
'options']);
1344 $paramoptions = preg_split(
'/[\r\n]+/', $tmpparamoptions[0]);
1346 $InfoFieldList = explode(
":", $paramoptions[0], 5);
1358 if (! empty($InfoFieldList[4])) {
1360 $parenthesisopen = 0;
1361 while (substr($InfoFieldList[4], $pos, 1) !==
'' && ($parenthesisopen || $pos == 0 || substr($InfoFieldList[4], $pos, 1) !=
':')) {
1362 if (substr($InfoFieldList[4], $pos, 1) ==
'(') {
1365 if (substr($InfoFieldList[4], $pos, 1) ==
')') {
1370 $tmpbefore = substr($InfoFieldList[4], 0, $pos);
1371 $tmpafter = substr($InfoFieldList[4], $pos + 1);
1373 $InfoFieldList[4] = $tmpbefore;
1374 if ($tmpafter !==
'') {
1375 $InfoFieldList = array_merge($InfoFieldList, explode(
':', $tmpafter));
1380 if (preg_match(
'/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) {
1381 $InfoFieldList[4] =
'('.$reg[1].
':'.$reg[2].
':'.$reg[3].
')';
1391 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1393 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1394 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1395 $keyList .=
', '.$parentField;
1397 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1398 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1399 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1401 $keyList = $InfoFieldList[2].
' as rowid';
1405 $filter_categorie =
false;
1406 if (count($InfoFieldList) > 5) {
1407 if ($InfoFieldList[0] ==
'categorie') {
1408 $filter_categorie =
true;
1412 if ($filter_categorie ===
false) {
1413 $fields_label = explode(
'|', $InfoFieldList[1]);
1414 if (is_array($fields_label)) {
1416 $keyList .= implode(
', ', $fields_label);
1420 $sql =
"SELECT ".$keyList;
1421 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1424 if (!empty($InfoFieldList[4])) {
1426 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1427 $InfoFieldList[4] = str_replace(
'$ENTITY$', (
string) $conf->entity, $InfoFieldList[4]);
1430 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1431 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1435 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1436 $InfoFieldList[4] = str_replace(
'$ID$', (
string) $objectid, $InfoFieldList[4]);
1438 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1443 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1444 $sql .=
' as main, '.$this->db->sanitize($this->db->prefix().$InfoFieldList[0]).
'_extrafields as extra';
1445 $sqlwhere .=
" WHERE extra.fk_object = main.".$this->db->sanitize($InfoFieldList[2]);
1451 $sqlwhere .=
' WHERE 1=1';
1468 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1469 $sqlwhere .=
' AND entity = '.((int) $conf->entity);
1474 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1476 dol_syslog(get_class($this).
'::showInputField type=sellist', LOG_DEBUG);
1477 $resql = $this->db->query($sql);
1479 $out .=
'<option value="0"> </option>';
1480 $num = $this->db->num_rows($resql);
1484 $obj = $this->db->fetch_object($resql);
1488 $fields_label = explode(
'|', $InfoFieldList[1]);
1489 if (is_array($fields_label) && count($fields_label) > 1) {
1491 foreach ($fields_label as $field_toshow) {
1492 $labeltoshow .= $obj->$field_toshow.
' ';
1495 $labeltoshow = $obj->{$InfoFieldList[1]};
1498 if ($value == $obj->rowid) {
1500 foreach ($fields_label as $field_toshow) {
1501 $translabel = $langs->trans($obj->$field_toshow);
1502 $labeltoshow = $translabel.
' ';
1505 $out .=
'<option value="'.$obj->rowid.
'" selected>'.$labeltoshow.
'</option>';
1508 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1509 $labeltoshow = $translabel;
1511 if (empty($labeltoshow)) {
1512 $labeltoshow =
'(not defined)';
1515 if (!empty($InfoFieldList[3]) && $parentField) {
1516 $parent = $parentName.
':'.$obj->{$parentField};
1519 $out .=
'<option value="'.$obj->rowid.
'"';
1520 $out .= ($value == $obj->rowid ?
' selected' :
'');
1521 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1522 $out .=
'>'.$labeltoshow.
'</option>';
1527 $this->db->free($resql);
1529 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1532 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1533 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1534 $out .=
'<option value="0"> </option>';
1535 if (is_array($data)) {
1536 foreach ($data as $data_key => $data_value) {
1537 $out .=
'<option value="'.$data_key.
'"';
1538 $out .= ($value == $data_key ?
' selected' :
'');
1539 $out .=
'>'.$data_value.
'</option>';
1544 $out .=
'</select>';
1545 } elseif ($type ==
'checkbox') {
1546 $value_arr = $value;
1547 if (!is_array($value)) {
1548 $value_arr = explode(
',', $value);
1550 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param[
'options']) ?
null : $param[
'options']), $value_arr,
'', 0,
'', 0,
'100%');
1551 } elseif ($type ==
'radio') {
1553 foreach ($param[
'options'] as $keyopt => $val) {
1554 $out .=
'<input class="flat '.$morecss.
'" type="radio" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'');
1555 $out .=
' value="'.$keyopt.
'"';
1556 $out .=
' id="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'"';
1557 $out .= ($value == $keyopt ?
'checked' :
'');
1558 $out .=
'/><label for="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'">'.$langs->trans($val).
'</label><br>';
1560 } elseif ($type ==
'chkbxlst') {
1561 if (is_array($value)) {
1562 $value_arr = $value;
1564 $value_arr = explode(
',', $value);
1567 if (is_array($param[
'options'])) {
1568 $tmpparamoptions = array_keys($param[
'options']);
1569 $paramoptions = preg_split(
'/[\r\n]+/', $tmpparamoptions[0]);
1571 $InfoFieldList = explode(
":", $paramoptions[0], 5);
1583 if (! empty($InfoFieldList[4])) {
1585 $parenthesisopen = 0;
1586 while (substr($InfoFieldList[4], $pos, 1) !==
'' && ($parenthesisopen || $pos == 0 || substr($InfoFieldList[4], $pos, 1) !=
':')) {
1587 if (substr($InfoFieldList[4], $pos, 1) ==
'(') {
1590 if (substr($InfoFieldList[4], $pos, 1) ==
')') {
1595 $tmpbefore = substr($InfoFieldList[4], 0, $pos);
1596 $tmpafter = substr($InfoFieldList[4], $pos + 1);
1598 $InfoFieldList[4] = $tmpbefore;
1599 if ($tmpafter !==
'') {
1600 $InfoFieldList = array_merge($InfoFieldList, explode(
':', $tmpafter));
1605 if (preg_match(
'/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) {
1606 $InfoFieldList[4] =
'('.$reg[1].
':'.$reg[2].
':'.$reg[3].
')';
1616 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1618 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1619 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1620 $keyList .=
', '.$parentField;
1622 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1623 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1624 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1626 $keyList = $InfoFieldList[2].
' as rowid';
1630 $filter_categorie =
false;
1631 if (count($InfoFieldList) > 5) {
1632 if ($InfoFieldList[0] ==
'categorie') {
1633 $filter_categorie =
true;
1637 if ($filter_categorie ===
false) {
1638 $fields_label = explode(
'|', $InfoFieldList[1]);
1639 if (is_array($fields_label)) {
1641 $keyList .= implode(
', ', $fields_label);
1645 $sql =
"SELECT ".$keyList;
1646 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1649 if (!empty($InfoFieldList[4])) {
1651 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1652 $InfoFieldList[4] = str_replace(
'$ENTITY$', (
string) $conf->entity, $InfoFieldList[4]);
1655 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1656 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1660 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1661 $InfoFieldList[4] = str_replace(
'$ID$', (
string) $objectid, $InfoFieldList[4]);
1662 } elseif (preg_match(
"#^.*list.php$#", $_SERVER[
"PHP_SELF"])) {
1664 $word =
'\b[a-zA-Z0-9-\.-_]+\b=\$ID\$';
1667 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1671 while ($nbPreg != 0) {
1673 $nbPregRepl = $nbPregSel = 0;
1675 $InfoFieldList[4] = preg_replace(
'#([^=])(\([^)^(]*('.$word.
')[^)^(]*\))#',
'$1 $3 ', $InfoFieldList[4], -1, $nbPregRepl);
1677 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1679 $InfoFieldList[4] = preg_replace(
'#\b[a-zA-Z0-9-\.-_]+\b=\([^)^(]*('.$word.
')[^)^(]*\)#',
'$1 ', $InfoFieldList[4], -1, $nbPregSel);
1681 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1684 $nbPreg = $nbPregRepl + $nbPregSel;
1688 $matchCondition = array();
1689 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1690 while (!empty($matchCondition[0])) {
1692 if (!empty($matchCondition[1]) && !empty($matchCondition[3]) && $matchCondition[1] != $matchCondition[3]) {
1694 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1696 if (!empty($matchCondition[1])) {
1697 $boolCond = (($matchCondition[1] ==
"AND") ?
' AND TRUE ' :
' OR FALSE ');
1698 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond.$matchCondition[3], $InfoFieldList[4]);
1699 } elseif (!empty($matchCondition[3])) {
1700 $boolCond = (($matchCondition[3] ==
"AND") ?
' TRUE AND ' :
' FALSE OR');
1701 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond, $InfoFieldList[4]);
1703 $InfoFieldList[4] =
" TRUE ";
1708 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1711 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1716 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1717 $sql .=
' as main, '.$this->db->sanitize($this->db->prefix().$InfoFieldList[0]).
'_extrafields as extra';
1718 $sqlwhere .=
" WHERE extra.fk_object = main.".$this->db->sanitize($InfoFieldList[2]);
1724 $sqlwhere .=
' WHERE 1=1';
1741 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1742 $sqlwhere .=
" AND entity = ".((int) $conf->entity);
1748 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1750 dol_syslog(get_class($this).
'::showInputField type=chkbxlst', LOG_DEBUG);
1751 $resql = $this->db->query($sql);
1753 $num = $this->db->num_rows($resql);
1760 $obj = $this->db->fetch_object($resql);
1764 $fields_label = explode(
'|', $InfoFieldList[1]);
1765 if (is_array($fields_label)) {
1767 foreach ($fields_label as $field_toshow) {
1768 $labeltoshow .= $obj->$field_toshow.
' ';
1771 $labeltoshow = $obj->{$InfoFieldList[1]};
1773 $labeltoshow =
dol_trunc($labeltoshow, 45);
1775 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1777 foreach ($fields_label as $field_toshow) {
1778 $translabel = $langs->trans($obj->$field_toshow);
1779 if ($translabel != $obj->$field_toshow) {
1780 $labeltoshow .=
' '.dol_trunc($translabel, 18).
' ';
1782 $labeltoshow .=
' '.dol_trunc($obj->$field_toshow, 18).
' ';
1785 $data[$obj->rowid] = $labeltoshow;
1788 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1789 if ($translabel != $obj->{$InfoFieldList[1]}) {
1790 $labeltoshow =
dol_trunc($translabel, 18);
1792 $labeltoshow =
dol_trunc($obj->{$InfoFieldList[1]}, 18);
1795 if (empty($labeltoshow)) {
1796 $labeltoshow =
'(not defined)';
1799 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1800 $data[$obj->rowid] = $labeltoshow;
1803 if (!empty($InfoFieldList[3]) && $parentField) {
1804 $parent = $parentName.
':'.$obj->{$parentField};
1807 $data[$obj->rowid] = $labeltoshow;
1812 $this->db->free($resql);
1814 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr,
'', 0,
'', 0,
'100%');
1816 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1819 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1820 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1821 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr,
'', 0,
'', 0,
'100%');
1824 } elseif ($type ==
'link') {
1825 $param_list = array_keys($param[
'options']);
1832 $showempty = (($required && $default !=
'') ? 0 : 1);
1834 $tmparray = explode(
':', $param_list[0]);
1836 $element = $extrafieldsobjectkey;
1837 if ($element ==
'socpeople') {
1838 $element =
'contact';
1839 } elseif ($element ==
'projet') {
1840 $element =
'project';
1844 $objectdesc = $tmparray[0];
1845 $objectfield = $element.
':options_'.$key;
1847 $out = $form->selectForForms($objectdesc, $keyprefix.$key.$keysuffix, $value, $showempty,
'',
'', $morecss,
'', 0, 0,
'', $objectfield);
1848 } elseif (in_array($type, [
'point',
'multipts',
'linestrg',
'polygon'])) {
1849 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeophp.class.php';
1853 if (!empty($value)) {
1854 $tmparray = $dolgeophp->parseGeoString($value);
1855 $geojson = $tmparray[
'geojson'];
1856 $centroidjson = $tmparray[
'centroidjson'];
1858 if (!preg_match(
'/search_/', $keyprefix)) {
1859 require_once DOL_DOCUMENT_ROOT.
'/core/class/geomapeditor.class.php';
1861 $out .= $geomapeditor->getHtml($keyprefix.$key.$keysuffix, $geojson, $centroidjson, $type);
1866 } elseif ($type ==
'password') {
1868 $out =
'<input style="display:none" type="text" name="fakeusernameremembered">';
1869 $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 :
'').
'>';
1871 if (!empty($hidden)) {
1872 $out =
'<input type="hidden" value="'.$value.
'" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'"/>';
1895 public function showOutputField($key, $value, $moreparam =
'', $extrafieldsobjectkey =
'', $outputlangs =
null)
1897 global $conf, $langs;
1899 if (is_null($outputlangs) || !is_object($outputlangs)) {
1900 $outputlangs = $langs;
1903 if (empty($extrafieldsobjectkey)) {
1904 dol_syslog(get_class($this).
'::showOutputField extrafieldsobjectkey required', LOG_ERR);
1905 return 'BadValueForParamExtraFieldsObjectKey';
1908 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
1909 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1910 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
1911 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
1912 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
1913 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
1914 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
1915 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
1916 $perms = (int)
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
1917 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
1918 $list = (string)
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
1919 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
1920 $cssview = $this->attributes[$extrafieldsobjectkey][
'cssview'][$key];
1922 $hidden = (empty($list) ? 1 : 0);
1931 if ($type ==
'date') {
1933 if ($value !==
'') {
1936 } elseif ($type ==
'datetime') {
1938 if ($value !==
'') {
1941 } elseif ($type ==
'datetimegmt') {
1943 if ($value !==
'') {
1946 } elseif ($type ==
'int') {
1948 } elseif ($type ==
'double') {
1949 if (!empty($value)) {
1951 $sizeparts = explode(
",", $size);
1952 $number_decimals = array_key_exists(1, $sizeparts) ? $sizeparts[1] : 0;
1953 $value =
price($value, 0, $outputlangs, 0, 0, $number_decimals,
'');
1955 } elseif ($type ==
'boolean') {
1957 if (!empty($value)) {
1958 $checked =
' checked ';
1961 $value =
'<input type="checkbox" '.$checked.
' '.($moreparam ? $moreparam :
'').
' readonly disabled>';
1963 $value =
yn($value ? 1 : 0);
1965 } elseif ($type ==
'mail') {
1967 } elseif ($type ==
'ip') {
1969 } elseif ($type ==
'icon') {
1970 $value =
'<span class="'.$value.
'"></span>';
1971 } elseif ($type ==
'url') {
1973 } elseif ($type ==
'phone') {
1975 } elseif ($type ==
'price') {
1977 if ($value || $value ==
'0') {
1978 $value =
price($value, 0, $outputlangs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1).
' '.$outputlangs->getCurrencySymbol($conf->currency);
1980 } elseif ($type ==
'pricecy') {
1981 $currency = $conf->currency;
1982 if (!empty($value)) {
1984 $pricetmp = explode(
':', $value);
1985 $currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
1986 $value = $pricetmp[0];
1988 if ($value || $value ==
'0') {
1989 $value =
price($value, 0, $outputlangs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1, $currency);
1991 } elseif ($type ==
'select') {
1992 $valstr = (!empty($param[
'options'][$value]) ? $param[
'options'][$value] :
'');
1993 if (($pos = strpos($valstr,
"|")) !==
false) {
1994 $valstr = substr($valstr, 0, $pos);
1996 if ($langfile && $valstr) {
1997 $value = $outputlangs->trans($valstr);
2001 } elseif ($type ==
'sellist') {
2002 $param_list = array_keys($param[
'options']);
2003 $InfoFieldList = explode(
":", $param_list[0]);
2005 $selectkey =
"rowid";
2008 if (count($InfoFieldList) >= 3) {
2009 $selectkey = $InfoFieldList[2];
2010 $keyList = $InfoFieldList[2].
' as rowid';
2013 $fields_label = explode(
'|', $InfoFieldList[1]);
2014 if (is_array($fields_label)) {
2016 $keyList .= implode(
', ', $fields_label);
2019 $filter_categorie =
false;
2020 if (count($InfoFieldList) > 5) {
2021 if ($InfoFieldList[0] ==
'categorie') {
2022 $filter_categorie =
true;
2026 $sql =
"SELECT ".$keyList;
2027 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
2028 if (!empty($InfoFieldList[4]) && strpos($InfoFieldList[4],
'extra.') !==
false) {
2031 if ($selectkey ==
'rowid' && empty($value)) {
2032 $sql .=
" WHERE ".$selectkey.
" = 0";
2033 } elseif ($selectkey ==
'rowid') {
2034 $sql .=
" WHERE ".$selectkey.
" = ".((int) $value);
2036 $sql .=
" WHERE ".$selectkey.
" = '".$this->db->escape($value).
"'";
2041 dol_syslog(get_class($this).
':showOutputField:$type=sellist', LOG_DEBUG);
2042 $resql = $this->db->query($sql);
2044 if ($filter_categorie ===
false) {
2047 $obj = $this->db->fetch_object($resql);
2050 $fields_label = explode(
'|', $InfoFieldList[1]);
2052 if (is_array($fields_label) && count($fields_label) > 1) {
2053 foreach ($fields_label as $field_toshow) {
2055 if (!empty($obj->$field_toshow)) {
2056 $translabel = $outputlangs->trans($obj->$field_toshow);
2058 if ($translabel != $obj->$field_toshow) {
2059 $value .=
dol_trunc($translabel, 24) .
' ';
2061 $value .= $obj->$field_toshow .
' ';
2067 $tmppropname = $InfoFieldList[1];
2069 if (!empty(isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
2070 $translabel = $outputlangs->trans($obj->$tmppropname);
2072 if ($translabel != (isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
2075 $value = isset($obj->$tmppropname) ? $obj->$tmppropname :
'';
2080 $obj = $this->db->fetch_object($resql);
2082 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
2084 $result = $c->fetch($obj->rowid);
2086 $ways = $c->print_all_ways();
2087 foreach ($ways as $way) {
2088 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ?
' style="background: #' . $c->color .
';"' :
' style="background: #bbb"') .
'>' .
img_object(
'',
'category') .
' ' . $way .
'</li>';
2092 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
2095 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
2097 } elseif ($type ==
'radio') {
2098 if (!isset($param[
'options'][$value])) {
2099 $outputlangs->load(
'errors');
2100 $value = $outputlangs->trans(
'ErrorNoValueForRadioType');
2102 $value = $outputlangs->trans($param[
'options'][$value]);
2104 } elseif ($type ==
'checkbox') {
2105 $value_arr = explode(
',', $value);
2108 if (is_array($value_arr)) {
2109 foreach ($value_arr as $keyval => $valueval) {
2110 if (!empty($valueval)) {
2111 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$param[
'options'][$valueval].
'</li>';
2115 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
2116 } elseif ($type ==
'chkbxlst') {
2117 $value_arr = explode(
',', $value);
2119 $param_list = array_keys($param[
'options']);
2120 $InfoFieldList = explode(
":", $param_list[0]);
2122 $selectkey =
"rowid";
2125 if (count($InfoFieldList) >= 3) {
2126 $selectkey = $InfoFieldList[2];
2127 $keyList = $InfoFieldList[2].
' as rowid';
2130 $fields_label = explode(
'|', $InfoFieldList[1]);
2131 if (is_array($fields_label)) {
2133 $keyList .= implode(
', ', $fields_label);
2136 $filter_categorie =
false;
2137 if (count($InfoFieldList) > 5) {
2138 if ($InfoFieldList[0] ==
'categorie') {
2139 $filter_categorie =
true;
2143 $sql =
"SELECT ".$keyList;
2144 $sql .=
" FROM ".$this->db->prefix().$InfoFieldList[0];
2145 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
2151 dol_syslog(get_class($this).
':showOutputField:$type=chkbxlst', LOG_DEBUG);
2152 $resql = $this->db->query($sql);
2154 if ($filter_categorie ===
false) {
2157 while ($obj = $this->db->fetch_object($resql)) {
2159 $fields_label = explode(
'|', $InfoFieldList[1]);
2160 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
2161 if (is_array($fields_label) && count($fields_label) > 1) {
2162 $label =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">';
2163 foreach ($fields_label as $field_toshow) {
2165 if (!empty($obj->$field_toshow)) {
2166 $translabel = $outputlangs->trans($obj->$field_toshow);
2168 if ($translabel != $field_toshow) {
2169 $label .=
' '.dol_trunc($translabel, 18);
2171 $label .=
' '.$obj->$field_toshow;
2175 $toprint[] = $label;
2178 if (!empty($obj->{$InfoFieldList[1]})) {
2179 $translabel = $outputlangs->trans($obj->{$InfoFieldList[1]});
2181 if ($translabel != $obj->{$InfoFieldList[1]}) {
2182 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).
'</li>';
2184 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->{$InfoFieldList[1]}.
'</li>';
2190 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2193 while ($obj = $this->db->fetch_object($resql)) {
2194 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
2196 $c->fetch($obj->rowid);
2197 $ways = $c->print_all_ways();
2198 foreach ($ways as $way) {
2199 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ?
' style="background: #'.$c->color.
';"' :
' style="background: #bbb"').
'>'.
img_object(
'',
'category').
' '.$way.
'</li>';
2204 if (!empty($toprint)) {
2205 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
2208 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
2210 } elseif ($type ==
'link') {
2215 $param_list = array_keys($param[
'options']);
2217 $InfoFieldList = explode(
":", $param_list[0]);
2218 $classname = $InfoFieldList[0];
2219 $classpath = $InfoFieldList[1];
2220 if (!empty($classpath)) {
2222 if ($classname && class_exists($classname)) {
2223 $object =
new $classname($this->db);
2225 $value =
$object->getNomUrl(3);
2228 dol_syslog(
'Error bad setup of extrafield', LOG_WARNING);
2229 return 'Error bad setup of extrafield';
2232 } elseif ($type ==
'point') {
2233 if (!empty($value)) {
2234 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeophp.class.php';
2236 $value = $dolgeophp->getXYString($value);
2240 } elseif (in_array($type, [
'multipts',
'linestrg',
'polygon'])) {
2241 if (!empty($value)) {
2242 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeophp.class.php';
2244 $value = $dolgeophp->getPointString($value);
2248 } elseif ($type ==
'text') {
2249 $value =
'<div class="'.($cssview ? $cssview :
'shortmessagecut').
'">'.
dol_htmlentitiesbr($value).
'</div>';
2250 } elseif ($type ==
'html') {
2252 } elseif ($type ==
'password') {
2253 $value =
dol_trunc(preg_replace(
'/./i',
'*', $value), 8,
'right',
'UTF-8', 1);
2255 $showsize = round((
float) $size);
2256 if ($showsize > 48) {