Fix extrafield date or datetime with bad timezone
This commit is contained in:
parent
71cbcce3a2
commit
e465b0c40e
@ -4481,7 +4481,7 @@ abstract class CommonObject
|
||||
if (! is_array($optionsArray))
|
||||
{
|
||||
// If $extrafields is not a known object, we initialize it. Best practice is to have $extrafields defined into card.php or list.php page.
|
||||
// TODO Use of existing extrafield is not yet ready (must mutualize code that use extrafields in form first)
|
||||
// TODO Use of existing $extrafield is not yet ready (must mutualize code that use extrafields in form first)
|
||||
// global $extrafields;
|
||||
//if (! is_object($extrafields))
|
||||
//{
|
||||
@ -4496,6 +4496,10 @@ abstract class CommonObject
|
||||
}
|
||||
$optionsArray = $extrafields->attributes[$this->table_element]['label'];
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("Warning: fetch_optionals was called with param $optionsArray defined when you should pass null now", LOG_WARNING);
|
||||
}
|
||||
|
||||
$table_element = $this->table_element;
|
||||
if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility
|
||||
@ -4529,7 +4533,17 @@ abstract class CommonObject
|
||||
if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key))
|
||||
{
|
||||
// we can add this attribute to object
|
||||
$this->array_options["options_".$key]=$value;
|
||||
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date','datetime')))
|
||||
{
|
||||
//var_dump($extrafields->attributes[$this->table_element]['type'][$key]);
|
||||
$this->array_options["options_".$key]=$this->db->jdate($value);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->array_options["options_".$key]=$value;
|
||||
}
|
||||
|
||||
//var_dump('key '.$key.' '.$value.' type='.$extrafields->attributes[$this->table_element]['type'][$key].' '.$this->array_options["options_".$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1404,12 +1404,12 @@ class ExtraFields
|
||||
if ($type == 'date')
|
||||
{
|
||||
$showsize=10;
|
||||
$value=dol_print_date($value, 'day', 'tzuser');
|
||||
$value=dol_print_date($value, 'day');
|
||||
}
|
||||
elseif ($type == 'datetime')
|
||||
{
|
||||
$showsize=19;
|
||||
$value=dol_print_date($value, 'dayhour', 'tzuser');
|
||||
$value=dol_print_date($value, 'dayhour');
|
||||
}
|
||||
elseif ($type == 'int')
|
||||
{
|
||||
|
||||
@ -107,8 +107,16 @@ if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element][
|
||||
print '<td id="'.$html_id.'" class="'.$object->element.'_extras_'.$key.'" colspan="'.$cols.'">';
|
||||
|
||||
// Convert date into timestamp format
|
||||
if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('date','datetime'))) {
|
||||
$value = isset($_POST["options_" . $key]) ? dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]) : $db->jdate($object->array_options['options_' . $key]);
|
||||
if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('date','datetime')))
|
||||
{
|
||||
$datenotinstring = $object->array_options['options_' . $key];
|
||||
// print 'X'.$object->array_options['options_' . $key].'-'.$datenotinstring.'x';
|
||||
if (! is_numeric($object->array_options['options_' . $key])) // For backward compatibility
|
||||
{
|
||||
$datenotinstring = $db->jdate($datenotinstring);
|
||||
}
|
||||
//print 'x'.$object->array_options['options_' . $key].'-'.$datenotinstring.' - '.dol_print_date($datenotinstring, 'dayhour');
|
||||
$value = isset($_POST["options_" . $key]) ? dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]) : $datenotinstring;
|
||||
}
|
||||
|
||||
//TODO Improve element and rights detection
|
||||
|
||||
Loading…
Reference in New Issue
Block a user