From 227539d647cd70a447c645b4080d06f5dbc35e3e Mon Sep 17 00:00:00 2001 From: bgenere Date: Mon, 21 May 2018 16:55:35 +0200 Subject: [PATCH 1/2] FIX : showOptionals function is now consistent with template Extrafield_view.tpl.php for date and datetime fields The jdate function is not called when not needed. --- htdocs/core/class/commonobject.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c6442c730f0..b74bc8a4e96 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6080,7 +6080,12 @@ abstract class CommonObject // Convert date into timestamp format (value in memory must be a timestamp) if (in_array($extrafields->attributes[$this->table_element]['type'][$key],array('date','datetime'))) { - $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min",'int',3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year",'int',3)):$this->db->jdate($this->array_options['options_'.$key]); + $datenotinstring = $this->array_options['options_' . $key]; + if (! is_numeric($this->array_options['options_' . $key])) // For backward compatibility + { + $datenotinstring = $db->jdate($datenotinstring); + } + $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min",'int',3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year",'int',3)):$datenotinstring; } // Convert float submited string into real php numeric (value in memory must be a php numeric) if (in_array($extrafields->attributes[$this->table_element]['type'][$key],array('price','double'))) From a3bea8d29857284b4a6b54326903eedb4ffa6619 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 25 May 2018 11:17:01 +0200 Subject: [PATCH 2/2] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b74bc8a4e96..fef4856a46e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6083,7 +6083,7 @@ abstract class CommonObject $datenotinstring = $this->array_options['options_' . $key]; if (! is_numeric($this->array_options['options_' . $key])) // For backward compatibility { - $datenotinstring = $db->jdate($datenotinstring); + $datenotinstring = $this->db->jdate($datenotinstring); } $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min",'int',3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year",'int',3)):$datenotinstring; }