FIX Timezone management for datetime on list of events

This commit is contained in:
Laurent Destailleur 2021-03-04 10:31:31 +01:00
parent 5553bae3a1
commit ffa0e6c391
7 changed files with 100 additions and 45 deletions

View File

@ -63,16 +63,27 @@ $search_desc = GETPOST("search_desc", "alpha");
$search_ua = GETPOST("search_ua", "restricthtml"); $search_ua = GETPOST("search_ua", "restricthtml");
$search_prefix_session = GETPOST("search_prefix_session", "restricthtml"); $search_prefix_session = GETPOST("search_prefix_session", "restricthtml");
if (GETPOST("date_startmonth") == '' || GETPOST("date_startmonth") > 0) $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); $now = dol_now();
else $date_start = -1; $nowarray = dol_getdate($now);
if (GETPOST("date_endmonth") == '' || GETPOST("date_endmonth") > 0) $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
else $date_end = -1; if (!GETPOSTISSET("date_startmonth")) {
$date_start = dol_get_first_day($nowarray['year'], $nowarray['mon'], 'tzuserrel');
} else if (GETPOST("date_startmonth") > 0) {
$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth", 'int'), GETPOST("date_startday", 'int'), GETPOST("date_startyear", 'int'), 'tzuserrel');
} else {
$date_start = -1;
}
if (!GETPOSTISSET("date_endmonth")) {
$date_end = dol_get_last_hour(dol_now('gmt'), 'tzuserrel');
} elseif (GETPOST("date_endmonth") > 0) {
$date_end = dol_get_last_hour(dol_mktime(23, 59, 59, GETPOST("date_endmonth", 'int'), GETPOST("date_endday", 'int'), GETPOST("date_endyear", 'int'), 'tzuserrel'), 'tzuserrel');
} else {
$date_end = -1;
}
// checks:if date_start>date_end then date_end=date_start + 24 hours // checks:if date_start>date_end then date_end=date_start + 24 hours
if ($date_start > 0 && $date_end > 0 && $date_start > $date_end) $date_end = $date_start + 86400; if ($date_start > 0 && $date_end > 0 && $date_start > $date_end) $date_end = $date_start + 86400;
$now = dol_now();
$nowarray = dol_getdate($now);
if (empty($date_start)) // We define date_start and date_end if (empty($date_start)) // We define date_start and date_end
{ {
@ -94,7 +105,6 @@ $date_endyear = $tmp['year'];
$arrayfields = array(); $arrayfields = array();
/* /*
* Actions * Actions
*/ */
@ -256,19 +266,22 @@ if ($result)
// Fields title search // Fields title search
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre" width="15%">'.$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0).'</td>'; print '<td class="liste_titre" width="15%">';
print $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
print $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
print '</td>';
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
print '<input class="flat maxwidth100" type="text" name="search_code" value="'.$search_code.'">'; print '<input class="flat maxwidth100" type="text" name="search_code" value="'.dol_escape_htmltag($search_code).'">';
print '</td>'; print '</td>';
// IP // IP
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
print '<input class="flat maxwidth100" type="text" name="search_ip" value="'.$search_ip.'">'; print '<input class="flat maxwidth100" type="text" name="search_ip" value="'.dol_escape_htmltag($search_ip).'">';
print '</td>'; print '</td>';
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
print '<input class="flat maxwidth100" type="text" name="search_user" value="'.$search_user.'">'; print '<input class="flat maxwidth100" type="text" name="search_user" value="'.dol_escape_htmltag($search_user).'">';
print '</td>'; print '</td>';
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
@ -278,14 +291,14 @@ if ($result)
if (!empty($arrayfields['e.user_agent']['checked'])) if (!empty($arrayfields['e.user_agent']['checked']))
{ {
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
print '<input class="flat maxwidth100" type="text" name="search_ua" value="'.$search_ua.'">'; print '<input class="flat maxwidth100" type="text" name="search_ua" value="'.dol_escape_htmltag($search_ua).'">';
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['e.prefix_session']['checked'])) if (!empty($arrayfields['e.prefix_session']['checked']))
{ {
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
print '<input class="flat maxwidth100" type="text" name="search_prefix_session" value="'.$search_prefix_session.'">'; print '<input class="flat maxwidth100" type="text" name="search_prefix_session" value="'.dol_escape_htmltag($search_prefix_session).'">';
print '</td>'; print '</td>';
} }
@ -321,7 +334,7 @@ if ($result)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Date // Date
print '<td class="nowrap left">'.dol_print_date($db->jdate($obj->dateevent), '%Y-%m-%d %H:%M:%S').'</td>'; print '<td class="nowrap left">'.dol_print_date($db->jdate($obj->dateevent), '%Y-%m-%d %H:%M:%S', 'tzuserrel').'</td>';
// Code // Code
print '<td>'.$obj->type.'</td>'; print '<td>'.$obj->type.'</td>';

View File

@ -71,7 +71,7 @@ if ($action == 'add' && !empty($permissiontoadd))
} elseif ($object->fields[$key]['type'] == 'date') { } elseif ($object->fields[$key]['type'] == 'date') {
$value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); // for date without hour, we use gmt $value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); // for date without hour, we use gmt
} elseif ($object->fields[$key]['type'] == 'datetime') { } elseif ($object->fields[$key]['type'] == 'datetime') {
$value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int'), 'tzuserrel'); $value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), GETPOST($key.'sec', 'int'), GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int'), 'tzuserrel');
} elseif ($object->fields[$key]['type'] == 'duration') { } elseif ($object->fields[$key]['type'] == 'duration') {
$value = 60 * 60 * GETPOST($key.'hour', 'int') + 60 * GETPOST($key.'min', 'int'); $value = 60 * 60 * GETPOST($key.'hour', 'int') + 60 * GETPOST($key.'min', 'int');
} elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) { } elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
@ -158,9 +158,9 @@ if ($action == 'update' && !empty($permissiontoadd))
$value = GETPOST($key, 'restricthtml'); $value = GETPOST($key, 'restricthtml');
} }
} elseif ($object->fields[$key]['type'] == 'date') { } elseif ($object->fields[$key]['type'] == 'date') {
$value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); // for date without hour, we use gmt $value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); // for date without hour, we use gmt
} elseif ($object->fields[$key]['type'] == 'datetime') { } elseif ($object->fields[$key]['type'] == 'datetime') {
$value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year'), 'tzuserrel'); $value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), GETPOST($key.'sec', 'int'), GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int'), 'tzuserrel');
} elseif ($object->fields[$key]['type'] == 'duration') { } elseif ($object->fields[$key]['type'] == 'duration') {
if (GETPOST($key.'hour', 'int') != '' || GETPOST($key.'min', 'int') != '') { if (GETPOST($key.'hour', 'int') != '' || GETPOST($key.'min', 'int') != '') {
$value = 60 * 60 * GETPOST($key.'hour', 'int') + 60 * GETPOST($key.'min', 'int'); $value = 60 * 60 * GETPOST($key.'hour', 'int') + 60 * GETPOST($key.'min', 'int');

View File

@ -5962,17 +5962,26 @@ abstract class CommonObject
} }
} }
if (in_array($type, array('date', 'datetime'))) { if (in_array($type, array('date'))) {
$tmp = explode(',', $size); $tmp = explode(',', $size);
$newsize = $tmp[0]; $newsize = $tmp[0];
$showtime = 0;
$showtime = in_array($type, array('datetime')) ? 1 : 0;
// Do not show current date when field not required (see selectDate() method) // Do not show current date when field not required (see selectDate() method)
if (!$required && $value == '') $value = '-1'; if (!$required && $value == '') $value = '-1';
// TODO Must also support $moreparam // TODO Must also support $moreparam
$out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1);
} elseif (in_array($type, array('datetime'))) {
$tmp = explode(',', $size);
$newsize = $tmp[0];
$showtime = 1;
// Do not show current date when field not required (see selectDate() method)
if (!$required && $value == '') $value = '-1';
// TODO Must also support $moreparam
$out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1, '', '', '', 1, '', '', 'tzuserrel');
} elseif (in_array($type, array('duration'))) { } elseif (in_array($type, array('duration'))) {
$out = $form->select_duration($keyprefix.$key.$keysuffix, $value, 0, 'text', 0, 1); $out = $form->select_duration($keyprefix.$key.$keysuffix, $value, 0, 'text', 0, 1);
} elseif (in_array($type, array('int', 'integer'))) { } elseif (in_array($type, array('int', 'integer'))) {
@ -6911,14 +6920,23 @@ abstract class CommonObject
if ($action == 'selectlines') { $colspan++; } if ($action == 'selectlines') { $colspan++; }
// Convert date into timestamp format (value in memory must be a timestamp) // 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'))) if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date')))
{ {
$datenotinstring = $this->array_options['options_'.$key]; $datenotinstring = $this->array_options['options_'.$key];
if (!is_numeric($this->array_options['options_'.$key])) // For backward compatibility if (!is_numeric($this->array_options['options_'.$key])) // For backward compatibility
{ {
$datenotinstring = $this->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; $value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) ? dol_mktime(12, 0, 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;
}
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('datetime')))
{
$datenotinstring = $this->array_options['options_'.$key];
if (!is_numeric($this->array_options['options_'.$key])) // For backward compatibility
{
$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), GETPOST($keyprefix.'options_'.$key.$keysuffix."sec", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3), 'tzuserrel') : $datenotinstring;
} }
// Convert float submited string into real php numeric (value in memory must be a php numeric) // 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'))) if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('price', 'double')))

View File

@ -1015,17 +1015,26 @@ class ExtraFields
} }
} }
if (in_array($type, array('date', 'datetime'))) { if (in_array($type, array('date'))) {
$tmp = explode(',', $size); $tmp = explode(',', $size);
$newsize = $tmp[0]; $newsize = $tmp[0];
$showtime = 0;
$showtime = in_array($type, array('datetime')) ? 1 : 0;
// Do not show current date when field not required (see selectDate() method) // Do not show current date when field not required (see selectDate() method)
if (!$required && $value == '') $value = '-1'; if (!$required && $value == '') $value = '-1';
// TODO Must also support $moreparam // TODO Must also support $moreparam
$out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1);
} elseif (in_array($type, array('datetime'))) {
$tmp = explode(',', $size);
$newsize = $tmp[0];
$showtime = 1;
// Do not show current date when field not required (see selectDate() method)
if (!$required && $value == '') $value = '-1';
// TODO Must also support $moreparam
$out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1, '', '', '', 1, '', '', 'tzuserrel');
} elseif (in_array($type, array('int', 'integer'))) } elseif (in_array($type, array('int', 'integer')))
{ {
$tmp = explode(',', $size); $tmp = explode(',', $size);
@ -1562,11 +1571,11 @@ class ExtraFields
if ($type == 'date') if ($type == 'date')
{ {
$showsize = 10; $showsize = 10;
$value = dol_print_date($value, 'day'); $value = dol_print_date($value, 'day'); // For date without hour, date is always GMT for storage and output
} elseif ($type == 'datetime') } elseif ($type == 'datetime')
{ {
$showsize = 19; $showsize = 19;
$value = dol_print_date($value, 'dayhour'); $value = dol_print_date($value, 'dayhour', 'tzuserrel');
} elseif ($type == 'int') } elseif ($type == 'int')
{ {
$showsize = 10; $showsize = 10;
@ -2014,12 +2023,10 @@ class ExtraFields
if (in_array($key_type, array('date'))) { if (in_array($key_type, array('date'))) {
// Clean parameters // Clean parameters
// TODO GMT date in memory must be GMT so we should add gm=true in parameters $value_key = dol_mktime(12, 0, 0, GETPOST("options_".$key."month", 'int'), GETPOST("options_".$key."day", 'int'), GETPOST("options_".$key."year", 'int'));
$value_key = dol_mktime(0, 0, 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]);
} elseif (in_array($key_type, array('datetime'))) { } elseif (in_array($key_type, array('datetime'))) {
// Clean parameters // Clean parameters
// TODO GMT date in memory must be GMT so we should add gm=true in parameters $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');
$value_key = dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]);
} elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) { } elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) {
$value_arr = GETPOST("options_".$key, 'array'); // check if an array $value_arr = GETPOST("options_".$key, 'array'); // check if an array
if (!empty($value_arr)) { if (!empty($value_arr)) {
@ -2086,13 +2093,15 @@ class ExtraFields
$key_type = $this->attributes[$extrafieldsobjectkey]['type'][$key]; $key_type = $this->attributes[$extrafieldsobjectkey]['type'][$key];
} }
if (in_array($key_type, array('date', 'datetime'))) if (in_array($key_type, array('date'))) {
{
if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) continue; // Value was not provided, we should not set it. if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) continue; // Value was not provided, we should not set it.
// Clean parameters // Clean parameters
$value_key = dol_mktime(GETPOST($keysuffix."options_".$key.$keyprefix."hour", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."min", 'int'), 0, GETPOST($keysuffix."options_".$key.$keyprefix."month", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."day", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."year", 'int')); $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'));
} elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) } elseif (in_array($key_type, array('datetime'))) {
{ if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) continue; // Value was not provided, we should not set it.
// Clean parameters
$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');
} elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) {
if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it. if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it.
$value_arr = GETPOST($keysuffix."options_".$key.$keyprefix); $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix);
// Make sure we get an array even if there's only one checkbox // Make sure we get an array even if there's only one checkbox

View File

@ -517,24 +517,28 @@ function dol_get_last_day($year, $month = 12, $gm = false)
* Return GMT time for last hour of a given GMT date (it removes hours, min and second part) * Return GMT time for last hour of a given GMT date (it removes hours, min and second part)
* *
* @param int $date Date * @param int $date Date
* @param mixed $gm False or 0 or 'tzserver' = Return date to compare with server TZ,
* True or 1 or 'gmt' to compare with GMT date.
* @return int Date for last hour of a given date * @return int Date for last hour of a given date
*/ */
function dol_get_last_hour($date) function dol_get_last_hour($date, $gm = 'tzserver')
{ {
$tmparray = dol_getdate($date); $tmparray = dol_getdate($date);
return dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year'], false); return dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year'], $gm);
} }
/** /**
* Return GMT time for first hour of a given GMT date (it removes hours, min and second part) * Return GMT time for first hour of a given GMT date (it removes hours, min and second part)
* *
* @param int $date Date * @param int $date Date
* @param mixed $gm False or 0 or 'tzserver' = Return date to compare with server TZ,
* True or 1 or 'gmt' to compare with GMT date.
* @return int Date for last hour of a given date * @return int Date for last hour of a given date
*/ */
function dol_get_first_hour($date) function dol_get_first_hour($date, $gm = 'tzserver')
{ {
$tmparray = dol_getdate($date); $tmparray = dol_getdate($date);
return dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year'], false); return dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year'], $gm);
} }
/** Return first day of week for a date. First day of week may be monday if option MAIN_START_WEEK is 1. /** Return first day of week for a date. First day of week may be monday if option MAIN_START_WEEK is 1.

View File

@ -168,7 +168,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
print '<td id="'.$html_id.'" class="'.$object->element.'_extras_'.$tmpkeyextra.' wordbreak"'.($cols ? ' colspan="'.$cols.'"' : '').'>'; print '<td id="'.$html_id.'" class="'.$object->element.'_extras_'.$tmpkeyextra.' wordbreak"'.($cols ? ' colspan="'.$cols.'"' : '').'>';
// Convert date into timestamp format // Convert date into timestamp format
if (in_array($extrafields->attributes[$object->table_element]['type'][$tmpkeyextra], array('date', 'datetime'))) if (in_array($extrafields->attributes[$object->table_element]['type'][$tmpkeyextra], array('date')))
{ {
$datenotinstring = $object->array_options['options_'.$tmpkeyextra]; $datenotinstring = $object->array_options['options_'.$tmpkeyextra];
// print 'X'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.'x'; // print 'X'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.'x';
@ -177,7 +177,18 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
$datenotinstring = $db->jdate($datenotinstring); $datenotinstring = $db->jdate($datenotinstring);
} }
//print 'x'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.' - '.dol_print_date($datenotinstring, 'dayhour'); //print 'x'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.' - '.dol_print_date($datenotinstring, 'dayhour');
$value = GETPOSTISSET("options_".$tmpkeyextra) ? dol_mktime(GETPOST("options_".$tmpkeyextra."hour", 'int'), GETPOST("options_".$tmpkeyextra."min", 'int'), 0, GETPOST("options_".$tmpkeyextra."month", 'int'), GETPOST("options_".$tmpkeyextra."day", 'int'), GETPOST("options_".$tmpkeyextra."year", 'int')) : $datenotinstring; $value = GETPOSTISSET("options_".$tmpkeyextra) ? dol_mktime(12, 0, 0, GETPOST("options_".$tmpkeyextra."month", 'int'), GETPOST("options_".$tmpkeyextra."day", 'int'), GETPOST("options_".$tmpkeyextra."year", 'int')) : $datenotinstring;
}
if (in_array($extrafields->attributes[$object->table_element]['type'][$tmpkeyextra], array('datetime')))
{
$datenotinstring = $object->array_options['options_'.$tmpkeyextra];
// print 'X'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.'x';
if (!is_numeric($object->array_options['options_'.$tmpkeyextra])) // For backward compatibility
{
$datenotinstring = $db->jdate($datenotinstring);
}
//print 'x'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.' - '.dol_print_date($datenotinstring, 'dayhour');
$value = GETPOSTISSET("options_".$tmpkeyextra) ? dol_mktime(GETPOST("options_".$tmpkeyextra."hour", 'int'), GETPOST("options_".$tmpkeyextra."min", 'int'), GETPOST("options_".$tmpkeyextra."sec", 'int'), GETPOST("options_".$tmpkeyextra."month", 'int'), GETPOST("options_".$tmpkeyextra."day", 'int'), GETPOST("options_".$tmpkeyextra."year", 'int'), 'tzuserrel') : $datenotinstring;
} }
//TODO Improve element and rights detection //TODO Improve element and rights detection

View File

@ -493,11 +493,11 @@ if ($num > 0)
print '</td>'; print '</td>';
print '<td class="center">'; print '<td class="center">';
if (!empty($obj->datestart)) { print dol_print_date($db->jdate($obj->datestart), 'dayhour'); } if (!empty($obj->datestart)) { print dol_print_date($db->jdate($obj->datestart), 'dayhour', 'tzserver'); }
print '</td>'; print '</td>';
print '<td class="center">'; print '<td class="center">';
if (!empty($obj->dateend)) { print dol_print_date($db->jdate($obj->dateend), 'dayhour'); } if (!empty($obj->dateend)) { print dol_print_date($db->jdate($obj->dateend), 'dayhour', 'tzserver'); }
print '</td>'; print '</td>';
print '<td class="right">'; print '<td class="right">';
@ -507,7 +507,7 @@ if ($num > 0)
// Date start last run // Date start last run
print '<td class="center">'; print '<td class="center">';
if (!empty($datelastrun)) { print dol_print_date($datelastrun, 'dayhoursec'); } if (!empty($datelastrun)) { print dol_print_date($datelastrun, 'dayhoursec', 'tzserver'); }
print '</td>'; print '</td>';
// Duration // Duration