From c422904b990cb329276a72e430c471a658c782aa Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Sat, 1 Dec 2018 16:51:40 +0100 Subject: [PATCH 1/2] fix #9964 --- htdocs/commande/list.php | 4 ++-- htdocs/core/class/extrafields.class.php | 5 ++++- .../core/tpl/extrafields_list_search_sql.tpl.php | 16 ++++++++++------ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 4841e9be410..bbdf59a295c 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -468,8 +468,8 @@ if ($resql) print ''; print ''; print ''; - - + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, $newcardbutton, '', $limit); $topicmail="SendOrderRef"; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 1840f62ca5d..ee87426ddcb 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1927,7 +1927,10 @@ class ExtraFields // Get extra fields foreach ($extralabels as $key => $value) { - $key_type = $this->attributes[$object->table_element]['type'][$key]; + $key_type=$this->attribute_type[$key]; + if (! empty($object->table_element)) { + $key_type=$this->attributes[$extrafieldsobjectkey]['type'][$key]; + } if (in_array($key_type,array('date','datetime'))) { diff --git a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php index a8e43d6429f..8492160c185 100644 --- a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php @@ -17,13 +17,17 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_ $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $typ=$extrafields->attributes[$extrafieldsobjectkey]['type'][$tmpkey]; - - $mode_search=0; - if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric - if (in_array($typ, array('sellist','link')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int - if (in_array($typ, array('chkbxlst','checkbox'))) $mode_search=4; // Search on a multiselect field with sql type = text - if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0') && (! in_array($typ, array('link')) || $crit != '-1')) + if ($crit != '' && in_array($typ, array('date', 'datetime', 'timestamp'))) { + $sql .= " AND ef.".$tmpkey." = '".$db->idate($crit)."'"; + } + elseif ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0') && (! in_array($typ, array('link')) || $crit != '-1')) + { + $mode_search=0; + if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric + if (in_array($typ, array('sellist','link')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int + if (in_array($typ, array('chkbxlst','checkbox'))) $mode_search=4; // Search on a multiselect field with sql type = text + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search); } } From 2e57a8be51625f80e8240f1aa0b288abc760834f Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 13 Dec 2018 12:37:40 +0100 Subject: [PATCH 2/2] better fix --- htdocs/core/class/extrafields.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index ee87426ddcb..8ecae833805 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1928,8 +1928,8 @@ class ExtraFields foreach ($extralabels as $key => $value) { $key_type=$this->attribute_type[$key]; - if (! empty($object->table_element)) { - $key_type=$this->attributes[$extrafieldsobjectkey]['type'][$key]; + if (! empty($object->table_element) && is_array($this->attributes) && array_key_exists($object->table_element, $this->attributes)) { + $key_type=$this->attributes[$object->table_element]['type'][$key]; } if (in_array($key_type,array('date','datetime')))