1092 public function showInputField($key, $value, $moreparam =
'', $keysuffix =
'', $keyprefix =
'', $morecss =
'',
$object = 0, $extrafieldsobjectkey =
'', $mode = 0)
1094 global
$conf, $langs, $form;
1096 if (!is_object($form)) {
1097 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
1098 $form =
new Form($this->db);
1105 if (!preg_match(
'/options_$/', $keyprefix)) {
1106 $keyprefix .=
'options_';
1109 if (empty($extrafieldsobjectkey)) {
1110 dol_syslog(get_class($this).
'::showInputField extrafieldsobjectkey required', LOG_ERR);
1111 return 'BadValueForParamExtraFieldsObjectKey';
1114 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
1115 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1116 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
1117 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
1118 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
1119 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
1120 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
1121 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
1122 $perms = (int)
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
1123 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
1124 $list = (string)
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
1125 $totalizable = $this->attributes[$extrafieldsobjectkey][
'totalizable'][$key];
1126 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
1127 $alwayseditable = $this->attributes[$extrafieldsobjectkey][
'alwayseditable'][$key];
1128 $hidden = (empty($list) ? 1 : 0);
1134 if (!preg_match(
'/^search_/', $keyprefix)) {
1135 return '<span class="opacitymedium">'.$langs->trans(
"AutomaticallyCalculated").
'</span>';
1143 if (empty($morecss)) {
1145 if ($type ==
'date') {
1146 $morecss =
'minwidth100imp';
1147 } elseif ($type ==
'datetime' || $type ==
'datetimegmt' || $type ==
'link') {
1148 $morecss =
'minwidth200imp';
1149 } elseif (in_array($type, array(
'int',
'integer',
'double',
'price'))) {
1150 $morecss =
'maxwidth75';
1151 } elseif ($type ==
'password') {
1152 $morecss =
'maxwidth100';
1153 } elseif ($type ==
'url') {
1154 $morecss =
'minwidth400';
1155 } elseif ($type ==
'boolean') {
1157 } elseif ($type ==
'radio') {
1158 $morecss =
'width25';
1160 if (empty($size) || round((
float) $size) < 12) {
1161 $morecss =
'minwidth100';
1162 } elseif (round((
float) $size) <= 48) {
1163 $morecss =
'minwidth200';
1165 $morecss =
'minwidth400';
1169 if (!empty($this->attributes[$extrafieldsobjectkey][
'css'][$key])) {
1170 $morecss = $this->attributes[$extrafieldsobjectkey][
'css'][$key];
1174 if (in_array($type, array(
'date'))) {
1175 $tmp = explode(
',', $size);
1180 if (!$required && $value ==
'') {
1187 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1188 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1190 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1191 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1192 $out .=
'</div><div class="nowrap">';
1193 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1194 $out .=
'</div></div>';
1197 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1);
1199 } elseif (in_array($type, array(
'datetime',
'datetimegmt'))) {
1200 $tmp = explode(
',', $size);
1205 if (!$required && $value ==
'') {
1212 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1213 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1215 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1216 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"),
'tzuserrel');
1217 $out .=
'</div><div class="nowrap">';
1218 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
1219 $out .=
'</div></div>';
1222 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1,
'',
'',
'', 1,
'',
'',
'tzuserrel');
1224 } elseif (in_array($type, array(
'int',
'integer'))) {
1225 $tmp = explode(
',', $size);
1227 $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 :
'').
'>';
1228 } elseif (preg_match(
'/varchar/', $type)) {
1229 $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 :
'').
'>';
1230 } elseif (in_array($type, array(
'mail',
'ip',
'phone',
'url'))) {
1231 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1232 } elseif ($type ==
'icon') {
1238 $out .=
'<input type="text" class="form-control icp icp-auto iconpicker-element iconpicker-input flat '.$morecss.
' maxwidthonsmartphone"';
1239 $out .=
' name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1242 $options =
"{ title: '<b>".$langs->trans(
"IconFieldSelector").
"</b>', placement: 'right', showFooter: false, templates: {";
1243 $options .=
"iconpicker: '<div class=\"iconpicker\"><div style=\"background-color:#EFEFEF;\" class=\"iconpicker-items\"></div></div>',";
1244 $options .=
"iconpickerItem: '<a role=\"button\" href=\"#\" class=\"iconpicker-item\" style=\"background-color:#DDDDDD;\"><i></i></a>',";
1247 $options .=
"footer: '<div class=\"popover-footer\" style=\"background-color:#EFEFEF;\"></div>',";
1248 $options .=
"search: '<input type=\"search\" class\"form-control iconpicker-search\" placeholder=\"".$langs->trans(
"TypeToFilter").
"\" />',";
1249 $options .=
"popover: '<div class=\"iconpicker-popover popover\">";
1250 $options .=
" <div class=\"arrow\" ></div>";
1251 $options .=
" <div class=\"popover-title\" style=\"text-align:center;background-color:#EFEFEF;\"></div>";
1252 $options .=
" <div class=\"popover-content \" ></div>";
1253 $options .=
"</div>'}}";
1254 $out .=
"$('#".$keyprefix.$key.$keysuffix.
"').iconpicker(".$options.
");";
1255 $out .=
'</script>';
1257 } elseif ($type ==
'text') {
1258 if (!preg_match(
'/search_/', $keyprefix)) {
1259 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1260 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false,
false, ROWS_5,
'90%');
1261 $out = (string) $doleditor->Create(1);
1263 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1265 } elseif ($type ==
'html') {
1266 if (!preg_match(
'/search_/', $keyprefix)) {
1267 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1268 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false, isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_5,
'90%');
1269 $out = (string) $doleditor->Create(1);
1271 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1273 } elseif ($type ==
'boolean') {
1276 if (!empty($value)) {
1277 $checked =
' checked value="1" ';
1279 $checked =
' value="1" ';
1281 $out =
'<input type="checkbox" class="flat valignmiddle'.($morecss ?
' '.$morecss :
'').
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.$checked.
' '.($moreparam ? $moreparam :
'').
'>';
1283 $out = $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1,
false, 1, 1,
'width75 yesno');
1285 $out .=
'<input type="hidden" name="'.$keyprefix.$key.$keysuffix.
'_boolean" value="1">';
1286 } elseif ($type ==
'price') {
1287 if (!empty($value)) {
1288 $value =
price($value);
1290 $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).
'">';
1291 } elseif ($type ==
'pricecy') {
1292 $currency =
$conf->currency;
1293 if (!empty($value)) {
1295 $pricetmp = explode(
':', $value);
1296 $currency = !empty($pricetmp[1]) ? $pricetmp[1] :
$conf->currency;
1297 $value =
price($pricetmp[0]);
1299 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1300 $out .= $form->selectCurrency($currency, $keyprefix.$key.$keysuffix.
'currency_id');
1301 } elseif ($type ==
'duration') {
1302 $value = intval($value);
1303 $out = $form->select_duration($keyprefix . $key, $value, 0,
'text', 0, 1);
1304 } elseif ($type ==
'double') {
1305 if (!empty($value)) {
1306 $value =
price($value);
1308 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1309 } elseif ($type ==
'select') {
1313 foreach ($param[
'options'] as $okey => $val) {
1314 if ((
string) $okey ==
'') {
1318 $valarray = explode(
'|', $val);
1319 $val = $valarray[0];
1321 if ($langfile && $val) {
1322 $options[$okey] = $langs->trans($val);
1324 $options[$okey] = $val;
1327 $selected = array();
1328 if (!is_array($value)) {
1329 $selected = explode(
',', $value);
1332 $out .= $form->multiselectarray($keyprefix.$key.$keysuffix, $options, $selected, 0, 0, $morecss, 0, 0,
'',
'',
'', !empty(
$conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2'));
1335 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1336 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1339 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1340 $out .=
'<option value="0"> </option>';
1341 foreach ($param[
'options'] as $key2 => $val2) {
1342 if ((
string) $key2 ==
'') {
1345 $valarray = explode(
'|', $val2);
1346 $val2 = $valarray[0];
1348 if (!empty($valarray[1])) {
1349 $parent = $valarray[1];
1351 $out .=
'<option value="'.$key2.
'"';
1352 $out .= (((string) $value == (
string) $key2) ?
' selected' :
'');
1353 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1355 if ($langfile && $val2) {
1356 $out .= $langs->trans($val2);
1360 $out .=
'</option>';
1362 $out .=
'</select>';
1364 } elseif ($type ==
'sellist') {
1367 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1368 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1371 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1372 if (is_array($param[
'options'])) {
1373 $tmpparamoptions = array_keys($param[
'options']);
1374 $paramoptions = preg_split(
'/[\r\n]+/', $tmpparamoptions[0]);
1376 $InfoFieldList = explode(
":", $paramoptions[0], 5);
1388 if (! empty($InfoFieldList[4])) {
1390 $parenthesisopen = 0;
1391 while (substr($InfoFieldList[4], $pos, 1) !==
'' && ($parenthesisopen || $pos == 0 || substr($InfoFieldList[4], $pos, 1) !=
':')) {
1392 if (substr($InfoFieldList[4], $pos, 1) ==
'(') {
1395 if (substr($InfoFieldList[4], $pos, 1) ==
')') {
1400 $tmpbefore = substr($InfoFieldList[4], 0, $pos);
1401 $tmpafter = substr($InfoFieldList[4], $pos + 1);
1403 $InfoFieldList[4] = $tmpbefore;
1404 if ($tmpafter !==
'') {
1405 $InfoFieldList = array_merge($InfoFieldList, explode(
':', $tmpafter));
1410 if (preg_match(
'/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) {
1411 $InfoFieldList[4] =
'('.$reg[1].
':'.$reg[2].
':'.$reg[3].
')';
1421 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1423 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1424 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1425 $keyList .=
', '.$parentField;
1427 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1428 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1429 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1431 $keyList = $InfoFieldList[2].
' as rowid';
1435 $filter_categorie =
false;
1436 if (count($InfoFieldList) > 5) {
1437 if ($InfoFieldList[0] ==
'categorie') {
1438 $filter_categorie =
true;
1442 if (!$filter_categorie) {
1443 $fields_label = explode(
'|', $InfoFieldList[1]);
1444 if (is_array($fields_label)) {
1446 $keyList .= implode(
', ', $fields_label);
1450 $sql =
"SELECT ".$keyList;
1451 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1454 if (!empty($InfoFieldList[4])) {
1456 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1457 $InfoFieldList[4] = str_replace(
'$ENTITY$', (
string)
$conf->entity, $InfoFieldList[4]);
1460 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1461 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1465 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1466 $InfoFieldList[4] = str_replace(
'$ID$', (
string) $objectid, $InfoFieldList[4]);
1468 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1473 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1474 $sql .=
' as main, '.$this->db->sanitize($this->db->prefix().$InfoFieldList[0]).
'_extrafields as extra';
1475 $sqlwhere .=
" WHERE extra.fk_object = main.".$this->db->sanitize($InfoFieldList[2]);
1481 $sqlwhere .=
' WHERE 1=1';
1498 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1499 $sqlwhere .=
' AND entity = '.((int)
$conf->entity);
1504 $sql .= $this->db->order(implode(
',', $fields_label));
1506 dol_syslog(get_class($this).
'::showInputField type=sellist', LOG_DEBUG);
1507 $resql = $this->db->query($sql);
1509 $out .=
'<option value="0"> </option>';
1510 $num = $this->db->num_rows($resql);
1514 $obj = $this->db->fetch_object($resql);
1518 $fields_label = explode(
'|', $InfoFieldList[1]);
1519 if (is_array($fields_label) && count($fields_label) > 1) {
1521 foreach ($fields_label as $field_toshow) {
1522 $labeltoshow .= $obj->$field_toshow.
' ';
1525 $labeltoshow = $obj->{$InfoFieldList[1]};
1528 if ($value == $obj->rowid) {
1530 foreach ($fields_label as $field_toshow) {
1531 $translabel = $langs->trans($obj->$field_toshow);
1532 $labeltoshow = $translabel.
' ';
1535 $out .=
'<option value="'.$obj->rowid.
'" selected>'.$labeltoshow.
'</option>';
1538 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1539 $labeltoshow = $translabel;
1541 if (empty($labeltoshow)) {
1542 $labeltoshow =
'(not defined)';
1545 if (!empty($InfoFieldList[3]) && $parentField) {
1546 $parent = $parentName.
':'.$obj->{$parentField};
1549 $out .=
'<option value="'.$obj->rowid.
'"';
1550 $out .= ($value == $obj->rowid ?
' selected' :
'');
1551 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1552 $out .=
'>'.$labeltoshow.
'</option>';
1557 $this->db->free($resql);
1559 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1562 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1563 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1564 $out .=
'<option value="0"> </option>';
1565 if (is_array($data)) {
1566 foreach ($data as $data_key => $data_value) {
1567 $out .=
'<option value="'.$data_key.
'"';
1568 $out .= ($value == $data_key ?
' selected' :
'');
1569 $out .=
'>'.$data_value.
'</option>';
1574 $out .=
'</select>';
1575 } elseif ($type ==
'checkbox') {
1576 $value_arr = $value;
1577 if (!is_array($value)) {
1578 $value_arr = explode(
',', $value);
1580 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param[
'options']) ?
null : $param[
'options']), $value_arr, 0, 0,
'', 0,
'100%');
1581 } elseif ($type ==
'radio') {
1583 foreach ($param[
'options'] as $keyopt => $val) {
1584 $out .=
'<input class="flat '.$morecss.
'" type="radio" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'');
1585 $out .=
' value="'.$keyopt.
'"';
1586 $out .=
' id="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'"';
1587 $out .= ($value == $keyopt ?
'checked' :
'');
1588 $out .=
'/><label for="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'">'.$langs->trans($val).
'</label><br>';
1590 } elseif ($type ==
'chkbxlst') {
1591 if (is_array($value)) {
1592 $value_arr = $value;
1594 $value_arr = explode(
',', $value);
1597 if (is_array($param[
'options'])) {
1598 $tmpparamoptions = array_keys($param[
'options']);
1599 $paramoptions = preg_split(
'/[\r\n]+/', $tmpparamoptions[0]);
1601 $InfoFieldList = explode(
":", $paramoptions[0], 5);
1613 if (! empty($InfoFieldList[4])) {
1615 $parenthesisopen = 0;
1616 while (substr($InfoFieldList[4], $pos, 1) !==
'' && ($parenthesisopen || $pos == 0 || substr($InfoFieldList[4], $pos, 1) !=
':')) {
1617 if (substr($InfoFieldList[4], $pos, 1) ==
'(') {
1620 if (substr($InfoFieldList[4], $pos, 1) ==
')') {
1625 $tmpbefore = substr($InfoFieldList[4], 0, $pos);
1626 $tmpafter = substr($InfoFieldList[4], $pos + 1);
1628 $InfoFieldList[4] = $tmpbefore;
1629 if ($tmpafter !==
'') {
1630 $InfoFieldList = array_merge($InfoFieldList, explode(
':', $tmpafter));
1635 if (preg_match(
'/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) {
1636 $InfoFieldList[4] =
'('.$reg[1].
':'.$reg[2].
':'.$reg[3].
')';
1646 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1648 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1649 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1650 $keyList .=
', '.$parentField;
1652 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1653 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1654 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1656 $keyList = $InfoFieldList[2].
' as rowid';
1660 $filter_categorie =
false;
1661 if (count($InfoFieldList) > 5) {
1662 if ($InfoFieldList[0] ==
'categorie') {
1663 $filter_categorie =
true;
1667 if (!$filter_categorie) {
1668 $fields_label = explode(
'|', $InfoFieldList[1]);
1669 if (is_array($fields_label)) {
1671 $keyList .= implode(
', ', $fields_label);
1675 $sql =
"SELECT ".$keyList;
1676 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1679 if (!empty($InfoFieldList[4])) {
1681 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1682 $InfoFieldList[4] = str_replace(
'$ENTITY$', (
string)
$conf->entity, $InfoFieldList[4]);
1685 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1686 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1690 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1691 $InfoFieldList[4] = str_replace(
'$ID$', (
string) $objectid, $InfoFieldList[4]);
1692 } elseif (preg_match(
"#^.*list.php$#", $_SERVER[
"PHP_SELF"])) {
1694 $word =
'\b[a-zA-Z0-9-\.-_]+\b=\$ID\$';
1697 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1701 while ($nbPreg != 0) {
1703 $nbPregRepl = $nbPregSel = 0;
1705 $InfoFieldList[4] = preg_replace(
'#([^=])(\([^)^(]*('.$word.
')[^)^(]*\))#',
'$1 $3 ', $InfoFieldList[4], -1, $nbPregRepl);
1707 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1709 $InfoFieldList[4] = preg_replace(
'#\b[a-zA-Z0-9-\.-_]+\b=\([^)^(]*('.$word.
')[^)^(]*\)#',
'$1 ', $InfoFieldList[4], -1, $nbPregSel);
1711 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1714 $nbPreg = $nbPregRepl + $nbPregSel;
1718 $matchCondition = array();
1719 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1720 while (!empty($matchCondition[0])) {
1722 if (!empty($matchCondition[1]) && !empty($matchCondition[3]) && $matchCondition[1] != $matchCondition[3]) {
1724 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1726 if (!empty($matchCondition[1])) {
1727 $boolCond = (($matchCondition[1] ==
"AND") ?
' AND TRUE ' :
' OR FALSE ');
1728 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond.$matchCondition[3], $InfoFieldList[4]);
1729 } elseif (!empty($matchCondition[3])) {
1730 $boolCond = (($matchCondition[3] ==
"AND") ?
' TRUE AND ' :
' FALSE OR');
1731 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond, $InfoFieldList[4]);
1733 $InfoFieldList[4] =
" TRUE ";
1738 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1741 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1746 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1747 $sql .=
' as main, '.$this->db->sanitize($this->db->prefix().$InfoFieldList[0]).
'_extrafields as extra';
1748 $sqlwhere .=
" WHERE extra.fk_object = main.".$this->db->sanitize($InfoFieldList[2]);
1754 $sqlwhere .=
' WHERE 1=1';
1771 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1772 $sqlwhere .=
" AND entity = ".((int)
$conf->entity);
1778 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1780 dol_syslog(get_class($this).
'::showInputField type=chkbxlst', LOG_DEBUG);
1781 $resql = $this->db->query($sql);
1783 $num = $this->db->num_rows($resql);
1790 $obj = $this->db->fetch_object($resql);
1794 $fields_label = explode(
'|', $InfoFieldList[1]);
1795 if (is_array($fields_label)) {
1797 foreach ($fields_label as $field_toshow) {
1798 $labeltoshow .= $obj->$field_toshow.
' ';
1801 $labeltoshow = $obj->{$InfoFieldList[1]};
1803 $labeltoshow =
dol_trunc($labeltoshow, 45);
1805 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1807 foreach ($fields_label as $field_toshow) {
1808 $translabel = $langs->trans($obj->$field_toshow);
1809 if ($translabel != $obj->$field_toshow) {
1810 $labeltoshow .=
' '.dol_trunc($translabel, 18).
' ';
1812 $labeltoshow .=
' '.dol_trunc($obj->$field_toshow, 18).
' ';
1815 $data[$obj->rowid] = $labeltoshow;
1818 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1819 if ($translabel != $obj->{$InfoFieldList[1]}) {
1820 $labeltoshow =
dol_trunc($translabel, 18);
1822 $labeltoshow =
dol_trunc($obj->{$InfoFieldList[1]}, 18);
1825 if (empty($labeltoshow)) {
1826 $labeltoshow =
'(not defined)';
1829 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1830 $data[$obj->rowid] = $labeltoshow;
1833 if (!empty($InfoFieldList[3]) && $parentField) {
1834 $parent = $parentName.
':'.$obj->{$parentField};
1837 $data[$obj->rowid] = $labeltoshow;
1842 $this->db->free($resql);
1844 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, 0, 0,
'', 0,
'100%');
1846 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1849 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1850 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1851 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, 0, 0,
'', 0,
'100%');
1854 } elseif ($type ==
'link') {
1855 $param_list = array_keys($param[
'options']);
1862 $showempty = (($required && $default !=
'') ? 0 : 1);
1864 $tmparray = explode(
':', $param_list[0]);
1866 $element = $extrafieldsobjectkey;
1867 if ($element ==
'socpeople') {
1868 $element =
'contact';
1869 } elseif ($element ==
'projet') {
1870 $element =
'project';
1874 $objectdesc = $tmparray[0];
1875 $objectfield = $element.
':options_'.$key;
1877 $out = $form->selectForForms($objectdesc, $keyprefix.$key.$keysuffix, $value, $showempty,
'',
'', $morecss,
'', 0, 0,
'', $objectfield);
1878 } elseif (in_array($type, [
'point',
'multipts',
'linestrg',
'polygon'])) {
1879 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeophp.class.php';
1883 if (!empty($value)) {
1884 $tmparray = $dolgeophp->parseGeoString($value);
1885 $geojson = $tmparray[
'geojson'];
1886 $centroidjson = $tmparray[
'centroidjson'];
1888 if (!preg_match(
'/search_/', $keyprefix)) {
1889 require_once DOL_DOCUMENT_ROOT.
'/core/class/geomapeditor.class.php';
1891 $out .= $geomapeditor->getHtml($keyprefix.$key.$keysuffix, $geojson, $centroidjson, $type);
1896 } elseif ($type ==
'password') {
1898 $out =
'<input style="display:none" type="text" name="fakeusernameremembered">';
1899 $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 :
'').
'>';
1900 } elseif ($type ==
'stars') {
1901 $out =
'<input type="hidden" class="flat '.$morecss.
'" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'"'.($moreparam ? $moreparam :
'').
'>';
1902 $out .=
'<div class="star-selection" id="'.$keyprefix.$key.$keysuffix.
'_selection">';
1904 while ($i <= $size) {
1905 $out .=
'<span class="star" data-value="'.$i.
'">'.
img_picto(
'',
'fontawesome_star_fas').
'</span>';
1910 jQuery(function($) {
1911 let container = $("#'.$keyprefix.$key.$keysuffix.
'_selection");
1912 let selectedStars = parseInt($("#'.$keyprefix.$key.$keysuffix.
'").val()) || 0;
1913 container.find(".star").each(function() {
1914 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
1916 container.find(".star").on("mouseover", function() {
1917 let selectedStar = $(this).data("value");
1918 container.find(".star").each(function() {
1919 $(this).toggleClass("active", $(this).data("value") <= selectedStar);
1922 container.on("mouseout", function() {
1923 container.find(".star").each(function() {
1924 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
1927 container.find(".star").off("click").on("click", function() {
1928 selectedStars = $(this).data("value");
1929 if (selectedStars === 1 && $("#'.$keyprefix.$key.$keysuffix.
'").val() == 1) {
1932 $("#'.$keyprefix.$key.$keysuffix.
'").val(selectedStars);
1933 container.find(".star").each(function() {
1934 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
1940 if (!empty($hidden)) {
1941 $out =
'<input type="hidden" value="'.$value.
'" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'"/>';
1946 if ($alwayseditable == 0 && is_object(
$object) && isset(
$object->status) && defined(get_class(
$object).
"::STATUS_DRAFT") &&
$object->status != $object::STATUS_DRAFT) {
1947 $out = $this->showOutputField($key, $value, $moreparam, $extrafieldsobjectkey,
null,
$object);
1971 public function showOutputField($key, $value, $moreparam =
'', $extrafieldsobjectkey =
'', $outputlangs =
null,
$object =
null)
1973 global
$conf, $langs;
1975 if (is_null($outputlangs) || !is_object($outputlangs)) {
1976 $outputlangs = $langs;
1979 if (empty($extrafieldsobjectkey)) {
1980 dol_syslog(get_class($this).
'::showOutputField extrafieldsobjectkey required', LOG_ERR);
1981 return 'BadValueForParamExtraFieldsObjectKey';
1984 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
1985 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1986 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
1987 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
1988 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
1989 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
1990 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
1991 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
1992 $perms = (int)
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
1993 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
1994 $list = (string)
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
1995 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
1996 $cssview = $this->attributes[$extrafieldsobjectkey][
'cssview'][$key];
1997 $alwayseditable = $this->attributes[$extrafieldsobjectkey][
'alwayseditable'][$key];
2000 $showValueInsteadOfInputField = 0;
2002 if ($alwayseditable == 0 && is_object(
$object) && isset(
$object->status) && defined(get_class(
$object).
"::STATUS_DRAFT") &&
$object->status != $object::STATUS_DRAFT) {
2003 $showValueInsteadOfInputField = 1;
2006 $hidden = (empty($list) ? 1 : 0);
2015 if ($type ==
'date') {
2017 if ($value !==
'') {
2020 } elseif ($type ==
'datetime') {
2022 if ($value !==
'') {
2025 } elseif ($type ==
'duration') {
2027 if ($value !==
'') {
2028 $value = intval($value);
2031 } elseif ($type ==
'datetimegmt') {
2033 if ($value !==
'') {
2036 } elseif ($type ==
'int') {
2038 } elseif ($type ==
'double') {
2039 if (!empty($value)) {
2041 $sizeparts = explode(
",", $size);
2042 $number_decimals = array_key_exists(1, $sizeparts) ? $sizeparts[1] : 0;
2043 $value =
price($value, 0, $outputlangs, 0, 0, $number_decimals,
'');
2045 } elseif ($type ==
'boolean') {
2047 if (!empty($value)) {
2048 $checked =
' checked ';
2051 $value =
'<input type="checkbox" '.$checked.
' '.($moreparam ? $moreparam :
'').
' readonly disabled>';
2053 $value =
yn($value ? 1 : 0);
2055 } elseif ($type ==
'mail') {
2057 } elseif ($type ==
'ip') {
2059 } elseif ($type ==
'icon') {
2060 $value =
'<span class="'.$value.
'"></span>';
2061 } elseif ($type ==
'url') {
2063 } elseif ($type ==
'phone') {
2065 } elseif ($type ==
'price') {
2067 if ($value || $value ==
'0') {
2068 $value =
price($value, 0, $outputlangs, 0,
$conf->global->MAIN_MAX_DECIMALS_TOT, -1).
' '.$outputlangs->getCurrencySymbol(
$conf->currency);
2070 } elseif ($type ==
'pricecy') {
2071 $currency =
$conf->currency;
2072 if (!empty($value)) {
2074 $pricetmp = explode(
':', $value);
2075 $currency = !empty($pricetmp[1]) ? $pricetmp[1] :
$conf->currency;
2076 $value = $pricetmp[0];
2078 if ($value || $value ==
'0') {
2079 $value =
price($value, 0, $outputlangs, 0,
$conf->global->MAIN_MAX_DECIMALS_TOT, -1, $currency);
2081 } elseif ($type ==
'select') {
2082 $valstr = (!empty($param[
'options'][$value]) ? $param[
'options'][$value] :
'');
2083 if (($pos = strpos($valstr,
"|")) !==
false) {
2084 $valstr = substr($valstr, 0, $pos);
2086 if ($langfile && $valstr) {
2087 $value = $outputlangs->trans($valstr);
2091 } elseif ($type ==
'sellist') {
2092 $param_list = array_keys($param[
'options']);
2093 $InfoFieldList = explode(
":", $param_list[0]);
2095 $selectkey =
"rowid";
2098 if (count($InfoFieldList) >= 3) {
2099 $selectkey = $InfoFieldList[2];
2100 $keyList = $InfoFieldList[2].
' as rowid';
2103 $fields_label = explode(
'|', $InfoFieldList[1]);
2104 if (is_array($fields_label)) {
2106 $keyList .= implode(
', ', $fields_label);
2109 $filter_categorie =
false;
2110 if (count($InfoFieldList) > 5) {
2111 if ($InfoFieldList[0] ==
'categorie') {
2112 $filter_categorie =
true;
2116 $sql =
"SELECT ".$keyList;
2117 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
2118 if (!empty($InfoFieldList[4]) && strpos($InfoFieldList[4],
'extra.') !==
false) {
2121 if ($selectkey ==
'rowid' && empty($value)) {
2122 $sql .=
" WHERE ".$selectkey.
" = 0";
2123 } elseif ($selectkey ==
'rowid') {
2124 $sql .=
" WHERE ".$selectkey.
" = ".((int) $value);
2126 $sql .=
" WHERE ".$selectkey.
" = '".$this->db->escape($value).
"'";
2131 dol_syslog(get_class($this).
':showOutputField:$type=sellist', LOG_DEBUG);
2132 $resql = $this->db->query($sql);
2134 if (!$filter_categorie) {
2137 $obj = $this->db->fetch_object($resql);
2140 $fields_label = explode(
'|', $InfoFieldList[1]);
2142 if (is_array($fields_label) && count($fields_label) > 1) {
2143 foreach ($fields_label as $field_toshow) {
2145 if (!empty($obj->$field_toshow)) {
2146 $translabel = $outputlangs->trans($obj->$field_toshow);
2148 if ($translabel != $obj->$field_toshow) {
2149 $value .=
dol_trunc($translabel, 24) .
' ';
2151 $value .= $obj->$field_toshow .
' ';
2157 $tmppropname = $InfoFieldList[1];
2159 if (!empty(isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
2160 $translabel = $outputlangs->trans($obj->$tmppropname);
2162 if ($translabel != (isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
2165 $value = isset($obj->$tmppropname) ? $obj->$tmppropname :
'';
2170 $obj = $this->db->fetch_object($resql);
2172 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
2174 $result = $c->fetch($obj->rowid);
2176 $ways = $c->print_all_ways();
2177 foreach ($ways as $way) {
2178 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ?
' style="background: #' . $c->color .
';"' :
' style="background: #bbb"') .
'>' .
img_object(
'',
'category') .
' ' . $way .
'</li>';
2182 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
2185 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
2187 } elseif ($type ==
'radio') {
2188 if (!isset($param[
'options'][$value])) {
2189 $outputlangs->load(
'errors');
2190 $value = $outputlangs->trans(
'ErrorNoValueForRadioType');
2192 $value = $outputlangs->trans($param[
'options'][$value]);
2194 } elseif ($type ==
'checkbox') {
2195 $value_arr = explode(
',', $value);
2198 if (is_array($value_arr)) {
2199 foreach ($value_arr as $keyval => $valueval) {
2200 if (!empty($valueval)) {
2201 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$param[
'options'][$valueval].
'</li>';
2205 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
2206 } elseif ($type ==
'chkbxlst') {
2207 $value_arr = explode(
',', $value);
2209 $param_list = array_keys($param[
'options']);
2210 $InfoFieldList = explode(
":", $param_list[0]);
2212 $selectkey =
"rowid";
2215 if (count($InfoFieldList) >= 3) {
2216 $selectkey = $InfoFieldList[2];
2217 $keyList = $InfoFieldList[2].
' as rowid';
2220 $fields_label = explode(
'|', $InfoFieldList[1]);
2221 if (is_array($fields_label)) {
2223 $keyList .= implode(
', ', $fields_label);
2226 $filter_categorie =
false;
2227 if (count($InfoFieldList) > 5) {
2228 if ($InfoFieldList[0] ==
'categorie') {
2229 $filter_categorie =
true;
2233 $sql =
"SELECT ".$keyList;
2234 $sql .=
" FROM ".$this->db->prefix().$InfoFieldList[0];
2235 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
2241 dol_syslog(get_class($this).
':showOutputField:$type=chkbxlst', LOG_DEBUG);
2242 $resql = $this->db->query($sql);
2244 if (!$filter_categorie) {
2247 while ($obj = $this->db->fetch_object($resql)) {
2249 $fields_label = explode(
'|', $InfoFieldList[1]);
2250 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
2251 if (is_array($fields_label) && count($fields_label) > 1) {
2252 $label =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">';
2253 foreach ($fields_label as $field_toshow) {
2255 if (!empty($obj->$field_toshow)) {
2256 $translabel = $outputlangs->trans($obj->$field_toshow);
2258 if ($translabel != $field_toshow) {
2259 $label .=
' '.dol_trunc($translabel, 18);
2261 $label .=
' '.$obj->$field_toshow;
2265 $toprint[] = $label;
2268 if (!empty($obj->{$InfoFieldList[1]})) {
2269 $translabel = $outputlangs->trans($obj->{$InfoFieldList[1]});
2271 if ($translabel != $obj->{$InfoFieldList[1]}) {
2272 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).
'</li>';
2274 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->{$InfoFieldList[1]}.
'</li>';
2280 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2283 while ($obj = $this->db->fetch_object($resql)) {
2284 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
2286 $c->fetch($obj->rowid);
2287 $ways = $c->print_all_ways();
2288 foreach ($ways as $way) {
2289 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ?
' style="background: #'.$c->color.
';"' :
' style="background: #bbb"').
'>'.
img_object(
'',
'category').
' '.$way.
'</li>';
2294 if (!empty($toprint)) {
2295 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
2298 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
2300 } elseif ($type ==
'link') {
2305 $param_list = array_keys($param[
'options']);
2307 $InfoFieldList = explode(
":", $param_list[0]);
2308 $classname = $InfoFieldList[0];
2309 $classpath = $InfoFieldList[1];
2310 if (!empty($classpath)) {
2312 if ($classname && class_exists($classname)) {
2313 $tmpobject =
new $classname($this->db);
2314 '@phan-var-force CommonObject $tmpobject';
2315 $tmpobject->fetch($value);
2316 $value = $tmpobject->getNomUrl(3);
2319 dol_syslog(
'Error bad setup of extrafield', LOG_WARNING);
2320 return 'Error bad setup of extrafield';
2323 } elseif ($type ==
'point') {
2324 if (!empty($value)) {
2325 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeophp.class.php';
2327 $value = $dolgeophp->getXYString($value);
2331 } elseif (in_array($type, [
'multipts',
'linestrg',
'polygon'])) {
2332 if (!empty($value)) {
2333 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeophp.class.php';
2335 $value = $dolgeophp->getPointString($value);
2339 } elseif ($type ==
'text') {
2340 $value =
'<div class="'.($cssview ? $cssview :
'shortmessagecut').
'">'.
dol_htmlentitiesbr($value).
'</div>';
2341 } elseif ($type ==
'html') {
2343 } elseif ($type ==
'password') {
2344 $value =
dol_trunc(preg_replace(
'/./i',
'*', $value), 8,
'right',
'UTF-8', 1);
2345 } elseif ($type ==
'stars') {
2346 $objectid = (int)
$object->id;
2347 if ($showValueInsteadOfInputField == 1) {
2348 $value =
'<span style="display:none;" id="'.$key.$object->id.
'">'.
dol_escape_htmltag($value).
'</span>';
2350 $value =
'<input type="hidden" class="flat" name="'.$key.
'" id="'.$key.$objectid.
'" value="'.
dol_escape_htmltag($value).
'"'.($moreparam ? $moreparam :
'').
'>';
2353 $value .=
'<div class="star-selection" id="'.$key.$objectid.
'_selection">';
2355 while ($i <= $size) {
2356 $value .=
'<span class="star" data-value="'.$i.
'">'.
img_picto(
'',
'fontawesome_star_fas').
'</span>';
2361 $(document).ready(function() {
2362 let container = $("#'.$key.$objectid.
'_selection");
2363 let selectedStars = parseInt($("#'.$key.$objectid.
'").val() || $("#'.$key.$objectid.
'").text()) || 0;
2364 container.find(".star").each(function() {
2365 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
2367 if ($showValueInsteadOfInputField == 0) {
2369 container.find(".star").on("mouseover", function() {
2370 let selectedStar = $(this).data("value");
2371 container.find(".star").each(function() {
2372 $(this).toggleClass("active", $(this).data("value") <= selectedStar);
2375 container.on("mouseout", function() {
2376 container.find(".star").each(function() {
2377 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
2380 container.find(".star").off("click").on("click", function() {
2381 selectedStars = $(this).data("value");
2382 if (selectedStars == 1 && $("#'.$key.$objectid.
'").val() == 1) {
2385 container.find("#'.$key.$objectid.
'").val(selectedStars);
2386 container.find(".star").each(function() {
2387 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
2390 url: "'.DOL_URL_ROOT.
'/core/ajax/editextrafield.php",
2394 objectId:
'.((int) $objectid).',
2395 field: \
''.dol_escape_js($key).
'\',
2396 value: selectedStars,
2397 token:
"'.newToken().'"
2399 success:
function(response) {
2400 var res = JSON.parse(response);
2401 console[res.status ===
"success" ?
"log" :
"error"](res.message);
2403 error:
function(xhr,
status, error) {
2404 console.log(
"Ajax request failed while updating '.$key.':", error);
2413 $showsize = round((float) $size);
2414 if ($showsize > 48) {
2419 //print $type.'-
'.$size;