1093 public function showInputField($key, $value, $moreparam =
'', $keysuffix =
'', $keyprefix =
'', $morecss =
'',
$object = 0, $extrafieldsobjectkey =
'', $mode = 0)
1095 global
$conf, $langs, $form;
1097 if (!is_object($form)) {
1098 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
1099 $form =
new Form($this->db);
1106 if (!preg_match(
'/options_$/', $keyprefix)) {
1107 $keyprefix .=
'options_';
1110 if (empty($extrafieldsobjectkey)) {
1111 dol_syslog(get_class($this).
'::showInputField extrafieldsobjectkey required', LOG_ERR);
1112 return 'BadValueForParamExtraFieldsObjectKey';
1115 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
1116 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1117 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
1118 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
1119 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
1120 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
1121 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
1122 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
1123 $perms = (int)
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
1124 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
1125 $list = (string)
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
1126 $totalizable = $this->attributes[$extrafieldsobjectkey][
'totalizable'][$key];
1127 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
1128 $alwayseditable = $this->attributes[$extrafieldsobjectkey][
'alwayseditable'][$key];
1129 $hidden = (empty($list) ? 1 : 0);
1135 if (!preg_match(
'/^search_/', $keyprefix)) {
1136 return '<span class="opacitymedium">'.$langs->trans(
"AutomaticallyCalculated").
'</span>';
1144 if (empty($morecss)) {
1146 if ($type ==
'date') {
1147 $morecss =
'minwidth100imp';
1148 } elseif ($type ==
'datetime' || $type ==
'datetimegmt' || $type ==
'link') {
1149 $morecss =
'minwidth200imp';
1150 } elseif (in_array($type, array(
'int',
'integer',
'double',
'price'))) {
1151 $morecss =
'maxwidth75';
1152 } elseif ($type ==
'password') {
1153 $morecss =
'maxwidth100';
1154 } elseif ($type ==
'url') {
1155 $morecss =
'minwidth400';
1156 } elseif ($type ==
'boolean') {
1158 } elseif ($type ==
'radio') {
1159 $morecss =
'width25';
1161 if (empty($size) || round((
float) $size) < 12) {
1162 $morecss =
'minwidth100';
1163 } elseif (round((
float) $size) <= 48) {
1164 $morecss =
'minwidth200';
1166 $morecss =
'minwidth400';
1170 if (!empty($this->attributes[$extrafieldsobjectkey][
'css'][$key])) {
1171 $morecss = $this->attributes[$extrafieldsobjectkey][
'css'][$key];
1175 if (in_array($type, array(
'date'))) {
1176 $tmp = explode(
',', $size);
1181 if (!$required && $value ==
'') {
1188 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1189 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1191 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1192 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1193 $out .=
'</div><div class="nowrap">';
1194 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1195 $out .=
'</div></div>';
1198 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1);
1200 } elseif (in_array($type, array(
'datetime',
'datetimegmt'))) {
1201 $tmp = explode(
',', $size);
1206 if (!$required && $value ==
'') {
1213 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1214 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1216 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1217 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"),
'tzuserrel');
1218 $out .=
'</div><div class="nowrap">';
1219 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
1220 $out .=
'</div></div>';
1223 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1,
'',
'',
'', 1,
'',
'',
'tzuserrel');
1225 } elseif (in_array($type, array(
'int',
'integer'))) {
1226 $tmp = explode(
',', $size);
1228 $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 :
'').
'>';
1229 } elseif (preg_match(
'/varchar/', $type)) {
1230 $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 :
'').
'>';
1231 } elseif (in_array($type, array(
'mail',
'ip',
'phone',
'url'))) {
1232 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1233 } elseif ($type ==
'icon') {
1239 $out .=
'<input type="text" class="form-control icp icp-auto iconpicker-element iconpicker-input flat '.$morecss.
' maxwidthonsmartphone"';
1240 $out .=
' name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1243 $options =
"{ title: '<b>".$langs->trans(
"IconFieldSelector").
"</b>', placement: 'right', showFooter: false, templates: {";
1244 $options .=
"iconpicker: '<div class=\"iconpicker\"><div style=\"background-color:#EFEFEF;\" class=\"iconpicker-items\"></div></div>',";
1245 $options .=
"iconpickerItem: '<a role=\"button\" href=\"#\" class=\"iconpicker-item\" style=\"background-color:#DDDDDD;\"><i></i></a>',";
1248 $options .=
"footer: '<div class=\"popover-footer\" style=\"background-color:#EFEFEF;\"></div>',";
1249 $options .=
"search: '<input type=\"search\" class\"form-control iconpicker-search\" placeholder=\"".$langs->trans(
"TypeToFilter").
"\" />',";
1250 $options .=
"popover: '<div class=\"iconpicker-popover popover\">";
1251 $options .=
" <div class=\"arrow\" ></div>";
1252 $options .=
" <div class=\"popover-title\" style=\"text-align:center;background-color:#EFEFEF;\"></div>";
1253 $options .=
" <div class=\"popover-content \" ></div>";
1254 $options .=
"</div>'}}";
1255 $out .=
"$('#".$keyprefix.$key.$keysuffix.
"').iconpicker(".$options.
");";
1256 $out .=
'</script>';
1258 } elseif ($type ==
'text') {
1259 if (!preg_match(
'/search_/', $keyprefix)) {
1260 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1261 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false,
false, ROWS_5,
'90%');
1262 $out = (string) $doleditor->Create(1);
1264 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1266 } elseif ($type ==
'html') {
1267 if (!preg_match(
'/search_/', $keyprefix)) {
1268 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1269 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false, isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_5,
'90%');
1270 $out = (string) $doleditor->Create(1);
1272 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1274 } elseif ($type ==
'boolean') {
1277 if (!empty($value)) {
1278 $checked =
' checked value="1" ';
1280 $checked =
' value="1" ';
1282 $out =
'<input type="checkbox" class="flat valignmiddle'.($morecss ?
' '.$morecss :
'').
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.$checked.
' '.($moreparam ? $moreparam :
'').
'>';
1284 $out = $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1,
false, 1, 1,
'width75 yesno');
1286 $out .=
'<input type="hidden" name="'.$keyprefix.$key.$keysuffix.
'_boolean" value="1">';
1287 } elseif ($type ==
'price') {
1288 if (!empty($value)) {
1289 $value =
price($value);
1291 $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).
'">';
1292 } elseif ($type ==
'pricecy') {
1293 $currency =
$conf->currency;
1294 if (!empty($value)) {
1296 $pricetmp = explode(
':', $value);
1297 $currency = !empty($pricetmp[1]) ? $pricetmp[1] :
$conf->currency;
1298 $value =
price($pricetmp[0]);
1300 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1301 $out .= $form->selectCurrency($currency, $keyprefix.$key.$keysuffix.
'currency_id');
1302 } elseif ($type ==
'duration') {
1303 $value = intval($value);
1304 $out = $form->select_duration($keyprefix . $key, $value, 0,
'text', 0, 1);
1305 } elseif ($type ==
'double') {
1306 if (!empty($value)) {
1307 $value =
price($value);
1309 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1310 } elseif ($type ==
'select') {
1314 foreach ($param[
'options'] as $okey => $val) {
1315 if ((
string) $okey ==
'') {
1319 $valarray = explode(
'|', $val);
1320 $val = $valarray[0];
1322 if ($langfile && $val) {
1323 $options[$okey] = $langs->trans($val);
1325 $options[$okey] = $val;
1328 $selected = array();
1329 if (!is_array($value)) {
1330 $selected = explode(
',', $value);
1333 $out .= $form->multiselectarray($keyprefix.$key.$keysuffix, $options, $selected, 0, 0, $morecss, 0, 0,
'',
'',
'', !empty(
$conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2'));
1336 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1337 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1340 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1341 $out .=
'<option value="0"> </option>';
1342 foreach ($param[
'options'] as $key2 => $val2) {
1343 if ((
string) $key2 ==
'') {
1346 $valarray = explode(
'|', $val2);
1347 $val2 = $valarray[0];
1349 if (!empty($valarray[1])) {
1350 $parent = $valarray[1];
1352 $out .=
'<option value="'.$key2.
'"';
1353 $out .= (((string) $value == (
string) $key2) ?
' selected' :
'');
1354 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1356 if ($langfile && $val2) {
1357 $out .= $langs->trans($val2);
1361 $out .=
'</option>';
1363 $out .=
'</select>';
1365 } elseif ($type ==
'sellist') {
1368 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1369 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1372 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1373 if (is_array($param[
'options'])) {
1374 $tmpparamoptions = array_keys($param[
'options']);
1375 $paramoptions = preg_split(
'/[\r\n]+/', $tmpparamoptions[0]);
1377 $InfoFieldList = explode(
":", $paramoptions[0], 5);
1389 if (! empty($InfoFieldList[4])) {
1391 $parenthesisopen = 0;
1392 while (substr($InfoFieldList[4], $pos, 1) !==
'' && ($parenthesisopen || $pos == 0 || substr($InfoFieldList[4], $pos, 1) !=
':')) {
1393 if (substr($InfoFieldList[4], $pos, 1) ==
'(') {
1396 if (substr($InfoFieldList[4], $pos, 1) ==
')') {
1401 $tmpbefore = substr($InfoFieldList[4], 0, $pos);
1402 $tmpafter = substr($InfoFieldList[4], $pos + 1);
1404 $InfoFieldList[4] = $tmpbefore;
1405 if ($tmpafter !==
'') {
1406 $InfoFieldList = array_merge($InfoFieldList, explode(
':', $tmpafter));
1411 if (preg_match(
'/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) {
1412 $InfoFieldList[4] =
'('.$reg[1].
':'.$reg[2].
':'.$reg[3].
')';
1422 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1424 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1425 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1426 $keyList .=
', '.$parentField;
1428 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1429 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1430 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1432 $keyList = $InfoFieldList[2].
' as rowid';
1436 $filter_categorie =
false;
1437 if (count($InfoFieldList) > 5) {
1438 if ($InfoFieldList[0] ==
'categorie') {
1439 $filter_categorie =
true;
1443 if (!$filter_categorie) {
1444 $fields_label = explode(
'|', $InfoFieldList[1]);
1445 if (is_array($fields_label)) {
1447 $keyList .= implode(
', ', $fields_label);
1451 $sql =
"SELECT ".$keyList;
1452 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1455 if (!empty($InfoFieldList[4])) {
1457 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1458 $InfoFieldList[4] = str_replace(
'$ENTITY$', (
string)
$conf->entity, $InfoFieldList[4]);
1461 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1462 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1466 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1467 $InfoFieldList[4] = str_replace(
'$ID$', (
string) $objectid, $InfoFieldList[4]);
1469 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1474 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1475 $sql .=
' as main, '.$this->db->sanitize($this->db->prefix().$InfoFieldList[0]).
'_extrafields as extra';
1476 $sqlwhere .=
" WHERE extra.fk_object = main.".$this->db->sanitize($InfoFieldList[2]);
1483 $sqlwhere .=
' WHERE 1=1';
1500 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1501 $sqlwhere .=
' AND entity = '.((int)
$conf->entity);
1505 $sql .= $this->db->order(implode(
',', $fields_label));
1508 dol_syslog(get_class($this).
'::showInputField type=sellist', LOG_DEBUG);
1509 $resql = $this->db->query($sql);
1511 $out .=
'<option value="0"> </option>';
1512 $num = $this->db->num_rows($resql);
1516 $obj = $this->db->fetch_object($resql);
1520 $fields_label = explode(
'|', $InfoFieldList[1]);
1521 if (is_array($fields_label) && count($fields_label) > 1) {
1523 foreach ($fields_label as $field_toshow) {
1524 $labeltoshow .= $obj->$field_toshow.
' ';
1527 $labeltoshow = $obj->{$InfoFieldList[1]};
1530 if ($value == $obj->rowid) {
1532 foreach ($fields_label as $field_toshow) {
1533 $translabel = $langs->trans($obj->$field_toshow);
1534 $labeltoshow = $translabel.
' ';
1537 $out .=
'<option value="'.$obj->rowid.
'" selected>'.$labeltoshow.
'</option>';
1540 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1541 $labeltoshow = $translabel;
1543 if (empty($labeltoshow)) {
1544 $labeltoshow =
'(not defined)';
1547 if (!empty($InfoFieldList[3]) && $parentField) {
1548 $parent = $parentName.
':'.$obj->{$parentField};
1551 $out .=
'<option value="'.$obj->rowid.
'"';
1552 $out .= ($value == $obj->rowid ?
' selected' :
'');
1553 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1554 $out .=
'>'.$labeltoshow.
'</option>';
1559 $this->db->free($resql);
1561 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1564 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1565 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1566 $out .=
'<option value="0"> </option>';
1567 if (is_array($data)) {
1568 foreach ($data as $data_key => $data_value) {
1569 $out .=
'<option value="'.$data_key.
'"';
1570 $out .= ($value == $data_key ?
' selected' :
'');
1571 $out .=
'>'.$data_value.
'</option>';
1576 $out .=
'</select>';
1577 } elseif ($type ==
'checkbox') {
1578 $value_arr = $value;
1579 if (!is_array($value)) {
1580 $value_arr = explode(
',', $value);
1582 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param[
'options']) ?
null : $param[
'options']), $value_arr, 0, 0,
'', 0,
'100%');
1583 } elseif ($type ==
'radio') {
1585 foreach ($param[
'options'] as $keyopt => $val) {
1586 $out .=
'<input class="flat '.$morecss.
'" type="radio" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'');
1587 $out .=
' value="'.$keyopt.
'"';
1588 $out .=
' id="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'"';
1589 $out .= ($value == $keyopt ?
'checked' :
'');
1590 $out .=
'/><label for="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'">'.$langs->trans($val).
'</label><br>';
1592 } elseif ($type ==
'chkbxlst') {
1593 if (is_array($value)) {
1594 $value_arr = $value;
1596 $value_arr = explode(
',', $value);
1599 if (is_array($param[
'options'])) {
1600 $tmpparamoptions = array_keys($param[
'options']);
1601 $paramoptions = preg_split(
'/[\r\n]+/', $tmpparamoptions[0]);
1603 $InfoFieldList = explode(
":", $paramoptions[0], 5);
1615 if (! empty($InfoFieldList[4])) {
1617 $parenthesisopen = 0;
1618 while (substr($InfoFieldList[4], $pos, 1) !==
'' && ($parenthesisopen || $pos == 0 || substr($InfoFieldList[4], $pos, 1) !=
':')) {
1619 if (substr($InfoFieldList[4], $pos, 1) ==
'(') {
1622 if (substr($InfoFieldList[4], $pos, 1) ==
')') {
1627 $tmpbefore = substr($InfoFieldList[4], 0, $pos);
1628 $tmpafter = substr($InfoFieldList[4], $pos + 1);
1630 $InfoFieldList[4] = $tmpbefore;
1631 if ($tmpafter !==
'') {
1632 $InfoFieldList = array_merge($InfoFieldList, explode(
':', $tmpafter));
1637 if (preg_match(
'/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) {
1638 $InfoFieldList[4] =
'('.$reg[1].
':'.$reg[2].
':'.$reg[3].
')';
1648 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1650 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1651 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1652 $keyList .=
', '.$parentField;
1654 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1655 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1656 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1658 $keyList = $InfoFieldList[2].
' as rowid';
1662 $filter_categorie =
false;
1663 if (count($InfoFieldList) > 5) {
1664 if ($InfoFieldList[0] ==
'categorie') {
1665 $filter_categorie =
true;
1669 if (!$filter_categorie) {
1670 $fields_label = explode(
'|', $InfoFieldList[1]);
1671 if (is_array($fields_label)) {
1673 $keyList .= implode(
', ', $fields_label);
1677 $sql =
"SELECT ".$keyList;
1678 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1681 if (!empty($InfoFieldList[4])) {
1683 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1684 $InfoFieldList[4] = str_replace(
'$ENTITY$', (
string)
$conf->entity, $InfoFieldList[4]);
1687 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1688 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1692 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1693 $InfoFieldList[4] = str_replace(
'$ID$', (
string) $objectid, $InfoFieldList[4]);
1694 } elseif (preg_match(
"#^.*list.php$#", $_SERVER[
"PHP_SELF"])) {
1696 $word =
'\b[a-zA-Z0-9-\.-_]+\b=\$ID\$';
1699 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1703 while ($nbPreg != 0) {
1705 $nbPregRepl = $nbPregSel = 0;
1707 $InfoFieldList[4] = preg_replace(
'#([^=])(\([^)^(]*('.$word.
')[^)^(]*\))#',
'$1 $3 ', $InfoFieldList[4], -1, $nbPregRepl);
1709 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1711 $InfoFieldList[4] = preg_replace(
'#\b[a-zA-Z0-9-\.-_]+\b=\([^)^(]*('.$word.
')[^)^(]*\)#',
'$1 ', $InfoFieldList[4], -1, $nbPregSel);
1713 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1716 $nbPreg = $nbPregRepl + $nbPregSel;
1720 $matchCondition = array();
1721 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1722 while (!empty($matchCondition[0])) {
1724 if (!empty($matchCondition[1]) && !empty($matchCondition[3]) && $matchCondition[1] != $matchCondition[3]) {
1726 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1728 if (!empty($matchCondition[1])) {
1729 $boolCond = (($matchCondition[1] ==
"AND") ?
' AND TRUE ' :
' OR FALSE ');
1730 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond.$matchCondition[3], $InfoFieldList[4]);
1731 } elseif (!empty($matchCondition[3])) {
1732 $boolCond = (($matchCondition[3] ==
"AND") ?
' TRUE AND ' :
' FALSE OR');
1733 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond, $InfoFieldList[4]);
1735 $InfoFieldList[4] =
" TRUE ";
1740 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1743 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1748 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1749 $sql .=
' as main, '.$this->db->sanitize($this->db->prefix().$InfoFieldList[0]).
'_extrafields as extra';
1750 $sqlwhere .=
" WHERE extra.fk_object = main.".$this->db->sanitize($InfoFieldList[2]);
1756 $sqlwhere .=
' WHERE 1=1';
1773 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1774 $sqlwhere .=
" AND entity = ".((int)
$conf->entity);
1780 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1782 dol_syslog(get_class($this).
'::showInputField type=chkbxlst', LOG_DEBUG);
1783 $resql = $this->db->query($sql);
1785 $num = $this->db->num_rows($resql);
1792 $obj = $this->db->fetch_object($resql);
1796 $fields_label = explode(
'|', $InfoFieldList[1]);
1797 if (is_array($fields_label)) {
1799 foreach ($fields_label as $field_toshow) {
1800 $labeltoshow .= $obj->$field_toshow.
' ';
1803 $labeltoshow = $obj->{$InfoFieldList[1]};
1805 $labeltoshow =
dol_trunc($labeltoshow, 45);
1807 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1809 foreach ($fields_label as $field_toshow) {
1810 $translabel = $langs->trans($obj->$field_toshow);
1811 if ($translabel != $obj->$field_toshow) {
1812 $labeltoshow .=
' '.dol_trunc($translabel, 18).
' ';
1814 $labeltoshow .=
' '.dol_trunc($obj->$field_toshow, 18).
' ';
1817 $data[$obj->rowid] = $labeltoshow;
1820 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1821 if ($translabel != $obj->{$InfoFieldList[1]}) {
1822 $labeltoshow =
dol_trunc($translabel, 18);
1824 $labeltoshow =
dol_trunc($obj->{$InfoFieldList[1]}, 18);
1827 if (empty($labeltoshow)) {
1828 $labeltoshow =
'(not defined)';
1831 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1832 $data[$obj->rowid] = $labeltoshow;
1835 if (!empty($InfoFieldList[3]) && $parentField) {
1836 $parent = $parentName.
':'.$obj->{$parentField};
1839 $data[$obj->rowid] = $labeltoshow;
1844 $this->db->free($resql);
1846 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, 0, 0,
'', 0,
'100%');
1848 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1851 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1852 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1853 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, 0, 0,
'', 0,
'100%');
1856 } elseif ($type ==
'link') {
1857 $param_list = array_keys($param[
'options']);
1864 $showempty = (($required && $default !=
'') ? 0 : 1);
1866 $tmparray = explode(
':', $param_list[0]);
1868 $element = $extrafieldsobjectkey;
1869 if ($element ==
'socpeople') {
1870 $element =
'contact';
1871 } elseif ($element ==
'projet') {
1872 $element =
'project';
1876 $objectdesc = $tmparray[0];
1877 $objectfield = $element.
':options_'.$key;
1879 $out = $form->selectForForms($objectdesc, $keyprefix.$key.$keysuffix, $value, $showempty,
'',
'', $morecss,
'', 0, 0,
'', $objectfield);
1880 } elseif (in_array($type, [
'point',
'multipts',
'linestrg',
'polygon'])) {
1881 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeophp.class.php';
1885 if (!empty($value)) {
1886 $tmparray = $dolgeophp->parseGeoString($value);
1887 $geojson = $tmparray[
'geojson'];
1888 $centroidjson = $tmparray[
'centroidjson'];
1890 if (!preg_match(
'/search_/', $keyprefix)) {
1891 require_once DOL_DOCUMENT_ROOT.
'/core/class/geomapeditor.class.php';
1893 $out .= $geomapeditor->getHtml($keyprefix.$key.$keysuffix, $geojson, $centroidjson, $type);
1898 } elseif ($type ==
'password') {
1900 $out =
'<input style="display:none" type="text" name="fakeusernameremembered">';
1901 $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 :
'').
'>';
1902 } elseif ($type ==
'stars') {
1903 $out =
'<input type="hidden" class="flat '.$morecss.
'" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'"'.($moreparam ? $moreparam :
'').
'>';
1904 $out .=
'<div class="star-selection" id="'.$keyprefix.$key.$keysuffix.
'_selection">';
1906 while ($i <= $size) {
1907 $out .=
'<span class="star" data-value="'.$i.
'">'.
img_picto(
'',
'fontawesome_star_fas').
'</span>';
1912 jQuery(function($) {
1913 let container = $("#'.$keyprefix.$key.$keysuffix.
'_selection");
1914 let selectedStars = parseInt($("#'.$keyprefix.$key.$keysuffix.
'").val()) || 0;
1915 container.find(".star").each(function() {
1916 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
1918 container.find(".star").on("mouseover", function() {
1919 let selectedStar = $(this).data("value");
1920 container.find(".star").each(function() {
1921 $(this).toggleClass("active", $(this).data("value") <= selectedStar);
1924 container.on("mouseout", function() {
1925 container.find(".star").each(function() {
1926 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
1929 container.find(".star").off("click").on("click", function() {
1930 selectedStars = $(this).data("value");
1931 if (selectedStars === 1 && $("#'.$keyprefix.$key.$keysuffix.
'").val() == 1) {
1934 $("#'.$keyprefix.$key.$keysuffix.
'").val(selectedStars);
1935 container.find(".star").each(function() {
1936 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
1942 if (!empty($hidden)) {
1943 $out =
'<input type="hidden" value="'.$value.
'" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'"/>';
1948 if ($alwayseditable == 0 && is_object(
$object) && isset(
$object->status) && defined(get_class(
$object).
"::STATUS_DRAFT") &&
$object->status != $object::STATUS_DRAFT) {
1949 $out = $this->showOutputField($key, $value, $moreparam, $extrafieldsobjectkey,
null,
$object);
1973 public function showOutputField($key, $value, $moreparam =
'', $extrafieldsobjectkey =
'', $outputlangs =
null,
$object =
null)
1975 global
$conf, $langs;
1977 if (is_null($outputlangs) || !is_object($outputlangs)) {
1978 $outputlangs = $langs;
1981 if (empty($extrafieldsobjectkey)) {
1982 dol_syslog(get_class($this).
'::showOutputField extrafieldsobjectkey required', LOG_ERR);
1983 return 'BadValueForParamExtraFieldsObjectKey';
1986 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
1987 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1988 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
1989 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
1990 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
1991 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
1992 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
1993 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
1994 $perms = (int)
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
1995 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
1996 $list = (string)
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
1997 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
1998 $cssview = $this->attributes[$extrafieldsobjectkey][
'cssview'][$key];
1999 $alwayseditable = $this->attributes[$extrafieldsobjectkey][
'alwayseditable'][$key];
2002 $showValueInsteadOfInputField = 0;
2004 if ($alwayseditable == 0 && is_object(
$object) && isset(
$object->status) && defined(get_class(
$object).
"::STATUS_DRAFT") &&
$object->status != $object::STATUS_DRAFT) {
2005 $showValueInsteadOfInputField = 1;
2008 $hidden = (empty($list) ? 1 : 0);
2016 if ($type ==
'date') {
2018 if ($value !==
'') {
2021 } elseif ($type ==
'datetime') {
2023 if ($value !==
'') {
2026 } elseif ($type ==
'duration') {
2028 if ($value !==
'') {
2029 $value = intval($value);
2032 } elseif ($type ==
'datetimegmt') {
2034 if ($value !==
'') {
2037 } elseif ($type ==
'int') {
2039 } elseif ($type ==
'double') {
2040 if (!empty($value)) {
2044 $value =
price($value, 0, $outputlangs, 0, 0, -2,
'');
2046 } elseif ($type ==
'boolean') {
2048 if (!empty($value)) {
2049 $checked =
' checked ';
2052 $value =
'<input type="checkbox" '.$checked.
' '.($moreparam ? $moreparam :
'').
' readonly disabled>';
2054 $value =
yn($value ? 1 : 0);
2056 } elseif ($type ==
'mail') {
2058 } elseif ($type ==
'ip') {
2060 } elseif ($type ==
'icon') {
2061 $value =
'<span class="'.$value.
'"></span>';
2062 } elseif ($type ==
'url') {
2064 } elseif ($type ==
'phone') {
2066 } elseif ($type ==
'price') {
2068 if ($value || $value ==
'0') {
2069 $value =
price($value, 0, $outputlangs, 0,
getDolGlobalInt(
'MAIN_MAX_DECIMALS_TOT'), -1).
' '.$outputlangs->getCurrencySymbol(
$conf->currency);
2071 } elseif ($type ==
'pricecy') {
2072 $currency =
$conf->currency;
2073 if (!empty($value)) {
2075 $pricetmp = explode(
':', $value);
2076 $currency = !empty($pricetmp[1]) ? $pricetmp[1] :
$conf->currency;
2077 $value = $pricetmp[0];
2079 if ($value || $value ==
'0') {
2080 $value =
price($value, 0, $outputlangs, 0,
getDolGlobalInt(
'MAIN_MAX_DECIMALS_TOT'), -1, $currency);
2082 } elseif ($type ==
'select') {
2083 $valstr = (!empty($param[
'options'][$value]) ? $param[
'options'][$value] :
'');
2084 if (($pos = strpos($valstr,
"|")) !==
false) {
2085 $valstr = substr($valstr, 0, $pos);
2087 if ($langfile && $valstr) {
2088 $value = $outputlangs->trans($valstr);
2092 } elseif ($type ==
'sellist') {
2093 $param_list = array_keys($param[
'options']);
2094 $InfoFieldList = explode(
":", $param_list[0]);
2096 $selectkey =
"rowid";
2099 if (count($InfoFieldList) >= 3) {
2100 $selectkey = $InfoFieldList[2];
2101 $keyList = $InfoFieldList[2].
' as rowid';
2104 $fields_label = explode(
'|', $InfoFieldList[1]);
2105 if (is_array($fields_label)) {
2107 $keyList .= implode(
', ', $fields_label);
2110 $filter_categorie =
false;
2111 if (count($InfoFieldList) > 5) {
2112 if ($InfoFieldList[0] ==
'categorie') {
2113 $filter_categorie =
true;
2117 $sql =
"SELECT ".$keyList;
2118 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
2119 if (!empty($InfoFieldList[4]) && strpos($InfoFieldList[4],
'extra.') !==
false) {
2122 if ($selectkey ==
'rowid' && empty($value)) {
2123 $sql .=
" WHERE ".$selectkey.
" = 0";
2124 } elseif ($selectkey ==
'rowid') {
2125 $sql .=
" WHERE ".$selectkey.
" = ".((int) $value);
2127 $sql .=
" WHERE ".$selectkey.
" = '".$this->db->escape($value).
"'";
2132 dol_syslog(get_class($this).
':showOutputField:$type=sellist', LOG_DEBUG);
2133 $resql = $this->db->query($sql);
2135 if (!$filter_categorie) {
2138 $obj = $this->db->fetch_object($resql);
2141 $fields_label = explode(
'|', $InfoFieldList[1]);
2143 if (is_array($fields_label) && count($fields_label) > 1) {
2144 foreach ($fields_label as $field_toshow) {
2146 if (!empty($obj->$field_toshow)) {
2147 $translabel = $outputlangs->trans($obj->$field_toshow);
2149 if ($translabel != $obj->$field_toshow) {
2150 $value .=
dol_trunc($translabel, 24) .
' ';
2152 $value .= $obj->$field_toshow .
' ';
2158 $tmppropname = $InfoFieldList[1];
2160 if (!empty(isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
2161 $translabel = $outputlangs->trans($obj->$tmppropname);
2163 if ($translabel != (isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
2166 $value = isset($obj->$tmppropname) ? $obj->$tmppropname :
'';
2171 $obj = $this->db->fetch_object($resql);
2173 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
2175 $result =
$c->fetch($obj->rowid);
2177 $ways =
$c->print_all_ways();
2178 foreach ($ways as $way) {
2179 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . (
$c->color ?
' style="background: #' .
$c->color .
';"' :
' style="background: #bbb"') .
'>' .
img_object(
'',
'category') .
' ' . $way .
'</li>';
2183 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
2186 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
2188 } elseif ($type ==
'radio') {
2189 if (!isset($param[
'options'][$value])) {
2190 $outputlangs->load(
'errors');
2191 $value = $outputlangs->trans(
'ErrorNoValueForRadioType');
2193 $value = $outputlangs->trans($param[
'options'][$value]);
2195 } elseif ($type ==
'checkbox') {
2196 $value_arr = explode(
',', $value);
2199 if (is_array($value_arr)) {
2200 foreach ($value_arr as $keyval => $valueval) {
2201 if (!empty($valueval)) {
2202 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$param[
'options'][$valueval].
'</li>';
2206 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
2207 } elseif ($type ==
'chkbxlst') {
2208 $value_arr = explode(
',', $value);
2210 $param_list = array_keys($param[
'options']);
2211 $InfoFieldList = explode(
":", $param_list[0]);
2213 $selectkey =
"rowid";
2216 if (count($InfoFieldList) >= 3) {
2217 $selectkey = $InfoFieldList[2];
2218 $keyList = $InfoFieldList[2].
' as rowid';
2221 $fields_label = explode(
'|', $InfoFieldList[1]);
2222 if (is_array($fields_label)) {
2224 $keyList .= implode(
', ', $fields_label);
2227 $filter_categorie =
false;
2228 if (count($InfoFieldList) > 5) {
2229 if ($InfoFieldList[0] ==
'categorie') {
2230 $filter_categorie =
true;
2234 $sql =
"SELECT ".$keyList;
2235 $sql .=
" FROM ".$this->db->prefix().$InfoFieldList[0];
2236 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
2242 dol_syslog(get_class($this).
':showOutputField:$type=chkbxlst', LOG_DEBUG);
2243 $resql = $this->db->query($sql);
2245 if (!$filter_categorie) {
2248 while ($obj = $this->db->fetch_object($resql)) {
2250 $fields_label = explode(
'|', $InfoFieldList[1]);
2251 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
2252 if (is_array($fields_label) && count($fields_label) > 1) {
2253 $label =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">';
2254 foreach ($fields_label as $field_toshow) {
2256 if (!empty($obj->$field_toshow)) {
2257 $translabel = $outputlangs->trans($obj->$field_toshow);
2259 if ($translabel != $field_toshow) {
2260 $label .=
' '.dol_trunc($translabel, 18);
2262 $label .=
' '.$obj->$field_toshow;
2266 $toprint[] = $label;
2269 if (!empty($obj->{$InfoFieldList[1]})) {
2270 $translabel = $outputlangs->trans($obj->{$InfoFieldList[1]});
2272 if ($translabel != $obj->{$InfoFieldList[1]}) {
2273 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).
'</li>';
2275 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->{$InfoFieldList[1]}.
'</li>';
2281 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2284 while ($obj = $this->db->fetch_object($resql)) {
2285 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
2287 $c->fetch($obj->rowid);
2288 $ways =
$c->print_all_ways();
2289 foreach ($ways as $way) {
2290 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ?
' style="background: #'.$c->color.
';"' :
' style="background: #bbb"').
'>'.
img_object(
'',
'category').
' '.$way.
'</li>';
2295 if (!empty($toprint)) {
2296 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
2299 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
2301 } elseif ($type ==
'link') {
2306 $param_list = array_keys($param[
'options']);
2308 $InfoFieldList = explode(
":", $param_list[0]);
2309 $classname = $InfoFieldList[0];
2310 $classpath = $InfoFieldList[1];
2311 if (!empty($classpath)) {
2313 if ($classname && class_exists($classname)) {
2314 $tmpobject =
new $classname($this->db);
2315 '@phan-var-force CommonObject $tmpobject';
2316 $tmpobject->fetch($value);
2318 if (get_class($tmpobject) ==
'Categorie') {
2320 $color = $tmpobject->color;
2321 $sfortag =
'<span class="noborderoncategories"' . ($color ?
' style="background: #' . $color .
';"' :
' style="background: #bbb"') .
'>';
2322 $sfortag .= $tmpobject->getNomUrl(3);
2323 $sfortag .=
'</span>';
2326 $value = $tmpobject->getNomUrl(3);
2330 dol_syslog(
'Error bad setup of extrafield', LOG_WARNING);
2331 return 'Error bad setup of extrafield';
2334 } elseif ($type ==
'point') {
2335 if (!empty($value)) {
2336 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeophp.class.php';
2338 $value = $dolgeophp->getXYString($value);
2342 } elseif (in_array($type, [
'multipts',
'linestrg',
'polygon'])) {
2343 if (!empty($value)) {
2344 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeophp.class.php';
2346 $value = $dolgeophp->getPointString($value);
2350 } elseif ($type ==
'text') {
2351 $value =
'<div class="'.($cssview ? $cssview :
'shortmessagecut').
'">'.
dol_htmlentitiesbr($value).
'</div>';
2352 } elseif ($type ==
'html') {
2354 } elseif ($type ==
'password') {
2355 $value =
dol_trunc(preg_replace(
'/./i',
'*', $value), 8,
'right',
'UTF-8', 1);
2356 } elseif ($type ==
'stars') {
2357 $objectid = (int)
$object->id;
2358 if ($showValueInsteadOfInputField == 1) {
2359 $value =
'<span style="display:none;" id="'.$key.$object->id.
'">'.
dol_escape_htmltag($value).
'</span>';
2361 $value =
'<input type="hidden" class="flat" name="'.$key.
'" id="'.$key.$objectid.
'" value="'.
dol_escape_htmltag($value).
'"'.($moreparam ? $moreparam :
'').
'>';
2364 $value .=
'<div class="star-selection" id="'.$key.$objectid.
'_selection">';
2366 while ($i <= $size) {
2367 $value .=
'<span class="star" data-value="'.$i.
'">'.
img_picto(
'',
'fontawesome_star_fas').
'</span>';
2372 $(document).ready(function() {
2373 let container = $("#'.$key.$objectid.
'_selection");
2374 let selectedStars = parseInt($("#'.$key.$objectid.
'").val() || $("#'.$key.$objectid.
'").text()) || 0;
2375 container.find(".star").each(function() {
2376 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
2378 if ($showValueInsteadOfInputField == 0) {
2380 container.find(".star").on("mouseover", function() {
2381 let selectedStar = $(this).data("value");
2382 container.find(".star").each(function() {
2383 $(this).toggleClass("active", $(this).data("value") <= selectedStar);
2386 container.on("mouseout", function() {
2387 container.find(".star").each(function() {
2388 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
2391 container.find(".star").off("click").on("click", function() {
2392 selectedStars = $(this).data("value");
2393 if (selectedStars == 1 && $("#'.$key.$objectid.
'").val() == 1) {
2396 container.find("#'.$key.$objectid.
'").val(selectedStars);
2397 container.find(".star").each(function() {
2398 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
2401 url: "'.DOL_URL_ROOT.
'/core/ajax/editextrafield.php",
2405 objectId:
'.((int) $objectid).',
2406 field: \
''.dol_escape_js($key).
'\',
2407 value: selectedStars,
2408 token:
"'.newToken().'"
2410 success:
function(response) {
2411 var res = JSON.parse(response);
2412 console[res.status ===
"success" ?
"log" :
"error"](res.message);
2414 error:
function(xhr,
status, error) {
2415 console.log(
"Ajax request failed while updating '.$key.':", error);
2424 $showsize = round((float) $size);
2425 if ($showsize > 48) {
2430 //print $type.'-
'.$size;