839 if (empty($elementtype)) {
843 if ($elementtype ==
'thirdparty') {
844 $elementtype =
'societe';
846 if ($elementtype ==
'contact') {
847 $elementtype =
'socpeople';
849 if ($elementtype ==
'order_supplier') {
850 $elementtype =
'commande_fournisseur';
856 $array_name_label = array();
859 $sql =
"SELECT rowid, name, label, type, size, elementtype, fieldunique, fieldrequired, param, pos, alwayseditable, perms, langs, list, printable, totalizable, fielddefault, fieldcomputed, entity, enabled, help,";
860 $sql .=
" css, cssview, csslist";
861 $sql .=
" FROM ".$this->db->prefix().
"extrafields";
863 if ($elementtype && $elementtype !=
'all') {
864 $sql .=
" WHERE elementtype = '".$this->db->escape($elementtype).
"'";
866 $sql .=
" ORDER BY pos";
868 $resql = $this->db->query($sql);
871 if ($this->db->num_rows($resql)) {
872 while ($tab = $this->db->fetch_object($resql)) {
873 if ($tab->entity != 0 && $tab->entity != $conf->entity) {
875 if ($tab->fieldrequired && is_null($tab->fielddefault)) {
876 $this->attributes[$tab->elementtype][
'mandatoryfieldsofotherentities'][$tab->name] = $tab->type;
882 if ($tab->type !=
'separate') {
883 $array_name_label[$tab->name] = $tab->label;
886 $this->attributes[$tab->elementtype][
'type'][$tab->name] = $tab->type;
887 $this->attributes[$tab->elementtype][
'label'][$tab->name] = $tab->label;
888 $this->attributes[$tab->elementtype][
'size'][$tab->name] = $tab->size;
889 $this->attributes[$tab->elementtype][
'elementtype'][$tab->name] = $tab->elementtype;
890 $this->attributes[$tab->elementtype][
'default'][$tab->name] = $tab->fielddefault;
891 $this->attributes[$tab->elementtype][
'computed'][$tab->name] = $tab->fieldcomputed;
892 $this->attributes[$tab->elementtype][
'unique'][$tab->name] = $tab->fieldunique;
893 $this->attributes[$tab->elementtype][
'required'][$tab->name] = $tab->fieldrequired;
894 $this->attributes[$tab->elementtype][
'param'][$tab->name] = ($tab->param ?
jsonOrUnserialize($tab->param) :
'');
895 $this->attributes[$tab->elementtype][
'pos'][$tab->name] = $tab->pos;
896 $this->attributes[$tab->elementtype][
'alwayseditable'][$tab->name] = $tab->alwayseditable;
897 $this->attributes[$tab->elementtype][
'perms'][$tab->name] = ((is_null($tab->perms) || strlen($tab->perms) == 0) ? 1 : $tab->perms);
898 $this->attributes[$tab->elementtype][
'langfile'][$tab->name] = $tab->langs;
899 $this->attributes[$tab->elementtype][
'list'][$tab->name] = $tab->list;
900 $this->attributes[$tab->elementtype][
'printable'][$tab->name] = $tab->printable;
901 $this->attributes[$tab->elementtype][
'totalizable'][$tab->name] = ($tab->totalizable ? 1 : 0);
902 $this->attributes[$tab->elementtype][
'entityid'][$tab->name] = $tab->entity;
903 $this->attributes[$tab->elementtype][
'enabled'][$tab->name] = $tab->enabled;
904 $this->attributes[$tab->elementtype][
'help'][$tab->name] = $tab->help;
905 $this->attributes[$tab->elementtype][
'css'][$tab->name] = $tab->css;
906 $this->attributes[$tab->elementtype][
'cssview'][$tab->name] = $tab->cssview;
907 $this->attributes[$tab->elementtype][
'csslist'][$tab->name] = $tab->csslist;
909 $this->attributes[$tab->elementtype][
'loaded'] = 1;
914 $this->attributes[$elementtype][
'loaded'] = 1;
915 $this->attributes[$elementtype][
'count'] = $count;
918 $this->error = $this->db->lasterror();
919 dol_syslog(get_class($this).
"::fetch_name_optionals_label ".$this->error, LOG_ERR);
922 return $array_name_label;
941 public function showInputField($key, $value, $moreparam =
'', $keysuffix =
'', $keyprefix =
'', $morecss =
'', $objectid = 0, $extrafieldsobjectkey =
'', $mode = 0)
943 global $conf, $langs, $form;
945 if (!is_object($form)) {
946 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
947 $form =
new Form($this->db);
952 if (!preg_match(
'/options_$/', $keyprefix)) {
953 $keyprefix = $keyprefix.
'options_';
956 if (empty($extrafieldsobjectkey)) {
957 dol_syslog(get_class($this).
'::showInputField extrafieldsobjectkey required', LOG_ERR);
958 return 'BadValueForParamExtraFieldsObjectKey';
961 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
962 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
963 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
964 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
965 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
966 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
967 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
968 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
969 $perms =
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
970 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
971 $list =
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
972 $totalizable = $this->attributes[$extrafieldsobjectkey][
'totalizable'][$key];
973 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
974 $hidden = (empty($list) ? 1 : 0);
980 if (!preg_match(
'/^search_/', $keyprefix)) {
981 return '<span class="opacitymedium">'.$langs->trans(
"AutomaticallyCalculated").
'</span>';
989 if (empty($morecss)) {
991 if ($type ==
'date') {
992 $morecss =
'minwidth100imp';
993 } elseif ($type ==
'datetime' || $type ==
'datetimegmt' || $type ==
'link') {
994 $morecss =
'minwidth200imp';
995 } elseif (in_array($type, array(
'int',
'integer',
'double',
'price'))) {
996 $morecss =
'maxwidth75';
997 } elseif ($type ==
'password') {
998 $morecss =
'maxwidth100';
999 } elseif ($type ==
'url') {
1000 $morecss =
'minwidth400';
1001 } elseif ($type ==
'boolean') {
1003 } elseif ($type ==
'radio') {
1004 $morecss =
'width25';
1006 if (empty($size) || round((
float) $size) < 12) {
1007 $morecss =
'minwidth100';
1008 } elseif (round((
float) $size) <= 48) {
1009 $morecss =
'minwidth200';
1011 $morecss =
'minwidth400';
1015 if (!empty($this->attributes[$extrafieldsobjectkey][
'css'][$key])) {
1016 $morecss = $this->attributes[$extrafieldsobjectkey][
'css'][$key];
1020 if (in_array($type, array(
'date'))) {
1021 $tmp = explode(
',', $size);
1026 if (!$required && $value ==
'') {
1033 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1034 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1036 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1037 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1038 $out .=
'</div><div class="nowrap">';
1039 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1040 $out .=
'</div></div>';
1043 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1);
1045 } elseif (in_array($type, array(
'datetime',
'datetimegmt'))) {
1046 $tmp = explode(
',', $size);
1051 if (!$required && $value ==
'') {
1058 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1059 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1061 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1062 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"),
'tzuserrel');
1063 $out .=
'</div><div class="nowrap">';
1064 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
1065 $out .=
'</div></div>';
1068 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1,
'',
'',
'', 1,
'',
'',
'tzuserrel');
1070 } elseif (in_array($type, array(
'int',
'integer'))) {
1071 $tmp = explode(
',', $size);
1073 $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 :
'').
'>';
1074 } elseif (preg_match(
'/varchar/', $type)) {
1075 $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 :
'').
'>';
1076 } elseif (in_array($type, array(
'mail',
'ip',
'phone',
'url'))) {
1077 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1078 } elseif ($type ==
'icon') {
1084 $out.=
'<input type="text" class="form-control icp icp-auto iconpicker-element iconpicker-input flat '.$morecss.
' maxwidthonsmartphone"';
1085 $out.=
' name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1088 $options=
"{ title: '<b>".$langs->trans(
"IconFieldSelector").
"</b>', placement: 'right', showFooter: false, templates: {";
1089 $options.=
"iconpicker: '<div class=\"iconpicker\"><div style=\"background-color:#EFEFEF;\" class=\"iconpicker-items\"></div></div>',";
1090 $options.=
"iconpickerItem: '<a role=\"button\" href=\"#\" class=\"iconpicker-item\" style=\"background-color:#DDDDDD;\"><i></i></a>',";
1093 $options.=
"footer: '<div class=\"popover-footer\" style=\"background-color:#EFEFEF;\"></div>',";
1094 $options.=
"search: '<input type=\"search\" class\"form-control iconpicker-search\" placeholder=\"".$langs->trans(
"TypeToFilter").
"\" />',";
1095 $options.=
"popover: '<div class=\"iconpicker-popover popover\">";
1096 $options.=
" <div class=\"arrow\" ></div>";
1097 $options.=
" <div class=\"popover-title\" style=\"text-align:center;background-color:#EFEFEF;\"></div>";
1098 $options.=
" <div class=\"popover-content \" ></div>";
1099 $options.=
"</div>'}}";
1100 $out.=
"$('#".$keyprefix.$key.$keysuffix.
"').iconpicker(".$options.
");";
1103 } elseif ($type ==
'text') {
1104 if (!preg_match(
'/search_/', $keyprefix)) {
1105 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1106 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false,
false, ROWS_5,
'90%');
1107 $out = $doleditor->Create(1);
1109 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1111 } elseif ($type ==
'html') {
1112 if (!preg_match(
'/search_/', $keyprefix)) {
1113 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1114 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false, isModEnabled(
'fckeditor') && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5,
'90%');
1115 $out = $doleditor->Create(1);
1117 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1119 } elseif ($type ==
'boolean') {
1122 if (!empty($value)) {
1123 $checked =
' checked value="1" ';
1125 $checked =
' value="1" ';
1128 $out =
'<input type="checkbox" class="flat valignmiddle'.($morecss ?
' '.$morecss :
'').
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.$checked.
' '.($moreparam ? $moreparam :
'').
'>';
1130 $out = $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1,
false, 1);
1132 $out .=
'<input type="hidden" name="'.$keyprefix.$key.$keysuffix.
'_boolean" value="1">';
1133 } elseif ($type ==
'price') {
1134 if (!empty($value)) {
1135 $value =
price($value);
1137 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> '.$langs->getCurrencySymbol($conf->currency);
1138 } elseif ($type ==
'pricecy') {
1139 $currency = $conf->currency;
1140 if (!empty($value)) {
1142 $pricetmp = explode(
':', $value);
1143 $currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
1144 $value =
price($pricetmp[0]);
1146 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1147 $out .= $form->selectCurrency($currency, $keyprefix.$key.$keysuffix.
'currency_id');
1148 } elseif ($type ==
'double') {
1149 if (!empty($value)) {
1150 $value =
price($value);
1152 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1153 } elseif ($type ==
'select') {
1157 foreach ($param[
'options'] as $okey => $val) {
1158 if ((
string) $okey ==
'') {
1162 $valarray = explode(
'|', $val);
1163 $val = $valarray[0];
1165 if ($langfile && $val) {
1166 $options[$okey] = $langs->trans($val);
1168 $options[$okey] = $val;
1171 $selected = array();
1172 if (!is_array($value)) {
1173 $selected = explode(
',', $value);
1176 $out .= $form->multiselectarray($keyprefix.$key.$keysuffix, $options, $selected, 0, 0, $morecss, 0, 0,
'',
'',
'', !empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2'));
1178 if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2')) {
1179 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1180 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1183 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1184 $out .=
'<option value="0"> </option>';
1185 foreach ($param[
'options'] as $key2 => $val2) {
1186 if ((
string) $key2 ==
'') {
1189 $valarray = explode(
'|', $val2);
1190 $val2 = $valarray[0];
1192 if (!empty($valarray[1])) {
1193 $parent = $valarray[1];
1195 $out .=
'<option value="'.$key2.
'"';
1196 $out .= (((string) $value == (
string) $key2) ?
' selected' :
'');
1197 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1199 if ($langfile && $val2) {
1200 $out .= $langs->trans($val2);
1204 $out .=
'</option>';
1206 $out .=
'</select>';
1208 } elseif ($type ==
'sellist') {
1210 if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2')) {
1211 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1212 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1215 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1216 if (is_array($param[
'options'])) {
1217 $param_list = array_keys($param[
'options']);
1218 $InfoFieldList = explode(
":", $param_list[0]);
1229 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1232 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1233 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1234 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1236 $keyList = $InfoFieldList[2].
' as rowid';
1239 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1240 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1241 $keyList .=
', '.$parentField;
1244 $filter_categorie =
false;
1245 if (count($InfoFieldList) > 5) {
1246 if ($InfoFieldList[0] ==
'categorie') {
1247 $filter_categorie =
true;
1251 if ($filter_categorie ===
false) {
1252 $fields_label = explode(
'|', $InfoFieldList[1]);
1253 if (is_array($fields_label)) {
1255 $keyList .= implode(
', ', $fields_label);
1259 $sql =
"SELECT ".$keyList;
1260 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1261 if (!empty($InfoFieldList[4])) {
1263 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1264 $InfoFieldList[4] = str_replace(
'$ENTITY$', $conf->entity, $InfoFieldList[4]);
1267 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1268 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1272 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1273 $InfoFieldList[4] = str_replace(
'$ID$', $objectid, $InfoFieldList[4]);
1275 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1278 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1279 $sql .=
' as main, '.$this->db->prefix().$InfoFieldList[0].
'_extrafields as extra';
1280 $sqlwhere .=
" WHERE extra.fk_object=main.".$InfoFieldList[2].
" AND ".$InfoFieldList[4];
1282 $sqlwhere .=
" WHERE ".$InfoFieldList[4];
1285 $sqlwhere .=
' WHERE 1=1';
1288 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1289 $sqlwhere .=
' AND entity = '.((int) $conf->entity);
1294 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1296 dol_syslog(get_class($this).
'::showInputField type=sellist', LOG_DEBUG);
1297 $resql = $this->db->query($sql);
1299 $out .=
'<option value="0"> </option>';
1300 $num = $this->db->num_rows($resql);
1304 $obj = $this->db->fetch_object($resql);
1308 $fields_label = explode(
'|', $InfoFieldList[1]);
1309 if (is_array($fields_label) && count($fields_label) > 1) {
1311 foreach ($fields_label as $field_toshow) {
1312 $labeltoshow .= $obj->$field_toshow.
' ';
1315 $labeltoshow = $obj->{$InfoFieldList[1]};
1317 $labeltoshow = $labeltoshow;
1319 if ($value == $obj->rowid) {
1321 foreach ($fields_label as $field_toshow) {
1322 $translabel = $langs->trans($obj->$field_toshow);
1323 $labeltoshow = $translabel.
' ';
1326 $out .=
'<option value="'.$obj->rowid.
'" selected>'.$labeltoshow.
'</option>';
1329 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1330 $labeltoshow = $translabel;
1332 if (empty($labeltoshow)) {
1333 $labeltoshow =
'(not defined)';
1336 if (!empty($InfoFieldList[3]) && $parentField) {
1337 $parent = $parentName.
':'.$obj->{$parentField};
1340 $out .=
'<option value="'.$obj->rowid.
'"';
1341 $out .= ($value == $obj->rowid ?
' selected' :
'');
1342 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1343 $out .=
'>'.$labeltoshow.
'</option>';
1348 $this->db->free($resql);
1350 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1353 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1354 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1355 $out .=
'<option value="0"> </option>';
1356 if (is_array($data)) {
1357 foreach ($data as $data_key => $data_value) {
1358 $out .=
'<option value="'.$data_key.
'"';
1359 $out .= ($value == $data_key ?
' selected' :
'');
1360 $out .=
'>'.$data_value.
'</option>';
1365 $out .=
'</select>';
1366 } elseif ($type ==
'checkbox') {
1367 $value_arr = $value;
1368 if (!is_array($value)) {
1369 $value_arr = explode(
',', $value);
1371 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param[
'options']) ?
null : $param[
'options']), $value_arr,
'', 0,
'', 0,
'100%');
1372 } elseif ($type ==
'radio') {
1374 foreach ($param[
'options'] as $keyopt => $val) {
1375 $out .=
'<input class="flat '.$morecss.
'" type="radio" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'');
1376 $out .=
' value="'.$keyopt.
'"';
1377 $out .=
' id="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'"';
1378 $out .= ($value == $keyopt ?
'checked' :
'');
1379 $out .=
'/><label for="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'">'.$langs->trans($val).
'</label><br>';
1381 } elseif ($type ==
'chkbxlst') {
1382 if (is_array($value)) {
1383 $value_arr = $value;
1385 $value_arr = explode(
',', $value);
1388 if (is_array($param[
'options'])) {
1389 $param_list = array_keys($param[
'options']);
1390 $InfoFieldList = explode(
":", $param_list[0]);
1401 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1403 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1404 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1405 $keyList .=
', '.$parentField;
1407 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1408 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1409 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1411 $keyList = $InfoFieldList[2].
' as rowid';
1415 $filter_categorie =
false;
1416 if (count($InfoFieldList) > 5) {
1417 if ($InfoFieldList[0] ==
'categorie') {
1418 $filter_categorie =
true;
1422 if ($filter_categorie ===
false) {
1423 $fields_label = explode(
'|', $InfoFieldList[1]);
1424 if (is_array($fields_label)) {
1426 $keyList .= implode(
', ', $fields_label);
1430 $sql =
"SELECT ".$keyList;
1431 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1432 if (!empty($InfoFieldList[4])) {
1434 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1435 $InfoFieldList[4] = str_replace(
'$ENTITY$', $conf->entity, $InfoFieldList[4]);
1438 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1439 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1443 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1444 $InfoFieldList[4] = str_replace(
'$ID$', $objectid, $InfoFieldList[4]);
1445 } elseif (preg_match(
"#^.*list.php$#", $_SERVER[
"PHP_SELF"])) {
1447 $word =
'\b[a-zA-Z0-9-\.-_]+\b=\$ID\$';
1450 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1454 while ($nbPreg != 0) {
1456 $nbPregRepl = $nbPregSel = 0;
1458 $InfoFieldList[4] = preg_replace(
'#([^=])(\([^)^(]*('.$word.
')[^)^(]*\))#',
'$1 $3 ', $InfoFieldList[4], -1, $nbPregRepl);
1460 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1462 $InfoFieldList[4] = preg_replace(
'#\b[a-zA-Z0-9-\.-_]+\b=\([^)^(]*('.$word.
')[^)^(]*\)#',
'$1 ', $InfoFieldList[4], -1, $nbPregSel);
1464 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1467 $nbPreg = $nbPregRepl + $nbPregSel;
1471 $matchCondition = array();
1472 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1473 while (!empty($matchCondition[0])) {
1475 if (!empty($matchCondition[1]) && !empty($matchCondition[3]) && $matchCondition[1] != $matchCondition[3]) {
1477 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1479 if (!empty($matchCondition[1])) {
1480 $boolCond = (($matchCondition[1] ==
"AND") ?
' AND TRUE ' :
' OR FALSE ');
1481 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond.$matchCondition[3], $InfoFieldList[4]);
1482 } elseif (!empty($matchCondition[3])) {
1483 $boolCond = (($matchCondition[3] ==
"AND") ?
' TRUE AND ' :
' FALSE OR');
1484 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond, $InfoFieldList[4]);
1486 $InfoFieldList[4] =
" TRUE ";
1491 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1494 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1498 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1499 $sql .=
' as main, '.$this->db->prefix().$InfoFieldList[0].
'_extrafields as extra';
1500 $sqlwhere .=
" WHERE extra.fk_object=main.".$InfoFieldList[2].
" AND ".$InfoFieldList[4];
1502 $sqlwhere .=
" WHERE ".$InfoFieldList[4];
1505 $sqlwhere .=
' WHERE 1=1';
1508 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1509 $sqlwhere .=
" AND entity = ".((int) $conf->entity);
1515 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1517 dol_syslog(get_class($this).
'::showInputField type=chkbxlst', LOG_DEBUG);
1518 $resql = $this->db->query($sql);
1520 $num = $this->db->num_rows($resql);
1527 $obj = $this->db->fetch_object($resql);
1531 $fields_label = explode(
'|', $InfoFieldList[1]);
1532 if (is_array($fields_label)) {
1534 foreach ($fields_label as $field_toshow) {
1535 $labeltoshow .= $obj->$field_toshow.
' ';
1538 $labeltoshow = $obj->{$InfoFieldList[1]};
1540 $labeltoshow =
dol_trunc($labeltoshow, 45);
1542 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1544 foreach ($fields_label as $field_toshow) {
1545 $translabel = $langs->trans($obj->$field_toshow);
1546 if ($translabel != $obj->$field_toshow) {
1547 $labeltoshow .=
' '.dol_trunc($translabel, 18).
' ';
1549 $labeltoshow .=
' '.dol_trunc($obj->$field_toshow, 18).
' ';
1552 $data[$obj->rowid] = $labeltoshow;
1555 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1556 if ($translabel != $obj->{$InfoFieldList[1]}) {
1557 $labeltoshow =
dol_trunc($translabel, 18);
1559 $labeltoshow =
dol_trunc($obj->{$InfoFieldList[1]}, 18);
1562 if (empty($labeltoshow)) {
1563 $labeltoshow =
'(not defined)';
1566 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1567 $data[$obj->rowid] = $labeltoshow;
1570 if (!empty($InfoFieldList[3]) && $parentField) {
1571 $parent = $parentName.
':'.$obj->{$parentField};
1574 $data[$obj->rowid] = $labeltoshow;
1579 $this->db->free($resql);
1581 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr,
'', 0,
'', 0,
'100%');
1583 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1586 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1587 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1588 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr,
'', 0,
'', 0,
'100%');
1591 } elseif ($type ==
'link') {
1592 $param_list = array_keys($param[
'options']);
1599 $showempty = (($required && $default !=
'') ? 0 : 1);
1601 $tmparray = explode(
':', $param_list[0]);
1603 $element = $extrafieldsobjectkey;
1604 if ($element ==
'socpeople') {
1605 $element =
'contact';
1606 } elseif ( $element ==
'projet' ) {
1607 $element =
'project';
1611 $objectdesc = $tmparray[0];
1612 $objectfield = $element.
':options_'.$key;
1614 $out = $form->selectForForms($objectdesc, $keyprefix.$key.$keysuffix, $value, $showempty,
'',
'', $morecss,
'', 0, 0,
'', $objectfield);
1615 } elseif ($type ==
'password') {
1617 $out =
'<input style="display:none" type="text" name="fakeusernameremembered">';
1618 $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 :
'').
'>';
1620 if (!empty($hidden)) {
1621 $out =
'<input type="hidden" value="'.$value.
'" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'"/>';
1644 public function showOutputField($key, $value, $moreparam =
'', $extrafieldsobjectkey =
'', $outputlangs =
null)
1646 global $conf, $langs;
1648 if (is_null($outputlangs) || !is_object($outputlangs)) {
1649 $outputlangs = $langs;
1652 if (empty($extrafieldsobjectkey)) {
1653 dol_syslog(get_class($this).
'::showOutputField extrafieldsobjectkey required', LOG_ERR);
1654 return 'BadValueForParamExtraFieldsObjectKey';
1657 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
1658 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1659 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
1660 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
1661 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
1662 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
1663 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
1664 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
1665 $perms =
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
1666 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
1667 $list =
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
1668 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
1669 $hidden = (empty($list) ? 1 : 0);
1678 if ($type ==
'date') {
1680 if ($value !==
'') {
1683 } elseif ($type ==
'datetime') {
1685 if ($value !==
'') {
1688 } elseif ($type ==
'datetimegmt') {
1690 if ($value !==
'') {
1693 } elseif ($type ==
'int') {
1695 } elseif ($type ==
'double') {
1696 if (!empty($value)) {
1698 $sizeparts = explode(
",", $size);
1699 $number_decimals = array_key_exists(1, $sizeparts) ? $sizeparts[1] : 0;
1700 $value =
price($value, 0, $outputlangs, 0, 0, $number_decimals,
'');
1702 } elseif ($type ==
'boolean') {
1704 if (!empty($value)) {
1705 $checked =
' checked ';
1707 $value =
'<input type="checkbox" '.$checked.
' '.($moreparam ? $moreparam :
'').
' readonly disabled>';
1708 } elseif ($type ==
'mail') {
1710 } elseif ($type ==
'ip') {
1712 } elseif ($type ==
'icon') {
1713 $value =
'<span class="'.$value.
'"></span>';
1714 } elseif ($type ==
'url') {
1716 } elseif ($type ==
'phone') {
1718 } elseif ($type ==
'price') {
1720 if ($value || $value ==
'0') {
1721 $value =
price($value, 0, $outputlangs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1).
' '.$outputlangs->getCurrencySymbol($conf->currency);
1723 } elseif ($type ==
'pricecy') {
1724 $currency = $conf->currency;
1725 if (!empty($value)) {
1727 $pricetmp = explode(
':', $value);
1728 $currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
1729 $value = $pricetmp[0];
1731 if ($value || $value ==
'0') {
1732 $value =
price($value, 0, $outputlangs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1, $currency);
1734 } elseif ($type ==
'select') {
1735 $valstr = (!empty($param[
'options'][$value]) ? $param[
'options'][$value] :
'');
1736 if (($pos = strpos($valstr,
"|")) !==
false) {
1737 $valstr = substr($valstr, 0, $pos);
1739 if ($langfile && $valstr) {
1740 $value = $outputlangs->trans($valstr);
1744 } elseif ($type ==
'sellist') {
1745 $param_list = array_keys($param[
'options']);
1746 $InfoFieldList = explode(
":", $param_list[0]);
1748 $selectkey =
"rowid";
1751 if (count($InfoFieldList) >= 3) {
1752 $selectkey = $InfoFieldList[2];
1753 $keyList = $InfoFieldList[2].
' as rowid';
1756 $fields_label = explode(
'|', $InfoFieldList[1]);
1757 if (is_array($fields_label)) {
1759 $keyList .= implode(
', ', $fields_label);
1762 $filter_categorie =
false;
1763 if (count($InfoFieldList) > 5) {
1764 if ($InfoFieldList[0] ==
'categorie') {
1765 $filter_categorie =
true;
1769 $sql =
"SELECT ".$keyList;
1770 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1771 if (!empty($InfoFieldList[4]) && strpos($InfoFieldList[4],
'extra.') !==
false) {
1774 if ($selectkey ==
'rowid' && empty($value)) {
1775 $sql .=
" WHERE ".$selectkey.
" = 0";
1776 } elseif ($selectkey ==
'rowid') {
1777 $sql .=
" WHERE ".$selectkey.
" = ".((int) $value);
1779 $sql .=
" WHERE ".$selectkey.
" = '".$this->db->escape($value).
"'";
1784 dol_syslog(get_class($this).
':showOutputField:$type=sellist', LOG_DEBUG);
1785 $resql = $this->db->query($sql);
1787 if ($filter_categorie ===
false) {
1790 $obj = $this->db->fetch_object($resql);
1793 $fields_label = explode(
'|', $InfoFieldList[1]);
1795 if (is_array($fields_label) && count($fields_label) > 1) {
1796 foreach ($fields_label as $field_toshow) {
1798 if (!empty($obj->$field_toshow)) {
1799 $translabel = $outputlangs->trans($obj->$field_toshow);
1801 if ($translabel != $obj->$field_toshow) {
1802 $value .=
dol_trunc($translabel, 24) .
' ';
1804 $value .= $obj->$field_toshow .
' ';
1810 $tmppropname = $InfoFieldList[1];
1812 if (!empty(isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
1813 $translabel = $outputlangs->trans($obj->$tmppropname);
1815 if ($translabel != (isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
1818 $value = isset($obj->$tmppropname) ? $obj->$tmppropname :
'';
1823 $obj = $this->db->fetch_object($resql);
1825 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1827 $result = $c->fetch($obj->rowid);
1829 $ways = $c->print_all_ways();
1830 foreach ($ways as $way) {
1831 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ?
' style="background: #' . $c->color .
';"' :
' style="background: #bbb"') .
'>' .
img_object(
'',
'category') .
' ' . $way .
'</li>';
1835 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1838 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
1840 } elseif ($type ==
'radio') {
1841 if (!isset($param[
'options'][$value])) {
1842 $outputlangs->load(
'errors');
1843 $value = $outputlangs->trans(
'ErrorNoValueForRadioType');
1845 $value = $outputlangs->trans($param[
'options'][$value]);
1847 } elseif ($type ==
'checkbox') {
1848 $value_arr = explode(
',', $value);
1851 if (is_array($value_arr)) {
1852 foreach ($value_arr as $keyval => $valueval) {
1853 if (!empty($valueval)) {
1854 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$param[
'options'][$valueval].
'</li>';
1858 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1859 } elseif ($type ==
'chkbxlst') {
1860 $value_arr = explode(
',', $value);
1862 $param_list = array_keys($param[
'options']);
1863 $InfoFieldList = explode(
":", $param_list[0]);
1865 $selectkey =
"rowid";
1868 if (count($InfoFieldList) >= 3) {
1869 $selectkey = $InfoFieldList[2];
1870 $keyList = $InfoFieldList[2].
' as rowid';
1873 $fields_label = explode(
'|', $InfoFieldList[1]);
1874 if (is_array($fields_label)) {
1876 $keyList .= implode(
', ', $fields_label);
1879 $filter_categorie =
false;
1880 if (count($InfoFieldList) > 5) {
1881 if ($InfoFieldList[0] ==
'categorie') {
1882 $filter_categorie =
true;
1886 $sql =
"SELECT ".$keyList;
1887 $sql .=
" FROM ".$this->db->prefix().$InfoFieldList[0];
1888 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1894 dol_syslog(get_class($this).
':showOutputField:$type=chkbxlst', LOG_DEBUG);
1895 $resql = $this->db->query($sql);
1897 if ($filter_categorie ===
false) {
1900 while ($obj = $this->db->fetch_object($resql)) {
1902 $fields_label = explode(
'|', $InfoFieldList[1]);
1903 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1904 if (is_array($fields_label) && count($fields_label) > 1) {
1905 $label =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">';
1906 foreach ($fields_label as $field_toshow) {
1908 if (!empty($obj->$field_toshow)) {
1909 $translabel = $outputlangs->trans($obj->$field_toshow);
1911 if ($translabel != $field_toshow) {
1912 $label .=
' '.dol_trunc($translabel, 18);
1914 $label .=
' '.$obj->$field_toshow;
1918 $toprint[] = $label;
1921 if (!empty($obj->{$InfoFieldList[1]})) {
1922 $translabel = $outputlangs->trans($obj->{$InfoFieldList[1]});
1924 if ($translabel != $obj->{$InfoFieldList[1]}) {
1925 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).
'</li>';
1927 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->{$InfoFieldList[1]}.
'</li>';
1933 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1936 while ($obj = $this->db->fetch_object($resql)) {
1937 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1939 $c->fetch($obj->rowid);
1940 $ways = $c->print_all_ways();
1941 foreach ($ways as $way) {
1942 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ?
' style="background: #'.$c->color.
';"' :
' style="background: #bbb"').
'>'.
img_object(
'',
'category').
' '.$way.
'</li>';
1947 if (!empty($toprint)) {
1948 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1951 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
1953 } elseif ($type ==
'link') {
1958 $param_list = array_keys($param[
'options']);
1960 $InfoFieldList = explode(
":", $param_list[0]);
1961 $classname = $InfoFieldList[0];
1962 $classpath = $InfoFieldList[1];
1963 if (!empty($classpath)) {
1965 if ($classname && class_exists($classname)) {
1966 $object =
new $classname($this->db);
1967 $object->fetch($value);
1968 $value = $object->getNomUrl(3);
1971 dol_syslog(
'Error bad setup of extrafield', LOG_WARNING);
1972 return 'Error bad setup of extrafield';
1975 } elseif ($type ==
'text') {
1977 } elseif ($type ==
'html') {
1979 } elseif ($type ==
'password') {
1980 $value =
dol_trunc(preg_replace(
'/./i',
'*', $value), 8,
'right',
'UTF-8', 1);
1982 $showsize = round((
float) $size);
1983 if ($showsize > 48) {
2142 global $conf, $_POST, $langs;
2144 $nofillrequired = 0;
2145 $error_field_required = array();
2147 if (isset($this->attributes[$object->table_element][
'label']) && is_array($this->attributes[$object->table_element][
'label'])) {
2148 $extralabels = $this->attributes[$object->table_element][
'label'];
2151 if (is_array($extralabels)) {
2153 foreach ($extralabels as $key => $value) {
2154 if (!empty($onlykey) && $onlykey !=
'@GETPOSTISSET' && $key != $onlykey) {
2158 if (!empty($onlykey) && $onlykey ==
'@GETPOSTISSET' && !GETPOSTISSET(
'options_'.$key) && (! in_array($this->attributes[$object->table_element][
'type'][$key], array(
'boolean',
'checkbox',
'chkbxlst')))) {
2163 $key_type = $this->attributes[$object->table_element][
'type'][$key];
2164 if ($key_type ==
'separate') {
2169 if (isset($this->attributes[$object->table_element][
'enabled'][$key])) {
2170 $enabled =
dol_eval($this->attributes[$object->table_element][
'enabled'][$key], 1, 1,
'2');
2174 if (isset($this->attributes[$object->table_element][
'list'][$key])) {
2175 $visibility = intval(
dol_eval($this->attributes[$object->table_element][
'list'][$key], 1, 1,
'2'));
2179 if (isset($this->attributes[$object->table_element][
'perms'][$key])) {
2180 $perms =
dol_eval($this->attributes[$object->table_element][
'perms'][$key], 1, 1,
'2');
2184 $onlykey ===
'@GETPOSTISSET'
2185 && in_array($this->attributes[$object->table_element][
'type'][$key], array(
'boolean',
'checkbox',
'chkbxlst'))
2186 && in_array(abs($enabled), array(2, 5))
2187 && ! GETPOSTISSET(
'options_' . $key)
2193 $visibility_abs = abs($visibility);
2195 if (empty($visibility_abs) || $visibility_abs == 2 || $visibility_abs == 5) {
2198 if (empty($perms)) {
2202 if ($this->attributes[$object->table_element][
'required'][$key]) {
2206 $v = $_POST[
"options_".$key] ??
null;
2207 $type = $this->attributes[$object->table_element][
'type'][$key];
2208 if (self::isEmptyValue($v, $type)) {
2214 if (!empty($this->attributes[$object->table_element][
'langfile'][$key])) {
2215 $langs->load($this->attributes[$object->table_element][
'langfile'][$key]);
2217 $error_field_required[$key] = $langs->transnoentitiesnoconv($value);
2221 if (in_array($key_type, array(
'date'))) {
2223 $value_key =
dol_mktime(12, 0, 0,
GETPOST(
"options_".$key.
"month",
'int'),
GETPOST(
"options_".$key.
"day",
'int'),
GETPOST(
"options_".$key.
"year",
'int'));
2224 } elseif (in_array($key_type, array(
'datetime'))) {
2226 $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');
2227 } elseif (in_array($key_type, array(
'datetimegmt'))) {
2229 $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');
2230 } elseif (in_array($key_type, array(
'checkbox',
'chkbxlst'))) {
2231 $value_arr =
GETPOST(
"options_".$key,
'array');
2232 if (!empty($value_arr)) {
2233 $value_key = implode(
',', $value_arr);
2237 } elseif (in_array($key_type, array(
'price',
'double'))) {
2238 $value_arr =
GETPOST(
"options_".$key,
'alpha');
2240 } elseif (in_array($key_type, array(
'pricecy',
'double'))) {
2241 $value_key =
price2num(
GETPOST(
"options_".$key,
'alpha')).
':'.
GETPOST(
"options_".$key.
"currency_id",
'alpha');
2242 } elseif (in_array($key_type, array(
'html'))) {
2243 $value_key =
GETPOST(
"options_".$key,
'restricthtml');
2244 } elseif (in_array($key_type, array(
'text'))) {
2245 $label_security_check =
'alphanohtml';
2248 $label_security_check =
'nohtml';
2250 $label_security_check = !
getDolGlobalString(
'MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML') ?
'alphanohtml' :
'restricthtml';
2252 $value_key =
GETPOST(
"options_".$key, $label_security_check);
2254 $value_key =
GETPOST(
"options_".$key);
2255 if (in_array($key_type, array(
'link')) && $value_key ==
'-1') {
2260 if (!empty($error_field_required[$key]) && $todefaultifmissing) {
2262 if (!empty($this->attributes[$object->table_element][
'default']) && !is_null($this->attributes[$object->table_element][
'default'][$key])) {
2263 $value_key = $this->attributes[$object->table_element][
'default'][$key];
2264 unset($error_field_required[$key]);
2269 $object->array_options[
"options_".$key] = $value_key;
2272 if ($nofillrequired) {
2273 $langs->load(
'errors');
2274 $this->error = $langs->trans(
'ErrorFieldsRequired').
' : '.implode(
', ', $error_field_required);