852 if (empty($elementtype)) {
856 if ($elementtype ==
'thirdparty') {
857 $elementtype =
'societe';
859 if ($elementtype ==
'contact') {
860 $elementtype =
'socpeople';
862 if ($elementtype ==
'order_supplier') {
863 $elementtype =
'commande_fournisseur';
869 $array_name_label = array();
872 $sql =
"SELECT rowid, name, label, type, size, elementtype, fieldunique, fieldrequired, param, pos, alwayseditable, perms, langs, list, printable, totalizable, fielddefault, fieldcomputed, entity, enabled, help,";
873 $sql .=
" css, cssview, csslist";
874 $sql .=
" FROM ".$this->db->prefix().
"extrafields";
876 if ($elementtype && $elementtype !=
'all') {
877 $sql .=
" WHERE elementtype = '".$this->db->escape($elementtype).
"'";
879 $sql .=
" ORDER BY pos";
881 $resql = $this->db->query($sql);
884 if ($this->db->num_rows($resql)) {
885 while ($tab = $this->db->fetch_object($resql)) {
886 if ($tab->entity != 0 && $tab->entity != $conf->entity) {
888 if ($tab->fieldrequired && is_null($tab->fielddefault)) {
889 $this->attributes[$tab->elementtype][
'mandatoryfieldsofotherentities'][$tab->name] = $tab->type;
895 if ($tab->type !=
'separate') {
896 $array_name_label[$tab->name] = $tab->label;
899 $this->attributes[$tab->elementtype][
'type'][$tab->name] = $tab->type;
900 $this->attributes[$tab->elementtype][
'label'][$tab->name] = $tab->label;
901 $this->attributes[$tab->elementtype][
'size'][$tab->name] = $tab->size;
902 $this->attributes[$tab->elementtype][
'elementtype'][$tab->name] = $tab->elementtype;
903 $this->attributes[$tab->elementtype][
'default'][$tab->name] = $tab->fielddefault;
904 $this->attributes[$tab->elementtype][
'computed'][$tab->name] = $tab->fieldcomputed;
905 $this->attributes[$tab->elementtype][
'unique'][$tab->name] = $tab->fieldunique;
906 $this->attributes[$tab->elementtype][
'required'][$tab->name] = $tab->fieldrequired;
907 $this->attributes[$tab->elementtype][
'param'][$tab->name] = ($tab->param ?
jsonOrUnserialize($tab->param) :
'');
908 $this->attributes[$tab->elementtype][
'pos'][$tab->name] = $tab->pos;
909 $this->attributes[$tab->elementtype][
'alwayseditable'][$tab->name] = $tab->alwayseditable;
910 $this->attributes[$tab->elementtype][
'perms'][$tab->name] = ((is_null($tab->perms) || strlen($tab->perms) == 0) ? 1 : $tab->perms);
911 $this->attributes[$tab->elementtype][
'langfile'][$tab->name] = $tab->langs;
912 $this->attributes[$tab->elementtype][
'list'][$tab->name] = $tab->list;
913 $this->attributes[$tab->elementtype][
'printable'][$tab->name] = $tab->printable;
914 $this->attributes[$tab->elementtype][
'totalizable'][$tab->name] = ($tab->totalizable ? 1 : 0);
915 $this->attributes[$tab->elementtype][
'entityid'][$tab->name] = $tab->entity;
916 $this->attributes[$tab->elementtype][
'enabled'][$tab->name] = $tab->enabled;
917 $this->attributes[$tab->elementtype][
'help'][$tab->name] = $tab->help;
918 $this->attributes[$tab->elementtype][
'css'][$tab->name] = $tab->css;
919 $this->attributes[$tab->elementtype][
'cssview'][$tab->name] = $tab->cssview;
920 $this->attributes[$tab->elementtype][
'csslist'][$tab->name] = $tab->csslist;
922 $this->attributes[$tab->elementtype][
'loaded'] = 1;
927 $this->attributes[$elementtype][
'loaded'] = 1;
928 $this->attributes[$elementtype][
'count'] = $count;
931 $this->error = $this->db->lasterror();
932 dol_syslog(get_class($this).
"::fetch_name_optionals_label ".$this->error, LOG_ERR);
935 return $array_name_label;
954 public function showInputField($key, $value, $moreparam =
'', $keysuffix =
'', $keyprefix =
'', $morecss =
'', $objectid = 0, $extrafieldsobjectkey =
'', $mode = 0)
956 global $conf, $langs, $form;
958 if (!is_object($form)) {
959 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
960 $form =
new Form($this->db);
965 if (!preg_match(
'/options_$/', $keyprefix)) {
966 $keyprefix = $keyprefix.
'options_';
969 if (empty($extrafieldsobjectkey)) {
970 dol_syslog(get_class($this).
'::showInputField extrafieldsobjectkey required', LOG_ERR);
971 return 'BadValueForParamExtraFieldsObjectKey';
974 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
975 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
976 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
977 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
978 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
979 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
980 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
981 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
982 $perms =
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
983 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
984 $list =
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
985 $totalizable = $this->attributes[$extrafieldsobjectkey][
'totalizable'][$key];
986 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
987 $hidden = (empty($list) ? 1 : 0);
993 if (!preg_match(
'/^search_/', $keyprefix)) {
994 return '<span class="opacitymedium">'.$langs->trans(
"AutomaticallyCalculated").
'</span>';
1002 if (empty($morecss)) {
1004 if ($type ==
'date') {
1005 $morecss =
'minwidth100imp';
1006 } elseif ($type ==
'datetime' || $type ==
'datetimegmt' || $type ==
'link') {
1007 $morecss =
'minwidth200imp';
1008 } elseif (in_array($type, array(
'int',
'integer',
'double',
'price'))) {
1009 $morecss =
'maxwidth75';
1010 } elseif ($type ==
'password') {
1011 $morecss =
'maxwidth100';
1012 } elseif ($type ==
'url') {
1013 $morecss =
'minwidth400';
1014 } elseif ($type ==
'boolean') {
1016 } elseif ($type ==
'radio') {
1017 $morecss =
'width25';
1019 if (empty($size) || round((
float) $size) < 12) {
1020 $morecss =
'minwidth100';
1021 } elseif (round((
float) $size) <= 48) {
1022 $morecss =
'minwidth200';
1024 $morecss =
'minwidth400';
1028 if (!empty($this->attributes[$extrafieldsobjectkey][
'css'][$key])) {
1029 $morecss = $this->attributes[$extrafieldsobjectkey][
'css'][$key];
1033 if (in_array($type, array(
'date'))) {
1034 $tmp = explode(
',', $size);
1039 if (!$required && $value ==
'') {
1046 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1047 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1049 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1050 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1051 $out .=
'</div><div class="nowrap">';
1052 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1053 $out .=
'</div></div>';
1056 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1);
1058 } elseif (in_array($type, array(
'datetime',
'datetimegmt'))) {
1059 $tmp = explode(
',', $size);
1064 if (!$required && $value ==
'') {
1071 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1072 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1074 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1075 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"),
'tzuserrel');
1076 $out .=
'</div><div class="nowrap">';
1077 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
1078 $out .=
'</div></div>';
1081 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1,
'',
'',
'', 1,
'',
'',
'tzuserrel');
1083 } elseif (in_array($type, array(
'int',
'integer'))) {
1084 $tmp = explode(
',', $size);
1086 $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 :
'').
'>';
1087 } elseif (preg_match(
'/varchar/', $type)) {
1088 $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 :
'').
'>';
1089 } elseif (in_array($type, array(
'mail',
'ip',
'phone',
'url'))) {
1090 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1091 } elseif ($type ==
'icon') {
1097 $out.=
'<input type="text" class="form-control icp icp-auto iconpicker-element iconpicker-input flat '.$morecss.
' maxwidthonsmartphone"';
1098 $out.=
' name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1101 $options=
"{ title: '<b>".$langs->trans(
"IconFieldSelector").
"</b>', placement: 'right', showFooter: false, templates: {";
1102 $options.=
"iconpicker: '<div class=\"iconpicker\"><div style=\"background-color:#EFEFEF;\" class=\"iconpicker-items\"></div></div>',";
1103 $options.=
"iconpickerItem: '<a role=\"button\" href=\"#\" class=\"iconpicker-item\" style=\"background-color:#DDDDDD;\"><i></i></a>',";
1106 $options.=
"footer: '<div class=\"popover-footer\" style=\"background-color:#EFEFEF;\"></div>',";
1107 $options.=
"search: '<input type=\"search\" class\"form-control iconpicker-search\" placeholder=\"".$langs->trans(
"TypeToFilter").
"\" />',";
1108 $options.=
"popover: '<div class=\"iconpicker-popover popover\">";
1109 $options.=
" <div class=\"arrow\" ></div>";
1110 $options.=
" <div class=\"popover-title\" style=\"text-align:center;background-color:#EFEFEF;\"></div>";
1111 $options.=
" <div class=\"popover-content \" ></div>";
1112 $options.=
"</div>'}}";
1113 $out.=
"$('#".$keyprefix.$key.$keysuffix.
"').iconpicker(".$options.
");";
1116 } elseif ($type ==
'text') {
1117 if (!preg_match(
'/search_/', $keyprefix)) {
1118 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1119 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false,
false, ROWS_5,
'90%');
1120 $out = $doleditor->Create(1);
1122 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1124 } elseif ($type ==
'html') {
1125 if (!preg_match(
'/search_/', $keyprefix)) {
1126 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1127 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false, isModEnabled(
'fckeditor') && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5,
'90%');
1128 $out = $doleditor->Create(1);
1130 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1132 } elseif ($type ==
'boolean') {
1135 if (!empty($value)) {
1136 $checked =
' checked value="1" ';
1138 $checked =
' value="1" ';
1141 $out =
'<input type="checkbox" class="flat valignmiddle'.($morecss ?
' '.$morecss :
'').
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.$checked.
' '.($moreparam ? $moreparam :
'').
'>';
1143 $out = $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1,
false, 1);
1145 $out .=
'<input type="hidden" name="'.$keyprefix.$key.$keysuffix.
'_boolean" value="1">';
1146 } elseif ($type ==
'price') {
1147 if (!empty($value)) {
1148 $value =
price($value);
1150 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> '.$langs->getCurrencySymbol($conf->currency);
1151 } elseif ($type ==
'pricecy') {
1152 $currency = $conf->currency;
1153 if (!empty($value)) {
1155 $pricetmp = explode(
':', $value);
1156 $currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
1157 $value =
price($pricetmp[0]);
1159 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1160 $out .= $form->selectCurrency($currency, $keyprefix.$key.$keysuffix.
'currency_id');
1161 } elseif ($type ==
'double') {
1162 if (!empty($value)) {
1163 $value =
price($value);
1165 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1166 } elseif ($type ==
'select') {
1170 foreach ($param[
'options'] as $okey => $val) {
1171 if ((
string) $okey ==
'') {
1175 $valarray = explode(
'|', $val);
1176 $val = $valarray[0];
1178 if ($langfile && $val) {
1179 $options[$okey] = $langs->trans($val);
1181 $options[$okey] = $val;
1184 $selected = array();
1185 if (!is_array($value)) {
1186 $selected = explode(
',', $value);
1189 $out .= $form->multiselectarray($keyprefix.$key.$keysuffix, $options, $selected, 0, 0, $morecss, 0, 0,
'',
'',
'', !empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2'));
1191 if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2')) {
1192 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1193 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1196 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1197 $out .=
'<option value="0"> </option>';
1198 foreach ($param[
'options'] as $key2 => $val2) {
1199 if ((
string) $key2 ==
'') {
1202 $valarray = explode(
'|', $val2);
1203 $val2 = $valarray[0];
1205 if (!empty($valarray[1])) {
1206 $parent = $valarray[1];
1208 $out .=
'<option value="'.$key2.
'"';
1209 $out .= (((string) $value == (
string) $key2) ?
' selected' :
'');
1210 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1212 if ($langfile && $val2) {
1213 $out .= $langs->trans($val2);
1217 $out .=
'</option>';
1219 $out .=
'</select>';
1221 } elseif ($type ==
'sellist') {
1223 if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2')) {
1224 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1225 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1228 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1229 if (is_array($param[
'options'])) {
1230 $param_list = array_keys($param[
'options']);
1231 $InfoFieldList = explode(
":", $param_list[0]);
1242 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1245 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1246 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1247 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1249 $keyList = $InfoFieldList[2].
' as rowid';
1252 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1253 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1254 $keyList .=
', '.$parentField;
1257 $filter_categorie =
false;
1258 if (count($InfoFieldList) > 5) {
1259 if ($InfoFieldList[0] ==
'categorie') {
1260 $filter_categorie =
true;
1264 if ($filter_categorie ===
false) {
1265 $fields_label = explode(
'|', $InfoFieldList[1]);
1266 if (is_array($fields_label)) {
1268 $keyList .= implode(
', ', $fields_label);
1272 $sql =
"SELECT ".$keyList;
1273 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1274 if (!empty($InfoFieldList[4])) {
1276 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1277 $InfoFieldList[4] = str_replace(
'$ENTITY$', $conf->entity, $InfoFieldList[4]);
1280 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1281 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1285 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1286 $InfoFieldList[4] = str_replace(
'$ID$', $objectid, $InfoFieldList[4]);
1288 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1291 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1292 $sql .=
' as main, '.$this->db->prefix().$InfoFieldList[0].
'_extrafields as extra';
1293 $sqlwhere .=
" WHERE extra.fk_object=main.".$InfoFieldList[2].
" AND ".$InfoFieldList[4];
1295 $sqlwhere .=
" WHERE ".$InfoFieldList[4];
1298 $sqlwhere .=
' WHERE 1=1';
1301 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1302 $sqlwhere .=
' AND entity = '.((int) $conf->entity);
1307 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1309 dol_syslog(get_class($this).
'::showInputField type=sellist', LOG_DEBUG);
1310 $resql = $this->db->query($sql);
1312 $out .=
'<option value="0"> </option>';
1313 $num = $this->db->num_rows($resql);
1317 $obj = $this->db->fetch_object($resql);
1321 $fields_label = explode(
'|', $InfoFieldList[1]);
1322 if (is_array($fields_label) && count($fields_label) > 1) {
1324 foreach ($fields_label as $field_toshow) {
1325 $labeltoshow .= $obj->$field_toshow.
' ';
1328 $labeltoshow = $obj->{$InfoFieldList[1]};
1330 $labeltoshow = $labeltoshow;
1332 if ($value == $obj->rowid) {
1334 foreach ($fields_label as $field_toshow) {
1335 $translabel = $langs->trans($obj->$field_toshow);
1336 $labeltoshow = $translabel.
' ';
1339 $out .=
'<option value="'.$obj->rowid.
'" selected>'.$labeltoshow.
'</option>';
1342 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1343 $labeltoshow = $translabel;
1345 if (empty($labeltoshow)) {
1346 $labeltoshow =
'(not defined)';
1349 if (!empty($InfoFieldList[3]) && $parentField) {
1350 $parent = $parentName.
':'.$obj->{$parentField};
1353 $out .=
'<option value="'.$obj->rowid.
'"';
1354 $out .= ($value == $obj->rowid ?
' selected' :
'');
1355 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1356 $out .=
'>'.$labeltoshow.
'</option>';
1361 $this->db->free($resql);
1363 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1366 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1367 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1368 $out .=
'<option value="0"> </option>';
1369 if (is_array($data)) {
1370 foreach ($data as $data_key => $data_value) {
1371 $out .=
'<option value="'.$data_key.
'"';
1372 $out .= ($value == $data_key ?
' selected' :
'');
1373 $out .=
'>'.$data_value.
'</option>';
1378 $out .=
'</select>';
1379 } elseif ($type ==
'checkbox') {
1380 $value_arr = $value;
1381 if (!is_array($value)) {
1382 $value_arr = explode(
',', $value);
1384 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param[
'options']) ?
null : $param[
'options']), $value_arr,
'', 0,
'', 0,
'100%');
1385 } elseif ($type ==
'radio') {
1387 foreach ($param[
'options'] as $keyopt => $val) {
1388 $out .=
'<input class="flat '.$morecss.
'" type="radio" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'');
1389 $out .=
' value="'.$keyopt.
'"';
1390 $out .=
' id="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'"';
1391 $out .= ($value == $keyopt ?
'checked' :
'');
1392 $out .=
'/><label for="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'">'.$langs->trans($val).
'</label><br>';
1394 } elseif ($type ==
'chkbxlst') {
1395 if (is_array($value)) {
1396 $value_arr = $value;
1398 $value_arr = explode(
',', $value);
1401 if (is_array($param[
'options'])) {
1402 $param_list = array_keys($param[
'options']);
1403 $InfoFieldList = explode(
":", $param_list[0]);
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 ===
false) {
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];
1445 if (!empty($InfoFieldList[4])) {
1447 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1448 $InfoFieldList[4] = str_replace(
'$ENTITY$', $conf->entity, $InfoFieldList[4]);
1451 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1452 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1456 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1457 $InfoFieldList[4] = str_replace(
'$ID$', $objectid, $InfoFieldList[4]);
1458 } elseif (preg_match(
"#^.*list.php$#", $_SERVER[
"PHP_SELF"])) {
1460 $word =
'\b[a-zA-Z0-9-\.-_]+\b=\$ID\$';
1463 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1467 while ($nbPreg != 0) {
1469 $nbPregRepl = $nbPregSel = 0;
1471 $InfoFieldList[4] = preg_replace(
'#([^=])(\([^)^(]*('.$word.
')[^)^(]*\))#',
'$1 $3 ', $InfoFieldList[4], -1, $nbPregRepl);
1473 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1475 $InfoFieldList[4] = preg_replace(
'#\b[a-zA-Z0-9-\.-_]+\b=\([^)^(]*('.$word.
')[^)^(]*\)#',
'$1 ', $InfoFieldList[4], -1, $nbPregSel);
1477 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1480 $nbPreg = $nbPregRepl + $nbPregSel;
1484 $matchCondition = array();
1485 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1486 while (!empty($matchCondition[0])) {
1488 if (!empty($matchCondition[1]) && !empty($matchCondition[3]) && $matchCondition[1] != $matchCondition[3]) {
1490 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1492 if (!empty($matchCondition[1])) {
1493 $boolCond = (($matchCondition[1] ==
"AND") ?
' AND TRUE ' :
' OR FALSE ');
1494 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond.$matchCondition[3], $InfoFieldList[4]);
1495 } elseif (!empty($matchCondition[3])) {
1496 $boolCond = (($matchCondition[3] ==
"AND") ?
' TRUE AND ' :
' FALSE OR');
1497 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond, $InfoFieldList[4]);
1499 $InfoFieldList[4] =
" TRUE ";
1504 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1507 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1511 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1512 $sql .=
' as main, '.$this->db->prefix().$InfoFieldList[0].
'_extrafields as extra';
1513 $sqlwhere .=
" WHERE extra.fk_object=main.".$InfoFieldList[2].
" AND ".$InfoFieldList[4];
1515 $sqlwhere .=
" WHERE ".$InfoFieldList[4];
1518 $sqlwhere .=
' WHERE 1=1';
1521 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1522 $sqlwhere .=
" AND entity = ".((int) $conf->entity);
1528 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1530 dol_syslog(get_class($this).
'::showInputField type=chkbxlst', LOG_DEBUG);
1531 $resql = $this->db->query($sql);
1533 $num = $this->db->num_rows($resql);
1540 $obj = $this->db->fetch_object($resql);
1544 $fields_label = explode(
'|', $InfoFieldList[1]);
1545 if (is_array($fields_label)) {
1547 foreach ($fields_label as $field_toshow) {
1548 $labeltoshow .= $obj->$field_toshow.
' ';
1551 $labeltoshow = $obj->{$InfoFieldList[1]};
1553 $labeltoshow =
dol_trunc($labeltoshow, 45);
1555 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1557 foreach ($fields_label as $field_toshow) {
1558 $translabel = $langs->trans($obj->$field_toshow);
1559 if ($translabel != $obj->$field_toshow) {
1560 $labeltoshow .=
' '.dol_trunc($translabel, 18).
' ';
1562 $labeltoshow .=
' '.dol_trunc($obj->$field_toshow, 18).
' ';
1565 $data[$obj->rowid] = $labeltoshow;
1568 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1569 if ($translabel != $obj->{$InfoFieldList[1]}) {
1570 $labeltoshow =
dol_trunc($translabel, 18);
1572 $labeltoshow =
dol_trunc($obj->{$InfoFieldList[1]}, 18);
1575 if (empty($labeltoshow)) {
1576 $labeltoshow =
'(not defined)';
1579 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1580 $data[$obj->rowid] = $labeltoshow;
1583 if (!empty($InfoFieldList[3]) && $parentField) {
1584 $parent = $parentName.
':'.$obj->{$parentField};
1587 $data[$obj->rowid] = $labeltoshow;
1592 $this->db->free($resql);
1594 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr,
'', 0,
'', 0,
'100%');
1596 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1599 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1600 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1601 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr,
'', 0,
'', 0,
'100%');
1604 } elseif ($type ==
'link') {
1605 $param_list = array_keys($param[
'options']);
1612 $showempty = (($required && $default !=
'') ? 0 : 1);
1614 $tmparray = explode(
':', $param_list[0]);
1616 $element = $extrafieldsobjectkey;
1617 if ($element ==
'socpeople') {
1618 $element =
'contact';
1619 } elseif ( $element ==
'projet' ) {
1620 $element =
'project';
1624 $objectdesc = $tmparray[0];
1625 $objectfield = $element.
':options_'.$key;
1627 $out = $form->selectForForms($objectdesc, $keyprefix.$key.$keysuffix, $value, $showempty,
'',
'', $morecss,
'', 0, 0,
'', $objectfield);
1628 } elseif ($type ==
'password') {
1630 $out =
'<input style="display:none" type="text" name="fakeusernameremembered">';
1631 $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 :
'').
'>';
1633 if (!empty($hidden)) {
1634 $out =
'<input type="hidden" value="'.$value.
'" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'"/>';
1657 public function showOutputField($key, $value, $moreparam =
'', $extrafieldsobjectkey =
'', $outputlangs =
null)
1659 global $conf, $langs;
1661 if (is_null($outputlangs) || !is_object($outputlangs)) {
1662 $outputlangs = $langs;
1665 if (empty($extrafieldsobjectkey)) {
1666 dol_syslog(get_class($this).
'::showOutputField extrafieldsobjectkey required', LOG_ERR);
1667 return 'BadValueForParamExtraFieldsObjectKey';
1670 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
1671 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1672 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
1673 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
1674 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
1675 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
1676 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
1677 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
1678 $perms =
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
1679 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
1680 $list =
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
1681 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
1682 $hidden = (empty($list) ? 1 : 0);
1691 if ($type ==
'date') {
1693 if ($value !==
'') {
1696 } elseif ($type ==
'datetime') {
1698 if ($value !==
'') {
1701 } elseif ($type ==
'datetimegmt') {
1703 if ($value !==
'') {
1706 } elseif ($type ==
'int') {
1708 } elseif ($type ==
'double') {
1709 if (!empty($value)) {
1711 $sizeparts = explode(
",", $size);
1712 $number_decimals = array_key_exists(1, $sizeparts) ? $sizeparts[1] : 0;
1713 $value =
price($value, 0, $outputlangs, 0, 0, $number_decimals,
'');
1715 } elseif ($type ==
'boolean') {
1717 if (!empty($value)) {
1718 $checked =
' checked ';
1720 $value =
'<input type="checkbox" '.$checked.
' '.($moreparam ? $moreparam :
'').
' readonly disabled>';
1721 } elseif ($type ==
'mail') {
1723 } elseif ($type ==
'ip') {
1725 } elseif ($type ==
'icon') {
1726 $value =
'<span class="'.$value.
'"></span>';
1727 } elseif ($type ==
'url') {
1729 } elseif ($type ==
'phone') {
1731 } elseif ($type ==
'price') {
1733 if ($value || $value ==
'0') {
1734 $value =
price($value, 0, $outputlangs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1).
' '.$outputlangs->getCurrencySymbol($conf->currency);
1736 } elseif ($type ==
'pricecy') {
1737 $currency = $conf->currency;
1738 if (!empty($value)) {
1740 $pricetmp = explode(
':', $value);
1741 $currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
1742 $value = $pricetmp[0];
1744 if ($value || $value ==
'0') {
1745 $value =
price($value, 0, $outputlangs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1, $currency);
1747 } elseif ($type ==
'select') {
1748 $valstr = (!empty($param[
'options'][$value]) ? $param[
'options'][$value] :
'');
1749 if (($pos = strpos($valstr,
"|")) !==
false) {
1750 $valstr = substr($valstr, 0, $pos);
1752 if ($langfile && $valstr) {
1753 $value = $outputlangs->trans($valstr);
1757 } elseif ($type ==
'sellist') {
1758 $param_list = array_keys($param[
'options']);
1759 $InfoFieldList = explode(
":", $param_list[0]);
1761 $selectkey =
"rowid";
1764 if (count($InfoFieldList) >= 3) {
1765 $selectkey = $InfoFieldList[2];
1766 $keyList = $InfoFieldList[2].
' as rowid';
1769 $fields_label = explode(
'|', $InfoFieldList[1]);
1770 if (is_array($fields_label)) {
1772 $keyList .= implode(
', ', $fields_label);
1775 $filter_categorie =
false;
1776 if (count($InfoFieldList) > 5) {
1777 if ($InfoFieldList[0] ==
'categorie') {
1778 $filter_categorie =
true;
1782 $sql =
"SELECT ".$keyList;
1783 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1784 if (!empty($InfoFieldList[4]) && strpos($InfoFieldList[4],
'extra.') !==
false) {
1787 if ($selectkey ==
'rowid' && empty($value)) {
1788 $sql .=
" WHERE ".$selectkey.
" = 0";
1789 } elseif ($selectkey ==
'rowid') {
1790 $sql .=
" WHERE ".$selectkey.
" = ".((int) $value);
1792 $sql .=
" WHERE ".$selectkey.
" = '".$this->db->escape($value).
"'";
1797 dol_syslog(get_class($this).
':showOutputField:$type=sellist', LOG_DEBUG);
1798 $resql = $this->db->query($sql);
1800 if ($filter_categorie ===
false) {
1803 $obj = $this->db->fetch_object($resql);
1806 $fields_label = explode(
'|', $InfoFieldList[1]);
1808 if (is_array($fields_label) && count($fields_label) > 1) {
1809 foreach ($fields_label as $field_toshow) {
1811 if (!empty($obj->$field_toshow)) {
1812 $translabel = $outputlangs->trans($obj->$field_toshow);
1814 if ($translabel != $obj->$field_toshow) {
1815 $value .=
dol_trunc($translabel, 24) .
' ';
1817 $value .= $obj->$field_toshow .
' ';
1823 $tmppropname = $InfoFieldList[1];
1825 if (!empty(isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
1826 $translabel = $outputlangs->trans($obj->$tmppropname);
1828 if ($translabel != (isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
1831 $value = isset($obj->$tmppropname) ? $obj->$tmppropname :
'';
1836 $obj = $this->db->fetch_object($resql);
1838 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1840 $result = $c->fetch($obj->rowid);
1842 $ways = $c->print_all_ways();
1843 foreach ($ways as $way) {
1844 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ?
' style="background: #' . $c->color .
';"' :
' style="background: #bbb"') .
'>' .
img_object(
'',
'category') .
' ' . $way .
'</li>';
1848 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1851 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
1853 } elseif ($type ==
'radio') {
1854 if (!isset($param[
'options'][$value])) {
1855 $outputlangs->load(
'errors');
1856 $value = $outputlangs->trans(
'ErrorNoValueForRadioType');
1858 $value = $outputlangs->trans($param[
'options'][$value]);
1860 } elseif ($type ==
'checkbox') {
1861 $value_arr = explode(
',', $value);
1864 if (is_array($value_arr)) {
1865 foreach ($value_arr as $keyval => $valueval) {
1866 if (!empty($valueval)) {
1867 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$param[
'options'][$valueval].
'</li>';
1871 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1872 } elseif ($type ==
'chkbxlst') {
1873 $value_arr = explode(
',', $value);
1875 $param_list = array_keys($param[
'options']);
1876 $InfoFieldList = explode(
":", $param_list[0]);
1878 $selectkey =
"rowid";
1881 if (count($InfoFieldList) >= 3) {
1882 $selectkey = $InfoFieldList[2];
1883 $keyList = $InfoFieldList[2].
' as rowid';
1886 $fields_label = explode(
'|', $InfoFieldList[1]);
1887 if (is_array($fields_label)) {
1889 $keyList .= implode(
', ', $fields_label);
1892 $filter_categorie =
false;
1893 if (count($InfoFieldList) > 5) {
1894 if ($InfoFieldList[0] ==
'categorie') {
1895 $filter_categorie =
true;
1899 $sql =
"SELECT ".$keyList;
1900 $sql .=
" FROM ".$this->db->prefix().$InfoFieldList[0];
1901 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1907 dol_syslog(get_class($this).
':showOutputField:$type=chkbxlst', LOG_DEBUG);
1908 $resql = $this->db->query($sql);
1910 if ($filter_categorie ===
false) {
1913 while ($obj = $this->db->fetch_object($resql)) {
1915 $fields_label = explode(
'|', $InfoFieldList[1]);
1916 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1917 if (is_array($fields_label) && count($fields_label) > 1) {
1918 $label =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">';
1919 foreach ($fields_label as $field_toshow) {
1921 if (!empty($obj->$field_toshow)) {
1922 $translabel = $outputlangs->trans($obj->$field_toshow);
1924 if ($translabel != $field_toshow) {
1925 $label .=
' '.dol_trunc($translabel, 18);
1927 $label .=
' '.$obj->$field_toshow;
1931 $toprint[] = $label;
1934 if (!empty($obj->{$InfoFieldList[1]})) {
1935 $translabel = $outputlangs->trans($obj->{$InfoFieldList[1]});
1937 if ($translabel != $obj->{$InfoFieldList[1]}) {
1938 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).
'</li>';
1940 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->{$InfoFieldList[1]}.
'</li>';
1946 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1949 while ($obj = $this->db->fetch_object($resql)) {
1950 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1952 $c->fetch($obj->rowid);
1953 $ways = $c->print_all_ways();
1954 foreach ($ways as $way) {
1955 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ?
' style="background: #'.$c->color.
';"' :
' style="background: #bbb"').
'>'.
img_object(
'',
'category').
' '.$way.
'</li>';
1960 if (!empty($toprint)) {
1961 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1964 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
1966 } elseif ($type ==
'link') {
1971 $param_list = array_keys($param[
'options']);
1973 $InfoFieldList = explode(
":", $param_list[0]);
1974 $classname = $InfoFieldList[0];
1975 $classpath = $InfoFieldList[1];
1976 if (!empty($classpath)) {
1978 if ($classname && class_exists($classname)) {
1979 $object =
new $classname($this->db);
1980 $object->fetch($value);
1981 $value = $object->getNomUrl(3);
1984 dol_syslog(
'Error bad setup of extrafield', LOG_WARNING);
1985 return 'Error bad setup of extrafield';
1988 } elseif ($type ==
'text') {
1990 } elseif ($type ==
'html') {
1992 } elseif ($type ==
'password') {
1993 $value =
dol_trunc(preg_replace(
'/./i',
'*', $value), 8,
'right',
'UTF-8', 1);
1995 $showsize = round((
float) $size);
1996 if ($showsize > 48) {
2155 global $conf, $_POST, $langs;
2157 $nofillrequired = 0;
2158 $error_field_required = array();
2160 if (isset($this->attributes[$object->table_element][
'label']) && is_array($this->attributes[$object->table_element][
'label'])) {
2161 $extralabels = $this->attributes[$object->table_element][
'label'];
2164 if (is_array($extralabels)) {
2166 foreach ($extralabels as $key => $value) {
2167 if (!empty($onlykey) && $onlykey !=
'@GETPOSTISSET' && $key != $onlykey) {
2171 if (!empty($onlykey) && $onlykey ==
'@GETPOSTISSET' && !GETPOSTISSET(
'options_'.$key) && (! in_array($this->attributes[$object->table_element][
'type'][$key], array(
'boolean',
'checkbox',
'chkbxlst')))) {
2176 $key_type = $this->attributes[$object->table_element][
'type'][$key];
2177 if ($key_type ==
'separate') {
2182 if (isset($this->attributes[$object->table_element][
'enabled'][$key])) {
2183 $enabled =
dol_eval($this->attributes[$object->table_element][
'enabled'][$key], 1, 1,
'2');
2187 if (isset($this->attributes[$object->table_element][
'list'][$key])) {
2188 $visibility = intval(
dol_eval($this->attributes[$object->table_element][
'list'][$key], 1, 1,
'2'));
2192 if (isset($this->attributes[$object->table_element][
'perms'][$key])) {
2193 $perms =
dol_eval($this->attributes[$object->table_element][
'perms'][$key], 1, 1,
'2');
2197 $onlykey ===
'@GETPOSTISSET'
2198 && in_array($this->attributes[$object->table_element][
'type'][$key], array(
'boolean',
'checkbox',
'chkbxlst'))
2199 && in_array(abs($enabled), array(2, 5))
2200 && ! GETPOSTISSET(
'options_' . $key)
2206 $visibility_abs = abs($visibility);
2208 if (empty($visibility_abs) || $visibility_abs == 2 || $visibility_abs == 5) {
2211 if (empty($perms)) {
2215 if ($this->attributes[$object->table_element][
'required'][$key]) {
2219 $v = $_POST[
"options_".$key] ??
null;
2220 $type = $this->attributes[$object->table_element][
'type'][$key];
2221 if (self::isEmptyValue($v, $type)) {
2227 if (!empty($this->attributes[$object->table_element][
'langfile'][$key])) {
2228 $langs->load($this->attributes[$object->table_element][
'langfile'][$key]);
2230 $error_field_required[$key] = $langs->transnoentitiesnoconv($value);
2234 if (in_array($key_type, array(
'date'))) {
2236 $value_key =
dol_mktime(12, 0, 0,
GETPOST(
"options_".$key.
"month",
'int'),
GETPOST(
"options_".$key.
"day",
'int'),
GETPOST(
"options_".$key.
"year",
'int'));
2237 } elseif (in_array($key_type, array(
'datetime'))) {
2239 $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');
2240 } elseif (in_array($key_type, array(
'datetimegmt'))) {
2242 $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');
2243 } elseif (in_array($key_type, array(
'checkbox',
'chkbxlst'))) {
2244 $value_arr =
GETPOST(
"options_".$key,
'array');
2245 if (!empty($value_arr)) {
2246 $value_key = implode(
',', $value_arr);
2250 } elseif (in_array($key_type, array(
'price',
'double'))) {
2251 $value_arr =
GETPOST(
"options_".$key,
'alpha');
2253 } elseif (in_array($key_type, array(
'pricecy',
'double'))) {
2254 $value_key =
price2num(
GETPOST(
"options_".$key,
'alpha')).
':'.
GETPOST(
"options_".$key.
"currency_id",
'alpha');
2255 } elseif (in_array($key_type, array(
'html'))) {
2256 $value_key =
GETPOST(
"options_".$key,
'restricthtml');
2257 } elseif (in_array($key_type, array(
'text'))) {
2258 $label_security_check =
'alphanohtml';
2261 $label_security_check =
'nohtml';
2263 $label_security_check = !
getDolGlobalString(
'MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML') ?
'alphanohtml' :
'restricthtml';
2265 $value_key =
GETPOST(
"options_".$key, $label_security_check);
2267 $value_key =
GETPOST(
"options_".$key);
2268 if (in_array($key_type, array(
'link')) && $value_key ==
'-1') {
2273 if (!empty($error_field_required[$key]) && $todefaultifmissing) {
2275 if (!empty($this->attributes[$object->table_element][
'default']) && !is_null($this->attributes[$object->table_element][
'default'][$key])) {
2276 $value_key = $this->attributes[$object->table_element][
'default'][$key];
2277 unset($error_field_required[$key]);
2282 $object->array_options[
"options_".$key] = $value_key;
2285 if ($nofillrequired) {
2286 $langs->load(
'errors');
2287 $this->error = $langs->trans(
'ErrorFieldsRequired').
' : '.implode(
', ', $error_field_required);