853 if (empty($elementtype)) {
857 if ($elementtype ==
'thirdparty') {
858 $elementtype =
'societe';
860 if ($elementtype ==
'contact') {
861 $elementtype =
'socpeople';
863 if ($elementtype ==
'order_supplier') {
864 $elementtype =
'commande_fournisseur';
870 $array_name_label = array();
873 $sql =
"SELECT rowid, name, label, type, size, elementtype, fieldunique, fieldrequired, param, pos, alwayseditable, perms, langs, list, printable, totalizable, fielddefault, fieldcomputed, entity, enabled, help,";
874 $sql .=
" css, cssview, csslist";
875 $sql .=
" FROM ".$this->db->prefix().
"extrafields";
877 if ($elementtype && $elementtype !=
'all') {
878 $sql .=
" WHERE elementtype = '".$this->db->escape($elementtype).
"'";
880 $sql .=
" ORDER BY pos";
882 $resql = $this->db->query($sql);
885 if ($this->db->num_rows($resql)) {
886 while ($tab = $this->db->fetch_object($resql)) {
887 if ($tab->entity != 0 && $tab->entity != $conf->entity) {
889 if ($tab->fieldrequired && is_null($tab->fielddefault)) {
890 $this->attributes[$tab->elementtype][
'mandatoryfieldsofotherentities'][$tab->name] = $tab->type;
896 if ($tab->type !=
'separate') {
897 $array_name_label[$tab->name] = $tab->label;
900 $this->attributes[$tab->elementtype][
'type'][$tab->name] = $tab->type;
901 $this->attributes[$tab->elementtype][
'label'][$tab->name] = $tab->label;
902 $this->attributes[$tab->elementtype][
'size'][$tab->name] = $tab->size;
903 $this->attributes[$tab->elementtype][
'elementtype'][$tab->name] = $tab->elementtype;
904 $this->attributes[$tab->elementtype][
'default'][$tab->name] = $tab->fielddefault;
905 $this->attributes[$tab->elementtype][
'computed'][$tab->name] = $tab->fieldcomputed;
906 $this->attributes[$tab->elementtype][
'unique'][$tab->name] = $tab->fieldunique;
907 $this->attributes[$tab->elementtype][
'required'][$tab->name] = $tab->fieldrequired;
908 $this->attributes[$tab->elementtype][
'param'][$tab->name] = ($tab->param ?
jsonOrUnserialize($tab->param) :
'');
909 $this->attributes[$tab->elementtype][
'pos'][$tab->name] = $tab->pos;
910 $this->attributes[$tab->elementtype][
'alwayseditable'][$tab->name] = $tab->alwayseditable;
911 $this->attributes[$tab->elementtype][
'perms'][$tab->name] = ((is_null($tab->perms) || strlen($tab->perms) == 0) ? 1 : $tab->perms);
912 $this->attributes[$tab->elementtype][
'langfile'][$tab->name] = $tab->langs;
913 $this->attributes[$tab->elementtype][
'list'][$tab->name] = $tab->list;
914 $this->attributes[$tab->elementtype][
'printable'][$tab->name] = $tab->printable;
915 $this->attributes[$tab->elementtype][
'totalizable'][$tab->name] = ($tab->totalizable ? 1 : 0);
916 $this->attributes[$tab->elementtype][
'entityid'][$tab->name] = $tab->entity;
917 $this->attributes[$tab->elementtype][
'enabled'][$tab->name] = $tab->enabled;
918 $this->attributes[$tab->elementtype][
'help'][$tab->name] = $tab->help;
919 $this->attributes[$tab->elementtype][
'css'][$tab->name] = $tab->css;
920 $this->attributes[$tab->elementtype][
'cssview'][$tab->name] = $tab->cssview;
921 $this->attributes[$tab->elementtype][
'csslist'][$tab->name] = $tab->csslist;
923 $this->attributes[$tab->elementtype][
'loaded'] = 1;
928 $this->attributes[$elementtype][
'loaded'] = 1;
929 $this->attributes[$elementtype][
'count'] = $count;
932 $this->error = $this->db->lasterror();
933 dol_syslog(get_class($this).
"::fetch_name_optionals_label ".$this->error, LOG_ERR);
936 return $array_name_label;
955 public function showInputField($key, $value, $moreparam =
'', $keysuffix =
'', $keyprefix =
'', $morecss =
'', $objectid = 0, $extrafieldsobjectkey =
'', $mode = 0)
957 global $conf, $langs, $form;
959 if (!is_object($form)) {
960 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
961 $form =
new Form($this->db);
966 if (!preg_match(
'/options_$/', $keyprefix)) {
967 $keyprefix = $keyprefix.
'options_';
970 if (empty($extrafieldsobjectkey)) {
971 dol_syslog(get_class($this).
'::showInputField extrafieldsobjectkey required', LOG_ERR);
972 return 'BadValueForParamExtraFieldsObjectKey';
975 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
976 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
977 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
978 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
979 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
980 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
981 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
982 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
983 $perms =
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
984 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
985 $list =
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
986 $totalizable = $this->attributes[$extrafieldsobjectkey][
'totalizable'][$key];
987 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
988 $hidden = (empty($list) ? 1 : 0);
994 if (!preg_match(
'/^search_/', $keyprefix)) {
995 return '<span class="opacitymedium">'.$langs->trans(
"AutomaticallyCalculated").
'</span>';
1003 if (empty($morecss)) {
1005 if ($type ==
'date') {
1006 $morecss =
'minwidth100imp';
1007 } elseif ($type ==
'datetime' || $type ==
'datetimegmt' || $type ==
'link') {
1008 $morecss =
'minwidth200imp';
1009 } elseif (in_array($type, array(
'int',
'integer',
'double',
'price'))) {
1010 $morecss =
'maxwidth75';
1011 } elseif ($type ==
'password') {
1012 $morecss =
'maxwidth100';
1013 } elseif ($type ==
'url') {
1014 $morecss =
'minwidth400';
1015 } elseif ($type ==
'boolean') {
1017 } elseif ($type ==
'radio') {
1018 $morecss =
'width25';
1020 if (empty($size) || round((
float) $size) < 12) {
1021 $morecss =
'minwidth100';
1022 } elseif (round((
float) $size) <= 48) {
1023 $morecss =
'minwidth200';
1025 $morecss =
'minwidth400';
1029 if (!empty($this->attributes[$extrafieldsobjectkey][
'css'][$key])) {
1030 $morecss = $this->attributes[$extrafieldsobjectkey][
'css'][$key];
1034 if (in_array($type, array(
'date'))) {
1035 $tmp = explode(
',', $size);
1040 if (!$required && $value ==
'') {
1047 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1048 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1050 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1051 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1052 $out .=
'</div><div class="nowrap">';
1053 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1054 $out .=
'</div></div>';
1057 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1);
1059 } elseif (in_array($type, array(
'datetime',
'datetimegmt'))) {
1060 $tmp = explode(
',', $size);
1065 if (!$required && $value ==
'') {
1072 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1073 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1075 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1076 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"),
'tzuserrel');
1077 $out .=
'</div><div class="nowrap">';
1078 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
1079 $out .=
'</div></div>';
1082 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1,
'',
'',
'', 1,
'',
'',
'tzuserrel');
1084 } elseif (in_array($type, array(
'int',
'integer'))) {
1085 $tmp = explode(
',', $size);
1087 $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 :
'').
'>';
1088 } elseif (preg_match(
'/varchar/', $type)) {
1089 $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 :
'').
'>';
1090 } elseif (in_array($type, array(
'mail',
'ip',
'phone',
'url'))) {
1091 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1092 } elseif ($type ==
'icon') {
1098 $out.=
'<input type="text" class="form-control icp icp-auto iconpicker-element iconpicker-input flat '.$morecss.
' maxwidthonsmartphone"';
1099 $out.=
' name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1102 $options=
"{ title: '<b>".$langs->trans(
"IconFieldSelector").
"</b>', placement: 'right', showFooter: false, templates: {";
1103 $options.=
"iconpicker: '<div class=\"iconpicker\"><div style=\"background-color:#EFEFEF;\" class=\"iconpicker-items\"></div></div>',";
1104 $options.=
"iconpickerItem: '<a role=\"button\" href=\"#\" class=\"iconpicker-item\" style=\"background-color:#DDDDDD;\"><i></i></a>',";
1107 $options.=
"footer: '<div class=\"popover-footer\" style=\"background-color:#EFEFEF;\"></div>',";
1108 $options.=
"search: '<input type=\"search\" class\"form-control iconpicker-search\" placeholder=\"".$langs->trans(
"TypeToFilter").
"\" />',";
1109 $options.=
"popover: '<div class=\"iconpicker-popover popover\">";
1110 $options.=
" <div class=\"arrow\" ></div>";
1111 $options.=
" <div class=\"popover-title\" style=\"text-align:center;background-color:#EFEFEF;\"></div>";
1112 $options.=
" <div class=\"popover-content \" ></div>";
1113 $options.=
"</div>'}}";
1114 $out.=
"$('#".$keyprefix.$key.$keysuffix.
"').iconpicker(".$options.
");";
1117 } elseif ($type ==
'text') {
1118 if (!preg_match(
'/search_/', $keyprefix)) {
1119 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1120 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false,
false, ROWS_5,
'90%');
1121 $out = $doleditor->Create(1);
1123 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1125 } elseif ($type ==
'html') {
1126 if (!preg_match(
'/search_/', $keyprefix)) {
1127 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1128 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false, isModEnabled(
'fckeditor') && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5,
'90%');
1129 $out = $doleditor->Create(1);
1131 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1133 } elseif ($type ==
'boolean') {
1136 if (!empty($value)) {
1137 $checked =
' checked value="1" ';
1139 $checked =
' value="1" ';
1142 $out =
'<input type="checkbox" class="flat valignmiddle'.($morecss ?
' '.$morecss :
'').
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.$checked.
' '.($moreparam ? $moreparam :
'').
'>';
1144 $out = $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1,
false, 1);
1146 $out .=
'<input type="hidden" name="'.$keyprefix.$key.$keysuffix.
'_boolean" value="1">';
1147 } elseif ($type ==
'price') {
1148 if (!empty($value)) {
1149 $value =
price($value);
1151 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> '.$langs->getCurrencySymbol($conf->currency);
1152 } elseif ($type ==
'pricecy') {
1153 $currency = $conf->currency;
1154 if (!empty($value)) {
1156 $pricetmp = explode(
':', $value);
1157 $currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
1158 $value =
price($pricetmp[0]);
1160 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1161 $out .= $form->selectCurrency($currency, $keyprefix.$key.$keysuffix.
'currency_id');
1162 } elseif ($type ==
'double') {
1163 if (!empty($value)) {
1164 $value =
price($value);
1166 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1167 } elseif ($type ==
'select') {
1171 foreach ($param[
'options'] as $okey => $val) {
1172 if ((
string) $okey ==
'') {
1176 $valarray = explode(
'|', $val);
1177 $val = $valarray[0];
1179 if ($langfile && $val) {
1180 $options[$okey] = $langs->trans($val);
1182 $options[$okey] = $val;
1185 $selected = array();
1186 if (!is_array($value)) {
1187 $selected = explode(
',', $value);
1190 $out .= $form->multiselectarray($keyprefix.$key.$keysuffix, $options, $selected, 0, 0, $morecss, 0, 0,
'',
'',
'', !empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2'));
1192 if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2')) {
1193 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1194 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1197 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1198 $out .=
'<option value="0"> </option>';
1199 foreach ($param[
'options'] as $key2 => $val2) {
1200 if ((
string) $key2 ==
'') {
1203 $valarray = explode(
'|', $val2);
1204 $val2 = $valarray[0];
1206 if (!empty($valarray[1])) {
1207 $parent = $valarray[1];
1209 $out .=
'<option value="'.$key2.
'"';
1210 $out .= (((string) $value == (
string) $key2) ?
' selected' :
'');
1211 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1213 if ($langfile && $val2) {
1214 $out .= $langs->trans($val2);
1218 $out .=
'</option>';
1220 $out .=
'</select>';
1222 } elseif ($type ==
'sellist') {
1224 if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2')) {
1225 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1226 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1229 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1230 if (is_array($param[
'options'])) {
1231 $param_list = array_keys($param[
'options']);
1232 $InfoFieldList = explode(
":", $param_list[0]);
1243 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1246 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1247 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1248 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1250 $keyList = $InfoFieldList[2].
' as rowid';
1253 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1254 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1255 $keyList .=
', '.$parentField;
1258 $filter_categorie =
false;
1259 if (count($InfoFieldList) > 5) {
1260 if ($InfoFieldList[0] ==
'categorie') {
1261 $filter_categorie =
true;
1265 if ($filter_categorie ===
false) {
1266 $fields_label = explode(
'|', $InfoFieldList[1]);
1267 if (is_array($fields_label)) {
1269 $keyList .= implode(
', ', $fields_label);
1273 $sql =
"SELECT ".$keyList;
1274 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1275 if (!empty($InfoFieldList[4])) {
1277 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1278 $InfoFieldList[4] = str_replace(
'$ENTITY$', $conf->entity, $InfoFieldList[4]);
1281 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1282 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1286 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1287 $InfoFieldList[4] = str_replace(
'$ID$', $objectid, $InfoFieldList[4]);
1289 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1292 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1293 $sql .=
' as main, '.$this->db->prefix().$InfoFieldList[0].
'_extrafields as extra';
1294 $sqlwhere .=
" WHERE extra.fk_object=main.".$InfoFieldList[2].
" AND ".$InfoFieldList[4];
1296 $sqlwhere .=
" WHERE ".$InfoFieldList[4];
1299 $sqlwhere .=
' WHERE 1=1';
1302 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1303 $sqlwhere .=
' AND entity = '.((int) $conf->entity);
1308 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1310 dol_syslog(get_class($this).
'::showInputField type=sellist', LOG_DEBUG);
1311 $resql = $this->db->query($sql);
1313 $out .=
'<option value="0"> </option>';
1314 $num = $this->db->num_rows($resql);
1318 $obj = $this->db->fetch_object($resql);
1322 $fields_label = explode(
'|', $InfoFieldList[1]);
1323 if (is_array($fields_label) && count($fields_label) > 1) {
1325 foreach ($fields_label as $field_toshow) {
1326 $labeltoshow .= $obj->$field_toshow.
' ';
1329 $labeltoshow = $obj->{$InfoFieldList[1]};
1331 $labeltoshow = $labeltoshow;
1333 if ($value == $obj->rowid) {
1335 foreach ($fields_label as $field_toshow) {
1336 $translabel = $langs->trans($obj->$field_toshow);
1337 $labeltoshow = $translabel.
' ';
1340 $out .=
'<option value="'.$obj->rowid.
'" selected>'.$labeltoshow.
'</option>';
1343 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1344 $labeltoshow = $translabel;
1346 if (empty($labeltoshow)) {
1347 $labeltoshow =
'(not defined)';
1350 if (!empty($InfoFieldList[3]) && $parentField) {
1351 $parent = $parentName.
':'.$obj->{$parentField};
1354 $out .=
'<option value="'.$obj->rowid.
'"';
1355 $out .= ($value == $obj->rowid ?
' selected' :
'');
1356 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1357 $out .=
'>'.$labeltoshow.
'</option>';
1362 $this->db->free($resql);
1364 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1367 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1368 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1369 $out .=
'<option value="0"> </option>';
1370 if (is_array($data)) {
1371 foreach ($data as $data_key => $data_value) {
1372 $out .=
'<option value="'.$data_key.
'"';
1373 $out .= ($value == $data_key ?
' selected' :
'');
1374 $out .=
'>'.$data_value.
'</option>';
1379 $out .=
'</select>';
1380 } elseif ($type ==
'checkbox') {
1381 $value_arr = $value;
1382 if (!is_array($value)) {
1383 $value_arr = explode(
',', $value);
1385 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param[
'options']) ?
null : $param[
'options']), $value_arr,
'', 0,
'', 0,
'100%');
1386 } elseif ($type ==
'radio') {
1388 foreach ($param[
'options'] as $keyopt => $val) {
1389 $out .=
'<input class="flat '.$morecss.
'" type="radio" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'');
1390 $out .=
' value="'.$keyopt.
'"';
1391 $out .=
' id="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'"';
1392 $out .= ($value == $keyopt ?
'checked' :
'');
1393 $out .=
'/><label for="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'">'.$langs->trans($val).
'</label><br>';
1395 } elseif ($type ==
'chkbxlst') {
1396 if (is_array($value)) {
1397 $value_arr = $value;
1399 $value_arr = explode(
',', $value);
1402 if (is_array($param[
'options'])) {
1403 $param_list = array_keys($param[
'options']);
1404 $InfoFieldList = explode(
":", $param_list[0]);
1415 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1417 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1418 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1419 $keyList .=
', '.$parentField;
1421 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1422 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1423 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1425 $keyList = $InfoFieldList[2].
' as rowid';
1429 $filter_categorie =
false;
1430 if (count($InfoFieldList) > 5) {
1431 if ($InfoFieldList[0] ==
'categorie') {
1432 $filter_categorie =
true;
1436 if ($filter_categorie ===
false) {
1437 $fields_label = explode(
'|', $InfoFieldList[1]);
1438 if (is_array($fields_label)) {
1440 $keyList .= implode(
', ', $fields_label);
1444 $sql =
"SELECT ".$keyList;
1445 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1446 if (!empty($InfoFieldList[4])) {
1448 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1449 $InfoFieldList[4] = str_replace(
'$ENTITY$', $conf->entity, $InfoFieldList[4]);
1452 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1453 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1457 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1458 $InfoFieldList[4] = str_replace(
'$ID$', $objectid, $InfoFieldList[4]);
1459 } elseif (preg_match(
"#^.*list.php$#", $_SERVER[
"PHP_SELF"])) {
1461 $word =
'\b[a-zA-Z0-9-\.-_]+\b=\$ID\$';
1464 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1468 while ($nbPreg != 0) {
1470 $nbPregRepl = $nbPregSel = 0;
1472 $InfoFieldList[4] = preg_replace(
'#([^=])(\([^)^(]*('.$word.
')[^)^(]*\))#',
'$1 $3 ', $InfoFieldList[4], -1, $nbPregRepl);
1474 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1476 $InfoFieldList[4] = preg_replace(
'#\b[a-zA-Z0-9-\.-_]+\b=\([^)^(]*('.$word.
')[^)^(]*\)#',
'$1 ', $InfoFieldList[4], -1, $nbPregSel);
1478 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1481 $nbPreg = $nbPregRepl + $nbPregSel;
1485 $matchCondition = array();
1486 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1487 while (!empty($matchCondition[0])) {
1489 if (!empty($matchCondition[1]) && !empty($matchCondition[3]) && $matchCondition[1] != $matchCondition[3]) {
1491 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1493 if (!empty($matchCondition[1])) {
1494 $boolCond = (($matchCondition[1] ==
"AND") ?
' AND TRUE ' :
' OR FALSE ');
1495 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond.$matchCondition[3], $InfoFieldList[4]);
1496 } elseif (!empty($matchCondition[3])) {
1497 $boolCond = (($matchCondition[3] ==
"AND") ?
' TRUE AND ' :
' FALSE OR');
1498 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond, $InfoFieldList[4]);
1500 $InfoFieldList[4] =
" TRUE ";
1505 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1508 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1512 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1513 $sql .=
' as main, '.$this->db->prefix().$InfoFieldList[0].
'_extrafields as extra';
1514 $sqlwhere .=
" WHERE extra.fk_object=main.".$InfoFieldList[2].
" AND ".$InfoFieldList[4];
1516 $sqlwhere .=
" WHERE ".$InfoFieldList[4];
1519 $sqlwhere .=
' WHERE 1=1';
1522 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1523 $sqlwhere .=
" AND entity = ".((int) $conf->entity);
1529 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1531 dol_syslog(get_class($this).
'::showInputField type=chkbxlst', LOG_DEBUG);
1532 $resql = $this->db->query($sql);
1534 $num = $this->db->num_rows($resql);
1541 $obj = $this->db->fetch_object($resql);
1545 $fields_label = explode(
'|', $InfoFieldList[1]);
1546 if (is_array($fields_label)) {
1548 foreach ($fields_label as $field_toshow) {
1549 $labeltoshow .= $obj->$field_toshow.
' ';
1552 $labeltoshow = $obj->{$InfoFieldList[1]};
1554 $labeltoshow =
dol_trunc($labeltoshow, 45);
1556 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1558 foreach ($fields_label as $field_toshow) {
1559 $translabel = $langs->trans($obj->$field_toshow);
1560 if ($translabel != $obj->$field_toshow) {
1561 $labeltoshow .=
' '.dol_trunc($translabel, 18).
' ';
1563 $labeltoshow .=
' '.dol_trunc($obj->$field_toshow, 18).
' ';
1566 $data[$obj->rowid] = $labeltoshow;
1569 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1570 if ($translabel != $obj->{$InfoFieldList[1]}) {
1571 $labeltoshow =
dol_trunc($translabel, 18);
1573 $labeltoshow =
dol_trunc($obj->{$InfoFieldList[1]}, 18);
1576 if (empty($labeltoshow)) {
1577 $labeltoshow =
'(not defined)';
1580 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1581 $data[$obj->rowid] = $labeltoshow;
1584 if (!empty($InfoFieldList[3]) && $parentField) {
1585 $parent = $parentName.
':'.$obj->{$parentField};
1588 $data[$obj->rowid] = $labeltoshow;
1593 $this->db->free($resql);
1595 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr,
'', 0,
'', 0,
'100%');
1597 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1600 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1601 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1602 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr,
'', 0,
'', 0,
'100%');
1605 } elseif ($type ==
'link') {
1606 $param_list = array_keys($param[
'options']);
1613 $showempty = (($required && $default !=
'') ? 0 : 1);
1615 $tmparray = explode(
':', $param_list[0]);
1617 $element = $extrafieldsobjectkey;
1618 if ($element ==
'socpeople') {
1619 $element =
'contact';
1620 } elseif ( $element ==
'projet' ) {
1621 $element =
'project';
1625 $objectdesc = $tmparray[0];
1626 $objectfield = $element.
':options_'.$key;
1628 $out = $form->selectForForms($objectdesc, $keyprefix.$key.$keysuffix, $value, $showempty,
'',
'', $morecss,
'', 0, 0,
'', $objectfield);
1629 } elseif ($type ==
'password') {
1631 $out =
'<input style="display:none" type="text" name="fakeusernameremembered">';
1632 $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 :
'').
'>';
1634 if (!empty($hidden)) {
1635 $out =
'<input type="hidden" value="'.$value.
'" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'"/>';
1658 public function showOutputField($key, $value, $moreparam =
'', $extrafieldsobjectkey =
'', $outputlangs =
null)
1660 global $conf, $langs;
1662 if (is_null($outputlangs) || !is_object($outputlangs)) {
1663 $outputlangs = $langs;
1666 if (empty($extrafieldsobjectkey)) {
1667 dol_syslog(get_class($this).
'::showOutputField extrafieldsobjectkey required', LOG_ERR);
1668 return 'BadValueForParamExtraFieldsObjectKey';
1671 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
1672 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1673 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
1674 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
1675 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
1676 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
1677 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
1678 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
1679 $perms =
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
1680 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
1681 $list =
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
1682 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
1683 $hidden = (empty($list) ? 1 : 0);
1692 if ($type ==
'date') {
1694 if ($value !==
'') {
1697 } elseif ($type ==
'datetime') {
1699 if ($value !==
'') {
1702 } elseif ($type ==
'datetimegmt') {
1704 if ($value !==
'') {
1707 } elseif ($type ==
'int') {
1709 } elseif ($type ==
'double') {
1710 if (!empty($value)) {
1712 $sizeparts = explode(
",", $size);
1713 $number_decimals = array_key_exists(1, $sizeparts) ? $sizeparts[1] : 0;
1714 $value =
price($value, 0, $outputlangs, 0, 0, $number_decimals,
'');
1716 } elseif ($type ==
'boolean') {
1718 if (!empty($value)) {
1719 $checked =
' checked ';
1721 $value =
'<input type="checkbox" '.$checked.
' '.($moreparam ? $moreparam :
'').
' readonly disabled>';
1722 } elseif ($type ==
'mail') {
1724 } elseif ($type ==
'ip') {
1726 } elseif ($type ==
'icon') {
1727 $value =
'<span class="'.$value.
'"></span>';
1728 } elseif ($type ==
'url') {
1730 } elseif ($type ==
'phone') {
1732 } elseif ($type ==
'price') {
1734 if ($value || $value ==
'0') {
1735 $value =
price($value, 0, $outputlangs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1).
' '.$outputlangs->getCurrencySymbol($conf->currency);
1737 } elseif ($type ==
'pricecy') {
1738 $currency = $conf->currency;
1739 if (!empty($value)) {
1741 $pricetmp = explode(
':', $value);
1742 $currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
1743 $value = $pricetmp[0];
1745 if ($value || $value ==
'0') {
1746 $value =
price($value, 0, $outputlangs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1, $currency);
1748 } elseif ($type ==
'select') {
1749 $valstr = (!empty($param[
'options'][$value]) ? $param[
'options'][$value] :
'');
1750 if (($pos = strpos($valstr,
"|")) !==
false) {
1751 $valstr = substr($valstr, 0, $pos);
1753 if ($langfile && $valstr) {
1754 $value = $outputlangs->trans($valstr);
1758 } elseif ($type ==
'sellist') {
1759 $param_list = array_keys($param[
'options']);
1760 $InfoFieldList = explode(
":", $param_list[0]);
1762 $selectkey =
"rowid";
1765 if (count($InfoFieldList) >= 3) {
1766 $selectkey = $InfoFieldList[2];
1767 $keyList = $InfoFieldList[2].
' as rowid';
1770 $fields_label = explode(
'|', $InfoFieldList[1]);
1771 if (is_array($fields_label)) {
1773 $keyList .= implode(
', ', $fields_label);
1776 $filter_categorie =
false;
1777 if (count($InfoFieldList) > 5) {
1778 if ($InfoFieldList[0] ==
'categorie') {
1779 $filter_categorie =
true;
1783 $sql =
"SELECT ".$keyList;
1784 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1785 if (!empty($InfoFieldList[4]) && strpos($InfoFieldList[4],
'extra.') !==
false) {
1788 if ($selectkey ==
'rowid' && empty($value)) {
1789 $sql .=
" WHERE ".$selectkey.
" = 0";
1790 } elseif ($selectkey ==
'rowid') {
1791 $sql .=
" WHERE ".$selectkey.
" = ".((int) $value);
1793 $sql .=
" WHERE ".$selectkey.
" = '".$this->db->escape($value).
"'";
1798 dol_syslog(get_class($this).
':showOutputField:$type=sellist', LOG_DEBUG);
1799 $resql = $this->db->query($sql);
1801 if ($filter_categorie ===
false) {
1804 $obj = $this->db->fetch_object($resql);
1807 $fields_label = explode(
'|', $InfoFieldList[1]);
1809 if (is_array($fields_label) && count($fields_label) > 1) {
1810 foreach ($fields_label as $field_toshow) {
1812 if (!empty($obj->$field_toshow)) {
1813 $translabel = $outputlangs->trans($obj->$field_toshow);
1815 if ($translabel != $obj->$field_toshow) {
1816 $value .=
dol_trunc($translabel, 24) .
' ';
1818 $value .= $obj->$field_toshow .
' ';
1824 $tmppropname = $InfoFieldList[1];
1826 if (!empty(isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
1827 $translabel = $outputlangs->trans($obj->$tmppropname);
1829 if ($translabel != (isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
1832 $value = isset($obj->$tmppropname) ? $obj->$tmppropname :
'';
1837 $obj = $this->db->fetch_object($resql);
1839 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1841 $result = $c->fetch($obj->rowid);
1843 $ways = $c->print_all_ways();
1844 foreach ($ways as $way) {
1845 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ?
' style="background: #' . $c->color .
';"' :
' style="background: #bbb"') .
'>' .
img_object(
'',
'category') .
' ' . $way .
'</li>';
1849 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1852 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
1854 } elseif ($type ==
'radio') {
1855 if (!isset($param[
'options'][$value])) {
1856 $outputlangs->load(
'errors');
1857 $value = $outputlangs->trans(
'ErrorNoValueForRadioType');
1859 $value = $outputlangs->trans($param[
'options'][$value]);
1861 } elseif ($type ==
'checkbox') {
1862 $value_arr = explode(
',', $value);
1865 if (is_array($value_arr)) {
1866 foreach ($value_arr as $keyval => $valueval) {
1867 if (!empty($valueval)) {
1868 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$param[
'options'][$valueval].
'</li>';
1872 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1873 } elseif ($type ==
'chkbxlst') {
1874 $value_arr = explode(
',', $value);
1876 $param_list = array_keys($param[
'options']);
1877 $InfoFieldList = explode(
":", $param_list[0]);
1879 $selectkey =
"rowid";
1882 if (count($InfoFieldList) >= 3) {
1883 $selectkey = $InfoFieldList[2];
1884 $keyList = $InfoFieldList[2].
' as rowid';
1887 $fields_label = explode(
'|', $InfoFieldList[1]);
1888 if (is_array($fields_label)) {
1890 $keyList .= implode(
', ', $fields_label);
1893 $filter_categorie =
false;
1894 if (count($InfoFieldList) > 5) {
1895 if ($InfoFieldList[0] ==
'categorie') {
1896 $filter_categorie =
true;
1900 $sql =
"SELECT ".$keyList;
1901 $sql .=
" FROM ".$this->db->prefix().$InfoFieldList[0];
1902 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1908 dol_syslog(get_class($this).
':showOutputField:$type=chkbxlst', LOG_DEBUG);
1909 $resql = $this->db->query($sql);
1911 if ($filter_categorie ===
false) {
1914 while ($obj = $this->db->fetch_object($resql)) {
1916 $fields_label = explode(
'|', $InfoFieldList[1]);
1917 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1918 if (is_array($fields_label) && count($fields_label) > 1) {
1919 $label =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">';
1920 foreach ($fields_label as $field_toshow) {
1922 if (!empty($obj->$field_toshow)) {
1923 $translabel = $outputlangs->trans($obj->$field_toshow);
1925 if ($translabel != $field_toshow) {
1926 $label .=
' '.dol_trunc($translabel, 18);
1928 $label .=
' '.$obj->$field_toshow;
1932 $toprint[] = $label;
1935 if (!empty($obj->{$InfoFieldList[1]})) {
1936 $translabel = $outputlangs->trans($obj->{$InfoFieldList[1]});
1938 if ($translabel != $obj->{$InfoFieldList[1]}) {
1939 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).
'</li>';
1941 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->{$InfoFieldList[1]}.
'</li>';
1947 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1950 while ($obj = $this->db->fetch_object($resql)) {
1951 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1953 $c->fetch($obj->rowid);
1954 $ways = $c->print_all_ways();
1955 foreach ($ways as $way) {
1956 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ?
' style="background: #'.$c->color.
';"' :
' style="background: #bbb"').
'>'.
img_object(
'',
'category').
' '.$way.
'</li>';
1961 if (!empty($toprint)) {
1962 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1965 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
1967 } elseif ($type ==
'link') {
1972 $param_list = array_keys($param[
'options']);
1974 $InfoFieldList = explode(
":", $param_list[0]);
1975 $classname = $InfoFieldList[0];
1976 $classpath = $InfoFieldList[1];
1977 if (!empty($classpath)) {
1979 if ($classname && class_exists($classname)) {
1980 $object =
new $classname($this->db);
1981 $object->fetch($value);
1982 $value = $object->getNomUrl(3);
1985 dol_syslog(
'Error bad setup of extrafield', LOG_WARNING);
1986 return 'Error bad setup of extrafield';
1989 } elseif ($type ==
'text') {
1991 } elseif ($type ==
'html') {
1993 } elseif ($type ==
'password') {
1994 $value =
dol_trunc(preg_replace(
'/./i',
'*', $value), 8,
'right',
'UTF-8', 1);
1996 $showsize = round((
float) $size);
1997 if ($showsize > 48) {
2156 global $conf, $_POST, $langs;
2158 $nofillrequired = 0;
2159 $error_field_required = array();
2161 if (isset($this->attributes[$object->table_element][
'label']) && is_array($this->attributes[$object->table_element][
'label'])) {
2162 $extralabels = $this->attributes[$object->table_element][
'label'];
2165 if (is_array($extralabels)) {
2167 foreach ($extralabels as $key => $value) {
2168 if (!empty($onlykey) && $onlykey !=
'@GETPOSTISSET' && $key != $onlykey) {
2172 if (!empty($onlykey) && $onlykey ==
'@GETPOSTISSET' && !GETPOSTISSET(
'options_'.$key) && (! in_array($this->attributes[$object->table_element][
'type'][$key], array(
'boolean',
'checkbox',
'chkbxlst')))) {
2177 $key_type = $this->attributes[$object->table_element][
'type'][$key];
2178 if ($key_type ==
'separate') {
2183 if (isset($this->attributes[$object->table_element][
'enabled'][$key])) {
2184 $enabled =
dol_eval($this->attributes[$object->table_element][
'enabled'][$key], 1, 1,
'2');
2188 if (isset($this->attributes[$object->table_element][
'list'][$key])) {
2189 $visibility = intval(
dol_eval($this->attributes[$object->table_element][
'list'][$key], 1, 1,
'2'));
2193 if (isset($this->attributes[$object->table_element][
'perms'][$key])) {
2194 $perms =
dol_eval($this->attributes[$object->table_element][
'perms'][$key], 1, 1,
'2');
2198 $onlykey ===
'@GETPOSTISSET'
2199 && in_array($this->attributes[$object->table_element][
'type'][$key], array(
'boolean',
'checkbox',
'chkbxlst'))
2200 && in_array(abs($enabled), array(2, 5))
2201 && ! GETPOSTISSET(
'options_' . $key)
2207 $visibility_abs = abs($visibility);
2209 if (empty($visibility_abs) || $visibility_abs == 2 || $visibility_abs == 5) {
2212 if (empty($perms)) {
2216 if ($this->attributes[$object->table_element][
'required'][$key]) {
2220 $v = $_POST[
"options_".$key] ??
null;
2221 $type = $this->attributes[$object->table_element][
'type'][$key];
2222 if (self::isEmptyValue($v, $type)) {
2228 if (!empty($this->attributes[$object->table_element][
'langfile'][$key])) {
2229 $langs->load($this->attributes[$object->table_element][
'langfile'][$key]);
2231 $error_field_required[$key] = $langs->transnoentitiesnoconv($value);
2235 if (in_array($key_type, array(
'date'))) {
2237 $value_key =
dol_mktime(12, 0, 0,
GETPOST(
"options_".$key.
"month",
'int'),
GETPOST(
"options_".$key.
"day",
'int'),
GETPOST(
"options_".$key.
"year",
'int'));
2238 } elseif (in_array($key_type, array(
'datetime'))) {
2240 $value_key =
dol_mktime(
GETPOST(
"options_".$key.
"hour",
'int'),
GETPOST(
"options_".$key.
"min",
'int'),
GETPOST(
"options_".$key.
"sec",
'int'),
GETPOST(
"options_".$key.
"month",
'int'),
GETPOST(
"options_".$key.
"day",
'int'),
GETPOST(
"options_".$key.
"year",
'int'),
'tzuserrel');
2241 } elseif (in_array($key_type, array(
'datetimegmt'))) {
2243 $value_key =
dol_mktime(
GETPOST(
"options_".$key.
"hour",
'int'),
GETPOST(
"options_".$key.
"min",
'int'),
GETPOST(
"options_".$key.
"sec",
'int'),
GETPOST(
"options_".$key.
"month",
'int'),
GETPOST(
"options_".$key.
"day",
'int'),
GETPOST(
"options_".$key.
"year",
'int'),
'gmt');
2244 } elseif (in_array($key_type, array(
'checkbox',
'chkbxlst'))) {
2245 $value_arr =
GETPOST(
"options_".$key,
'array');
2246 if (!empty($value_arr)) {
2247 $value_key = implode(
',', $value_arr);
2251 } elseif (in_array($key_type, array(
'price',
'double'))) {
2252 $value_arr =
GETPOST(
"options_".$key,
'alpha');
2254 } elseif (in_array($key_type, array(
'pricecy',
'double'))) {
2255 $value_key =
price2num(
GETPOST(
"options_".$key,
'alpha')).
':'.
GETPOST(
"options_".$key.
"currency_id",
'alpha');
2256 } elseif (in_array($key_type, array(
'html'))) {
2257 $value_key =
GETPOST(
"options_".$key,
'restricthtml');
2258 } elseif (in_array($key_type, array(
'text'))) {
2259 $label_security_check =
'alphanohtml';
2262 $label_security_check =
'nohtml';
2264 $label_security_check = !
getDolGlobalString(
'MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML') ?
'alphanohtml' :
'restricthtml';
2266 $value_key =
GETPOST(
"options_".$key, $label_security_check);
2268 $value_key =
GETPOST(
"options_".$key);
2269 if (in_array($key_type, array(
'link')) && $value_key ==
'-1') {
2274 if (!empty($error_field_required[$key]) && $todefaultifmissing) {
2276 if (!empty($this->attributes[$object->table_element][
'default']) && !is_null($this->attributes[$object->table_element][
'default'][$key])) {
2277 $value_key = $this->attributes[$object->table_element][
'default'][$key];
2278 unset($error_field_required[$key]);
2283 $object->array_options[
"options_".$key] = $value_key;
2286 if ($nofillrequired) {
2287 $langs->load(
'errors');
2288 $this->error = $langs->trans(
'ErrorFieldsRequired').
' : '.implode(
', ', $error_field_required);