50 public $attribute_type;
56 public $attribute_label;
62 public $attribute_choice;
68 public $attribute_list;
78 public $expand_display;
88 public $errors = array();
96 public static $type2label = array(
97 'varchar'=>
'String1Line',
98 'text'=>
'TextLongNLines',
103 'datetime'=>
'DateAndTime',
104 'boolean'=>
'Boolean',
105 'price'=>
'ExtrafieldPrice',
106 'phone'=>
'ExtrafieldPhone',
107 'mail'=>
'ExtrafieldMail',
108 'url'=>
'ExtrafieldUrl',
109 'password' =>
'ExtrafieldPassword',
110 'select' =>
'ExtrafieldSelect',
111 'sellist' =>
'ExtrafieldSelectList',
112 'radio' =>
'ExtrafieldRadio',
113 'checkbox' =>
'ExtrafieldCheckBox',
114 'chkbxlst' =>
'ExtrafieldCheckBoxFromList',
115 'link' =>
'ExtrafieldLink',
116 'separate' =>
'ExtrafieldSeparator',
129 $this->errors = array();
130 $this->attributes = array();
133 $this->attribute_type = array();
134 $this->attribute_label = array();
162 public function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value =
'', $param =
'', $alwayseditable = 0, $perms =
'', $list =
'-1', $help =
'', $computed =
'', $entity =
'', $langfile =
'', $enabled =
'1', $totalizable = 0, $printable = 0)
164 if (empty($attrname)) {
173 if ($type ==
'separate') {
177 if ($elementtype ==
'thirdparty') {
178 $elementtype =
'societe';
180 if ($elementtype ==
'contact') {
181 $elementtype =
'socpeople';
185 if ($type !=
'separate') {
186 $result = $this->
create($attrname, $type, $size, $elementtype, $unique, $required, $default_value, $param, $perms, $list, $computed, $help);
188 $err1 = $this->errno;
189 if ($result > 0 || $err1 ==
'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type ==
'separate') {
191 $result2 = $this->
create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $help, $default_value, $computed, $entity, $langfile, $enabled, $totalizable, $printable);
192 $err2 = $this->errno;
193 if ($result2 > 0 || ($err1 ==
'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 ==
'DB_ERROR_RECORD_ALREADY_EXISTS')) {
223 private function create($attrname, $type =
'varchar', $length = 255, $elementtype =
'member', $unique = 0, $required = 0, $default_value =
'', $param =
'', $perms =
'', $list =
'0', $computed =
'', $help =
'')
225 if ($elementtype ==
'thirdparty') {
226 $elementtype =
'societe';
228 if ($elementtype ==
'contact') {
229 $elementtype =
'socpeople';
232 $table = $elementtype.
'_extrafields';
233 if ($elementtype ==
'categorie') {
234 $table =
'categories_extrafields';
237 if (!empty($attrname) && preg_match(
"/^\w[a-zA-Z0-9_]*$/", $attrname) && !is_numeric($attrname)) {
238 if ($type ==
'boolean') {
241 } elseif ($type ==
'price') {
244 } elseif ($type ==
'phone') {
247 } elseif ($type ==
'mail') {
250 } elseif ($type ==
'url') {
253 } elseif (($type ==
'select') || ($type ==
'sellist') || ($type ==
'radio') || ($type ==
'checkbox') || ($type ==
'chkbxlst')) {
256 } elseif ($type ==
'link') {
259 } elseif ($type ==
'html') {
262 } elseif ($type ==
'password') {
268 if ($type ==
'varchar' && empty($lengthdb)) {
275 'null'=>($required ?
'NOT NULL' :
'NULL'),
276 'default' => $default_value
279 $result = $this->
db->DDLAddField($this->
db->prefix().$table, $attrname, $field_desc);
282 $sql =
"ALTER TABLE ".$this->db->prefix().$table.
" ADD UNIQUE INDEX uk_".$table.
"_".$attrname.
" (".$attrname.
")";
283 $resql = $this->
db->query($sql, 1,
'dml');
287 $this->error = $this->
db->lasterror();
288 $this->errno = $this->
db->lasterrno();
323 private function create_label($attrname, $label =
'', $type =
'', $pos = 0, $size = 0, $elementtype =
'member', $unique = 0, $required = 0, $param =
'', $alwayseditable = 0, $perms =
'', $list =
'-1', $help =
'', $default =
'', $computed =
'', $entity =
'', $langfile =
'', $enabled =
'1', $totalizable = 0, $printable = 0)
328 if ($elementtype ==
'thirdparty') {
329 $elementtype =
'societe';
331 if ($elementtype ==
'contact') {
332 $elementtype =
'socpeople';
342 if (empty($required)) {
345 if (empty($unique)) {
348 if (empty($printable)) {
351 if (empty($alwayseditable)) {
354 if (empty($totalizable)) {
358 if (!empty($attrname) && preg_match(
"/^\w[a-zA-Z0-9-_]*$/", $attrname) && !is_numeric($attrname)) {
359 if (is_array($param) && count($param) > 0) {
360 $params = serialize($param);
361 } elseif (strlen($param) > 0) {
362 $params = trim($param);
367 $sql =
"INSERT INTO ".$this->db->prefix().
"extrafields(";
374 $sql .=
" elementtype,";
375 $sql .=
" fieldunique,";
376 $sql .=
" fieldrequired,";
378 $sql .=
" alwayseditable,";
382 $sql .=
" printable,";
383 $sql .=
" fielddefault,";
384 $sql .=
" fieldcomputed,";
385 $sql .=
" fk_user_author,";
386 $sql .=
" fk_user_modif,";
390 $sql .=
" totalizable";
392 $sql .=
" VALUES('".$this->db->escape($attrname).
"',";
393 $sql .=
" '".$this->db->escape($label).
"',";
394 $sql .=
" '".$this->db->escape($type).
"',";
395 $sql .=
" ".((int) $pos).
",";
396 $sql .=
" '".$this->db->escape($size).
"',";
397 $sql .=
" ".($entity ===
'' ? $conf->entity : $entity).
",";
398 $sql .=
" '".$this->db->escape($elementtype).
"',";
399 $sql .=
" ".((int) $unique).
",";
400 $sql .=
" ".((int) $required).
",";
401 $sql .=
" '".$this->db->escape($params).
"',";
402 $sql .=
" ".((int) $alwayseditable).
",";
403 $sql .=
" ".($perms ?
"'".$this->db->escape($perms).
"'" :
"null").
",";
404 $sql .=
" ".($langfile ?
"'".$this->db->escape($langfile).
"'" :
"null").
",";
405 $sql .=
" '".$this->db->escape($list).
"',";
406 $sql .=
" '".$this->db->escape($printable).
"',";
407 $sql .=
" ".($default ?
"'".$this->db->escape($default).
"'" :
"null").
",";
408 $sql .=
" ".($computed ?
"'".$this->db->escape($computed).
"'" :
"null").
",";
409 $sql .=
" ".(is_object($user) ? $user->id : 0).
",";
410 $sql .=
" ".(is_object($user) ? $user->id : 0).
",";
411 $sql .=
"'".$this->db->idate(
dol_now()).
"',";
412 $sql .=
" ".($enabled ?
"'".$this->db->escape($enabled).
"'" :
"1").
",";
413 $sql .=
" ".($help ?
"'".$this->db->escape($help).
"'" :
"null").
",";
414 $sql .=
" ".($totalizable ?
'TRUE' :
'FALSE');
417 dol_syslog(get_class($this).
"::create_label", LOG_DEBUG);
418 if ($this->
db->query($sql)) {
421 $this->error = $this->
db->lasterror();
422 $this->errno = $this->
db->lasterrno();
435 public function delete($attrname, $elementtype =
'member')
437 if ($elementtype ==
'thirdparty') {
438 $elementtype =
'societe';
440 if ($elementtype ==
'contact') {
441 $elementtype =
'socpeople';
444 $table = $elementtype.
'_extrafields';
445 if ($elementtype ==
'categorie') {
446 $table =
'categories_extrafields';
451 if (!empty($attrname) && preg_match(
"/^\w[a-zA-Z0-9-_]*$/", $attrname)) {
454 $this->error = $this->
db->lasterror();
455 $this->errors[] = $this->
db->lasterror();
460 $sql =
"SELECT COUNT(rowid) as nb";
461 $sql .=
" FROM ".$this->db->prefix().
"extrafields";
462 $sql .=
" WHERE elementtype = '".$this->db->escape($elementtype).
"'";
463 $sql .=
" AND name = '".$this->db->escape($attrname).
"'";
467 $obj = $this->
db->fetch_object(
$resql);
469 $result = $this->
db->DDLDropField($this->
db->prefix().$table, $attrname);
471 $this->error = $this->
db->lasterror();
472 $this->errors[] = $this->
db->lasterror();
498 if ($elementtype ==
'thirdparty') {
499 $elementtype =
'societe';
501 if ($elementtype ==
'contact') {
502 $elementtype =
'socpeople';
505 if (isset($attrname) && $attrname !=
'' && preg_match(
"/^\w[a-zA-Z0-9-_]*$/", $attrname)) {
506 $sql =
"DELETE FROM ".$this->db->prefix().
"extrafields";
507 $sql .=
" WHERE name = '".$this->db->escape($attrname).
"'";
508 $sql .=
" AND entity IN (0,".$conf->entity.
')';
509 $sql .=
" AND elementtype = '".$this->db->escape($elementtype).
"'";
511 dol_syslog(get_class($this).
"::delete_label", LOG_DEBUG);
550 public function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param =
'', $alwayseditable = 0, $perms =
'', $list =
'', $help =
'', $default =
'', $computed =
'', $entity =
'', $langfile =
'', $enabled =
'1', $totalizable = 0, $printable = 0)
554 if ($elementtype ==
'thirdparty') {
555 $elementtype =
'societe';
557 if ($elementtype ==
'contact') {
558 $elementtype =
'socpeople';
561 $table = $elementtype.
'_extrafields';
562 if ($elementtype ==
'categorie') {
563 $table =
'categories_extrafields';
566 if (isset($attrname) && $attrname !=
'' && preg_match(
"/^\w[a-zA-Z0-9-_]*$/", $attrname)) {
567 if ($type ==
'boolean') {
570 } elseif ($type ==
'price') {
573 } elseif ($type ==
'phone') {
576 } elseif ($type ==
'mail') {
579 } elseif ($type ==
'url') {
582 } elseif (($type ==
'select') || ($type ==
'sellist') || ($type ==
'radio') || ($type ==
'checkbox') || ($type ==
'chkbxlst')) {
585 } elseif ($type ==
'html') {
587 } elseif ($type ==
'link') {
590 } elseif ($type ==
'password') {
597 $field_desc = array(
'type'=>$typedb,
'value'=>$lengthdb,
'null'=>($required ?
'NOT NULL' :
'NULL'),
'default'=>$default);
599 if (is_object($hookmanager)) {
600 $hookmanager->initHooks(array(
'extrafieldsdao'));
601 $parameters = array(
'field_desc'=>&$field_desc,
'table'=>$table,
'attr_name'=>$attrname,
'label'=>$label,
'type'=>$type,
'length'=>$length,
'unique'=>$unique,
'required'=>$required,
'pos'=>$pos,
'param'=>$param,
'alwayseditable'=>$alwayseditable,
'perms'=>$perms,
'list'=>$list,
'help'=>$help,
'default'=>$default,
'computed'=>$computed,
'entity'=>$entity,
'langfile'=>$langfile,
'enabled'=>$enabled,
'totalizable'=>$totalizable,
'printable'=>$printable);
602 $reshook = $hookmanager->executeHooks(
'updateExtrafields', $parameters, $this, $action);
605 $this->error = $this->
db->lasterror();
610 if ($type !=
'separate') {
611 $result = $this->
db->DDLUpdateField($this->
db->prefix().$table, $attrname, $field_desc);
613 if ($result > 0 || $type ==
'separate') {
615 $result = $this->
update_label($attrname, $label, $type, $length, $elementtype, $unique, $required, $pos, $param, $alwayseditable, $perms, $list, $help, $default, $computed, $entity, $langfile, $enabled, $totalizable, $printable);
620 $sql =
"ALTER TABLE ".$this->db->prefix().$table.
" ADD UNIQUE INDEX uk_".$table.
"_".$attrname.
" (".$attrname.
")";
622 $sql =
"ALTER TABLE ".$this->db->prefix().$table.
" DROP INDEX IF EXISTS uk_".$table.
"_".$attrname;
624 dol_syslog(get_class($this).
'::update', LOG_DEBUG);
625 $resql = $this->
db->query($sql, 1,
'dml');
632 $this->error = $this->
db->lasterror();
636 $this->error = $this->
db->lasterror();
671 private function update_label($attrname, $label, $type, $size, $elementtype, $unique = 0, $required = 0, $pos = 0, $param =
'', $alwayseditable = 0, $perms =
'', $list =
'0', $help =
'', $default =
'', $computed =
'', $entity =
'', $langfile =
'', $enabled =
'1', $totalizable = 0, $printable = 0)
675 dol_syslog(get_class($this).
"::update_label ".$attrname.
", ".$label.
", ".$type.
", ".$size.
", ".$elementtype.
", ".$unique.
", ".$required.
", ".$pos.
", ".$alwayseditable.
", ".$perms.
", ".$list.
", ".$default.
", ".$computed.
", ".$entity.
", ".$langfile.
", ".$enabled.
", ".$totalizable.
", ".$printable);
678 if ($elementtype ==
'thirdparty') {
679 $elementtype =
'societe';
681 if ($elementtype ==
'contact') {
682 $elementtype =
'socpeople';
691 if (empty($totalizable)) {
694 if (empty($required)) {
697 if (empty($unique)) {
700 if (empty($alwayseditable)) {
704 if (isset($attrname) && $attrname !=
'' && preg_match(
"/^\w[a-zA-Z0-9-_]*$/", $attrname)) {
707 if (is_array($param) && count($param) > 0) {
708 $params = serialize($param);
709 } elseif (strlen($param) > 0) {
710 $params = trim($param);
715 if ($entity ===
'' || $entity !=
'0') {
717 $sql_del =
"DELETE FROM ".$this->db->prefix().
"extrafields";
718 $sql_del .=
" WHERE name = '".$this->db->escape($attrname).
"'";
719 $sql_del .=
" AND entity IN (0, ".($entity ===
'' ? $conf->entity : $entity).
")";
720 $sql_del .=
" AND elementtype = '".$this->db->escape($elementtype).
"'";
723 $sql_del =
"DELETE FROM ".$this->db->prefix().
"extrafields";
724 $sql_del .=
" WHERE name = '".$this->db->escape($attrname).
"'";
725 $sql_del .=
" AND entity = 0";
726 $sql_del .=
" AND elementtype = '".$this->db->escape($elementtype).
"'";
728 $resql1 = $this->
db->query($sql_del);
730 $sql =
"INSERT INTO ".$this->db->prefix().
"extrafields(";
736 $sql .=
" elementtype,";
737 $sql .=
" fieldunique,";
738 $sql .=
" fieldrequired,";
742 $sql .=
" alwayseditable,";
745 $sql .=
" printable,";
746 $sql .=
" totalizable,";
747 $sql .=
" fielddefault,";
748 $sql .=
" fieldcomputed,";
749 $sql .=
" fk_user_author,";
750 $sql .=
" fk_user_modif,";
754 $sql .=
") VALUES (";
755 $sql .=
"'".$this->db->escape($attrname).
"',";
756 $sql .=
" ".($entity ===
'' ? $conf->entity : $entity).
",";
757 $sql .=
" '".$this->db->escape($label).
"',";
758 $sql .=
" '".$this->db->escape($type).
"',";
759 $sql .=
" '".$this->db->escape($size).
"',";
760 $sql .=
" '".$this->db->escape($elementtype).
"',";
761 $sql .=
" ".$unique.
",";
762 $sql .=
" ".$required.
",";
763 $sql .=
" ".($perms ?
"'".$this->db->escape($perms).
"'" :
"null").
",";
764 $sql .=
" ".($langfile ?
"'".$this->db->escape($langfile).
"'" :
"null").
",";
765 $sql .=
" ".$pos.
",";
766 $sql .=
" '".$this->db->escape($alwayseditable).
"',";
767 $sql .=
" '".$this->db->escape($params).
"',";
768 $sql .=
" '".$this->db->escape($list).
"', ";
769 $sql .=
" '".$this->db->escape($printable).
"', ";
770 $sql .=
" ".($totalizable ?
'TRUE' :
'FALSE').
",";
771 $sql .=
" ".(($default !=
'') ?
"'".$this->
db->escape($default).
"'" :
"null").
",";
772 $sql .=
" ".($computed ?
"'".$this->db->escape($computed).
"'" :
"null").
",";
773 $sql .=
" ".$user->id.
",";
774 $sql .=
" ".$user->id.
",";
775 $sql .=
"'".$this->db->idate(
dol_now()).
"',";
776 $sql .=
"'".$this->db->escape($enabled).
"',";
777 $sql .=
" ".($help ?
"'".$this->db->escape($help).
"'" :
"null");
780 $resql2 = $this->
db->query($sql);
782 if ($resql1 && $resql2) {
786 $this->
db->rollback();
809 if (empty($elementtype)) {
813 if ($elementtype ==
'thirdparty') {
814 $elementtype =
'societe';
816 if ($elementtype ==
'contact') {
817 $elementtype =
'socpeople';
819 if ($elementtype ==
'order_supplier') {
820 $elementtype =
'commande_fournisseur';
823 $array_name_label = array();
826 $sql =
"SELECT rowid, name, label, type, size, elementtype, fieldunique, fieldrequired, param, pos, alwayseditable, perms, langs, list, printable, totalizable, fielddefault, fieldcomputed, entity, enabled, help,";
827 $sql .=
" css, cssview, csslist";
828 $sql .=
" FROM ".$this->db->prefix().
"extrafields";
831 $sql .=
" WHERE elementtype = '".$this->db->escape($elementtype).
"'";
833 $sql .=
" ORDER BY pos";
838 while ($tab = $this->
db->fetch_object(
$resql)) {
839 if ($tab->entity != 0 && $tab->entity != $conf->entity) {
841 if ($tab->fieldrequired && is_null($tab->fielddefault)) {
842 $this->attributes[$tab->elementtype][
'mandatoryfieldsofotherentities'][$tab->name] = $tab->type;
848 if ($tab->type !=
'separate') {
849 $array_name_label[$tab->name] = $tab->label;
853 $this->attribute_type[$tab->name] = $tab->type;
854 $this->attribute_label[$tab->name] = $tab->label;
857 $this->attributes[$tab->elementtype][
'type'][$tab->name] = $tab->type;
858 $this->attributes[$tab->elementtype][
'label'][$tab->name] = $tab->label;
859 $this->attributes[$tab->elementtype][
'size'][$tab->name] = $tab->size;
860 $this->attributes[$tab->elementtype][
'elementtype'][$tab->name] = $tab->elementtype;
861 $this->attributes[$tab->elementtype][
'default'][$tab->name] = $tab->fielddefault;
862 $this->attributes[$tab->elementtype][
'computed'][$tab->name] = $tab->fieldcomputed;
863 $this->attributes[$tab->elementtype][
'unique'][$tab->name] = $tab->fieldunique;
864 $this->attributes[$tab->elementtype][
'required'][$tab->name] = $tab->fieldrequired;
865 $this->attributes[$tab->elementtype][
'param'][$tab->name] = ($tab->param ?
jsonOrUnserialize($tab->param) :
'');
866 $this->attributes[$tab->elementtype][
'pos'][$tab->name] = $tab->pos;
867 $this->attributes[$tab->elementtype][
'alwayseditable'][$tab->name] = $tab->alwayseditable;
868 $this->attributes[$tab->elementtype][
'perms'][$tab->name] = ((is_null($tab->perms) || strlen($tab->perms) == 0) ? 1 : $tab->perms);
869 $this->attributes[$tab->elementtype][
'langfile'][$tab->name] = $tab->langs;
870 $this->attributes[$tab->elementtype][
'list'][$tab->name] = $tab->list;
871 $this->attributes[$tab->elementtype][
'printable'][$tab->name] = $tab->printable;
872 $this->attributes[$tab->elementtype][
'totalizable'][$tab->name] = ($tab->totalizable ? 1 : 0);
873 $this->attributes[$tab->elementtype][
'entityid'][$tab->name] = $tab->entity;
874 $this->attributes[$tab->elementtype][
'enabled'][$tab->name] = $tab->enabled;
875 $this->attributes[$tab->elementtype][
'help'][$tab->name] = $tab->help;
876 $this->attributes[$tab->elementtype][
'css'][$tab->name] = $tab->css;
877 $this->attributes[$tab->elementtype][
'cssview'][$tab->name] = $tab->cssview;
878 $this->attributes[$tab->elementtype][
'csslist'][$tab->name] = $tab->csslist;
880 $this->attributes[$tab->elementtype][
'loaded'] = 1;
884 $this->attributes[$elementtype][
'loaded'] = 1;
887 $this->error = $this->
db->lasterror();
888 dol_syslog(get_class($this).
"::fetch_name_optionals_label ".$this->error, LOG_ERR);
891 return $array_name_label;
910 public function showInputField($key, $value, $moreparam =
'', $keysuffix =
'', $keyprefix =
'', $morecss =
'', $objectid = 0, $extrafieldsobjectkey =
'', $mode = 0)
912 global $conf, $langs,
$form;
914 if (!is_object(
$form)) {
915 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
921 if (!preg_match(
'/options_$/', $keyprefix)) {
922 $keyprefix = $keyprefix.
'options_';
925 if (!empty($extrafieldsobjectkey)) {
926 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
927 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
928 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
929 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
930 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
931 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
932 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
933 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
934 $perms =
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'1');
935 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
936 $list =
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'1');
937 $totalizable = $this->attributes[$extrafieldsobjectkey][
'totalizable'][$key];
938 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
939 $hidden = (empty($list) ? 1 : 0);
942 $label = $this->attribute_label[$key];
943 $type = $this->attribute_type[$key];
944 $list = $this->attribute_list[$key];
945 $hidden = (empty($list) ? 1 : 0);
949 if (!preg_match(
'/^search_/', $keyprefix)) {
950 return '<span class="opacitymedium">'.$langs->trans(
"AutomaticallyCalculated").
'</span>';
956 if (empty($morecss)) {
957 if ($type ==
'date') {
958 $morecss =
'minwidth100imp';
959 } elseif ($type ==
'datetime' || $type ==
'link') {
960 $morecss =
'minwidth200imp';
961 } elseif (in_array($type, array(
'int',
'integer',
'double',
'price'))) {
962 $morecss =
'maxwidth75';
963 } elseif ($type ==
'password') {
964 $morecss =
'maxwidth100';
965 } elseif ($type ==
'url') {
966 $morecss =
'minwidth400';
967 } elseif ($type ==
'boolean') {
969 } elseif ($type ==
'radio') {
970 $morecss =
'width25';
972 if (empty($size) || round($size) < 12) {
973 $morecss =
'minwidth100';
974 } elseif (round($size) <= 48) {
975 $morecss =
'minwidth200';
977 $morecss =
'minwidth400';
982 if (in_array($type, array(
'date'))) {
983 $tmp = explode(
',', $size);
988 if (!$required && $value ==
'') {
995 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
996 'end' => isset($value[
'end']) ? $value[
'end'] :
''
998 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
999 $out .=
$form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
1000 $out .=
'</div><div class="nowrap">';
1001 $out .=
$form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1002 $out .=
'</div></div>';
1005 $out =
$form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1);
1007 } elseif (in_array($type, array(
'datetime'))) {
1008 $tmp = explode(
',', $size);
1013 if (!$required && $value ==
'') {
1020 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1021 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1023 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1024 $out .=
$form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"),
'tzuserrel');
1025 $out .=
'</div><div class="nowrap">';
1026 $out .=
$form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
1027 $out .=
'</div></div>';
1030 $out =
$form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1,
'',
'',
'', 1,
'',
'',
'tzuserrel');
1032 } elseif (in_array($type, array(
'int',
'integer'))) {
1033 $tmp = explode(
',', $size);
1035 $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 :
'').
'>';
1036 } elseif (preg_match(
'/varchar/', $type)) {
1037 $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 :
'').
'>';
1038 } elseif (in_array($type, array(
'mail',
'phone',
'url'))) {
1039 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1040 } elseif ($type ==
'text') {
1041 if (!preg_match(
'/search_/', $keyprefix)) {
1042 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1043 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false,
false, ROWS_5,
'90%');
1044 $out = $doleditor->Create(1);
1046 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1048 } elseif ($type ==
'html') {
1049 if (!preg_match(
'/search_/', $keyprefix)) {
1050 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1051 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false, !empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5,
'90%');
1052 $out = $doleditor->Create(1);
1054 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1056 } elseif ($type ==
'boolean') {
1059 if (!empty($value)) {
1060 $checked =
' checked value="1" ';
1062 $checked =
' value="1" ';
1064 $out =
'<input type="checkbox" class="flat valignmiddle'.($morecss ?
' '.$morecss :
'').
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.$checked.
' '.($moreparam ? $moreparam :
'').
'>';
1066 $out .=
$form->selectyesno($keyprefix.$key.$keysuffix, $value, 1,
false, 1);
1068 } elseif ($type ==
'price') {
1069 if (!empty($value)) {
1070 $value =
price($value);
1072 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> '.$langs->getCurrencySymbol($conf->currency);
1073 } elseif ($type ==
'double') {
1074 if (!empty($value)) {
1075 $value =
price($value);
1077 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1078 } elseif ($type ==
'select') {
1082 foreach ($param[
'options'] as $okey => $val) {
1083 if ((
string) $okey ==
'') {
1087 $valarray = explode(
'|', $val);
1088 $val = $valarray[0];
1090 if ($langfile && $val) {
1091 $options[$okey] = $langs->trans($val);
1093 $options[$okey] = $val;
1096 $selected = array();
1097 if (!is_array($value)) {
1098 $selected = explode(
',', $value);
1101 $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));
1103 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_EXTRAFIELDS_DISABLE_SELECT2)) {
1104 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1105 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1108 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1109 $out .=
'<option value="0"> </option>';
1110 foreach ($param[
'options'] as $key => $val) {
1111 if ((
string) $key ==
'') {
1114 $valarray = explode(
'|', $val);
1115 $val = $valarray[0];
1117 if (!empty($valarray[1])) {
1118 $parent = $valarray[1];
1120 $out .=
'<option value="'.$key.
'"';
1121 $out .= (((string) $value == (
string) $key) ?
' selected' :
'');
1122 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1124 if ($langfile && $val) {
1125 $out .= $langs->trans($val);
1129 $out .=
'</option>';
1131 $out .=
'</select>';
1133 } elseif ($type ==
'sellist') {
1135 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_EXTRAFIELDS_DISABLE_SELECT2)) {
1136 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1137 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1140 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1141 if (is_array($param[
'options'])) {
1142 $param_list = array_keys($param[
'options']);
1143 $InfoFieldList = explode(
":", $param_list[0]);
1153 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1156 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1157 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1158 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1160 $keyList = $InfoFieldList[2].
' as rowid';
1163 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1164 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1165 $keyList .=
', '.$parentField;
1168 $filter_categorie =
false;
1169 if (count($InfoFieldList) > 5) {
1170 if ($InfoFieldList[0] ==
'categorie') {
1171 $filter_categorie =
true;
1175 if ($filter_categorie ===
false) {
1176 $fields_label = explode(
'|', $InfoFieldList[1]);
1177 if (is_array($fields_label)) {
1179 $keyList .= implode(
', ', $fields_label);
1183 $sql =
"SELECT ".$keyList;
1184 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1185 if (!empty($InfoFieldList[4])) {
1187 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1188 $InfoFieldList[4] = str_replace(
'$ENTITY$', $conf->entity, $InfoFieldList[4]);
1191 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1192 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1196 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1197 $InfoFieldList[4] = str_replace(
'$ID$', $objectid, $InfoFieldList[4]);
1199 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1202 if (strpos($InfoFieldList[4],
'extra') !==
false) {
1203 $sql .=
' as main, '.$this->db->prefix().$InfoFieldList[0].
'_extrafields as extra';
1204 $sqlwhere .=
" WHERE extra.fk_object=main.".$InfoFieldList[2].
" AND ".$InfoFieldList[4];
1206 $sqlwhere .=
" WHERE ".$InfoFieldList[4];
1209 $sqlwhere .=
' WHERE 1=1';
1212 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1213 $sqlwhere .=
' AND entity = '.((int) $conf->entity);
1218 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1220 dol_syslog(get_class($this).
'::showInputField type=sellist', LOG_DEBUG);
1223 $out .=
'<option value="0"> </option>';
1224 $num = $this->
db->num_rows(
$resql);
1228 $obj = $this->
db->fetch_object(
$resql);
1232 $fields_label = explode(
'|', $InfoFieldList[1]);
1233 if (is_array($fields_label) && count($fields_label) > 1) {
1235 foreach ($fields_label as $field_toshow) {
1236 $labeltoshow .= $obj->$field_toshow.
' ';
1239 $labeltoshow = $obj->{$InfoFieldList[1]};
1241 $labeltoshow = $labeltoshow;
1243 if ($value == $obj->rowid) {
1245 foreach ($fields_label as $field_toshow) {
1246 $translabel = $langs->trans($obj->$field_toshow);
1247 $labeltoshow = $translabel.
' ';
1250 $out .=
'<option value="'.$obj->rowid.
'" selected>'.$labeltoshow.
'</option>';
1253 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1254 $labeltoshow = $translabel;
1256 if (empty($labeltoshow)) {
1257 $labeltoshow =
'(not defined)';
1260 if (!empty($InfoFieldList[3]) && $parentField) {
1261 $parent = $parentName.
':'.$obj->{$parentField};
1264 $out .=
'<option value="'.$obj->rowid.
'"';
1265 $out .= ($value == $obj->rowid ?
' selected' :
'');
1266 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1267 $out .=
'>'.$labeltoshow.
'</option>';
1274 print
'Error in request '.$sql.
' '.$this->
db->lasterror().
'. Check setup of extra parameters.<br>';
1277 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1278 $data =
$form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1279 $out .=
'<option value="0"> </option>';
1280 if (is_array($data)) {
1281 foreach ($data as $data_key => $data_value) {
1282 $out .=
'<option value="'.$data_key.
'"';
1283 $out .= ($value == $data_key ?
' selected' :
'');
1284 $out .=
'>'.$data_value.
'</option>';
1289 $out .=
'</select>';
1290 } elseif ($type ==
'checkbox') {
1291 $value_arr = $value;
1292 if (!is_array($value)) {
1293 $value_arr = explode(
',', $value);
1295 $out =
$form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param[
'options']) ?
null:$param[
'options']), $value_arr,
'', 0,
'', 0,
'100%');
1296 } elseif ($type ==
'radio') {
1298 foreach ($param[
'options'] as $keyopt => $val) {
1299 $out .=
'<input class="flat '.$morecss.
'" type="radio" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'');
1300 $out .=
' value="'.$keyopt.
'"';
1301 $out .=
' id="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'"';
1302 $out .= ($value == $keyopt ?
'checked' :
'');
1303 $out .=
'/><label for="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'">'.$langs->trans($val).
'</label><br>';
1305 } elseif ($type ==
'chkbxlst') {
1306 if (is_array($value)) {
1307 $value_arr = $value;
1309 $value_arr = explode(
',', $value);
1312 if (is_array($param[
'options'])) {
1313 $param_list = array_keys($param[
'options']);
1314 $InfoFieldList = explode(
":", $param_list[0]);
1324 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1326 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1327 list ($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1328 $keyList .=
', '.$parentField;
1330 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1331 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1332 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1334 $keyList = $InfoFieldList[2].
' as rowid';
1338 $filter_categorie =
false;
1339 if (count($InfoFieldList) > 5) {
1340 if ($InfoFieldList[0] ==
'categorie') {
1341 $filter_categorie =
true;
1345 if ($filter_categorie ===
false) {
1346 $fields_label = explode(
'|', $InfoFieldList[1]);
1347 if (is_array($fields_label)) {
1349 $keyList .= implode(
', ', $fields_label);
1353 $sql =
"SELECT ".$keyList;
1354 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1355 if (!empty($InfoFieldList[4])) {
1357 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1358 $InfoFieldList[4] = str_replace(
'$ENTITY$', $conf->entity, $InfoFieldList[4]);
1361 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1362 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1366 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1367 $InfoFieldList[4] = str_replace(
'$ID$', $objectid, $InfoFieldList[4]);
1368 } elseif (preg_match(
"#^.*list.php$#", $_SERVER[
"PHP_SELF"])) {
1370 $word =
'\b[a-zA-Z0-9-\.-_]+\b=\$ID\$';
1373 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1377 while ($nbPreg != 0) {
1379 $nbPregRepl = $nbPregSel = 0;
1381 $InfoFieldList[4] = preg_replace(
'#([^=])(\([^)^(]*('.$word.
')[^)^(]*\))#',
'$1 $3 ', $InfoFieldList[4], -1, $nbPregRepl);
1383 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1385 $InfoFieldList[4] = preg_replace(
'#\b[a-zA-Z0-9-\.-_]+\b=\([^)^(]*('.$word.
')[^)^(]*\)#',
'$1 ', $InfoFieldList[4], -1, $nbPregSel);
1387 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1390 $nbPreg = $nbPregRepl + $nbPregSel;
1394 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1395 while (!empty($matchCondition[0])) {
1397 if (!empty($matchCondition[1]) && !empty($matchCondition[3]) && $matchCondition[1] != $matchCondition[3]) {
1399 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1401 if (!empty($matchCondition[1])) {
1402 $boolCond = (($matchCondition[1] ==
"AND") ?
' AND TRUE ' :
' OR FALSE ');
1403 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond.$matchCondition[3], $InfoFieldList[4]);
1404 } elseif (!empty($matchCondition[3])) {
1405 $boolCond = (($matchCondition[3] ==
"AND") ?
' TRUE AND ' :
' FALSE OR');
1406 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond, $InfoFieldList[4]);
1408 $InfoFieldList[4] =
" TRUE ";
1413 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1416 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1420 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1421 $sql .=
' as main, '.$this->db->prefix().$InfoFieldList[0].
'_extrafields as extra';
1422 $sqlwhere .=
" WHERE extra.fk_object=main.".$InfoFieldList[2].
" AND ".$InfoFieldList[4];
1424 $sqlwhere .=
" WHERE ".$InfoFieldList[4];
1427 $sqlwhere .=
' WHERE 1=1';
1430 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1431 $sqlwhere .=
" AND entity = ".((int) $conf->entity);
1437 dol_syslog(get_class($this).
'::showInputField type=chkbxlst', LOG_DEBUG);
1440 $num = $this->
db->num_rows(
$resql);
1447 $obj = $this->
db->fetch_object(
$resql);
1451 $fields_label = explode(
'|', $InfoFieldList[1]);
1452 if (is_array($fields_label)) {
1454 foreach ($fields_label as $field_toshow) {
1455 $labeltoshow .= $obj->$field_toshow.
' ';
1458 $labeltoshow = $obj->{$InfoFieldList[1]};
1460 $labeltoshow =
dol_trunc($labeltoshow, 45);
1462 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1464 foreach ($fields_label as $field_toshow) {
1465 $translabel = $langs->trans($obj->$field_toshow);
1466 if ($translabel != $obj->$field_toshow) {
1467 $labeltoshow .=
' '.dol_trunc($translabel, 18).
' ';
1469 $labeltoshow .=
' '.dol_trunc($obj->$field_toshow, 18).
' ';
1472 $data[$obj->rowid] = $labeltoshow;
1475 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1476 if ($translabel != $obj->{$InfoFieldList[1]}) {
1477 $labeltoshow =
dol_trunc($translabel, 18);
1479 $labeltoshow =
dol_trunc($obj->{$InfoFieldList[1]}, 18);
1482 if (empty($labeltoshow)) {
1483 $labeltoshow =
'(not defined)';
1486 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1487 $data[$obj->rowid] = $labeltoshow;
1490 if (!empty($InfoFieldList[3]) && $parentField) {
1491 $parent = $parentName.
':'.$obj->{$parentField};
1494 $data[$obj->rowid] = $labeltoshow;
1501 $out =
$form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr,
'', 0,
'', 0,
'100%');
1503 print
'Error in request '.$sql.
' '.$this->
db->lasterror().
'. Check setup of extra parameters.<br>';
1506 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1507 $data =
$form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1508 $out =
$form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr,
'', 0,
'', 0,
'100%');
1511 } elseif ($type ==
'link') {
1512 $param_list = array_keys($param[
'options']);
1513 $showempty = (($required && $default !=
'') ? 0 : 1);
1514 $out =
$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty,
'',
'', $morecss);
1515 } elseif ($type ==
'password') {
1517 $out =
'<input style="display:none" type="text" name="fakeusernameremembered">';
1518 $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 :
'').
'>';
1520 if (!empty($hidden)) {
1521 $out =
'<input type="hidden" value="'.$value.
'" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'"/>';
1543 public function showOutputField($key, $value, $moreparam =
'', $extrafieldsobjectkey =
'')
1545 global $conf, $langs;
1547 if (!empty($extrafieldsobjectkey)) {
1548 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
1549 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1550 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
1551 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
1552 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
1553 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
1554 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
1555 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
1556 $perms =
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'1');
1557 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
1558 $list =
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'1');
1559 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
1560 $hidden = (empty($list) ? 1 : 0);
1563 dol_syslog(get_class($this).
'::showOutputField extrafieldsobjectkey required', LOG_WARNING);
1574 if ($type ==
'date') {
1576 if ($value !==
'') {
1579 } elseif ($type ==
'datetime') {
1581 if ($value !==
'') {
1584 } elseif ($type ==
'int') {
1586 } elseif ($type ==
'double') {
1587 if (!empty($value)) {
1589 $sizeparts = explode(
",", $size);
1590 $number_decimals = array_key_exists(1, $sizeparts) ? $sizeparts[1] : 0;
1591 $value =
price($value, 0, $langs, 0, 0, $number_decimals,
'');
1593 } elseif ($type ==
'boolean') {
1595 if (!empty($value)) {
1596 $checked =
' checked ';
1598 $value =
'<input type="checkbox" '.$checked.
' '.($moreparam ? $moreparam :
'').
' readonly disabled>';
1599 } elseif ($type ==
'mail') {
1601 } elseif ($type ==
'url') {
1603 } elseif ($type ==
'phone') {
1605 } elseif ($type ==
'price') {
1607 if ($value || $value ==
'0') {
1608 $value =
price($value, 0, $langs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1).
' '.$langs->getCurrencySymbol($conf->currency);
1610 } elseif ($type ==
'select') {
1611 $valstr = (!empty($param[
'options'][$value]) ? $param[
'options'][$value] :
'');
1612 if (($pos = strpos($valstr,
"|")) !==
false) {
1613 $valstr = substr($valstr, 0, $pos);
1615 if ($langfile && $valstr) {
1616 $value = $langs->trans($valstr);
1620 } elseif ($type ==
'sellist') {
1621 $param_list = array_keys($param[
'options']);
1622 $InfoFieldList = explode(
":", $param_list[0]);
1624 $selectkey =
"rowid";
1627 if (count($InfoFieldList) >= 3) {
1628 $selectkey = $InfoFieldList[2];
1629 $keyList = $InfoFieldList[2].
' as rowid';
1632 $fields_label = explode(
'|', $InfoFieldList[1]);
1633 if (is_array($fields_label)) {
1635 $keyList .= implode(
', ', $fields_label);
1638 $filter_categorie =
false;
1639 if (count($InfoFieldList) > 5) {
1640 if ($InfoFieldList[0] ==
'categorie') {
1641 $filter_categorie =
true;
1645 $sql =
"SELECT ".$keyList;
1646 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1647 if (!empty($InfoFieldList[4]) && strpos($InfoFieldList[4],
'extra') !==
false) {
1650 if ($selectkey ==
'rowid' && empty($value)) {
1651 $sql .=
" WHERE ".$selectkey.
" = 0";
1652 } elseif ($selectkey ==
'rowid') {
1653 $sql .=
" WHERE ".$selectkey.
" = ".((int) $value);
1655 $sql .=
" WHERE ".$selectkey.
" = '".$this->
db->escape($value).
"'";
1660 dol_syslog(get_class($this).
':showOutputField:$type=sellist', LOG_DEBUG);
1663 if ($filter_categorie ===
false) {
1666 $obj = $this->
db->fetch_object(
$resql);
1669 $fields_label = explode(
'|', $InfoFieldList[1]);
1671 if (is_array($fields_label) && count($fields_label) > 1) {
1672 foreach ($fields_label as $field_toshow) {
1674 if (!empty($obj->$field_toshow)) {
1675 $translabel = $langs->trans($obj->$field_toshow);
1677 if ($translabel != $field_toshow) {
1678 $value .=
dol_trunc($translabel, 18).
' ';
1680 $value .= $obj->$field_toshow.
' ';
1685 $tmppropname = $InfoFieldList[1];
1687 if (!empty(isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
1688 $translabel = $langs->trans($obj->$tmppropname);
1690 if ($translabel != (isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
1693 $value = isset($obj->$tmppropname) ? $obj->$tmppropname :
'';
1698 $obj = $this->
db->fetch_object(
$resql);
1700 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1702 $result = $c->fetch($obj->rowid);
1704 $ways = $c->print_all_ways();
1705 foreach ($ways as $way) {
1706 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ?
' style="background: #' . $c->color .
';"' :
' style="background: #bbb"') .
'>' .
img_object(
'',
'category') .
' ' . $way .
'</li>';
1710 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1713 dol_syslog(get_class($this).
'::showOutputField error '.$this->
db->lasterror(), LOG_WARNING);
1715 } elseif ($type ==
'radio') {
1716 if (!isset($param[
'options'][$value])) {
1717 $langs->load(
'errors');
1718 $value = $langs->trans(
'ErrorNoValueForRadioType');
1720 $value = $langs->trans($param[
'options'][$value]);
1722 } elseif ($type ==
'checkbox') {
1723 $value_arr = explode(
',', $value);
1726 if (is_array($value_arr)) {
1727 foreach ($value_arr as $keyval => $valueval) {
1728 if (!empty($valueval)) {
1729 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$param[
'options'][$valueval].
'</li>';
1733 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1734 } elseif ($type ==
'chkbxlst') {
1735 $value_arr = explode(
',', $value);
1737 $param_list = array_keys($param[
'options']);
1738 $InfoFieldList = explode(
":", $param_list[0]);
1740 $selectkey =
"rowid";
1743 if (count($InfoFieldList) >= 3) {
1744 $selectkey = $InfoFieldList[2];
1745 $keyList = $InfoFieldList[2].
' as rowid';
1748 $fields_label = explode(
'|', $InfoFieldList[1]);
1749 if (is_array($fields_label)) {
1751 $keyList .= implode(
', ', $fields_label);
1754 $filter_categorie =
false;
1755 if (count($InfoFieldList) > 5) {
1756 if ($InfoFieldList[0] ==
'categorie') {
1757 $filter_categorie =
true;
1761 $sql =
"SELECT ".$keyList;
1762 $sql .=
" FROM ".$this->db->prefix().$InfoFieldList[0];
1763 if (strpos($InfoFieldList[4],
'extra') !==
false) {
1769 dol_syslog(get_class($this).
':showOutputField:$type=chkbxlst', LOG_DEBUG);
1772 if ($filter_categorie ===
false) {
1775 while ($obj = $this->
db->fetch_object(
$resql)) {
1777 $fields_label = explode(
'|', $InfoFieldList[1]);
1778 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1779 if (is_array($fields_label) && count($fields_label) > 1) {
1780 $label =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">';
1781 foreach ($fields_label as $field_toshow) {
1783 if (!empty($obj->$field_toshow)) {
1784 $translabel = $langs->trans($obj->$field_toshow);
1786 if ($translabel != $field_toshow) {
1787 $label .=
' '.dol_trunc($translabel, 18);
1789 $label .=
' '.$obj->$field_toshow;
1793 $toprint[] = $label;
1796 if (!empty($obj->{$InfoFieldList[1]})) {
1797 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1799 if ($translabel != $obj->{$InfoFieldList[1]}) {
1800 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).
'</li>';
1802 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->{$InfoFieldList[1]}.
'</li>';
1808 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1811 while ($obj = $this->
db->fetch_object(
$resql)) {
1812 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1814 $c->fetch($obj->rowid);
1815 $ways = $c->print_all_ways();
1816 foreach ($ways as $way) {
1817 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ?
' style="background: #'.$c->color.
';"' :
' style="background: #bbb"').
'>'.
img_object(
'',
'category').
' '.$way.
'</li>';
1822 if (!empty($toprint)) $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1824 dol_syslog(get_class($this).
'::showOutputField error '.$this->
db->lasterror(), LOG_WARNING);
1826 } elseif ($type ==
'link') {
1831 $param_list = array_keys($param[
'options']);
1833 $InfoFieldList = explode(
":", $param_list[0]);
1834 $classname = $InfoFieldList[0];
1835 $classpath = $InfoFieldList[1];
1836 if (!empty($classpath)) {
1838 if ($classname && class_exists($classname)) {
1839 $object =
new $classname($this->
db);
1840 $object->fetch($value);
1841 $value = $object->getNomUrl(3);
1844 dol_syslog(
'Error bad setup of extrafield', LOG_WARNING);
1845 return 'Error bad setup of extrafield';
1848 } elseif ($type ==
'text') {
1850 } elseif ($type ==
'html') {
1852 } elseif ($type ==
'password') {
1853 $value =
dol_trunc(preg_replace(
'/./i',
'*', $value), 8,
'right',
'UTF-8', 1);
1855 $showsize = round((
float) $size);
1856 if ($showsize > 48) {
1876 global $conf, $langs;
1878 if (!empty($extrafieldsobjectkey)) {
1879 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1881 $type = $this->attribute_type[$key];
1886 if ($type ==
'date') {
1887 $cssstring =
"center";
1888 } elseif ($type ==
'datetime') {
1889 $cssstring =
"center";
1890 } elseif ($type ==
'int') {
1891 $cssstring =
"right";
1892 } elseif ($type ==
'price') {
1893 $cssstring =
"right";
1894 } elseif ($type ==
'double') {
1895 $cssstring =
"right";
1896 } elseif ($type ==
'boolean') {
1897 $cssstring =
"center";
1898 } elseif ($type ==
'radio') {
1899 $cssstring =
"center";
1900 } elseif ($type ==
'checkbox') {
1901 $cssstring =
"center";
1902 } elseif ($type ==
'price') {
1903 $cssstring =
"right";
1906 if (!empty($this->attributes[$extrafieldsobjectkey][
'csslist'][$key])) {
1907 $cssstring .= ($cssstring ?
' ' :
'').$this->attributes[$extrafieldsobjectkey][
'csslist'][$key];
1923 public function showSeparator($key, $object, $colspan = 2, $display_type =
'card', $mode =
'')
1925 global $conf, $langs;
1930 if ($display_type==
'line') {
1932 $tagtype_dyn=
'span';
1936 $extrafield_param = $this->attributes[$object->table_element][
'param'][$key];
1937 $extrafield_param_list = array();
1938 if (!empty($extrafield_param) && is_array($extrafield_param)) {
1939 $extrafield_param_list = array_keys($extrafield_param[
'options']);
1941 $extrafield_collapse_display_value = -1;
1942 $expand_display =
false;
1943 if (is_array($extrafield_param_list) && count($extrafield_param_list) > 0) {
1944 $extrafield_collapse_display_value = intval($extrafield_param_list[0]);
1945 $expand_display = ((isset($_COOKIE[
'DOLCOLLAPSE_'.$object->table_element.
'_extrafields_'.$key]) ||
GETPOST(
'ignorecollapsesetup',
'int')) ? ($_COOKIE[
'DOLCOLLAPSE_'.$object->table_element.
'_extrafields_'.$key] ?
true :
false) : ($extrafield_collapse_display_value == 2 ? false :
true));
1947 if ($mode ==
'create') {
1948 $extrafield_collapse_display_value = 0;
1951 $out =
'<'.$tagtype.
' id="trextrafieldseparator'.$key.(!empty($object->id)?
'_'.$object->id:
'').
'" class="trextrafieldseparator trextrafieldseparator'.$key.(!empty($object->id)?
'_'.$object->id:
'').
'">';
1952 $out .=
'<'.$tagtype_dyn.
' '.(!empty($colspan)?
'colspan="' . $colspan .
'"':
'').
'>';
1955 $out .=
'<span class="cursorpointer '.($extrafield_collapse_display_value == 0 ?
'fas fa-square opacitymedium' :
'far fa-'.(($expand_display ?
'minus' :
'plus').
'-square')).
'"></span>';
1958 $out .= $langs->trans($this->attributes[$object->table_element][
'label'][$key]);
1959 $out .=
'</strong>';
1960 $out .=
'</'.$tagtype_dyn.
'>';
1961 $out .=
'</'.$tagtype.
'>';
1963 $collapse_group = $key.(!empty($object->id) ?
'_'.$object->id :
'');
1966 if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) {
1968 $this->expand_display[$collapse_group] = $expand_display;
1970 if (!empty($conf->use_javascript_ajax) && $mode !=
'create') {
1971 $out .=
'<!-- Add js script to manage the collapse/uncollapse of extrafields separators '.$key.
' -->'.
"\n";
1972 $out .=
'<script type="text/javascript">'.
"\n";
1973 $out .=
'jQuery(document).ready(function(){'.
"\n";
1974 if ($expand_display ===
false) {
1975 $out .=
' console.log("Inject js for the collapsing of extrafield '.$key.
' - hide");'.
"\n";
1976 $out .=
' jQuery(".trextrafields_collapse'.$collapse_group.
'").hide();'.
"\n";
1978 $out .=
' console.log("Inject js for collapsing of extrafield '.$key.
' - keep visible and set cookie");'.
"\n";
1979 $out .=
' document.cookie = "DOLCOLLAPSE_'.$object->table_element.
'_extrafields_'.$key.
'=1; path='.$_SERVER[
"PHP_SELF"].
'"'.
"\n";
1981 $out .=
' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?
'_'.$object->id:
'').
'").click(function(){'.
"\n";
1982 $out .=
' console.log("We click on collapse/uncollapse .trextrafields_collapse'.$collapse_group.
'");'.
"\n";
1983 $out .=
' jQuery(".trextrafields_collapse'.$collapse_group.
'").toggle(100, function(){'.
"\n";
1984 $out .=
' if (jQuery(".trextrafields_collapse'.$collapse_group.
'").is(":hidden")) {'.
"\n";
1985 $out .=
' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?
'_'.$object->id:
'').
' '.$tagtype_dyn.
' span").addClass("fa-plus-square").removeClass("fa-minus-square");'.
"\n";
1986 $out .=
' document.cookie = "DOLCOLLAPSE_'.$object->table_element.
'_extrafields_'.$key.
'=0; path='.$_SERVER[
"PHP_SELF"].
'"'.
"\n";
1987 $out .=
' } else {'.
"\n";
1988 $out .=
' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?
'_'.$object->id:
'').
' '.$tagtype_dyn.
' span").addClass("fa-minus-square").removeClass("fa-plus-square");'.
"\n";
1989 $out .=
' document.cookie = "DOLCOLLAPSE_'.$object->table_element.
'_extrafields_'.$key.
'=1; path='.$_SERVER[
"PHP_SELF"].
'"'.
"\n";
1991 $out .=
' });'.
"\n";
1992 $out .=
' });'.
"\n";
1994 $out .=
'</script>'.
"\n";
1997 $this->expand_display[$collapse_group] = 1;
2016 global $_POST, $langs;
2018 $nofillrequired = 0;
2019 $error_field_required = array();
2021 if (isset($this->attributes[$object->table_element][
'label']) && is_array($this->attributes[$object->table_element][
'label'])) {
2022 $extralabels = $this->attributes[$object->table_element][
'label'];
2025 if (is_array($extralabels)) {
2027 foreach ($extralabels as $key => $value) {
2028 if (!empty($onlykey) && $onlykey !=
'@GETPOSTISSET' && $key != $onlykey) {
2032 if (!empty($onlykey) && $onlykey ==
'@GETPOSTISSET' && !
GETPOSTISSET(
'options_'.$key) && (! in_array($this->attributes[$object->table_element][
'type'][$key], array(
'boolean',
'chkbxlst')))) {
2037 $key_type = $this->attributes[$object->table_element][
'type'][$key];
2038 if ($key_type ==
'separate') {
2043 if (isset($this->attributes[$object->table_element][
'enabled'][$key])) {
2044 $enabled =
dol_eval($this->attributes[$object->table_element][
'enabled'][$key], 1, 1,
'1');
2048 if (isset($this->attributes[$object->table_element][
'list'][$key])) {
2049 $visibility = intval(
dol_eval($this->attributes[$object->table_element][
'list'][$key], 1, 1,
'1'));
2053 if (isset($this->attributes[$object->table_element][
'perms'][$key])) {
2054 $perms =
dol_eval($this->attributes[$object->table_element][
'perms'][$key], 1, 1,
'1');
2058 $onlykey ===
'@GETPOSTISSET'
2059 && in_array($this->attributes[$object->table_element][
'type'][$key], array(
'boolean',
'chkbxlst'))
2060 && in_array(abs($enabled), array(2, 5))
2066 if (empty($visibility)) {
2069 if (empty($perms)) {
2073 if ($this->attributes[$object->table_element][
'required'][$key]) {
2077 if ((!is_array($_POST[
"options_".$key]) && empty($_POST[
"options_".$key]) && $this->attributes[$object->table_element][
'type'][$key] !=
'select' && $_POST[
"options_".$key] !=
'0')
2078 || (!is_array($_POST[
"options_".$key]) && empty($_POST[
"options_".$key]) && $this->attributes[$object->table_element][
'type'][$key] ==
'select')
2079 || (!is_array($_POST[
"options_".$key]) && isset($_POST[
"options_".$key]) && $this->attributes[$object->table_element][
'type'][$key] ==
'sellist' && $_POST[
'options_'.$key] ==
'0')
2080 || (is_array($_POST[
"options_".$key]) && empty($_POST[
"options_".$key]))) {
2086 if (!empty($this->attributes[$object->table_element][
'langfile'][$key])) {
2087 $langs->load($this->attributes[$object->table_element][
'langfile'][$key]);
2089 $error_field_required[$key] = $langs->transnoentitiesnoconv($value);
2093 if (in_array($key_type, array(
'date'))) {
2095 $value_key =
dol_mktime(12, 0, 0,
GETPOST(
"options_".$key.
"month",
'int'),
GETPOST(
"options_".$key.
"day",
'int'),
GETPOST(
"options_".$key.
"year",
'int'));
2096 } elseif (in_array($key_type, array(
'datetime'))) {
2098 $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');
2099 } elseif (in_array($key_type, array(
'checkbox',
'chkbxlst'))) {
2100 $value_arr =
GETPOST(
"options_".$key,
'array');
2101 if (!empty($value_arr)) {
2102 $value_key = implode(
',', $value_arr);
2106 } elseif (in_array($key_type, array(
'price',
'double'))) {
2107 $value_arr =
GETPOST(
"options_".$key,
'alpha');
2109 } elseif (in_array($key_type, array(
'html'))) {
2110 $value_key =
GETPOST(
"options_".$key,
'restricthtml');
2111 } elseif (in_array($key_type, array(
'text'))) {
2112 $value_key =
GETPOST(
"options_".$key,
'alphanohtml');
2114 $value_key =
GETPOST(
"options_".$key);
2115 if (in_array($key_type, array(
'link')) && $value_key ==
'-1') {
2120 if (!empty($error_field_required[$key]) && $todefaultifmissing) {
2122 if (!empty($this->attributes[$object->table_element][
'default']) && !is_null($this->attributes[$object->table_element][
'default'][$key])) {
2123 $value_key = $this->attributes[$object->table_element][
'default'][$key];
2124 unset($error_field_required[$key]);
2129 $object->array_options[
"options_".$key] = $value_key;
2132 if ($nofillrequired) {
2133 $langs->load(
'errors');
2134 $this->error = $langs->trans(
'ErrorFieldsRequired').
' : '.implode(
', ', $error_field_required);
2157 if (is_string($extrafieldsobjectkey) && !empty($this->attributes[$extrafieldsobjectkey][
'label']) && is_array($this->attributes[$extrafieldsobjectkey][
'label'])) {
2158 $extralabels = $this->attributes[$extrafieldsobjectkey][
'label'];
2160 $extralabels = $extrafieldsobjectkey;
2163 if (is_array($extralabels)) {
2164 $array_options = array();
2167 foreach ($extralabels as $key => $value) {
2169 if (is_string($extrafieldsobjectkey)) {
2170 $key_type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
2173 if (in_array($key_type, array(
'date'))) {
2174 $dateparamname_start = $keysuffix .
'options_' . $key . $keyprefix .
'_start';
2175 $dateparamname_end = $keysuffix .
'options_' . $key . $keyprefix .
'_end';
2179 'start' =>
dol_mktime(0, 0, 0,
GETPOST($dateparamname_start .
'month',
'int'),
GETPOST($dateparamname_start .
'day',
'int'),
GETPOST($dateparamname_start .
'year',
'int')),
2180 'end' =>
dol_mktime(23, 59, 59,
GETPOST($dateparamname_end .
'month',
'int'),
GETPOST($dateparamname_end .
'day',
'int'),
GETPOST($dateparamname_end .
'year',
'int'))
2182 } elseif (
GETPOSTISSET($keysuffix.
"options_".$key.$keyprefix.
"year")) {
2184 $value_key =
dol_mktime(12, 0, 0,
GETPOST($keysuffix.
"options_".$key.$keyprefix.
"month",
'int'),
GETPOST($keysuffix.
"options_".$key.$keyprefix.
"day",
'int'),
GETPOST($keysuffix.
"options_".$key.$keyprefix.
"year",
'int'));
2188 } elseif (in_array($key_type, array(
'datetime'))) {
2189 $dateparamname_start = $keysuffix .
'options_' . $key . $keyprefix .
'_start';
2190 $dateparamname_end = $keysuffix .
'options_' . $key . $keyprefix .
'_end';
2193 $dateparamname_end_hour =
GETPOST($dateparamname_end .
'hour',
'int') !=
'-1' ?
GETPOST($dateparamname_end .
'hour',
'int') :
'23';
2194 $dateparamname_end_min =
GETPOST($dateparamname_end .
'min',
'int') !=
'-1' ?
GETPOST($dateparamname_end .
'min',
'int') :
'59';
2195 $dateparamname_end_sec =
GETPOST($dateparamname_end .
'sec',
'int') !=
'-1' ?
GETPOST($dateparamname_end .
'sec',
'int') :
'59';
2197 'start' =>
dol_mktime(
GETPOST($dateparamname_start .
'hour',
'int'),
GETPOST($dateparamname_start .
'min',
'int'),
GETPOST($dateparamname_start .
'sec',
'int'),
GETPOST($dateparamname_start .
'month',
'int'),
GETPOST($dateparamname_start .
'day',
'int'),
GETPOST($dateparamname_start .
'year',
'int'),
'tzuserrel'),
2198 'end' =>
dol_mktime($dateparamname_end_hour, $dateparamname_end_min, $dateparamname_end_sec,
GETPOST($dateparamname_end .
'month',
'int'),
GETPOST($dateparamname_end .
'day',
'int'),
GETPOST($dateparamname_end .
'year',
'int'),
'tzuserrel')
2200 } elseif (
GETPOSTISSET($keysuffix.
"options_".$key.$keyprefix.
"year")) {
2202 $value_key =
dol_mktime(
GETPOST($keysuffix.
"options_".$key.$keyprefix.
"hour",
'int'),
GETPOST($keysuffix.
"options_".$key.$keyprefix.
"min",
'int'),
GETPOST($keysuffix.
"options_".$key.$keyprefix.
"sec",
'int'),
GETPOST($keysuffix.
"options_".$key.$keyprefix.
"month",
'int'),
GETPOST($keysuffix.
"options_".$key.$keyprefix.
"day",
'int'),
GETPOST($keysuffix.
"options_".$key.$keyprefix.
"year",
'int'),
'tzuserrel');
2206 } elseif ($key_type ==
'select') {
2209 $value_arr =
GETPOST($keysuffix.
"options_".$key.$keyprefix,
'array:aZ09');
2211 $value_arr = (array) $value_arr;
2212 $value_key = implode(
',', $value_arr);
2214 $value_key =
GETPOST($keysuffix.
"options_".$key.$keyprefix);
2216 } elseif (in_array($key_type, array(
'checkbox',
'chkbxlst'))) {
2217 if (!
GETPOSTISSET($keysuffix.
"options_".$key.$keyprefix)) {
2220 $value_arr =
GETPOST($keysuffix.
"options_".$key.$keyprefix);
2222 $value_arr = (array) $value_arr;
2223 $value_key = implode(
',', $value_arr);
2224 } elseif (in_array($key_type, array(
'price',
'double',
'int'))) {
2225 if (!
GETPOSTISSET($keysuffix.
"options_".$key.$keyprefix)) {
2228 $value_arr =
GETPOST($keysuffix.
"options_".$key.$keyprefix);
2229 if ($keysuffix !=
'search_') {
2232 $value_key = $value_arr;
2234 } elseif (in_array($key_type, array(
'boolean'))) {
2235 if (!
GETPOSTISSET($keysuffix.
"options_".$key.$keyprefix)) {
2238 $value_arr =
GETPOST($keysuffix.
"options_".$key.$keyprefix);
2239 $value_key = $value_arr;
2242 if (!
GETPOSTISSET($keysuffix.
"options_".$key.$keyprefix)) {
2245 $value_key =
GETPOST($keysuffix.
"options_".$key.$keyprefix);
2248 $array_options[$keysuffix.
"options_".$key] = $value_key;
2251 return $array_options;