49 public $attribute_type;
55 public $attribute_label;
61 public $attribute_choice;
67 public $attribute_list;
77 public $expand_display;
87 public $errors = array();
95 public static $type2label = array(
96 'varchar'=>
'String1Line',
97 'text'=>
'TextLongNLines',
102 'datetime'=>
'DateAndTime',
103 'boolean'=>
'Boolean',
104 'price'=>
'ExtrafieldPrice',
105 'phone'=>
'ExtrafieldPhone',
106 'mail'=>
'ExtrafieldMail',
107 'url'=>
'ExtrafieldUrl',
108 'password' =>
'ExtrafieldPassword',
109 'select' =>
'ExtrafieldSelect',
110 'sellist' =>
'ExtrafieldSelectList',
111 'radio' =>
'ExtrafieldRadio',
112 'checkbox' =>
'ExtrafieldCheckBox',
113 'chkbxlst' =>
'ExtrafieldCheckBoxFromList',
114 'link' =>
'ExtrafieldLink',
115 'separate' =>
'ExtrafieldSeparator',
128 $this->errors = array();
129 $this->attributes = array();
132 $this->attribute_type = array();
133 $this->attribute_label = array();
161 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)
163 if (empty($attrname)) {
172 if ($type ==
'separate') {
176 if ($elementtype ==
'thirdparty') {
177 $elementtype =
'societe';
179 if ($elementtype ==
'contact') {
180 $elementtype =
'socpeople';
184 if ($type !=
'separate') {
185 $result = $this->
create($attrname, $type, $size, $elementtype, $unique, $required, $default_value, $param, $perms, $list, $computed, $help);
187 $err1 = $this->errno;
188 if ($result > 0 || $err1 ==
'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type ==
'separate') {
190 $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);
191 $err2 = $this->errno;
192 if ($result2 > 0 || ($err1 ==
'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 ==
'DB_ERROR_RECORD_ALREADY_EXISTS')) {
222 private function create($attrname, $type =
'varchar', $length = 255, $elementtype =
'member', $unique = 0, $required = 0, $default_value =
'', $param =
'', $perms =
'', $list =
'0', $computed =
'', $help =
'')
224 if ($elementtype ==
'thirdparty') {
225 $elementtype =
'societe';
227 if ($elementtype ==
'contact') {
228 $elementtype =
'socpeople';
231 $table = $elementtype.
'_extrafields';
232 if ($elementtype ==
'categorie') {
233 $table =
'categories_extrafields';
236 if (!empty($attrname) && preg_match(
"/^\w[a-zA-Z0-9_]*$/", $attrname) && !is_numeric($attrname)) {
237 if ($type ==
'boolean') {
240 } elseif ($type ==
'price') {
243 } elseif ($type ==
'phone') {
246 } elseif ($type ==
'mail') {
249 } elseif ($type ==
'url') {
252 } elseif (($type ==
'select') || ($type ==
'sellist') || ($type ==
'radio') || ($type ==
'checkbox') || ($type ==
'chkbxlst')) {
255 } elseif ($type ==
'link') {
258 } elseif ($type ==
'html') {
261 } elseif ($type ==
'password') {
267 if ($type ==
'varchar' && empty($lengthdb)) {
274 'null'=>($required ?
'NOT NULL' :
'NULL'),
275 'default' => $default_value
278 $result = $this->
db->DDLAddField($this->
db->prefix().$table, $attrname, $field_desc);
281 $sql =
"ALTER TABLE ".$this->db->prefix().$table.
" ADD UNIQUE INDEX uk_".$table.
"_".$attrname.
" (".$attrname.
")";
282 $resql = $this->
db->query($sql, 1,
'dml');
286 $this->error = $this->
db->lasterror();
287 $this->errno = $this->
db->lasterrno();
322 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)
327 if ($elementtype ==
'thirdparty') {
328 $elementtype =
'societe';
330 if ($elementtype ==
'contact') {
331 $elementtype =
'socpeople';
341 if (empty($required)) {
344 if (empty($unique)) {
347 if (empty($printable)) {
350 if (empty($alwayseditable)) {
353 if (empty($totalizable)) {
357 if (!empty($attrname) && preg_match(
"/^\w[a-zA-Z0-9-_]*$/", $attrname) && !is_numeric($attrname)) {
358 if (is_array($param) && count($param) > 0) {
359 $params = serialize($param);
360 } elseif (strlen($param) > 0) {
361 $params = trim($param);
366 $sql =
"INSERT INTO ".$this->db->prefix().
"extrafields(";
373 $sql .=
" elementtype,";
374 $sql .=
" fieldunique,";
375 $sql .=
" fieldrequired,";
377 $sql .=
" alwayseditable,";
381 $sql .=
" printable,";
382 $sql .=
" fielddefault,";
383 $sql .=
" fieldcomputed,";
384 $sql .=
" fk_user_author,";
385 $sql .=
" fk_user_modif,";
389 $sql .=
" totalizable";
391 $sql .=
" VALUES('".$this->db->escape($attrname).
"',";
392 $sql .=
" '".$this->db->escape($label).
"',";
393 $sql .=
" '".$this->db->escape($type).
"',";
394 $sql .=
" ".((int) $pos).
",";
395 $sql .=
" '".$this->db->escape($size).
"',";
396 $sql .=
" ".($entity ===
'' ? $conf->entity : $entity).
",";
397 $sql .=
" '".$this->db->escape($elementtype).
"',";
398 $sql .=
" ".((int) $unique).
",";
399 $sql .=
" ".((int) $required).
",";
400 $sql .=
" '".$this->db->escape($params).
"',";
401 $sql .=
" ".((int) $alwayseditable).
",";
402 $sql .=
" ".($perms ?
"'".$this->db->escape($perms).
"'" :
"null").
",";
403 $sql .=
" ".($langfile ?
"'".$this->db->escape($langfile).
"'" :
"null").
",";
404 $sql .=
" '".$this->db->escape($list).
"',";
405 $sql .=
" '".$this->db->escape($printable).
"',";
406 $sql .=
" ".($default ?
"'".$this->db->escape($default).
"'" :
"null").
",";
407 $sql .=
" ".($computed ?
"'".$this->db->escape($computed).
"'" :
"null").
",";
408 $sql .=
" ".(is_object($user) ? $user->id : 0).
",";
409 $sql .=
" ".(is_object($user) ? $user->id : 0).
",";
410 $sql .=
"'".$this->db->idate(
dol_now()).
"',";
411 $sql .=
" ".($enabled ?
"'".$this->db->escape($enabled).
"'" :
"1").
",";
412 $sql .=
" ".($help ?
"'".$this->db->escape($help).
"'" :
"null").
",";
413 $sql .=
" ".($totalizable ?
'TRUE' :
'FALSE');
416 dol_syslog(get_class($this).
"::create_label", LOG_DEBUG);
417 if ($this->
db->query($sql)) {
420 $this->error = $this->
db->lasterror();
421 $this->errno = $this->
db->lasterrno();
434 public function delete($attrname, $elementtype =
'member')
436 if ($elementtype ==
'thirdparty') {
437 $elementtype =
'societe';
439 if ($elementtype ==
'contact') {
440 $elementtype =
'socpeople';
443 $table = $elementtype.
'_extrafields';
444 if ($elementtype ==
'categorie') {
445 $table =
'categories_extrafields';
450 if (!empty($attrname) && preg_match(
"/^\w[a-zA-Z0-9-_]*$/", $attrname)) {
453 $this->error = $this->
db->lasterror();
454 $this->errors[] = $this->
db->lasterror();
459 $sql =
"SELECT COUNT(rowid) as nb";
460 $sql .=
" FROM ".$this->db->prefix().
"extrafields";
461 $sql .=
" WHERE elementtype = '".$this->db->escape($elementtype).
"'";
462 $sql .=
" AND name = '".$this->db->escape($attrname).
"'";
466 $obj = $this->
db->fetch_object(
$resql);
468 $result = $this->
db->DDLDropField($this->
db->prefix().$table, $attrname);
470 $this->error = $this->
db->lasterror();
471 $this->errors[] = $this->
db->lasterror();
497 if ($elementtype ==
'thirdparty') {
498 $elementtype =
'societe';
500 if ($elementtype ==
'contact') {
501 $elementtype =
'socpeople';
504 if (isset($attrname) && $attrname !=
'' && preg_match(
"/^\w[a-zA-Z0-9-_]*$/", $attrname)) {
505 $sql =
"DELETE FROM ".$this->db->prefix().
"extrafields";
506 $sql .=
" WHERE name = '".$this->db->escape($attrname).
"'";
507 $sql .=
" AND entity IN (0,".$conf->entity.
')';
508 $sql .=
" AND elementtype = '".$this->db->escape($elementtype).
"'";
510 dol_syslog(get_class($this).
"::delete_label", LOG_DEBUG);
549 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)
553 if ($elementtype ==
'thirdparty') {
554 $elementtype =
'societe';
556 if ($elementtype ==
'contact') {
557 $elementtype =
'socpeople';
560 $table = $elementtype.
'_extrafields';
561 if ($elementtype ==
'categorie') {
562 $table =
'categories_extrafields';
565 if (isset($attrname) && $attrname !=
'' && preg_match(
"/^\w[a-zA-Z0-9-_]*$/", $attrname)) {
566 if ($type ==
'boolean') {
569 } elseif ($type ==
'price') {
572 } elseif ($type ==
'phone') {
575 } elseif ($type ==
'mail') {
578 } elseif ($type ==
'url') {
581 } elseif (($type ==
'select') || ($type ==
'sellist') || ($type ==
'radio') || ($type ==
'checkbox') || ($type ==
'chkbxlst')) {
584 } elseif ($type ==
'html') {
586 } elseif ($type ==
'link') {
589 } elseif ($type ==
'password') {
596 $field_desc = array(
'type'=>$typedb,
'value'=>$lengthdb,
'null'=>($required ?
'NOT NULL' :
'NULL'),
'default'=>$default);
598 if (is_object($hookmanager)) {
599 $hookmanager->initHooks(array(
'extrafieldsdao'));
600 $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);
601 $reshook = $hookmanager->executeHooks(
'updateExtrafields', $parameters, $this, $action);
604 $this->error = $this->
db->lasterror();
609 if ($type !=
'separate') {
610 $result = $this->
db->DDLUpdateField($this->
db->prefix().$table, $attrname, $field_desc);
612 if ($result > 0 || $type ==
'separate') {
614 $result = $this->
update_label($attrname, $label, $type, $length, $elementtype, $unique, $required, $pos, $param, $alwayseditable, $perms, $list, $help, $default, $computed, $entity, $langfile, $enabled, $totalizable, $printable);
619 $sql =
"ALTER TABLE ".$this->db->prefix().$table.
" ADD UNIQUE INDEX uk_".$table.
"_".$attrname.
" (".$attrname.
")";
621 $sql =
"ALTER TABLE ".$this->db->prefix().$table.
" DROP INDEX IF EXISTS uk_".$table.
"_".$attrname;
623 dol_syslog(get_class($this).
'::update', LOG_DEBUG);
624 $resql = $this->
db->query($sql, 1,
'dml');
631 $this->error = $this->
db->lasterror();
635 $this->error = $this->
db->lasterror();
670 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)
674 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);
677 if ($elementtype ==
'thirdparty') {
678 $elementtype =
'societe';
680 if ($elementtype ==
'contact') {
681 $elementtype =
'socpeople';
690 if (empty($totalizable)) {
693 if (empty($required)) {
696 if (empty($unique)) {
699 if (empty($alwayseditable)) {
703 if (isset($attrname) && $attrname !=
'' && preg_match(
"/^\w[a-zA-Z0-9-_]*$/", $attrname)) {
706 if (is_array($param) && count($param) > 0) {
707 $params = serialize($param);
708 } elseif (strlen($param) > 0) {
709 $params = trim($param);
714 if ($entity ===
'' || $entity !=
'0') {
716 $sql_del =
"DELETE FROM ".$this->db->prefix().
"extrafields";
717 $sql_del .=
" WHERE name = '".$this->db->escape($attrname).
"'";
718 $sql_del .=
" AND entity IN (0, ".($entity ===
'' ? $conf->entity : $entity).
")";
719 $sql_del .=
" AND elementtype = '".$this->db->escape($elementtype).
"'";
722 $sql_del =
"DELETE FROM ".$this->db->prefix().
"extrafields";
723 $sql_del .=
" WHERE name = '".$this->db->escape($attrname).
"'";
724 $sql_del .=
" AND entity = 0";
725 $sql_del .=
" AND elementtype = '".$this->db->escape($elementtype).
"'";
727 $resql1 = $this->
db->query($sql_del);
729 $sql =
"INSERT INTO ".$this->db->prefix().
"extrafields(";
735 $sql .=
" elementtype,";
736 $sql .=
" fieldunique,";
737 $sql .=
" fieldrequired,";
741 $sql .=
" alwayseditable,";
744 $sql .=
" printable,";
745 $sql .=
" totalizable,";
746 $sql .=
" fielddefault,";
747 $sql .=
" fieldcomputed,";
748 $sql .=
" fk_user_author,";
749 $sql .=
" fk_user_modif,";
753 $sql .=
") VALUES (";
754 $sql .=
"'".$this->db->escape($attrname).
"',";
755 $sql .=
" ".($entity ===
'' ? $conf->entity : $entity).
",";
756 $sql .=
" '".$this->db->escape($label).
"',";
757 $sql .=
" '".$this->db->escape($type).
"',";
758 $sql .=
" '".$this->db->escape($size).
"',";
759 $sql .=
" '".$this->db->escape($elementtype).
"',";
760 $sql .=
" ".$unique.
",";
761 $sql .=
" ".$required.
",";
762 $sql .=
" ".($perms ?
"'".$this->db->escape($perms).
"'" :
"null").
",";
763 $sql .=
" ".($langfile ?
"'".$this->db->escape($langfile).
"'" :
"null").
",";
764 $sql .=
" ".$pos.
",";
765 $sql .=
" '".$this->db->escape($alwayseditable).
"',";
766 $sql .=
" '".$this->db->escape($params).
"',";
767 $sql .=
" '".$this->db->escape($list).
"', ";
768 $sql .=
" '".$this->db->escape($printable).
"', ";
769 $sql .=
" ".($totalizable ?
'TRUE' :
'FALSE').
",";
770 $sql .=
" ".(($default !=
'') ?
"'".$this->
db->escape($default).
"'" :
"null").
",";
771 $sql .=
" ".($computed ?
"'".$this->db->escape($computed).
"'" :
"null").
",";
772 $sql .=
" ".$user->id.
",";
773 $sql .=
" ".$user->id.
",";
774 $sql .=
"'".$this->db->idate(
dol_now()).
"',";
775 $sql .=
"'".$this->db->escape($enabled).
"',";
776 $sql .=
" ".($help ?
"'".$this->db->escape($help).
"'" :
"null");
779 $resql2 = $this->
db->query($sql);
781 if ($resql1 && $resql2) {
785 $this->
db->rollback();
808 if (empty($elementtype)) {
812 if ($elementtype ==
'thirdparty') {
813 $elementtype =
'societe';
815 if ($elementtype ==
'contact') {
816 $elementtype =
'socpeople';
818 if ($elementtype ==
'order_supplier') {
819 $elementtype =
'commande_fournisseur';
822 $array_name_label = array();
825 $sql =
"SELECT rowid, name, label, type, size, elementtype, fieldunique, fieldrequired, param, pos, alwayseditable, perms, langs, list, printable, totalizable, fielddefault, fieldcomputed, entity, enabled, help,";
826 $sql .=
" css, cssview, csslist";
827 $sql .=
" FROM ".$this->db->prefix().
"extrafields";
830 $sql .=
" WHERE elementtype = '".$this->db->escape($elementtype).
"'";
832 $sql .=
" ORDER BY pos";
837 while ($tab = $this->
db->fetch_object(
$resql)) {
838 if ($tab->entity != 0 && $tab->entity != $conf->entity) {
840 if ($tab->fieldrequired && is_null($tab->fielddefault)) {
841 $this->attributes[$tab->elementtype][
'mandatoryfieldsofotherentities'][$tab->name] = $tab->type;
847 if ($tab->type !=
'separate') {
848 $array_name_label[$tab->name] = $tab->label;
852 $this->attribute_type[$tab->name] = $tab->type;
853 $this->attribute_label[$tab->name] = $tab->label;
856 $this->attributes[$tab->elementtype][
'type'][$tab->name] = $tab->type;
857 $this->attributes[$tab->elementtype][
'label'][$tab->name] = $tab->label;
858 $this->attributes[$tab->elementtype][
'size'][$tab->name] = $tab->size;
859 $this->attributes[$tab->elementtype][
'elementtype'][$tab->name] = $tab->elementtype;
860 $this->attributes[$tab->elementtype][
'default'][$tab->name] = $tab->fielddefault;
861 $this->attributes[$tab->elementtype][
'computed'][$tab->name] = $tab->fieldcomputed;
862 $this->attributes[$tab->elementtype][
'unique'][$tab->name] = $tab->fieldunique;
863 $this->attributes[$tab->elementtype][
'required'][$tab->name] = $tab->fieldrequired;
864 $this->attributes[$tab->elementtype][
'param'][$tab->name] = ($tab->param ?
jsonOrUnserialize($tab->param) :
'');
865 $this->attributes[$tab->elementtype][
'pos'][$tab->name] = $tab->pos;
866 $this->attributes[$tab->elementtype][
'alwayseditable'][$tab->name] = $tab->alwayseditable;
867 $this->attributes[$tab->elementtype][
'perms'][$tab->name] = ((is_null($tab->perms) || strlen($tab->perms) == 0) ? 1 : $tab->perms);
868 $this->attributes[$tab->elementtype][
'langfile'][$tab->name] = $tab->langs;
869 $this->attributes[$tab->elementtype][
'list'][$tab->name] = $tab->list;
870 $this->attributes[$tab->elementtype][
'printable'][$tab->name] = $tab->printable;
871 $this->attributes[$tab->elementtype][
'totalizable'][$tab->name] = ($tab->totalizable ? 1 : 0);
872 $this->attributes[$tab->elementtype][
'entityid'][$tab->name] = $tab->entity;
873 $this->attributes[$tab->elementtype][
'enabled'][$tab->name] = $tab->enabled;
874 $this->attributes[$tab->elementtype][
'help'][$tab->name] = $tab->help;
875 $this->attributes[$tab->elementtype][
'css'][$tab->name] = $tab->css;
876 $this->attributes[$tab->elementtype][
'cssview'][$tab->name] = $tab->cssview;
877 $this->attributes[$tab->elementtype][
'csslist'][$tab->name] = $tab->csslist;
879 $this->attributes[$tab->elementtype][
'loaded'] = 1;
883 $this->attributes[$elementtype][
'loaded'] = 1;
886 $this->error = $this->
db->lasterror();
887 dol_syslog(get_class($this).
"::fetch_name_optionals_label ".$this->error, LOG_ERR);
890 return $array_name_label;
909 public function showInputField($key, $value, $moreparam =
'', $keysuffix =
'', $keyprefix =
'', $morecss =
'', $objectid = 0, $extrafieldsobjectkey =
'', $mode = 0)
911 global $conf, $langs,
$form;
913 if (!is_object($form)) {
914 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
915 $form =
new Form($this->
db);
920 if (!preg_match(
'/options_$/', $keyprefix)) {
921 $keyprefix = $keyprefix.
'options_';
924 if (!empty($extrafieldsobjectkey)) {
925 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
926 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
927 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
928 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
929 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
930 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
931 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
932 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
933 $perms =
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'1');
934 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
935 $list =
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'1');
936 $totalizable = $this->attributes[$extrafieldsobjectkey][
'totalizable'][$key];
937 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
938 $hidden = (empty($list) ? 1 : 0);
941 $label = $this->attribute_label[$key];
942 $type = $this->attribute_type[$key];
943 $list = $this->attribute_list[$key];
944 $hidden = (empty($list) ? 1 : 0);
948 if (!preg_match(
'/^search_/', $keyprefix)) {
949 return '<span class="opacitymedium">'.$langs->trans(
"AutomaticallyCalculated").
'</span>';
955 if (empty($morecss)) {
956 if ($type ==
'date') {
957 $morecss =
'minwidth100imp';
958 } elseif ($type ==
'datetime' || $type ==
'link') {
959 $morecss =
'minwidth200imp';
960 } elseif (in_array($type, array(
'int',
'integer',
'double',
'price'))) {
961 $morecss =
'maxwidth75';
962 } elseif ($type ==
'password') {
963 $morecss =
'maxwidth100';
964 } elseif ($type ==
'url') {
965 $morecss =
'minwidth400';
966 } elseif ($type ==
'boolean') {
968 } elseif ($type ==
'radio') {
969 $morecss =
'width25';
971 if (empty($size) || round($size) < 12) {
972 $morecss =
'minwidth100';
973 } elseif (round($size) <= 48) {
974 $morecss =
'minwidth200';
976 $morecss =
'minwidth400';
981 if (in_array($type, array(
'date'))) {
982 $tmp = explode(
',', $size);
987 if (!$required && $value ==
'') {
994 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
995 'end' => isset($value[
'end']) ? $value[
'end'] :
''
997 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
998 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
999 $out .=
'</div><div class="nowrap">';
1000 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
1001 $out .=
'</div></div>';
1004 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1);
1006 } elseif (in_array($type, array(
'datetime'))) {
1007 $tmp = explode(
',', $size);
1012 if (!$required && $value ==
'') {
1019 'start' => isset($value[
'start']) ? $value[
'start'] :
'',
1020 'end' => isset($value[
'end']) ? $value[
'end'] :
''
1022 $out =
'<div ' . ($moreparam ? $moreparam :
'') .
'><div class="nowrap">';
1023 $out .= $form->selectDate($prefill[
'start'], $keyprefix.$key.$keysuffix.
'_start', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"),
'tzuserrel');
1024 $out .=
'</div><div class="nowrap">';
1025 $out .= $form->selectDate($prefill[
'end'], $keyprefix.$key.$keysuffix.
'_end', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
1026 $out .=
'</div></div>';
1029 $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required,
'', 1, (($keyprefix !=
'search_' && $keyprefix !=
'search_options_') ? 1 : 0), 0, 1,
'',
'',
'', 1,
'',
'',
'tzuserrel');
1031 } elseif (in_array($type, array(
'int',
'integer'))) {
1032 $tmp = explode(
',', $size);
1034 $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 :
'').
'>';
1035 } elseif (preg_match(
'/varchar/', $type)) {
1036 $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 :
'').
'>';
1037 } elseif (in_array($type, array(
'mail',
'phone',
'url'))) {
1038 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1039 } elseif ($type ==
'text') {
1040 if (!preg_match(
'/search_/', $keyprefix)) {
1041 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1042 $doleditor =
new DolEditor($keyprefix.$key.$keysuffix, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false,
false, ROWS_5,
'90%');
1043 $out = $doleditor->Create(1);
1045 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1047 } elseif ($type ==
'html') {
1048 if (!preg_match(
'/search_/', $keyprefix)) {
1049 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1050 $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%');
1051 $out = $doleditor->Create(1);
1053 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.
dol_escape_htmltag($value).
'" '.($moreparam ? $moreparam :
'').
'>';
1055 } elseif ($type ==
'boolean') {
1058 if (!empty($value)) {
1059 $checked =
' checked value="1" ';
1061 $checked =
' value="1" ';
1063 $out =
'<input type="checkbox" class="flat valignmiddle'.($morecss ?
' '.$morecss :
'').
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.$checked.
' '.($moreparam ? $moreparam :
'').
'>';
1065 $out .= $form->selectyesno($keyprefix.$key.$keysuffix, $value, 1,
false, 1);
1067 } elseif ($type ==
'price') {
1068 if (!empty($value)) {
1069 $value =
price($value);
1071 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> '.$langs->getCurrencySymbol($conf->currency);
1072 } elseif ($type ==
'double') {
1073 if (!empty($value)) {
1074 $value =
price($value);
1076 $out =
'<input type="text" class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" value="'.$value.
'" '.($moreparam ? $moreparam :
'').
'> ';
1077 } elseif ($type ==
'select') {
1081 foreach ($param[
'options'] as $okey => $val) {
1082 if ((
string) $okey ==
'') {
1086 if ($langfile && $val) {
1087 $options[$okey] = $langs->trans($val);
1089 $options[$okey] = $val;
1092 $selected = array();
1093 if (!is_array($value)) {
1094 $selected = explode(
',', $value);
1097 $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));
1099 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_EXTRAFIELDS_DISABLE_SELECT2)) {
1100 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1101 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1104 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1105 $out .=
'<option value="0"> </option>';
1106 foreach ($param[
'options'] as $key => $val) {
1107 if ((
string) $key ==
'') {
1110 $valarray = explode(
'|', $val);
1111 $val = $valarray[0];
1113 if (!empty($valarray[1])) {
1114 $parent = $valarray[1];
1116 $out .=
'<option value="'.$key.
'"';
1117 $out .= (((string) $value == (
string) $key) ?
' selected' :
'');
1118 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1120 if ($langfile && $val) {
1121 $out .= $langs->trans($val);
1125 $out .=
'</option>';
1127 $out .=
'</select>';
1129 } elseif ($type ==
'sellist') {
1131 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_EXTRAFIELDS_DISABLE_SELECT2)) {
1132 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1133 $out .=
ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
1136 $out .=
'<select class="flat '.$morecss.
' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'').
'>';
1137 if (is_array($param[
'options'])) {
1138 $param_list = array_keys($param[
'options']);
1139 $InfoFieldList = explode(
":", $param_list[0]);
1149 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1152 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1153 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1154 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1156 $keyList = $InfoFieldList[2].
' as rowid';
1159 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1160 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1161 $keyList .=
', '.$parentField;
1164 $filter_categorie =
false;
1165 if (count($InfoFieldList) > 5) {
1166 if ($InfoFieldList[0] ==
'categorie') {
1167 $filter_categorie =
true;
1171 if ($filter_categorie ===
false) {
1172 $fields_label = explode(
'|', $InfoFieldList[1]);
1173 if (is_array($fields_label)) {
1175 $keyList .= implode(
', ', $fields_label);
1179 $sql =
"SELECT ".$keyList;
1180 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1181 if (!empty($InfoFieldList[4])) {
1183 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1184 $InfoFieldList[4] = str_replace(
'$ENTITY$', $conf->entity, $InfoFieldList[4]);
1187 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1188 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1192 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1193 $InfoFieldList[4] = str_replace(
'$ID$', $objectid, $InfoFieldList[4]);
1195 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1198 if (strpos($InfoFieldList[4],
'extra') !==
false) {
1199 $sql .=
' as main, '.$this->db->prefix().$InfoFieldList[0].
'_extrafields as extra';
1200 $sqlwhere .=
" WHERE extra.fk_object=main.".$InfoFieldList[2].
" AND ".$InfoFieldList[4];
1202 $sqlwhere .=
" WHERE ".$InfoFieldList[4];
1205 $sqlwhere .=
' WHERE 1=1';
1208 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1209 $sqlwhere .=
' AND entity = '.((int) $conf->entity);
1214 $sql .=
' ORDER BY '.implode(
', ', $fields_label);
1216 dol_syslog(get_class($this).
'::showInputField type=sellist', LOG_DEBUG);
1219 $out .=
'<option value="0"> </option>';
1220 $num = $this->
db->num_rows(
$resql);
1224 $obj = $this->
db->fetch_object(
$resql);
1228 $fields_label = explode(
'|', $InfoFieldList[1]);
1229 if (is_array($fields_label) && count($fields_label) > 1) {
1231 foreach ($fields_label as $field_toshow) {
1232 $labeltoshow .= $obj->$field_toshow.
' ';
1235 $labeltoshow = $obj->{$InfoFieldList[1]};
1237 $labeltoshow = $labeltoshow;
1239 if ($value == $obj->rowid) {
1241 foreach ($fields_label as $field_toshow) {
1242 $translabel = $langs->trans($obj->$field_toshow);
1243 $labeltoshow = $translabel.
' ';
1246 $out .=
'<option value="'.$obj->rowid.
'" selected>'.$labeltoshow.
'</option>';
1249 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1250 $labeltoshow = $translabel;
1252 if (empty($labeltoshow)) {
1253 $labeltoshow =
'(not defined)';
1256 if (!empty($InfoFieldList[3]) && $parentField) {
1257 $parent = $parentName.
':'.$obj->{$parentField};
1260 $out .=
'<option value="'.$obj->rowid.
'"';
1261 $out .= ($value == $obj->rowid ?
' selected' :
'');
1262 $out .= (!empty($parent) ?
' parent="'.$parent.
'"' :
'');
1263 $out .=
'>'.$labeltoshow.
'</option>';
1270 print
'Error in request '.$sql.
' '.$this->
db->lasterror().
'. Check setup of extra parameters.<br>';
1273 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1274 $data =
$form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1275 $out .=
'<option value="0"> </option>';
1276 if (is_array($data)) {
1277 foreach ($data as $data_key => $data_value) {
1278 $out .=
'<option value="'.$data_key.
'"';
1279 $out .= ($value == $data_key ?
' selected' :
'');
1280 $out .=
'>'.$data_value.
'</option>';
1285 $out .=
'</select>';
1286 } elseif ($type ==
'checkbox') {
1287 $value_arr = $value;
1288 if (!is_array($value)) {
1289 $value_arr = explode(
',', $value);
1291 $out =
$form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param[
'options']) ?null:$param[
'options']), $value_arr,
'', 0,
'', 0,
'100%');
1292 } elseif ($type ==
'radio') {
1294 foreach ($param[
'options'] as $keyopt => $val) {
1295 $out .=
'<input class="flat '.$morecss.
'" type="radio" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'" '.($moreparam ? $moreparam :
'');
1296 $out .=
' value="'.$keyopt.
'"';
1297 $out .=
' id="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'"';
1298 $out .= ($value == $keyopt ?
'checked' :
'');
1299 $out .=
'/><label for="'.$keyprefix.$key.$keysuffix.
'_'.$keyopt.
'">'.$langs->trans($val).
'</label><br>';
1301 } elseif ($type ==
'chkbxlst') {
1302 if (is_array($value)) {
1303 $value_arr = $value;
1305 $value_arr = explode(
',', $value);
1308 if (is_array($param[
'options'])) {
1309 $param_list = array_keys($param[
'options']);
1310 $InfoFieldList = explode(
":", $param_list[0]);
1320 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2].
' as rowid');
1322 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
1323 list ($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
1324 $keyList .=
', '.$parentField;
1326 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1327 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1328 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
1330 $keyList = $InfoFieldList[2].
' as rowid';
1334 $filter_categorie =
false;
1335 if (count($InfoFieldList) > 5) {
1336 if ($InfoFieldList[0] ==
'categorie') {
1337 $filter_categorie =
true;
1341 if ($filter_categorie ===
false) {
1342 $fields_label = explode(
'|', $InfoFieldList[1]);
1343 if (is_array($fields_label)) {
1345 $keyList .= implode(
', ', $fields_label);
1349 $sql =
"SELECT ".$keyList;
1350 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1351 if (!empty($InfoFieldList[4])) {
1353 if (strpos($InfoFieldList[4],
'$ENTITY$') !==
false) {
1354 $InfoFieldList[4] = str_replace(
'$ENTITY$', $conf->entity, $InfoFieldList[4]);
1357 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
1358 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
1362 if (strpos($InfoFieldList[4],
'$ID$') !==
false && !empty($objectid)) {
1363 $InfoFieldList[4] = str_replace(
'$ID$', $objectid, $InfoFieldList[4]);
1364 } elseif (preg_match(
"#^.*list.php$#", $_SERVER[
"PHP_SELF"])) {
1366 $word =
'\b[a-zA-Z0-9-\.-_]+\b=\$ID\$';
1369 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1373 while ($nbPreg != 0) {
1375 $nbPregRepl = $nbPregSel = 0;
1377 $InfoFieldList[4] = preg_replace(
'#([^=])(\([^)^(]*('.$word.
')[^)^(]*\))#',
'$1 $3 ', $InfoFieldList[4], -1, $nbPregRepl);
1379 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1381 $InfoFieldList[4] = preg_replace(
'#\b[a-zA-Z0-9-\.-_]+\b=\([^)^(]*('.$word.
')[^)^(]*\)#',
'$1 ', $InfoFieldList[4], -1, $nbPregSel);
1383 $InfoFieldList[4] = preg_replace(
'# *(=|\(|\)) *#',
'$1', $InfoFieldList[4]);
1386 $nbPreg = $nbPregRepl + $nbPregSel;
1390 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1391 while (!empty($matchCondition[0])) {
1393 if (!empty($matchCondition[1]) && !empty($matchCondition[3]) && $matchCondition[1] != $matchCondition[3]) {
1395 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1397 if (!empty($matchCondition[1])) {
1398 $boolCond = (($matchCondition[1] ==
"AND") ?
' AND TRUE ' :
' OR FALSE ');
1399 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond.$matchCondition[3], $InfoFieldList[4]);
1400 } elseif (!empty($matchCondition[3])) {
1401 $boolCond = (($matchCondition[3] ==
"AND") ?
' TRUE AND ' :
' FALSE OR');
1402 $InfoFieldList[4] = str_replace($matchCondition[0], $boolCond, $InfoFieldList[4]);
1404 $InfoFieldList[4] =
" TRUE ";
1409 preg_match(
'#(AND|OR|) *('.$word.
') *(AND|OR|)#', $InfoFieldList[4], $matchCondition);
1412 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
1416 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
1417 $sql .=
' as main, '.$this->db->prefix().$InfoFieldList[0].
'_extrafields as extra';
1418 $sqlwhere .=
" WHERE extra.fk_object=main.".$InfoFieldList[2].
" AND ".$InfoFieldList[4];
1420 $sqlwhere .=
" WHERE ".$InfoFieldList[4];
1423 $sqlwhere .=
' WHERE 1=1';
1426 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
1427 $sqlwhere .=
" AND entity = ".((int) $conf->entity);
1433 dol_syslog(get_class($this).
'::showInputField type=chkbxlst', LOG_DEBUG);
1436 $num = $this->
db->num_rows(
$resql);
1443 $obj = $this->
db->fetch_object(
$resql);
1447 $fields_label = explode(
'|', $InfoFieldList[1]);
1448 if (is_array($fields_label)) {
1450 foreach ($fields_label as $field_toshow) {
1451 $labeltoshow .= $obj->$field_toshow.
' ';
1454 $labeltoshow = $obj->{$InfoFieldList[1]};
1456 $labeltoshow =
dol_trunc($labeltoshow, 45);
1458 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1459 foreach ($fields_label as $field_toshow) {
1460 $translabel = $langs->trans($obj->$field_toshow);
1461 if ($translabel != $obj->$field_toshow) {
1462 $labeltoshow =
dol_trunc($translabel, 18).
' ';
1464 $labeltoshow =
dol_trunc($obj->$field_toshow, 18).
' ';
1468 $data[$obj->rowid] = $labeltoshow;
1471 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1472 if ($translabel != $obj->{$InfoFieldList[1]}) {
1473 $labeltoshow =
dol_trunc($translabel, 18);
1475 $labeltoshow =
dol_trunc($obj->{$InfoFieldList[1]}, 18);
1478 if (empty($labeltoshow)) {
1479 $labeltoshow =
'(not defined)';
1482 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1483 $data[$obj->rowid] = $labeltoshow;
1486 if (!empty($InfoFieldList[3]) && $parentField) {
1487 $parent = $parentName.
':'.$obj->{$parentField};
1490 $data[$obj->rowid] = $labeltoshow;
1497 $out =
$form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr,
'', 0,
'', 0,
'100%');
1499 print
'Error in request '.$sql.
' '.$this->
db->lasterror().
'. Check setup of extra parameters.<br>';
1502 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1503 $data =
$form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
1504 $out =
$form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr,
'', 0,
'', 0,
'100%');
1507 } elseif ($type ==
'link') {
1508 $param_list = array_keys($param[
'options']);
1509 $showempty = (($required && $default !=
'') ? 0 : 1);
1510 $out =
$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty,
'',
'', $morecss);
1511 } elseif ($type ==
'password') {
1513 $out =
'<input style="display:none" type="text" name="fakeusernameremembered">';
1514 $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 :
'').
'>';
1516 if (!empty($hidden)) {
1517 $out =
'<input type="hidden" value="'.$value.
'" name="'.$keyprefix.$key.$keysuffix.
'" id="'.$keyprefix.$key.$keysuffix.
'"/>';
1539 public function showOutputField($key, $value, $moreparam =
'', $extrafieldsobjectkey =
'')
1541 global $conf, $langs;
1543 if (!empty($extrafieldsobjectkey)) {
1544 $label = $this->attributes[$extrafieldsobjectkey][
'label'][$key];
1545 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1546 $size = $this->attributes[$extrafieldsobjectkey][
'size'][$key];
1547 $default = $this->attributes[$extrafieldsobjectkey][
'default'][$key];
1548 $computed = $this->attributes[$extrafieldsobjectkey][
'computed'][$key];
1549 $unique = $this->attributes[$extrafieldsobjectkey][
'unique'][$key];
1550 $required = $this->attributes[$extrafieldsobjectkey][
'required'][$key];
1551 $param = $this->attributes[$extrafieldsobjectkey][
'param'][$key];
1552 $perms =
dol_eval($this->attributes[$extrafieldsobjectkey][
'perms'][$key], 1, 1,
'1');
1553 $langfile = $this->attributes[$extrafieldsobjectkey][
'langfile'][$key];
1554 $list =
dol_eval($this->attributes[$extrafieldsobjectkey][
'list'][$key], 1, 1,
'1');
1555 $help = $this->attributes[$extrafieldsobjectkey][
'help'][$key];
1556 $hidden = (empty($list) ? 1 : 0);
1559 dol_syslog(get_class($this).
'::showOutputField extrafieldsobjectkey required', LOG_WARNING);
1570 if ($type ==
'date') {
1572 if ($value !==
'') {
1575 } elseif ($type ==
'datetime') {
1577 if ($value !==
'') {
1580 } elseif ($type ==
'int') {
1582 } elseif ($type ==
'double') {
1583 if (!empty($value)) {
1585 $sizeparts = explode(
",", $size);
1586 $number_decimals = array_key_exists(1, $sizeparts) ? $sizeparts[1] : 0;
1587 $value =
price($value, 0, $langs, 0, 0, $number_decimals,
'');
1589 } elseif ($type ==
'boolean') {
1591 if (!empty($value)) {
1592 $checked =
' checked ';
1594 $value =
'<input type="checkbox" '.$checked.
' '.($moreparam ? $moreparam :
'').
' readonly disabled>';
1595 } elseif ($type ==
'mail') {
1597 } elseif ($type ==
'url') {
1599 } elseif ($type ==
'phone') {
1601 } elseif ($type ==
'price') {
1603 if ($value || $value ==
'0') {
1604 $value =
price($value, 0, $langs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1).
' '.$langs->getCurrencySymbol($conf->currency);
1606 } elseif ($type ==
'select') {
1607 $valstr = (!empty($param[
'options'][$value]) ? $param[
'options'][$value] :
'');
1608 if (($pos = strpos($valstr,
"|")) !==
false) {
1609 $valstr = substr($valstr, 0, $pos);
1611 if ($langfile && $valstr) {
1612 $value = $langs->trans($valstr);
1616 } elseif ($type ==
'sellist') {
1617 $param_list = array_keys($param[
'options']);
1618 $InfoFieldList = explode(
":", $param_list[0]);
1620 $selectkey =
"rowid";
1623 if (count($InfoFieldList) >= 3) {
1624 $selectkey = $InfoFieldList[2];
1625 $keyList = $InfoFieldList[2].
' as rowid';
1628 $fields_label = explode(
'|', $InfoFieldList[1]);
1629 if (is_array($fields_label)) {
1631 $keyList .= implode(
', ', $fields_label);
1634 $filter_categorie =
false;
1635 if (count($InfoFieldList) > 5) {
1636 if ($InfoFieldList[0] ==
'categorie') {
1637 $filter_categorie =
true;
1641 $sql =
"SELECT ".$keyList;
1642 $sql .=
' FROM '.$this->db->prefix().$InfoFieldList[0];
1643 if (!empty($InfoFieldList[4]) && strpos($InfoFieldList[4],
'extra') !==
false) {
1646 if ($selectkey ==
'rowid' && empty($value)) {
1647 $sql .=
" WHERE ".$selectkey.
" = 0";
1648 } elseif ($selectkey ==
'rowid') {
1649 $sql .=
" WHERE ".$selectkey.
" = ".((int) $value);
1651 $sql .=
" WHERE ".$selectkey.
" = '".$this->
db->escape($value).
"'";
1656 dol_syslog(get_class($this).
':showOutputField:$type=sellist', LOG_DEBUG);
1659 if ($filter_categorie ===
false) {
1662 $obj = $this->
db->fetch_object(
$resql);
1665 $fields_label = explode(
'|', $InfoFieldList[1]);
1667 if (is_array($fields_label) && count($fields_label) > 1) {
1668 foreach ($fields_label as $field_toshow) {
1670 if (!empty($obj->$field_toshow)) {
1671 $translabel = $langs->trans($obj->$field_toshow);
1673 if ($translabel != $field_toshow) {
1674 $value .=
dol_trunc($translabel, 18).
' ';
1676 $value .= $obj->$field_toshow.
' ';
1681 $tmppropname = $InfoFieldList[1];
1683 if (!empty(isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
1684 $translabel = $langs->trans($obj->$tmppropname);
1686 if ($translabel != (isset($obj->$tmppropname) ? $obj->$tmppropname :
'')) {
1689 $value = isset($obj->$tmppropname) ? $obj->$tmppropname :
'';
1694 $obj = $this->
db->fetch_object(
$resql);
1696 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1698 $result = $c->fetch($obj->rowid);
1700 $ways = $c->print_all_ways();
1701 foreach ($ways as $way) {
1702 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ?
' style="background: #' . $c->color .
';"' :
' style="background: #bbb"') .
'>' .
img_object(
'',
'category') .
' ' . $way .
'</li>';
1706 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1709 dol_syslog(get_class($this).
'::showOutputField error '.$this->
db->lasterror(), LOG_WARNING);
1711 } elseif ($type ==
'radio') {
1712 $value = $langs->trans($param[
'options'][$value]);
1713 } elseif ($type ==
'checkbox') {
1714 $value_arr = explode(
',', $value);
1717 if (is_array($value_arr)) {
1718 foreach ($value_arr as $keyval => $valueval) {
1719 if (!empty($valueval)) {
1720 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$param[
'options'][$valueval].
'</li>';
1724 $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1725 } elseif ($type ==
'chkbxlst') {
1726 $value_arr = explode(
',', $value);
1728 $param_list = array_keys($param[
'options']);
1729 $InfoFieldList = explode(
":", $param_list[0]);
1731 $selectkey =
"rowid";
1734 if (count($InfoFieldList) >= 3) {
1735 $selectkey = $InfoFieldList[2];
1736 $keyList = $InfoFieldList[2].
' as rowid';
1739 $fields_label = explode(
'|', $InfoFieldList[1]);
1740 if (is_array($fields_label)) {
1742 $keyList .= implode(
', ', $fields_label);
1745 $filter_categorie =
false;
1746 if (count($InfoFieldList) > 5) {
1747 if ($InfoFieldList[0] ==
'categorie') {
1748 $filter_categorie =
true;
1752 $sql =
"SELECT ".$keyList;
1753 $sql .=
" FROM ".$this->db->prefix().$InfoFieldList[0];
1754 if (strpos($InfoFieldList[4],
'extra') !==
false) {
1760 dol_syslog(get_class($this).
':showOutputField:$type=chkbxlst', LOG_DEBUG);
1763 if ($filter_categorie ===
false) {
1766 while ($obj = $this->
db->fetch_object(
$resql)) {
1768 $fields_label = explode(
'|', $InfoFieldList[1]);
1769 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1770 if (is_array($fields_label) && count($fields_label) > 1) {
1771 foreach ($fields_label as $field_toshow) {
1773 if (!empty($obj->$field_toshow)) {
1774 $translabel = $langs->trans($obj->$field_toshow);
1776 if ($translabel != $field_toshow) {
1777 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).
'</li>';
1779 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->$field_toshow.
'</li>';
1784 if (!empty($obj->{$InfoFieldList[1]})) {
1785 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1787 if ($translabel != $obj->{$InfoFieldList[1]}) {
1788 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).
'</li>';
1790 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->{$InfoFieldList[1]}.
'</li>';
1796 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1799 while ($obj = $this->
db->fetch_object(
$resql)) {
1800 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1802 $c->fetch($obj->rowid);
1803 $ways = $c->print_all_ways();
1804 foreach ($ways as $way) {
1805 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ?
' style="background: #'.$c->color.
';"' :
' style="background: #bbb"').
'>'.
img_object(
'',
'category').
' '.$way.
'</li>';
1810 if (!empty($toprint)) $value =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(
' ', $toprint).
'</ul></div>';
1812 dol_syslog(get_class($this).
'::showOutputField error '.$this->
db->lasterror(), LOG_WARNING);
1814 } elseif ($type ==
'link') {
1819 $param_list = array_keys($param[
'options']);
1821 $InfoFieldList = explode(
":", $param_list[0]);
1822 $classname = $InfoFieldList[0];
1823 $classpath = $InfoFieldList[1];
1824 if (!empty($classpath)) {
1826 if ($classname && class_exists($classname)) {
1827 $object =
new $classname($this->
db);
1828 $object->fetch($value);
1829 $value = $object->getNomUrl(3);
1832 dol_syslog(
'Error bad setup of extrafield', LOG_WARNING);
1833 return 'Error bad setup of extrafield';
1836 } elseif ($type ==
'text') {
1838 } elseif ($type ==
'html') {
1840 } elseif ($type ==
'password') {
1841 $value =
dol_trunc(preg_replace(
'/./i',
'*', $value), 8,
'right',
'UTF-8', 1);
1843 $showsize = round((
float) $size);
1844 if ($showsize > 48) {
1864 global $conf, $langs;
1866 if (!empty($extrafieldsobjectkey)) {
1867 $type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
1869 $type = $this->attribute_type[$key];
1874 if ($type ==
'date') {
1875 $cssstring =
"center";
1876 } elseif ($type ==
'datetime') {
1877 $cssstring =
"center";
1878 } elseif ($type ==
'int') {
1879 $cssstring =
"right";
1880 } elseif ($type ==
'price') {
1881 $cssstring =
"right";
1882 } elseif ($type ==
'double') {
1883 $cssstring =
"right";
1884 } elseif ($type ==
'boolean') {
1885 $cssstring =
"center";
1886 } elseif ($type ==
'radio') {
1887 $cssstring =
"center";
1888 } elseif ($type ==
'checkbox') {
1889 $cssstring =
"center";
1890 } elseif ($type ==
'price') {
1891 $cssstring =
"right";
1894 if (!empty($this->attributes[$extrafieldsobjectkey][
'csslist'][$key])) {
1895 $cssstring .= ($cssstring ?
' ' :
'').$this->attributes[$extrafieldsobjectkey][
'csslist'][$key];
1911 public function showSeparator($key, $object, $colspan = 2, $display_type =
'card', $mode =
'')
1913 global $conf, $langs;
1918 if ($display_type==
'line') {
1920 $tagtype_dyn=
'span';
1924 $extrafield_param = $this->attributes[$object->table_element][
'param'][$key];
1925 $extrafield_param_list = array();
1926 if (!empty($extrafield_param) && is_array($extrafield_param)) {
1927 $extrafield_param_list = array_keys($extrafield_param[
'options']);
1929 $extrafield_collapse_display_value = -1;
1930 $expand_display =
false;
1931 if (is_array($extrafield_param_list) && count($extrafield_param_list) > 0) {
1932 $extrafield_collapse_display_value = intval($extrafield_param_list[0]);
1933 $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));
1935 if ($mode ==
'create') {
1936 $extrafield_collapse_display_value = 0;
1939 $out =
'<'.$tagtype.
' id="trextrafieldseparator'.$key.(!empty($object->id)?
'_'.$object->id:
'').
'" class="trextrafieldseparator trextrafieldseparator'.$key.(!empty($object->id)?
'_'.$object->id:
'').
'">';
1940 $out .=
'<'.$tagtype_dyn.
' '.(!empty($colspan)?
'colspan="' . $colspan .
'"':
'').
'>';
1943 $out .=
'<span class="cursorpointer '.($extrafield_collapse_display_value == 0 ?
'fas fa-square opacitymedium' :
'far fa-'.(($expand_display ?
'minus' :
'plus').
'-square')).
'"></span>';
1946 $out .= $langs->trans($this->attributes[$object->table_element][
'label'][$key]);
1947 $out .=
'</strong>';
1948 $out .=
'</'.$tagtype_dyn.
'>';
1949 $out .=
'</'.$tagtype.
'>';
1951 $collapse_group = $key.(!empty($object->id) ?
'_'.$object->id :
'');
1954 if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) {
1956 $this->expand_display[$collapse_group] = $expand_display;
1958 if (!empty($conf->use_javascript_ajax) && $mode !=
'create') {
1959 $out .=
'<!-- Add js script to manage the collapse/uncollapse of extrafields separators '.$key.
' -->'.
"\n";
1960 $out .=
'<script type="text/javascript">'.
"\n";
1961 $out .=
'jQuery(document).ready(function(){'.
"\n";
1962 if ($expand_display ===
false) {
1963 $out .=
' console.log("Inject js for the collapsing of extrafield '.$key.
' - hide");'.
"\n";
1964 $out .=
' jQuery(".trextrafields_collapse'.$collapse_group.
'").hide();'.
"\n";
1966 $out .=
' console.log("Inject js for collapsing of extrafield '.$key.
' - keep visible and set cookie");'.
"\n";
1967 $out .=
' document.cookie = "DOLCOLLAPSE_'.$object->table_element.
'_extrafields_'.$key.
'=1; path='.$_SERVER[
"PHP_SELF"].
'"'.
"\n";
1969 $out .=
' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?
'_'.$object->id:
'').
'").click(function(){'.
"\n";
1970 $out .=
' console.log("We click on collapse/uncollapse .trextrafields_collapse'.$collapse_group.
'");'.
"\n";
1971 $out .=
' jQuery(".trextrafields_collapse'.$collapse_group.
'").toggle(100, function(){'.
"\n";
1972 $out .=
' if (jQuery(".trextrafields_collapse'.$collapse_group.
'").is(":hidden")) {'.
"\n";
1973 $out .=
' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?
'_'.$object->id:
'').
' '.$tagtype_dyn.
' span").addClass("fa-plus-square").removeClass("fa-minus-square");'.
"\n";
1974 $out .=
' document.cookie = "DOLCOLLAPSE_'.$object->table_element.
'_extrafields_'.$key.
'=0; path='.$_SERVER[
"PHP_SELF"].
'"'.
"\n";
1975 $out .=
' } else {'.
"\n";
1976 $out .=
' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?
'_'.$object->id:
'').
' '.$tagtype_dyn.
' span").addClass("fa-minus-square").removeClass("fa-plus-square");'.
"\n";
1977 $out .=
' document.cookie = "DOLCOLLAPSE_'.$object->table_element.
'_extrafields_'.$key.
'=1; path='.$_SERVER[
"PHP_SELF"].
'"'.
"\n";
1979 $out .=
' });'.
"\n";
1980 $out .=
' });'.
"\n";
1982 $out .=
'</script>'.
"\n";
1985 $this->expand_display[$collapse_group] = 1;
2004 global $_POST, $langs;
2006 $nofillrequired = 0;
2007 $error_field_required = array();
2009 if (isset($this->attributes[$object->table_element][
'label']) && is_array($this->attributes[$object->table_element][
'label'])) {
2010 $extralabels = $this->attributes[$object->table_element][
'label'];
2013 if (is_array($extralabels)) {
2015 foreach ($extralabels as $key => $value) {
2016 if (!empty($onlykey) && $onlykey !=
'@GETPOSTISSET' && $key != $onlykey) {
2020 if (!empty($onlykey) && $onlykey ==
'@GETPOSTISSET' && !
GETPOSTISSET(
'options_'.$key) && (! in_array($this->attributes[$object->table_element][
'type'][$key], array(
'boolean',
'chkbxlst')))) {
2025 $key_type = $this->attributes[$object->table_element][
'type'][$key];
2026 if ($key_type ==
'separate') {
2031 if (isset($this->attributes[$object->table_element][
'enabled'][$key])) {
2032 $enabled =
dol_eval($this->attributes[$object->table_element][
'enabled'][$key], 1, 1,
'1');
2036 if (isset($this->attributes[$object->table_element][
'list'][$key])) {
2037 $visibility =
dol_eval($this->attributes[$object->table_element][
'list'][$key], 1, 1,
'1');
2041 if (isset($this->attributes[$object->table_element][
'perms'][$key])) {
2042 $perms =
dol_eval($this->attributes[$object->table_element][
'perms'][$key], 1, 1,
'1');
2044 if (empty($enabled)) {
2047 if (empty($visibility)) {
2050 if (empty($perms)) {
2054 if ($this->attributes[$object->table_element][
'required'][$key]) {
2058 if ((!is_array($_POST[
"options_".$key]) && empty($_POST[
"options_".$key]) && $this->attributes[$object->table_element][
'type'][$key] !=
'select' && $_POST[
"options_".$key] !=
'0')
2059 || (!is_array($_POST[
"options_".$key]) && empty($_POST[
"options_".$key]) && $this->attributes[$object->table_element][
'type'][$key] ==
'select')
2060 || (!is_array($_POST[
"options_".$key]) && isset($_POST[
"options_".$key]) && $this->attributes[$object->table_element][
'type'][$key] ==
'sellist' && $_POST[
'options_'.$key] ==
'0')
2061 || (is_array($_POST[
"options_".$key]) && empty($_POST[
"options_".$key]))) {
2066 $error_field_required[$key] = $langs->transnoentitiesnoconv($value);
2070 if (in_array($key_type, array(
'date'))) {
2072 $value_key =
dol_mktime(12, 0, 0,
GETPOST(
"options_".$key.
"month",
'int'),
GETPOST(
"options_".$key.
"day",
'int'),
GETPOST(
"options_".$key.
"year",
'int'));
2073 } elseif (in_array($key_type, array(
'datetime'))) {
2075 $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');
2076 } elseif (in_array($key_type, array(
'checkbox',
'chkbxlst'))) {
2077 $value_arr =
GETPOST(
"options_".$key,
'array');
2078 if (!empty($value_arr)) {
2079 $value_key = implode(
',', $value_arr);
2083 } elseif (in_array($key_type, array(
'price',
'double'))) {
2084 $value_arr =
GETPOST(
"options_".$key,
'alpha');
2086 } elseif (in_array($key_type, array(
'html'))) {
2087 $value_key =
GETPOST(
"options_".$key,
'restricthtml');
2088 } elseif (in_array($key_type, array(
'text'))) {
2089 $value_key =
GETPOST(
"options_".$key,
'alphanohtml');
2091 $value_key =
GETPOST(
"options_".$key);
2092 if (in_array($key_type, array(
'link')) && $value_key ==
'-1') {
2097 if (!empty($error_field_required[$key]) && $todefaultifmissing) {
2099 if (!empty($this->attributes[$object->table_element][
'default']) && !is_null($this->attributes[$object->table_element][
'default'][$key])) {
2100 $value_key = $this->attributes[$object->table_element][
'default'][$key];
2101 unset($error_field_required[$key]);
2106 $object->array_options[
"options_".$key] = $value_key;
2109 if ($nofillrequired) {
2110 $langs->load(
'errors');
2111 $this->error = $langs->trans(
'ErrorFieldsRequired').
' : '.implode(
', ', $error_field_required);
2134 if (is_string($extrafieldsobjectkey) && !empty($this->attributes[$extrafieldsobjectkey][
'label']) && is_array($this->attributes[$extrafieldsobjectkey][
'label'])) {
2135 $extralabels = $this->attributes[$extrafieldsobjectkey][
'label'];
2137 $extralabels = $extrafieldsobjectkey;
2140 if (is_array($extralabels)) {
2141 $array_options = array();
2144 foreach ($extralabels as $key => $value) {
2146 if (is_string($extrafieldsobjectkey)) {
2147 $key_type = $this->attributes[$extrafieldsobjectkey][
'type'][$key];
2150 if (in_array($key_type, array(
'date'))) {
2151 $dateparamname_start = $keysuffix .
'options_' . $key . $keyprefix .
'_start';
2152 $dateparamname_end = $keysuffix .
'options_' . $key . $keyprefix .
'_end';
2156 'start' =>
dol_mktime(0, 0, 0,
GETPOST($dateparamname_start .
'month',
'int'),
GETPOST($dateparamname_start .
'day',
'int'),
GETPOST($dateparamname_start .
'year',
'int')),
2157 'end' =>
dol_mktime(23, 59, 59,
GETPOST($dateparamname_end .
'month',
'int'),
GETPOST($dateparamname_end .
'day',
'int'),
GETPOST($dateparamname_end .
'year',
'int'))
2159 } elseif (
GETPOSTISSET($keysuffix.
"options_".$key.$keyprefix.
"year")) {
2161 $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'));
2165 } elseif (in_array($key_type, array(
'datetime'))) {
2166 $dateparamname_start = $keysuffix .
'options_' . $key . $keyprefix .
'_start';
2167 $dateparamname_end = $keysuffix .
'options_' . $key . $keyprefix .
'_end';
2170 $dateparamname_end_hour =
GETPOST($dateparamname_end .
'hour',
'int') !=
'-1' ?
GETPOST($dateparamname_end .
'hour',
'int') :
'23';
2171 $dateparamname_end_min =
GETPOST($dateparamname_end .
'min',
'int') !=
'-1' ?
GETPOST($dateparamname_end .
'min',
'int') :
'59';
2172 $dateparamname_end_sec =
GETPOST($dateparamname_end .
'sec',
'int') !=
'-1' ?
GETPOST($dateparamname_end .
'sec',
'int') :
'59';
2174 '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'),
2175 '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')
2177 } elseif (
GETPOSTISSET($keysuffix.
"options_".$key.$keyprefix.
"year")) {
2179 $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');
2183 } elseif ($key_type ==
'select') {
2186 $value_arr =
GETPOST($keysuffix.
"options_".$key.$keyprefix,
'array:aZ09');
2188 $value_arr = (array) $value_arr;
2189 $value_key = implode(
',', $value_arr);
2191 $value_key =
GETPOST($keysuffix.
"options_".$key.$keyprefix);
2193 } elseif (in_array($key_type, array(
'checkbox',
'chkbxlst'))) {
2194 if (!
GETPOSTISSET($keysuffix.
"options_".$key.$keyprefix)) {
2197 $value_arr =
GETPOST($keysuffix.
"options_".$key.$keyprefix);
2199 $value_arr = (array) $value_arr;
2200 $value_key = implode(
',', $value_arr);
2201 } elseif (in_array($key_type, array(
'price',
'double',
'int'))) {
2202 if (!
GETPOSTISSET($keysuffix.
"options_".$key.$keyprefix)) {
2205 $value_arr =
GETPOST($keysuffix.
"options_".$key.$keyprefix);
2206 if ($keysuffix !=
'search_') {
2209 $value_key = $value_arr;
2211 } elseif (in_array($key_type, array(
'boolean'))) {
2212 if (!
GETPOSTISSET($keysuffix.
"options_".$key.$keyprefix)) {
2215 $value_arr =
GETPOST($keysuffix.
"options_".$key.$keyprefix);
2216 $value_key = $value_arr;
2219 if (!
GETPOSTISSET($keysuffix.
"options_".$key.$keyprefix)) {
2222 $value_key =
GETPOST($keysuffix.
"options_".$key.$keyprefix);
2225 $array_options[$keysuffix.
"options_".$key] = $value_key;
2228 return $array_options;
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_print_url($url, $target= '_blank', $max=32, $withpicto=0)
Show Url link.
$conf db
API class for accounts.
dol_now($mode= 'auto')
Return date for now.
dol_print_phone($phone, $countrycode= '', $cid=0, $socid=0, $addlink= '', $separ=" ", $withpicto= '', $titlealt= '', $adddivfloat=0)
Format phone numbers according to country.
jsonOrUnserialize($stringtodecode)
Decode an encode string.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom= 'UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring= '1')
Replace eval function to add more security.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
Class to manage categories.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array. ...
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve', $idforemptyvalue= '-1')
Convert a html select field into an ajax combobox.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
Class to manage a WYSIWYG editor.
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length. ...