1088 public function showInputField($key, $value, $moreparam =
'', $keysuffix =
'', $keyprefix =
'', $morecss =
'', $objectid = 0, $extrafieldsobjectkey =
'', $mode = 0)
1090 global $conf, $langs, $form;
1092 if (!is_object($form)) {
1093 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
1094 $form =
new Form($this->db);
1099 if (!preg_match(
'/options_$/', $keyprefix)) {
1100 $keyprefix .=
'options_';
1103 if (empty($extrafieldsobjectkey)) {
1104 dol_syslog(get_class($this).
'::showInputField extrafieldsobjectkey required', LOG_ERR);
1105 return 'BadValueForParamExtraFieldsObjectKey';
1108 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
1109 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1110 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
1111 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
1112 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
1113 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
1114 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
1115 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
1116 $perms = (int)
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
1117 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
1118 $list = (string)
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
1119 $totalizable = $this->attributes[$extrafieldsobjectkey][
'totalizable'][$key];
1120 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
1121 $hidden = (empty($list) ? 1 : 0);
1127 if (!preg_match(
'/^search_/', $keyprefix)) {
1128 return '<span class="opacitymedium">'.$langs->trans(
"AutomaticallyCalculated").
'</span>';
1136 if (empty($morecss)) {
1138 if ($type ==
'date') {
1139 $morecss =
'minwidth100imp';
1140 } elseif ($type ==
'datetime' || $type ==
'datetimegmt' || $type ==
'link') {
1141 $morecss =
'minwidth200imp';
1142 } elseif (in_array($type, array(
'int',
'integer',
'double',
'price'))) {
1143 $morecss =
'maxwidth75';
1144 } elseif ($type ==
'password') {
1145 $morecss =
'maxwidth100';
1146 } elseif ($type ==
'url') {
1147 $morecss =
'minwidth400';
1148 } elseif ($type ==
'boolean') {
1150 } elseif ($type ==
'radio') {
1151 $morecss =
'width25';
1153 if (empty($size) || round((
float) $size) < 12) {
1154 $morecss =
'minwidth100';
1155 } elseif (round((
float) $size) <= 48) {
1156 $morecss =
'minwidth200';
1158 $morecss =
'minwidth400';
1162 if (!empty($this->attributes[$extrafieldsobjectkey][
'css'][$key])) {
1163 $morecss = $this->attributes[$extrafieldsobjectkey][
'css'][$key];
1167 if (in_array($type, array(
'date'))) {
1168 $tmp = explode(
',', $size);
1173 if (!$required && $value ==
'') {
1180 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1181 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1183 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1184 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1185 $out .=
'</div><div class="nowrap">';
1186 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1187 $out .=
'</div></div>';
1190 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1);
1192 } elseif (in_array($type, array(
'datetime',
'datetimegmt'))) {
1193 $tmp = explode(
',', $size);
1198 if (!$required && $value ==
'') {
1205 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1206 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1208 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1209 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"),
'tzuserrel');
1210 $out .=
'</div><div class="nowrap">';
1211 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
1212 $out .=
'</div></div>';
1215 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1,
'',
'',
'', 1,
'',
'',
'tzuserrel');
1217 } elseif (in_array($type, array(
'int',
'integer'))) {
1218 $tmp = explode(
',', $size);
1220 $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 :
'').
'>';
1221 } elseif (preg_match(
'/varchar/', $type)) {
1222 $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 :
'').
'>';
1223 } elseif (in_array($type, array(
'mail',
'ip',
'phone',
'url'))) {
1224 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1225 } elseif ($type ==
'icon') {
1231 $out .=
'<input type="text" class="form-control icp icp-auto iconpicker-element iconpicker-input flat '.$morecss.
' maxwidthonsmartphone"';
1232 $out .=
' name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1235 $options =
"{ title: '<b>".$langs->trans(
"IconFieldSelector").
"</b>', placement: 'right', showFooter: false, templates: {";
1236 $options .=
"iconpicker: '<div class=\"iconpicker\"><div style=\"background-color:#EFEFEF;\" class=\"iconpicker-items\"></div></div>',";
1237 $options .=
"iconpickerItem: '<a role=\"button\" href=\"#\" class=\"iconpicker-item\" style=\"background-color:#DDDDDD;\"><i></i></a>',";
1240 $options .=
"footer: '<div class=\"popover-footer\" style=\"background-color:#EFEFEF;\"></div>',";
1241 $options .=
"search: '<input type=\"search\" class\"form-control iconpicker-search\" placeholder=\"".$langs->trans(
"TypeToFilter").
"\" />',";
1242 $options .=
"popover: '<div class=\"iconpicker-popover popover\">";
1243 $options .=
" <div class=\"arrow\" ></div>";
1244 $options .=
" <div class=\"popover-title\" style=\"text-align:center;background-color:#EFEFEF;\"></div>";
1245 $options .=
" <div class=\"popover-content \" ></div>";
1246 $options .=
"</div>'}}";
1247 $out .=
"$('#".$keyprefix.$key.$keysuffix.
"').iconpicker(".$options.
");";
1248 $out .=
'</script>';
1250 } elseif ($type ==
'text') {
1251 if (!preg_match(
'/search_/', $keyprefix)) {
1252 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1253 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false,
false, ROWS_5,
'90%');
1254 $out = (string) $doleditor->Create(1);
1256 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1258 } elseif ($type ==
'html') {
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, isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), 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 ==
'boolean') {
1269 if (!empty($value)) {
1270 $checked =
' checked value="1" ';
1272 $checked =
' value="1" ';
1274 $out =
'<input type="checkbox" class="flat valignmiddle'.($morecss ?
' '.$morecss :
'').
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.$checked.
' '.($moreparam ? $moreparam :
'').
'>';
1276 $out = $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1,
false, 1, 1,
'width75 yesno');
1278 $out .=
'<input type="hidden" name="'.$keyprefix.$key.$keysuffix.
'_boolean" value="1">';
1279 } elseif ($type ==
'price') {
1280 if (!empty($value)) {
1281 $value =
price($value);
1283 $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).
'">';
1284 } elseif ($type ==
'pricecy') {
1285 $currency = $conf->currency;
1286 if (!empty($value)) {
1288 $pricetmp = explode(
':', $value);
1289 $currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
1290 $value =
price($pricetmp[0]);
1292 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1293 $out .= $form->selectCurrency($currency, $keyprefix.$key.$keysuffix.
'currency_id');
1294 } elseif ($type ==
'duration') {
1295 $value = intval($value);
1296 $out = $form->select_duration($keyprefix . $key, $value, 0,
'text', 0, 1);
1297 } elseif ($type ==
'double') {
1298 if (!empty($value)) {
1299 $value =
price($value);
1301 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1302 } elseif ($type ==
'select') {
1306 foreach ($param[
'options'] as $okey => $val) {
1307 if ((
string) $okey ==
'') {
1311 $valarray = explode(
'|', $val);
1312 $val = $valarray[0];
1314 if ($langfile && $val) {
1315 $options[$okey] = $langs->trans($val);
1317 $options[$okey] = $val;
1320 $selected = array();
1321 if (!is_array($value)) {
1322 $selected = explode(
',', $value);
1325 $out .= $form->multiselectarray($keyprefix.$key.$keysuffix, $options, $selected, 0, 0, $morecss, 0, 0,
'',
'',
'', !empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2'));
1327 if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2')) {
1328 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1329 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1332 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1333 $out .=
'<option value="0"> </option>';
1334 foreach ($param[
'options'] as $key2 => $val2) {
1335 if ((
string) $key2 ==
'') {
1338 $valarray = explode(
'|', $val2);
1339 $val2 = $valarray[0];
1341 if (!empty($valarray[1])) {
1342 $parent = $valarray[1];
1344 $out .=
'<option value="'.$key2.
'"';
1345 $out .= (((string) $value == (
string) $key2) ?
' selected' :
'');
1346 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1348 if ($langfile && $val2) {
1349 $out .= $langs->trans($val2);
1353 $out .=
'</option>';
1355 $out .=
'</select>';
1357 } elseif ($type ==
'sellist') {
1359 if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2')) {
1360 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1361 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1364 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1365 if (is_array($param[
'options'])) {
1366 $tmpparamoptions = array_keys($param[
'options']);
1367 $paramoptions = preg_split(
'/[\r\n]+/', $tmpparamoptions[0]);
1369 $InfoFieldList = explode(
":", $paramoptions[0], 5);
1381 if (! empty($InfoFieldList[4])) {
1383 $parenthesisopen = 0;
1384 while (substr($InfoFieldList[4], $pos, 1) !==
'' && ($parenthesisopen || $pos == 0 || substr($InfoFieldList[4], $pos, 1) !=
':')) {
1385 if (substr($InfoFieldList[4], $pos, 1) ==
'(') {
1388 if (substr($InfoFieldList[4], $pos, 1) ==
')') {
1393 $tmpbefore = substr($InfoFieldList[4], 0, $pos);
1394 $tmpafter = substr($InfoFieldList[4], $pos + 1);
1396 $InfoFieldList[4] = $tmpbefore;
1397 if ($tmpafter !==
'') {
1398 $InfoFieldList = array_merge($InfoFieldList, explode(
':', $tmpafter));
1403 if (preg_match(
'/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) {
1404 $InfoFieldList[4] =
'('.$reg[1].
':'.$reg[2].
':'.$reg[3].
')';
1414 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1416 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1417 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1418 $keyList .=
', '.$parentField;
1420 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1421 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1422 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1424 $keyList = $InfoFieldList[2].
' as rowid';
1428 $filter_categorie =
false;
1429 if (count($InfoFieldList) > 5) {
1430 if ($InfoFieldList[0] ==
'categorie') {
1431 $filter_categorie =
true;
1435 if (!$filter_categorie) {
1436 $fields_label = explode(
'|', $InfoFieldList[1]);
1437 if (is_array($fields_label)) {
1439 $keyList .= implode(
', ', $fields_label);
1443 $sql =
"SELECT ".$keyList;
1444 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1447 if (!empty($InfoFieldList[4])) {
1449 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1450 $InfoFieldList[4] = str_replace(
'$ENTITY$', (
string) $conf->entity, $InfoFieldList[4]);
1453 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1454 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1458 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1459 $InfoFieldList[4] = str_replace(
'$ID$', (
string) $objectid, $InfoFieldList[4]);
1461 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1466 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1467 $sql .=
' as main, '.$this->db->sanitize($this->db->prefix().$InfoFieldList[0]).
'_extrafields as extra';
1468 $sqlwhere .=
" WHERE extra.fk_object = main.".$this->db->sanitize($InfoFieldList[2]);
1474 $sqlwhere .=
' WHERE 1=1';
1491 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1492 $sqlwhere .=
' AND entity = '.((int) $conf->entity);
1497 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1499 dol_syslog(get_class($this).
'::showInputField type=sellist', LOG_DEBUG);
1500 $resql = $this->db->query($sql);
1502 $out .=
'<option value="0"> </option>';
1503 $num = $this->db->num_rows($resql);
1507 $obj = $this->db->fetch_object($resql);
1511 $fields_label = explode(
'|', $InfoFieldList[1]);
1512 if (is_array($fields_label) && count($fields_label) > 1) {
1514 foreach ($fields_label as $field_toshow) {
1515 $labeltoshow .= $obj->$field_toshow.
' ';
1518 $labeltoshow = $obj->{$InfoFieldList[1]};
1521 if ($value == $obj->rowid) {
1523 foreach ($fields_label as $field_toshow) {
1524 $translabel = $langs->trans($obj->$field_toshow);
1525 $labeltoshow = $translabel.
' ';
1528 $out .=
'<option value="'.$obj->rowid.
'" selected>'.$labeltoshow.
'</option>';
1531 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1532 $labeltoshow = $translabel;
1534 if (empty($labeltoshow)) {
1535 $labeltoshow =
'(not defined)';
1538 if (!empty($InfoFieldList[3]) && $parentField) {
1539 $parent = $parentName.
':'.$obj->{$parentField};
1542 $out .=
'<option value="'.$obj->rowid.
'"';
1543 $out .= ($value == $obj->rowid ?
' selected' :
'');
1544 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1545 $out .=
'>'.$labeltoshow.
'</option>';
1550 $this->db->free($resql);
1552 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1555 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1556 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1557 $out .=
'<option value="0"> </option>';
1558 if (is_array($data)) {
1559 foreach ($data as $data_key => $data_value) {
1560 $out .=
'<option value="'.$data_key.
'"';
1561 $out .= ($value == $data_key ?
' selected' :
'');
1562 $out .=
'>'.$data_value.
'</option>';
1567 $out .=
'</select>';
1568 } elseif ($type ==
'checkbox') {
1569 $value_arr = $value;
1570 if (!is_array($value)) {
1571 $value_arr = explode(
',', $value);
1573 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param[
'options']) ?
null : $param[
'options']), $value_arr, 0, 0,
'', 0,
'100%');
1574 } elseif ($type ==
'radio') {
1576 foreach ($param[
'options'] as $keyopt => $val) {
1577 $out .=
'<input class="flat '.$morecss.
'" type="radio" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'');
1578 $out .=
' value="'.$keyopt.
'"';
1579 $out .=
' id="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'"';
1580 $out .= ($value == $keyopt ?
'checked' :
'');
1581 $out .=
'/><label for="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'">'.$langs->trans($val).
'</label><br>';
1583 } elseif ($type ==
'chkbxlst') {
1584 if (is_array($value)) {
1585 $value_arr = $value;
1587 $value_arr = explode(
',', $value);
1590 if (is_array($param[
'options'])) {
1591 $tmpparamoptions = array_keys($param[
'options']);
1592 $paramoptions = preg_split(
'/[\r\n]+/', $tmpparamoptions[0]);
1594 $InfoFieldList = explode(
":", $paramoptions[0], 5);
1606 if (! empty($InfoFieldList[4])) {
1608 $parenthesisopen = 0;
1609 while (substr($InfoFieldList[4], $pos, 1) !==
'' && ($parenthesisopen || $pos == 0 || substr($InfoFieldList[4], $pos, 1) !=
':')) {
1610 if (substr($InfoFieldList[4], $pos, 1) ==
'(') {
1613 if (substr($InfoFieldList[4], $pos, 1) ==
')') {
1618 $tmpbefore = substr($InfoFieldList[4], 0, $pos);
1619 $tmpafter = substr($InfoFieldList[4], $pos + 1);
1621 $InfoFieldList[4] = $tmpbefore;
1622 if ($tmpafter !==
'') {
1623 $InfoFieldList = array_merge($InfoFieldList, explode(
':', $tmpafter));
1628 if (preg_match(
'/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) {
1629 $InfoFieldList[4] =
'('.$reg[1].
':'.$reg[2].
':'.$reg[3].
')';
1639 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1641 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1642 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1643 $keyList .=
', '.$parentField;
1645 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1646 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1647 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1649 $keyList = $InfoFieldList[2].
' as rowid';
1653 $filter_categorie =
false;
1654 if (count($InfoFieldList) > 5) {
1655 if ($InfoFieldList[0] ==
'categorie') {
1656 $filter_categorie =
true;
1660 if (!$filter_categorie) {
1661 $fields_label = explode(
'|', $InfoFieldList[1]);
1662 if (is_array($fields_label)) {
1664 $keyList .= implode(
', ', $fields_label);
1668 $sql =
"SELECT ".$keyList;
1669 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1672 if (!empty($InfoFieldList[4])) {
1674 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1675 $InfoFieldList[4] = str_replace(
'$ENTITY$', (
string) $conf->entity, $InfoFieldList[4]);
1678 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1679 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1683 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1684 $InfoFieldList[4] = str_replace(
'$ID$', (
string) $objectid, $InfoFieldList[4]);
1685 } elseif (preg_match(
"#^.*list.php$#", $_SERVER[
"PHP_SELF"])) {
1687 $word =
'\b[a-zA-Z0-9-\.-_]+\b=\$ID\$';
1690 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1694 while ($nbPreg != 0) {
1696 $nbPregRepl = $nbPregSel = 0;
1698 $InfoFieldList[4] = preg_replace(
'#([^=])(\([^)^(]*('.$word.
')[^)^(]*\))#',
'$1 $3 ', $InfoFieldList[4], -1, $nbPregRepl);
1700 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1702 $InfoFieldList[4] = preg_replace(
'#\b[a-zA-Z0-9-\.-_]+\b=\([^)^(]*('.$word.
')[^)^(]*\)#',
'$1 ', $InfoFieldList[4], -1, $nbPregSel);
1704 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1707 $nbPreg = $nbPregRepl + $nbPregSel;
1711 $matchCondition = array();
1712 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1713 while (!empty($matchCondition[0])) {
1715 if (!empty($matchCondition[1]) && !empty($matchCondition[3]) && $matchCondition[1] != $matchCondition[3]) {
1717 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1719 if (!empty($matchCondition[1])) {
1720 $boolCond = (($matchCondition[1] ==
"AND") ?
' AND TRUE ' :
' OR FALSE ');
1721 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond.$matchCondition[3], $InfoFieldList[4]);
1722 } elseif (!empty($matchCondition[3])) {
1723 $boolCond = (($matchCondition[3] ==
"AND") ?
' TRUE AND ' :
' FALSE OR');
1724 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond, $InfoFieldList[4]);
1726 $InfoFieldList[4] =
" TRUE ";
1731 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1734 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1739 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1740 $sql .=
' as main, '.$this->db->sanitize($this->db->prefix().$InfoFieldList[0]).
'_extrafields as extra';
1741 $sqlwhere .=
" WHERE extra.fk_object = main.".$this->db->sanitize($InfoFieldList[2]);
1747 $sqlwhere .=
' WHERE 1=1';
1764 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1765 $sqlwhere .=
" AND entity = ".((int) $conf->entity);
1771 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1773 dol_syslog(get_class($this).
'::showInputField type=chkbxlst', LOG_DEBUG);
1774 $resql = $this->db->query($sql);
1776 $num = $this->db->num_rows($resql);
1783 $obj = $this->db->fetch_object($resql);
1787 $fields_label = explode(
'|', $InfoFieldList[1]);
1788 if (is_array($fields_label)) {
1790 foreach ($fields_label as $field_toshow) {
1791 $labeltoshow .= $obj->$field_toshow.
' ';
1794 $labeltoshow = $obj->{$InfoFieldList[1]};
1796 $labeltoshow =
dol_trunc($labeltoshow, 45);
1798 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1800 foreach ($fields_label as $field_toshow) {
1801 $translabel = $langs->trans($obj->$field_toshow);
1802 if ($translabel != $obj->$field_toshow) {
1803 $labeltoshow .=
' '.dol_trunc($translabel, 18).
' ';
1805 $labeltoshow .=
' '.dol_trunc($obj->$field_toshow, 18).
' ';
1808 $data[$obj->rowid] = $labeltoshow;
1811 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1812 if ($translabel != $obj->{$InfoFieldList[1]}) {
1813 $labeltoshow =
dol_trunc($translabel, 18);
1815 $labeltoshow =
dol_trunc($obj->{$InfoFieldList[1]}, 18);
1818 if (empty($labeltoshow)) {
1819 $labeltoshow =
'(not defined)';
1822 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1823 $data[$obj->rowid] = $labeltoshow;
1826 if (!empty($InfoFieldList[3]) && $parentField) {
1827 $parent = $parentName.
':'.$obj->{$parentField};
1830 $data[$obj->rowid] = $labeltoshow;
1835 $this->db->free($resql);
1837 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, 0, 0,
'', 0,
'100%');
1839 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1842 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1843 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1844 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, 0, 0,
'', 0,
'100%');
1847 } elseif ($type ==
'link') {
1848 $param_list = array_keys($param[
'options']);
1855 $showempty = (($required && $default !=
'') ? 0 : 1);
1857 $tmparray = explode(
':', $param_list[0]);
1859 $element = $extrafieldsobjectkey;
1860 if ($element ==
'socpeople') {
1861 $element =
'contact';
1862 } elseif ($element ==
'projet') {
1863 $element =
'project';
1867 $objectdesc = $tmparray[0];
1868 $objectfield = $element.
':options_'.$key;
1870 $out = $form->selectForForms($objectdesc, $keyprefix.$key.$keysuffix, $value, $showempty,
'',
'', $morecss,
'', 0, 0,
'', $objectfield);
1871 } elseif (in_array($type, [
'point',
'multipts',
'linestrg',
'polygon'])) {
1872 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeophp.class.php';
1876 if (!empty($value)) {
1877 $tmparray = $dolgeophp->parseGeoString($value);
1878 $geojson = $tmparray[
'geojson'];
1879 $centroidjson = $tmparray[
'centroidjson'];
1881 if (!preg_match(
'/search_/', $keyprefix)) {
1882 require_once DOL_DOCUMENT_ROOT.
'/core/class/geomapeditor.class.php';
1884 $out .= $geomapeditor->getHtml($keyprefix.$key.$keysuffix, $geojson, $centroidjson, $type);
1889 } elseif ($type ==
'password') {
1891 $out =
'<input style="display:none" type="text" name="fakeusernameremembered">';
1892 $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 :
'').
'>';
1893 } elseif ($type ==
'stars') {
1894 $out =
'<input type="hidden" class="flat '.$morecss.
'" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'"'.($moreparam ? $moreparam :
'').
'>';
1895 $out .=
'<div class="star-selection" id="'.$keyprefix.$key.$keysuffix.
'_selection">';
1897 while ($i <= $size) {
1898 $out .=
'<span class="star" data-value="'.$i.
'">'.
img_picto(
'',
'fontawesome_star_fas').
'</span>';
1903 jQuery(function($) {
1904 let container = $("#'.$keyprefix.$key.$keysuffix.
'_selection");
1905 let selectedStars = parseInt($("#'.$keyprefix.$key.$keysuffix.
'").val()) || 0;
1906 container.find(".star").each(function() {
1907 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
1909 container.find(".star").on("mouseover", function() {
1910 let selectedStar = $(this).data("value");
1911 container.find(".star").each(function() {
1912 $(this).toggleClass("active", $(this).data("value") <= selectedStar);
1915 container.on("mouseout", function() {
1916 container.find(".star").each(function() {
1917 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
1920 container.find(".star").off("click").on("click", function() {
1921 selectedStars = $(this).data("value");
1922 if (selectedStars === 1 && $("#'.$keyprefix.$key.$keysuffix.
'").val() == 1) {
1925 $("#'.$keyprefix.$key.$keysuffix.
'").val(selectedStars);
1926 container.find(".star").each(function() {
1927 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
1933 if (!empty($hidden)) {
1934 $out =
'<input type="hidden" value="'.$value.
'" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'"/>';
1958 public function showOutputField($key, $value, $moreparam =
'', $extrafieldsobjectkey =
'', $outputlangs =
null,
$object =
null)
1960 global $conf, $langs;
1962 if (is_null($outputlangs) || !is_object($outputlangs)) {
1963 $outputlangs = $langs;
1966 if (empty($extrafieldsobjectkey)) {
1967 dol_syslog(get_class($this).
'::showOutputField extrafieldsobjectkey required', LOG_ERR);
1968 return 'BadValueForParamExtraFieldsObjectKey';
1971 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
1972 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1973 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
1974 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
1975 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
1976 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
1977 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
1978 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
1979 $perms = (int)
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
1980 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
1981 $list = (string)
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
1982 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
1983 $cssview = $this->attributes[$extrafieldsobjectkey][
'cssview'][$key];
1985 $hidden = (empty($list) ? 1 : 0);
1994 if ($type ==
'date') {
1996 if ($value !==
'') {
1999 } elseif ($type ==
'datetime') {
2001 if ($value !==
'') {
2004 } elseif ($type ==
'duration') {
2006 if ($value !==
'') {
2007 $value = intval($value);
2010 } elseif ($type ==
'datetimegmt') {
2012 if ($value !==
'') {
2015 } elseif ($type ==
'int') {
2017 } elseif ($type ==
'double') {
2018 if (!empty($value)) {
2020 $sizeparts = explode(
",", $size);
2021 $number_decimals = array_key_exists(1, $sizeparts) ? $sizeparts[1] : 0;
2022 $value =
price($value, 0, $outputlangs, 0, 0, $number_decimals,
'');
2024 } elseif ($type ==
'boolean') {
2026 if (!empty($value)) {
2027 $checked =
' checked ';
2030 $value =
'<input type="checkbox" '.$checked.
' '.($moreparam ? $moreparam :
'').
' readonly disabled>';
2032 $value =
yn($value ? 1 : 0);
2034 } elseif ($type ==
'mail') {
2036 } elseif ($type ==
'ip') {
2038 } elseif ($type ==
'icon') {
2039 $value =
'<span class="'.$value.
'"></span>';
2040 } elseif ($type ==
'url') {
2042 } elseif ($type ==
'phone') {
2044 } elseif ($type ==
'price') {
2046 if ($value || $value ==
'0') {
2047 $value =
price($value, 0, $outputlangs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1).
' '.$outputlangs->getCurrencySymbol($conf->currency);
2049 } elseif ($type ==
'pricecy') {
2050 $currency = $conf->currency;
2051 if (!empty($value)) {
2053 $pricetmp = explode(
':', $value);
2054 $currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
2055 $value = $pricetmp[0];
2057 if ($value || $value ==
'0') {
2058 $value =
price($value, 0, $outputlangs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1, $currency);
2060 } elseif ($type ==
'select') {
2061 $valstr = (!empty($param[
'options'][$value]) ? $param[
'options'][$value] :
'');
2062 if (($pos = strpos($valstr,
"|")) !==
false) {
2063 $valstr = substr($valstr, 0, $pos);
2065 if ($langfile && $valstr) {
2066 $value = $outputlangs->trans($valstr);
2070 } elseif ($type ==
'sellist') {
2071 $param_list = array_keys($param[
'options']);
2072 $InfoFieldList = explode(
":", $param_list[0]);
2074 $selectkey =
"rowid";
2077 if (count($InfoFieldList) >= 3) {
2078 $selectkey = $InfoFieldList[2];
2079 $keyList = $InfoFieldList[2].
' as rowid';
2082 $fields_label = explode(
'|', $InfoFieldList[1]);
2083 if (is_array($fields_label)) {
2085 $keyList .= implode(
', ', $fields_label);
2088 $filter_categorie =
false;
2089 if (count($InfoFieldList) > 5) {
2090 if ($InfoFieldList[0] ==
'categorie') {
2091 $filter_categorie =
true;
2095 $sql =
"SELECT ".$keyList;
2096 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
2097 if (!empty($InfoFieldList[4]) && strpos($InfoFieldList[4],
'extra.') !==
false) {
2100 if ($selectkey ==
'rowid' && empty($value)) {
2101 $sql .=
" WHERE ".$selectkey.
" = 0";
2102 } elseif ($selectkey ==
'rowid') {
2103 $sql .=
" WHERE ".$selectkey.
" = ".((int) $value);
2105 $sql .=
" WHERE ".$selectkey.
" = '".$this->db->escape($value).
"'";
2110 dol_syslog(get_class($this).
':showOutputField:$type=sellist', LOG_DEBUG);
2111 $resql = $this->db->query($sql);
2113 if (!$filter_categorie) {
2116 $obj = $this->db->fetch_object($resql);
2119 $fields_label = explode(
'|', $InfoFieldList[1]);
2121 if (is_array($fields_label) && count($fields_label) > 1) {
2122 foreach ($fields_label as $field_toshow) {
2124 if (!empty($obj->$field_toshow)) {
2125 $translabel = $outputlangs->trans($obj->$field_toshow);
2127 if ($translabel != $obj->$field_toshow) {
2128 $value .=
dol_trunc($translabel, 24) .
' ';
2130 $value .= $obj->$field_toshow .
' ';
2136 $tmppropname = $InfoFieldList[1];
2138 if (!empty(isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
2139 $translabel = $outputlangs->trans($obj->$tmppropname);
2141 if ($translabel != (isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
2144 $value = isset($obj->$tmppropname) ? $obj->$tmppropname :
'';
2149 $obj = $this->db->fetch_object($resql);
2151 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
2153 $result = $c->fetch($obj->rowid);
2155 $ways = $c->print_all_ways();
2156 foreach ($ways as $way) {
2157 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ?
' style="background: #' . $c->color .
';"' :
' style="background: #bbb"') .
'>' .
img_object(
'',
'category') .
' ' . $way .
'</li>';
2161 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
2164 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
2166 } elseif ($type ==
'radio') {
2167 if (!isset($param[
'options'][$value])) {
2168 $outputlangs->load(
'errors');
2169 $value = $outputlangs->trans(
'ErrorNoValueForRadioType');
2171 $value = $outputlangs->trans($param[
'options'][$value]);
2173 } elseif ($type ==
'checkbox') {
2174 $value_arr = explode(
',', $value);
2177 if (is_array($value_arr)) {
2178 foreach ($value_arr as $keyval => $valueval) {
2179 if (!empty($valueval)) {
2180 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$param[
'options'][$valueval].
'</li>';
2184 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
2185 } elseif ($type ==
'chkbxlst') {
2186 $value_arr = explode(
',', $value);
2188 $param_list = array_keys($param[
'options']);
2189 $InfoFieldList = explode(
":", $param_list[0]);
2191 $selectkey =
"rowid";
2194 if (count($InfoFieldList) >= 3) {
2195 $selectkey = $InfoFieldList[2];
2196 $keyList = $InfoFieldList[2].
' as rowid';
2199 $fields_label = explode(
'|', $InfoFieldList[1]);
2200 if (is_array($fields_label)) {
2202 $keyList .= implode(
', ', $fields_label);
2205 $filter_categorie =
false;
2206 if (count($InfoFieldList) > 5) {
2207 if ($InfoFieldList[0] ==
'categorie') {
2208 $filter_categorie =
true;
2212 $sql =
"SELECT ".$keyList;
2213 $sql .=
" FROM ".$this->db->prefix().$InfoFieldList[0];
2214 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
2220 dol_syslog(get_class($this).
':showOutputField:$type=chkbxlst', LOG_DEBUG);
2221 $resql = $this->db->query($sql);
2223 if (!$filter_categorie) {
2226 while ($obj = $this->db->fetch_object($resql)) {
2228 $fields_label = explode(
'|', $InfoFieldList[1]);
2229 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
2230 if (is_array($fields_label) && count($fields_label) > 1) {
2231 $label =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">';
2232 foreach ($fields_label as $field_toshow) {
2234 if (!empty($obj->$field_toshow)) {
2235 $translabel = $outputlangs->trans($obj->$field_toshow);
2237 if ($translabel != $field_toshow) {
2238 $label .=
' '.dol_trunc($translabel, 18);
2240 $label .=
' '.$obj->$field_toshow;
2244 $toprint[] = $label;
2247 if (!empty($obj->{$InfoFieldList[1]})) {
2248 $translabel = $outputlangs->trans($obj->{$InfoFieldList[1]});
2250 if ($translabel != $obj->{$InfoFieldList[1]}) {
2251 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).
'</li>';
2253 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->{$InfoFieldList[1]}.
'</li>';
2259 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
2262 while ($obj = $this->db->fetch_object($resql)) {
2263 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
2265 $c->fetch($obj->rowid);
2266 $ways = $c->print_all_ways();
2267 foreach ($ways as $way) {
2268 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ?
' style="background: #'.$c->color.
';"' :
' style="background: #bbb"').
'>'.
img_object(
'',
'category').
' '.$way.
'</li>';
2273 if (!empty($toprint)) {
2274 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
2277 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
2279 } elseif ($type ==
'link') {
2284 $param_list = array_keys($param[
'options']);
2286 $InfoFieldList = explode(
":", $param_list[0]);
2287 $classname = $InfoFieldList[0];
2288 $classpath = $InfoFieldList[1];
2289 if (!empty($classpath)) {
2291 if ($classname && class_exists($classname)) {
2292 $tmpobject =
new $classname($this->db);
2293 '@phan-var-force CommonObject $tmpobject';
2294 $tmpobject->fetch($value);
2295 $value = $tmpobject->getNomUrl(3);
2298 dol_syslog(
'Error bad setup of extrafield', LOG_WARNING);
2299 return 'Error bad setup of extrafield';
2302 } elseif ($type ==
'point') {
2303 if (!empty($value)) {
2304 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeophp.class.php';
2306 $value = $dolgeophp->getXYString($value);
2310 } elseif (in_array($type, [
'multipts',
'linestrg',
'polygon'])) {
2311 if (!empty($value)) {
2312 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgeophp.class.php';
2314 $value = $dolgeophp->getPointString($value);
2318 } elseif ($type ==
'text') {
2319 $value =
'<div class="'.($cssview ? $cssview :
'shortmessagecut').
'">'.
dol_htmlentitiesbr($value).
'</div>';
2320 } elseif ($type ==
'html') {
2322 } elseif ($type ==
'password') {
2323 $value =
dol_trunc(preg_replace(
'/./i',
'*', $value), 8,
'right',
'UTF-8', 1);
2324 } elseif ($type ==
'stars') {
2325 $objectid = (int)
$object->id;
2326 $value =
'<input type="hidden" class="flat" name="'.$key.
'" id="'.$key.$objectid.
'" value="'.
dol_escape_htmltag($value).
'"'.($moreparam ? $moreparam :
'').
'>';
2327 $value .=
'<div class="star-selection" id="'.$key.$objectid.
'_selection">';
2329 while ($i <= $size) {
2330 $value .=
'<span class="star" data-value="'.$i.
'">'.
img_picto(
'',
'fontawesome_star_fas').
'</span>';
2335 $(document).ready(function() {
2336 let container = $("#'.$key.$objectid.
'_selection");
2337 let selectedStars = parseInt($("#'.$key.$objectid.
'").val()) || 0;
2338 container.find(".star").each(function() {
2339 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
2341 container.find(".star").on("mouseover", function() {
2342 let selectedStar = $(this).data("value");
2343 container.find(".star").each(function() {
2344 $(this).toggleClass("active", $(this).data("value") <= selectedStar);
2347 container.on("mouseout", function() {
2348 container.find(".star").each(function() {
2349 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
2352 container.find(".star").off("click").on("click", function() {
2353 selectedStars = $(this).data("value");
2354 if (selectedStars == 1 && $("#'.$key.$objectid.
'").val() == 1) {
2357 container.find("#'.$key.$objectid.
'").val(selectedStars);
2358 container.find(".star").each(function() {
2359 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
2362 url: "'.DOL_URL_ROOT.
'/core/ajax/editextrafield.php",
2366 objectId:
'.((int) $objectid).',
2367 field: \
''.dol_escape_js($key).
'\',
2368 value: selectedStars,
2369 token:
"'.newToken().'"
2371 success:
function(response) {
2372 var res = JSON.parse(response);
2373 console[res.status ===
"success" ?
"log" :
"error"](res.message);
2375 error:
function(xhr,
status, error) {
2376 console.log(
"Ajax request failed while updating '.$key.':", error);
2383 $showsize = round((float) $size);
2384 if ($showsize > 48) {
2389 //print $type.'-
'.$size;