838 if (empty($elementtype)) {
842 if ($elementtype ==
'thirdparty') {
843 $elementtype =
'societe';
845 if ($elementtype ==
'contact') {
846 $elementtype =
'socpeople';
848 if ($elementtype ==
'order_supplier') {
849 $elementtype =
'commande_fournisseur';
855 $array_name_label = array();
858 $sql =
"SELECT rowid, name, label, type, size, elementtype, fieldunique, fieldrequired, param, pos, alwayseditable, perms, langs, list, printable, totalizable, fielddefault, fieldcomputed, entity, enabled, help,";
859 $sql .=
" css, cssview, csslist";
860 $sql .=
" FROM ".$this->db->prefix().
"extrafields";
862 if ($elementtype && $elementtype !=
'all') {
863 $sql .=
" WHERE elementtype = '".$this->db->escape($elementtype).
"'";
865 $sql .=
" ORDER BY pos";
867 $resql = $this->db->query($sql);
870 if ($this->db->num_rows($resql)) {
871 while ($tab = $this->db->fetch_object($resql)) {
872 if ($tab->entity != 0 && $tab->entity != $conf->entity) {
874 if ($tab->fieldrequired && is_null($tab->fielddefault)) {
875 $this->attributes[$tab->elementtype][
'mandatoryfieldsofotherentities'][$tab->name] = $tab->type;
881 if ($tab->type !=
'separate') {
882 $array_name_label[$tab->name] = $tab->label;
885 $this->attributes[$tab->elementtype][
'type'][$tab->name] = $tab->type;
886 $this->attributes[$tab->elementtype][
'label'][$tab->name] = $tab->label;
887 $this->attributes[$tab->elementtype][
'size'][$tab->name] = $tab->size;
888 $this->attributes[$tab->elementtype][
'elementtype'][$tab->name] = $tab->elementtype;
889 $this->attributes[$tab->elementtype][
'default'][$tab->name] = $tab->fielddefault;
890 $this->attributes[$tab->elementtype][
'computed'][$tab->name] = $tab->fieldcomputed;
891 $this->attributes[$tab->elementtype][
'unique'][$tab->name] = $tab->fieldunique;
892 $this->attributes[$tab->elementtype][
'required'][$tab->name] = $tab->fieldrequired;
893 $this->attributes[$tab->elementtype][
'param'][$tab->name] = ($tab->param ?
jsonOrUnserialize($tab->param) :
'');
894 $this->attributes[$tab->elementtype][
'pos'][$tab->name] = $tab->pos;
895 $this->attributes[$tab->elementtype][
'alwayseditable'][$tab->name] = $tab->alwayseditable;
896 $this->attributes[$tab->elementtype][
'perms'][$tab->name] = ((is_null($tab->perms) || strlen($tab->perms) == 0) ? 1 : $tab->perms);
897 $this->attributes[$tab->elementtype][
'langfile'][$tab->name] = $tab->langs;
898 $this->attributes[$tab->elementtype][
'list'][$tab->name] = $tab->list;
899 $this->attributes[$tab->elementtype][
'printable'][$tab->name] = $tab->printable;
900 $this->attributes[$tab->elementtype][
'totalizable'][$tab->name] = ($tab->totalizable ? 1 : 0);
901 $this->attributes[$tab->elementtype][
'entityid'][$tab->name] = $tab->entity;
902 $this->attributes[$tab->elementtype][
'enabled'][$tab->name] = $tab->enabled;
903 $this->attributes[$tab->elementtype][
'help'][$tab->name] = $tab->help;
904 $this->attributes[$tab->elementtype][
'css'][$tab->name] = $tab->css;
905 $this->attributes[$tab->elementtype][
'cssview'][$tab->name] = $tab->cssview;
906 $this->attributes[$tab->elementtype][
'csslist'][$tab->name] = $tab->csslist;
908 $this->attributes[$tab->elementtype][
'loaded'] = 1;
913 $this->attributes[$elementtype][
'loaded'] = 1;
914 $this->attributes[$elementtype][
'count'] = $count;
917 $this->error = $this->db->lasterror();
918 dol_syslog(get_class($this).
"::fetch_name_optionals_label ".$this->error, LOG_ERR);
921 return $array_name_label;
940 public function showInputField($key, $value, $moreparam =
'', $keysuffix =
'', $keyprefix =
'', $morecss =
'', $objectid = 0, $extrafieldsobjectkey =
'', $mode = 0)
942 global $conf, $langs, $form;
944 if (!is_object($form)) {
945 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
946 $form =
new Form($this->db);
951 if (!preg_match(
'/options_$/', $keyprefix)) {
952 $keyprefix = $keyprefix.
'options_';
955 if (empty($extrafieldsobjectkey)) {
956 dol_syslog(get_class($this).
'::showInputField extrafieldsobjectkey required', LOG_ERR);
957 return 'BadValueForParamExtraFieldsObjectKey';
960 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
961 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
962 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
963 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
964 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
965 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
966 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
967 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
968 $perms =
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
969 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
970 $list =
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
971 $totalizable = $this->attributes[$extrafieldsobjectkey][
'totalizable'][$key];
972 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
973 $hidden = (empty($list) ? 1 : 0);
976 if (!preg_match(
'/^search_/', $keyprefix)) {
977 return '<span class="opacitymedium">'.$langs->trans(
"AutomaticallyCalculated").
'</span>';
985 if (empty($morecss)) {
987 if ($type ==
'date') {
988 $morecss =
'minwidth100imp';
989 } elseif ($type ==
'datetime' || $type ==
'datetimegmt' || $type ==
'link') {
990 $morecss =
'minwidth200imp';
991 } elseif (in_array($type, array(
'int',
'integer',
'double',
'price'))) {
992 $morecss =
'maxwidth75';
993 } elseif ($type ==
'password') {
994 $morecss =
'maxwidth100';
995 } elseif ($type ==
'url') {
996 $morecss =
'minwidth400';
997 } elseif ($type ==
'boolean') {
999 } elseif ($type ==
'radio') {
1000 $morecss =
'width25';
1002 if (empty($size) || round($size) < 12) {
1003 $morecss =
'minwidth100';
1004 } elseif (round($size) <= 48) {
1005 $morecss =
'minwidth200';
1007 $morecss =
'minwidth400';
1011 if (!empty($this->attributes[$extrafieldsobjectkey][
'css'][$key])) {
1012 $morecss = $this->attributes[$extrafieldsobjectkey][
'css'][$key];
1016 if (in_array($type, array(
'date'))) {
1017 $tmp = explode(
',', $size);
1022 if (!$required && $value ==
'') {
1029 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1030 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1032 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1033 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1034 $out .=
'</div><div class="nowrap">';
1035 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1036 $out .=
'</div></div>';
1039 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1);
1041 } elseif (in_array($type, array(
'datetime',
'datetimegmt'))) {
1042 $tmp = explode(
',', $size);
1047 if (!$required && $value ==
'') {
1054 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1055 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1057 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1058 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"),
'tzuserrel');
1059 $out .=
'</div><div class="nowrap">';
1060 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
1061 $out .=
'</div></div>';
1064 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1,
'',
'',
'', 1,
'',
'',
'tzuserrel');
1066 } elseif (in_array($type, array(
'int',
'integer'))) {
1067 $tmp = explode(
',', $size);
1069 $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 :
'').
'>';
1070 } elseif (preg_match(
'/varchar/', $type)) {
1071 $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 :
'').
'>';
1072 } elseif (in_array($type, array(
'mail',
'ip',
'phone',
'url'))) {
1073 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1074 } elseif ($type ==
'text') {
1075 if (!preg_match(
'/search_/', $keyprefix)) {
1076 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1077 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false,
false, ROWS_5,
'90%');
1078 $out = $doleditor->Create(1);
1080 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1082 } elseif ($type ==
'html') {
1083 if (!preg_match(
'/search_/', $keyprefix)) {
1084 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1085 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false, isModEnabled(
'fckeditor') && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5,
'90%');
1086 $out = $doleditor->Create(1);
1088 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1090 } elseif ($type ==
'boolean') {
1093 if (!empty($value)) {
1094 $checked =
' checked value="1" ';
1096 $checked =
' value="1" ';
1098 $out =
'<input type="checkbox" class="flat valignmiddle'.($morecss ?
' '.$morecss :
'').
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.$checked.
' '.($moreparam ? $moreparam :
'').
'>';
1100 $out .= $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1,
false, 1);
1102 } elseif ($type ==
'price') {
1103 if (!empty($value)) {
1104 $value =
price($value);
1106 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> '.$langs->getCurrencySymbol($conf->currency);
1107 } elseif ($type ==
'pricecy') {
1108 $currency = $conf->currency;
1109 if (!empty($value)) {
1111 $pricetmp = explode(
':', $value);
1112 $currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
1113 $value =
price($pricetmp[0]);
1115 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1116 $out .= $form->selectCurrency($currency, $keyprefix.$key.$keysuffix.
'currency_id');
1117 } elseif ($type ==
'double') {
1118 if (!empty($value)) {
1119 $value =
price($value);
1121 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1122 } elseif ($type ==
'select') {
1126 foreach ($param[
'options'] as $okey => $val) {
1127 if ((
string) $okey ==
'') {
1131 $valarray = explode(
'|', $val);
1132 $val = $valarray[0];
1134 if ($langfile && $val) {
1135 $options[$okey] = $langs->trans($val);
1137 $options[$okey] = $val;
1140 $selected = array();
1141 if (!is_array($value)) {
1142 $selected = explode(
',', $value);
1145 $out .= $form->multiselectarray($keyprefix.$key.$keysuffix, $options, $selected, 0, 0, $morecss, 0, 0,
'',
'',
'', !empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_EXTRAFIELDS_DISABLE_SELECT2));
1147 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_EXTRAFIELDS_DISABLE_SELECT2)) {
1148 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1149 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1152 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1153 $out .=
'<option value="0"> </option>';
1154 foreach ($param[
'options'] as $key2 => $val2) {
1155 if ((
string) $key2 ==
'') {
1158 $valarray = explode(
'|', $val2);
1159 $val2 = $valarray[0];
1161 if (!empty($valarray[1])) {
1162 $parent = $valarray[1];
1164 $out .=
'<option value="'.$key2.
'"';
1165 $out .= (((string) $value == (
string) $key2) ?
' selected' :
'');
1166 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1168 if ($langfile && $val2) {
1169 $out .= $langs->trans($val2);
1173 $out .=
'</option>';
1175 $out .=
'</select>';
1177 } elseif ($type ==
'sellist') {
1179 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_EXTRAFIELDS_DISABLE_SELECT2)) {
1180 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1181 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1184 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1185 if (is_array($param[
'options'])) {
1186 $param_list = array_keys($param[
'options']);
1187 $InfoFieldList = explode(
":", $param_list[0]);
1197 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1200 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1201 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1202 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1204 $keyList = $InfoFieldList[2].
' as rowid';
1207 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1208 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1209 $keyList .=
', '.$parentField;
1212 $filter_categorie =
false;
1213 if (count($InfoFieldList) > 5) {
1214 if ($InfoFieldList[0] ==
'categorie') {
1215 $filter_categorie =
true;
1219 if ($filter_categorie ===
false) {
1220 $fields_label = explode(
'|', $InfoFieldList[1]);
1221 if (is_array($fields_label)) {
1223 $keyList .= implode(
', ', $fields_label);
1227 $sql =
"SELECT ".$keyList;
1228 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1229 if (!empty($InfoFieldList[4])) {
1231 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1232 $InfoFieldList[4] = str_replace(
'$ENTITY$', $conf->entity, $InfoFieldList[4]);
1235 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1236 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1240 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1241 $InfoFieldList[4] = str_replace(
'$ID$', $objectid, $InfoFieldList[4]);
1243 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1246 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1247 $sql .=
' as main, '.$this->db->prefix().$InfoFieldList[0].
'_extrafields as extra';
1248 $sqlwhere .=
" WHERE extra.fk_object=main.".$InfoFieldList[2].
" AND ".$InfoFieldList[4];
1250 $sqlwhere .=
" WHERE ".$InfoFieldList[4];
1253 $sqlwhere .=
' WHERE 1=1';
1256 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1257 $sqlwhere .=
' AND entity = '.((int) $conf->entity);
1262 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1264 dol_syslog(get_class($this).
'::showInputField type=sellist', LOG_DEBUG);
1265 $resql = $this->db->query($sql);
1267 $out .=
'<option value="0"> </option>';
1268 $num = $this->db->num_rows($resql);
1272 $obj = $this->db->fetch_object($resql);
1276 $fields_label = explode(
'|', $InfoFieldList[1]);
1277 if (is_array($fields_label) && count($fields_label) > 1) {
1279 foreach ($fields_label as $field_toshow) {
1280 $labeltoshow .= $obj->$field_toshow.
' ';
1283 $labeltoshow = $obj->{$InfoFieldList[1]};
1285 $labeltoshow = $labeltoshow;
1287 if ($value == $obj->rowid) {
1289 foreach ($fields_label as $field_toshow) {
1290 $translabel = $langs->trans($obj->$field_toshow);
1291 $labeltoshow = $translabel.
' ';
1294 $out .=
'<option value="'.$obj->rowid.
'" selected>'.$labeltoshow.
'</option>';
1297 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1298 $labeltoshow = $translabel;
1300 if (empty($labeltoshow)) {
1301 $labeltoshow =
'(not defined)';
1304 if (!empty($InfoFieldList[3]) && $parentField) {
1305 $parent = $parentName.
':'.$obj->{$parentField};
1308 $out .=
'<option value="'.$obj->rowid.
'"';
1309 $out .= ($value == $obj->rowid ?
' selected' :
'');
1310 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1311 $out .=
'>'.$labeltoshow.
'</option>';
1316 $this->db->free($resql);
1318 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1321 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1322 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1323 $out .=
'<option value="0"> </option>';
1324 if (is_array($data)) {
1325 foreach ($data as $data_key => $data_value) {
1326 $out .=
'<option value="'.$data_key.
'"';
1327 $out .= ($value == $data_key ?
' selected' :
'');
1328 $out .=
'>'.$data_value.
'</option>';
1333 $out .=
'</select>';
1334 } elseif ($type ==
'checkbox') {
1335 $value_arr = $value;
1336 if (!is_array($value)) {
1337 $value_arr = explode(
',', $value);
1339 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param[
'options']) ?
null:$param[
'options']), $value_arr,
'', 0,
'', 0,
'100%');
1340 } elseif ($type ==
'radio') {
1342 foreach ($param[
'options'] as $keyopt => $val) {
1343 $out .=
'<input class="flat '.$morecss.
'" type="radio" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'');
1344 $out .=
' value="'.$keyopt.
'"';
1345 $out .=
' id="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'"';
1346 $out .= ($value == $keyopt ?
'checked' :
'');
1347 $out .=
'/><label for="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'">'.$langs->trans($val).
'</label><br>';
1349 } elseif ($type ==
'chkbxlst') {
1350 if (is_array($value)) {
1351 $value_arr = $value;
1353 $value_arr = explode(
',', $value);
1356 if (is_array($param[
'options'])) {
1357 $param_list = array_keys($param[
'options']);
1358 $InfoFieldList = explode(
":", $param_list[0]);
1368 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1370 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1371 list ($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1372 $keyList .=
', '.$parentField;
1374 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1375 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1376 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1378 $keyList = $InfoFieldList[2].
' as rowid';
1382 $filter_categorie =
false;
1383 if (count($InfoFieldList) > 5) {
1384 if ($InfoFieldList[0] ==
'categorie') {
1385 $filter_categorie =
true;
1389 if ($filter_categorie ===
false) {
1390 $fields_label = explode(
'|', $InfoFieldList[1]);
1391 if (is_array($fields_label)) {
1393 $keyList .= implode(
', ', $fields_label);
1397 $sql =
"SELECT ".$keyList;
1398 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1399 if (!empty($InfoFieldList[4])) {
1401 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1402 $InfoFieldList[4] = str_replace(
'$ENTITY$', $conf->entity, $InfoFieldList[4]);
1405 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1406 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1410 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1411 $InfoFieldList[4] = str_replace(
'$ID$', $objectid, $InfoFieldList[4]);
1412 } elseif (preg_match(
"#^.*list.php$#", $_SERVER[
"PHP_SELF"])) {
1414 $word =
'\b[a-zA-Z0-9-\.-_]+\b=\$ID\$';
1417 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1421 while ($nbPreg != 0) {
1423 $nbPregRepl = $nbPregSel = 0;
1425 $InfoFieldList[4] = preg_replace(
'#([^=])(\([^)^(]*('.$word.
')[^)^(]*\))#',
'$1 $3 ', $InfoFieldList[4], -1, $nbPregRepl);
1427 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1429 $InfoFieldList[4] = preg_replace(
'#\b[a-zA-Z0-9-\.-_]+\b=\([^)^(]*('.$word.
')[^)^(]*\)#',
'$1 ', $InfoFieldList[4], -1, $nbPregSel);
1431 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1434 $nbPreg = $nbPregRepl + $nbPregSel;
1438 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1439 while (!empty($matchCondition[0])) {
1441 if (!empty($matchCondition[1]) && !empty($matchCondition[3]) && $matchCondition[1] != $matchCondition[3]) {
1443 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1445 if (!empty($matchCondition[1])) {
1446 $boolCond = (($matchCondition[1] ==
"AND") ?
' AND TRUE ' :
' OR FALSE ');
1447 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond.$matchCondition[3], $InfoFieldList[4]);
1448 } elseif (!empty($matchCondition[3])) {
1449 $boolCond = (($matchCondition[3] ==
"AND") ?
' TRUE AND ' :
' FALSE OR');
1450 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond, $InfoFieldList[4]);
1452 $InfoFieldList[4] =
" TRUE ";
1457 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1460 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1464 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1465 $sql .=
' as main, '.$this->db->prefix().$InfoFieldList[0].
'_extrafields as extra';
1466 $sqlwhere .=
" WHERE extra.fk_object=main.".$InfoFieldList[2].
" AND ".$InfoFieldList[4];
1468 $sqlwhere .=
" WHERE ".$InfoFieldList[4];
1471 $sqlwhere .=
' WHERE 1=1';
1474 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1475 $sqlwhere .=
" AND entity = ".((int) $conf->entity);
1481 dol_syslog(get_class($this).
'::showInputField type=chkbxlst', LOG_DEBUG);
1482 $resql = $this->db->query($sql);
1484 $num = $this->db->num_rows($resql);
1491 $obj = $this->db->fetch_object($resql);
1495 $fields_label = explode(
'|', $InfoFieldList[1]);
1496 if (is_array($fields_label)) {
1498 foreach ($fields_label as $field_toshow) {
1499 $labeltoshow .= $obj->$field_toshow.
' ';
1502 $labeltoshow = $obj->{$InfoFieldList[1]};
1504 $labeltoshow =
dol_trunc($labeltoshow, 45);
1506 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1508 foreach ($fields_label as $field_toshow) {
1509 $translabel = $langs->trans($obj->$field_toshow);
1510 if ($translabel != $obj->$field_toshow) {
1511 $labeltoshow .=
' '.dol_trunc($translabel, 18).
' ';
1513 $labeltoshow .=
' '.dol_trunc($obj->$field_toshow, 18).
' ';
1516 $data[$obj->rowid] = $labeltoshow;
1519 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1520 if ($translabel != $obj->{$InfoFieldList[1]}) {
1521 $labeltoshow =
dol_trunc($translabel, 18);
1523 $labeltoshow =
dol_trunc($obj->{$InfoFieldList[1]}, 18);
1526 if (empty($labeltoshow)) {
1527 $labeltoshow =
'(not defined)';
1530 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1531 $data[$obj->rowid] = $labeltoshow;
1534 if (!empty($InfoFieldList[3]) && $parentField) {
1535 $parent = $parentName.
':'.$obj->{$parentField};
1538 $data[$obj->rowid] = $labeltoshow;
1543 $this->db->free($resql);
1545 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr,
'', 0,
'', 0,
'100%');
1547 print
'Error in request '.$sql.
' '.$this->db->lasterror().
'. Check setup of extra parameters.<br>';
1550 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1551 $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1552 $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr,
'', 0,
'', 0,
'100%');
1555 } elseif ($type ==
'link') {
1556 $param_list = array_keys($param[
'options']);
1557 $showempty = (($required && $default !=
'') ? 0 : 1);
1558 $out = $form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty,
'',
'', $morecss);
1559 } elseif ($type ==
'password') {
1561 $out =
'<input style="display:none" type="text" name="fakeusernameremembered">';
1562 $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 :
'').
'>';
1564 if (!empty($hidden)) {
1565 $out =
'<input type="hidden" value="'.$value.
'" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'"/>';
1588 public function showOutputField($key, $value, $moreparam =
'', $extrafieldsobjectkey =
'', $outputlangs =
null)
1590 global $conf, $langs;
1592 if (is_null($outputlangs) || !is_object($outputlangs)) {
1593 $outputlangs = $langs;
1596 if (empty($extrafieldsobjectkey)) {
1597 dol_syslog(get_class($this).
'::showOutputField extrafieldsobjectkey required', LOG_ERR);
1598 return 'BadValueForParamExtraFieldsObjectKey';
1601 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
1602 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1603 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
1604 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
1605 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
1606 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
1607 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
1608 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
1609 $perms =
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'2');
1610 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
1611 $list =
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'2');
1612 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
1613 $hidden = (empty($list) ? 1 : 0);
1622 if ($type ==
'date') {
1624 if ($value !==
'') {
1627 } elseif ($type ==
'datetime') {
1629 if ($value !==
'') {
1632 } elseif ($type ==
'datetimegmt') {
1634 if ($value !==
'') {
1637 } elseif ($type ==
'int') {
1639 } elseif ($type ==
'double') {
1640 if (!empty($value)) {
1642 $sizeparts = explode(
",", $size);
1643 $number_decimals = array_key_exists(1, $sizeparts) ? $sizeparts[1] : 0;
1644 $value =
price($value, 0, $outputlangs, 0, 0, $number_decimals,
'');
1646 } elseif ($type ==
'boolean') {
1648 if (!empty($value)) {
1649 $checked =
' checked ';
1651 $value =
'<input type="checkbox" '.$checked.
' '.($moreparam ? $moreparam :
'').
' readonly disabled>';
1652 } elseif ($type ==
'mail') {
1654 } elseif ($type ==
'ip') {
1656 } elseif ($type ==
'url') {
1658 } elseif ($type ==
'phone') {
1660 } elseif ($type ==
'price') {
1662 if ($value || $value ==
'0') {
1663 $value =
price($value, 0, $outputlangs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1).
' '.$outputlangs->getCurrencySymbol($conf->currency);
1665 } elseif ($type ==
'pricecy') {
1666 $currency = $conf->currency;
1667 if (!empty($value)) {
1669 $pricetmp = explode(
':', $value);
1670 $currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
1671 $value = $pricetmp[0];
1673 if ($value || $value ==
'0') {
1674 $value =
price($value, 0, $outputlangs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1, $currency);
1676 } elseif ($type ==
'select') {
1677 $valstr = (!empty($param[
'options'][$value]) ? $param[
'options'][$value] :
'');
1678 if (($pos = strpos($valstr,
"|")) !==
false) {
1679 $valstr = substr($valstr, 0, $pos);
1681 if ($langfile && $valstr) {
1682 $value = $outputlangs->trans($valstr);
1686 } elseif ($type ==
'sellist') {
1687 $param_list = array_keys($param[
'options']);
1688 $InfoFieldList = explode(
":", $param_list[0]);
1690 $selectkey =
"rowid";
1693 if (count($InfoFieldList) >= 3) {
1694 $selectkey = $InfoFieldList[2];
1695 $keyList = $InfoFieldList[2].
' as rowid';
1698 $fields_label = explode(
'|', $InfoFieldList[1]);
1699 if (is_array($fields_label)) {
1701 $keyList .= implode(
', ', $fields_label);
1704 $filter_categorie =
false;
1705 if (count($InfoFieldList) > 5) {
1706 if ($InfoFieldList[0] ==
'categorie') {
1707 $filter_categorie =
true;
1711 $sql =
"SELECT ".$keyList;
1712 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1713 if (!empty($InfoFieldList[4]) && strpos($InfoFieldList[4],
'extra.') !==
false) {
1716 if ($selectkey ==
'rowid' && empty($value)) {
1717 $sql .=
" WHERE ".$selectkey.
" = 0";
1718 } elseif ($selectkey ==
'rowid') {
1719 $sql .=
" WHERE ".$selectkey.
" = ".((int) $value);
1721 $sql .=
" WHERE ".$selectkey.
" = '".$this->db->escape($value).
"'";
1726 dol_syslog(get_class($this).
':showOutputField:$type=sellist', LOG_DEBUG);
1727 $resql = $this->db->query($sql);
1729 if ($filter_categorie ===
false) {
1732 $obj = $this->db->fetch_object($resql);
1735 $fields_label = explode(
'|', $InfoFieldList[1]);
1737 if (is_array($fields_label) && count($fields_label) > 1) {
1738 foreach ($fields_label as $field_toshow) {
1740 if (!empty($obj->$field_toshow)) {
1741 $translabel = $outputlangs->trans($obj->$field_toshow);
1743 if ($translabel != $obj->$field_toshow) {
1744 $value .=
dol_trunc($translabel, 24) .
' ';
1746 $value .= $obj->$field_toshow .
' ';
1752 $tmppropname = $InfoFieldList[1];
1754 if (!empty(isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
1755 $translabel = $outputlangs->trans($obj->$tmppropname);
1757 if ($translabel != (isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
1760 $value = isset($obj->$tmppropname) ? $obj->$tmppropname :
'';
1765 $obj = $this->db->fetch_object($resql);
1767 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1769 $result = $c->fetch($obj->rowid);
1771 $ways = $c->print_all_ways();
1772 foreach ($ways as $way) {
1773 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ?
' style="background: #' . $c->color .
';"' :
' style="background: #bbb"') .
'>' .
img_object(
'',
'category') .
' ' . $way .
'</li>';
1777 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1780 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
1782 } elseif ($type ==
'radio') {
1783 if (!isset($param[
'options'][$value])) {
1784 $outputlangs->load(
'errors');
1785 $value = $outputlangs->trans(
'ErrorNoValueForRadioType');
1787 $value = $outputlangs->trans($param[
'options'][$value]);
1789 } elseif ($type ==
'checkbox') {
1790 $value_arr = explode(
',', $value);
1793 if (is_array($value_arr)) {
1794 foreach ($value_arr as $keyval => $valueval) {
1795 if (!empty($valueval)) {
1796 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$param[
'options'][$valueval].
'</li>';
1800 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1801 } elseif ($type ==
'chkbxlst') {
1802 $value_arr = explode(
',', $value);
1804 $param_list = array_keys($param[
'options']);
1805 $InfoFieldList = explode(
":", $param_list[0]);
1807 $selectkey =
"rowid";
1810 if (count($InfoFieldList) >= 3) {
1811 $selectkey = $InfoFieldList[2];
1812 $keyList = $InfoFieldList[2].
' as rowid';
1815 $fields_label = explode(
'|', $InfoFieldList[1]);
1816 if (is_array($fields_label)) {
1818 $keyList .= implode(
', ', $fields_label);
1821 $filter_categorie =
false;
1822 if (count($InfoFieldList) > 5) {
1823 if ($InfoFieldList[0] ==
'categorie') {
1824 $filter_categorie =
true;
1828 $sql =
"SELECT ".$keyList;
1829 $sql .=
" FROM ".$this->db->prefix().$InfoFieldList[0];
1830 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1836 dol_syslog(get_class($this).
':showOutputField:$type=chkbxlst', LOG_DEBUG);
1837 $resql = $this->db->query($sql);
1839 if ($filter_categorie ===
false) {
1842 while ($obj = $this->db->fetch_object($resql)) {
1844 $fields_label = explode(
'|', $InfoFieldList[1]);
1845 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1846 if (is_array($fields_label) && count($fields_label) > 1) {
1847 $label =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">';
1848 foreach ($fields_label as $field_toshow) {
1850 if (!empty($obj->$field_toshow)) {
1851 $translabel = $outputlangs->trans($obj->$field_toshow);
1853 if ($translabel != $field_toshow) {
1854 $label .=
' '.dol_trunc($translabel, 18);
1856 $label .=
' '.$obj->$field_toshow;
1860 $toprint[] = $label;
1863 if (!empty($obj->{$InfoFieldList[1]})) {
1864 $translabel = $outputlangs->trans($obj->{$InfoFieldList[1]});
1866 if ($translabel != $obj->{$InfoFieldList[1]}) {
1867 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).
'</li>';
1869 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->{$InfoFieldList[1]}.
'</li>';
1875 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1878 while ($obj = $this->db->fetch_object($resql)) {
1879 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1881 $c->fetch($obj->rowid);
1882 $ways = $c->print_all_ways();
1883 foreach ($ways as $way) {
1884 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ?
' style="background: #'.$c->color.
';"' :
' style="background: #bbb"').
'>'.
img_object(
'',
'category').
' '.$way.
'</li>';
1889 if (!empty($toprint)) $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1891 dol_syslog(get_class($this).
'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
1893 } elseif ($type ==
'link') {
1898 $param_list = array_keys($param[
'options']);
1900 $InfoFieldList = explode(
":", $param_list[0]);
1901 $classname = $InfoFieldList[0];
1902 $classpath = $InfoFieldList[1];
1903 if (!empty($classpath)) {
1905 if ($classname && class_exists($classname)) {
1906 $object =
new $classname($this->db);
1907 $object->fetch($value);
1908 $value = $object->getNomUrl(3);
1911 dol_syslog(
'Error bad setup of extrafield', LOG_WARNING);
1912 return 'Error bad setup of extrafield';
1915 } elseif ($type ==
'text') {
1917 } elseif ($type ==
'html') {
1919 } elseif ($type ==
'password') {
1920 $value =
dol_trunc(preg_replace(
'/./i',
'*', $value), 8,
'right',
'UTF-8', 1);
1922 $showsize = round((
float) $size);
1923 if ($showsize > 48) {
2082 global $_POST, $langs;
2084 $nofillrequired = 0;
2085 $error_field_required = array();
2087 if (isset($this->attributes[$object->table_element][
'label']) && is_array($this->attributes[$object->table_element][
'label'])) {
2088 $extralabels = $this->attributes[$object->table_element][
'label'];
2091 if (is_array($extralabels)) {
2093 foreach ($extralabels as $key => $value) {
2094 if (!empty($onlykey) && $onlykey !=
'@GETPOSTISSET' && $key != $onlykey) {
2098 if (!empty($onlykey) && $onlykey ==
'@GETPOSTISSET' && !GETPOSTISSET(
'options_'.$key) && (! in_array($this->attributes[$object->table_element][
'type'][$key], array(
'boolean',
'checkbox',
'chkbxlst')))) {
2103 $key_type = $this->attributes[$object->table_element][
'type'][$key];
2104 if ($key_type ==
'separate') {
2109 if (isset($this->attributes[$object->table_element][
'enabled'][$key])) {
2110 $enabled =
dol_eval($this->attributes[$object->table_element][
'enabled'][$key], 1, 1,
'2');
2114 if (isset($this->attributes[$object->table_element][
'list'][$key])) {
2115 $visibility = intval(
dol_eval($this->attributes[$object->table_element][
'list'][$key], 1, 1,
'2'));
2119 if (isset($this->attributes[$object->table_element][
'perms'][$key])) {
2120 $perms =
dol_eval($this->attributes[$object->table_element][
'perms'][$key], 1, 1,
'2');
2124 $onlykey ===
'@GETPOSTISSET'
2125 && in_array($this->attributes[$object->table_element][
'type'][$key], array(
'boolean',
'checkbox',
'chkbxlst'))
2126 && in_array(abs($enabled), array(2, 5))
2127 && ! GETPOSTISSET(
'options_' . $key)
2133 $visibility_abs = abs($visibility);
2135 if (empty($visibility_abs) || $visibility_abs == 2 || $visibility_abs == 5) {
2138 if (empty($perms)) {
2142 if ($this->attributes[$object->table_element][
'required'][$key]) {
2146 if ((!is_array($_POST[
"options_".$key]) && empty($_POST[
"options_".$key]) && $this->attributes[$object->table_element][
'type'][$key] !=
'select' && $_POST[
"options_".$key] !=
'0')
2147 || (!is_array($_POST[
"options_".$key]) && empty($_POST[
"options_".$key]) && $this->attributes[$object->table_element][
'type'][$key] ==
'select')
2148 || (!is_array($_POST[
"options_".$key]) && isset($_POST[
"options_".$key]) && $this->attributes[$object->table_element][
'type'][$key] ==
'sellist' && $_POST[
'options_'.$key] ==
'0')
2149 || (is_array($_POST[
"options_".$key]) && empty($_POST[
"options_".$key]))) {
2155 if (!empty($this->attributes[$object->table_element][
'langfile'][$key])) {
2156 $langs->load($this->attributes[$object->table_element][
'langfile'][$key]);
2158 $error_field_required[$key] = $langs->transnoentitiesnoconv($value);
2162 if (in_array($key_type, array(
'date'))) {
2164 $value_key =
dol_mktime(12, 0, 0,
GETPOST(
"options_".$key.
"month",
'int'),
GETPOST(
"options_".$key.
"day",
'int'),
GETPOST(
"options_".$key.
"year",
'int'));
2165 } elseif (in_array($key_type, array(
'datetime'))) {
2167 $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');
2168 } elseif (in_array($key_type, array(
'datetimegmt'))) {
2170 $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');
2171 } elseif (in_array($key_type, array(
'checkbox',
'chkbxlst'))) {
2172 $value_arr =
GETPOST(
"options_".$key,
'array');
2173 if (!empty($value_arr)) {
2174 $value_key = implode(
',', $value_arr);
2178 } elseif (in_array($key_type, array(
'price',
'double'))) {
2179 $value_arr =
GETPOST(
"options_".$key,
'alpha');
2181 } elseif (in_array($key_type, array(
'pricecy',
'double'))) {
2182 $value_key =
price2num(
GETPOST(
"options_".$key,
'alpha')).
':'.
GETPOST(
"options_".$key.
"currency_id",
'alpha');
2183 } elseif (in_array($key_type, array(
'html'))) {
2184 $value_key =
GETPOST(
"options_".$key,
'restricthtml');
2185 } elseif (in_array($key_type, array(
'text'))) {
2186 $label_security_check =
'alphanohtml';
2188 if (!empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS)) {
2189 $label_security_check =
'nohtml';
2191 $label_security_check = empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML) ?
'alphanohtml' :
'restricthtml';
2193 $value_key =
GETPOST(
"options_".$key, $label_security_check);
2195 $value_key =
GETPOST(
"options_".$key);
2196 if (in_array($key_type, array(
'link')) && $value_key ==
'-1') {
2201 if (!empty($error_field_required[$key]) && $todefaultifmissing) {
2203 if (!empty($this->attributes[$object->table_element][
'default']) && !is_null($this->attributes[$object->table_element][
'default'][$key])) {
2204 $value_key = $this->attributes[$object->table_element][
'default'][$key];
2205 unset($error_field_required[$key]);
2210 $object->array_options[
"options_".$key] = $value_key;
2213 if ($nofillrequired) {
2214 $langs->load(
'errors');
2215 $this->error = $langs->trans(
'ErrorFieldsRequired').
' : '.implode(
', ', $error_field_required);