Preapre type "datetimegmt"
This commit is contained in:
parent
9f18938e5a
commit
7b546b4140
@ -2037,7 +2037,7 @@ abstract class CommonObject
|
||||
* @param mixed $value New value
|
||||
* @param string $table To force other table element or element line (should not be used)
|
||||
* @param int $id To force other object id (should not be used)
|
||||
* @param string $format Data format ('text', 'date'). 'text' is used if not defined
|
||||
* @param string $format Data format ('text', 'int', 'date'). 'text' is used if not defined
|
||||
* @param string $id_field To force rowid field name. 'rowid' is used if not defined
|
||||
* @param User|string $fuser Update the user of last update field with this user. If not provided, current user is used except if value is 'none'
|
||||
* @param string $trigkey Trigger key to run (in most cases something like 'XXX_MODIFY')
|
||||
@ -2082,6 +2082,8 @@ abstract class CommonObject
|
||||
$sql .= $field." = ".((int) $value);
|
||||
} elseif ($format == 'date') {
|
||||
$sql .= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null");
|
||||
} elseif ($format == 'dategmt') {
|
||||
$sql .= $field." = ".($value ? "'".$this->db->idate($value, 'gmt')."'" : "null");
|
||||
}
|
||||
|
||||
if ($fk_user_field) {
|
||||
@ -5340,7 +5342,7 @@ abstract class CommonObject
|
||||
$sql .= ", busy";
|
||||
$sql .= ", mandatory";
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= $resource_id;
|
||||
$sql .= ((int) $resource_id);
|
||||
$sql .= ", '".$this->db->escape($resource_type)."'";
|
||||
$sql .= ", '".$this->db->escape($this->id)."'";
|
||||
$sql .= ", '".$this->db->escape($this->element)."'";
|
||||
@ -6325,6 +6327,13 @@ abstract class CommonObject
|
||||
}
|
||||
$new_array_options[$key] = $this->db->idate($this->array_options[$key]);
|
||||
break;
|
||||
case 'datetimegmt':
|
||||
// If data is a string instead of a timestamp, we convert it
|
||||
if (!is_numeric($this->array_options[$key]) || $this->array_options[$key] != intval($this->array_options[$key])) {
|
||||
$this->array_options[$key] = strtotime($this->array_options[$key]);
|
||||
}
|
||||
$new_array_options[$key] = $this->db->idate($this->array_options[$key], 'gmt');
|
||||
break;
|
||||
case 'link':
|
||||
$param_list = array_keys($attributeParam['options']);
|
||||
// 0 : ObjectName
|
||||
@ -6665,6 +6674,13 @@ abstract class CommonObject
|
||||
$this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key]);
|
||||
}
|
||||
break;
|
||||
case 'datetimegmt':
|
||||
if (empty($this->array_options["options_".$key])) {
|
||||
$this->array_options["options_".$key] = null;
|
||||
} else {
|
||||
$this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key], 'gmt');
|
||||
}
|
||||
break;
|
||||
case 'boolean':
|
||||
if (empty($this->array_options["options_".$key])) {
|
||||
$this->array_options["options_".$key] = null;
|
||||
|
||||
@ -79,6 +79,7 @@ class ExtraFields
|
||||
'double'=>'Float',
|
||||
'date'=>'Date',
|
||||
'datetime'=>'DateAndTime',
|
||||
//'datetimegmt'=>'DateAndTimeUTC',
|
||||
'boolean'=>'Boolean',
|
||||
'price'=>'ExtrafieldPrice',
|
||||
'pricecy'=>'ExtrafieldPriceWithCurrency',
|
||||
@ -979,7 +980,7 @@ class ExtraFields
|
||||
// Add automatic css
|
||||
if ($type == 'date') {
|
||||
$morecss = 'minwidth100imp';
|
||||
} elseif ($type == 'datetime' || $type == 'link') {
|
||||
} elseif ($type == 'datetime' || $type == 'datetimegmt' || $type == 'link') {
|
||||
$morecss = 'minwidth200imp';
|
||||
} elseif (in_array($type, array('int', 'integer', 'double', 'price'))) {
|
||||
$morecss = 'maxwidth75';
|
||||
@ -1031,7 +1032,7 @@ class ExtraFields
|
||||
// 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);
|
||||
}
|
||||
} elseif (in_array($type, array('datetime'))) {
|
||||
} elseif (in_array($type, array('datetime', 'datetimegmt'))) {
|
||||
$tmp = explode(',', $size);
|
||||
$newsize = $tmp[0];
|
||||
$showtime = 1;
|
||||
@ -1614,6 +1615,11 @@ class ExtraFields
|
||||
if ($value !== '') {
|
||||
$value = dol_print_date($value, 'dayhour', 'tzuserrel');
|
||||
}
|
||||
} elseif ($type == 'datetimegmt') {
|
||||
$showsize = 19;
|
||||
if ($value !== '') {
|
||||
$value = dol_print_date($value, 'dayhour', 'gmt');
|
||||
}
|
||||
} elseif ($type == 'int') {
|
||||
$showsize = 10;
|
||||
} elseif ($type == 'double') {
|
||||
@ -1928,7 +1934,7 @@ class ExtraFields
|
||||
|
||||
$cssstring = '';
|
||||
|
||||
if (in_array($type, array('date', 'datetime'))) {
|
||||
if (in_array($type, array('date', 'datetime', 'datetimegmt'))) {
|
||||
$cssstring = "center";
|
||||
} elseif (in_array($type, array('int', 'price', 'double'))) {
|
||||
$cssstring = "right";
|
||||
@ -2137,6 +2143,9 @@ class ExtraFields
|
||||
} elseif (in_array($key_type, array('datetime'))) {
|
||||
// Clean 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');
|
||||
} elseif (in_array($key_type, array('datetimegmt'))) {
|
||||
// Clean 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'), 'gmt');
|
||||
} elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) {
|
||||
$value_arr = GETPOST("options_".$key, 'array'); // check if an array
|
||||
if (!empty($value_arr)) {
|
||||
@ -2228,7 +2237,7 @@ class ExtraFields
|
||||
} else {
|
||||
continue; // Value was not provided, we should not set it.
|
||||
}
|
||||
} elseif (in_array($key_type, array('datetime'))) {
|
||||
} elseif (in_array($key_type, array('datetime', 'datetimegmt'))) {
|
||||
$dateparamname_start = $keysuffix . 'options_' . $key . $keyprefix . '_start';
|
||||
$dateparamname_end = $keysuffix . 'options_' . $key . $keyprefix . '_end';
|
||||
if (GETPOSTISSET($dateparamname_start . 'year') && GETPOSTISSET($dateparamname_end . 'year')) {
|
||||
@ -2236,13 +2245,24 @@ class ExtraFields
|
||||
$dateparamname_end_hour = GETPOST($dateparamname_end . 'hour', 'int') !='-1' ? GETPOST($dateparamname_end . 'hour', 'int') : '23';
|
||||
$dateparamname_end_min = GETPOST($dateparamname_end . 'min', 'int') !='-1' ? GETPOST($dateparamname_end . 'min', 'int') : '59';
|
||||
$dateparamname_end_sec = GETPOST($dateparamname_end . 'sec', 'int') !='-1' ? GETPOST($dateparamname_end . 'sec', 'int') : '59';
|
||||
$value_key = array(
|
||||
'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'),
|
||||
'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')
|
||||
);
|
||||
if ($key_type == 'datetimegmt') {
|
||||
$value_key = array(
|
||||
'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'), 'gmt'),
|
||||
'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'), 'gmt')
|
||||
);
|
||||
} else {
|
||||
$value_key = array(
|
||||
'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'),
|
||||
'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')
|
||||
);
|
||||
}
|
||||
} elseif (GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) {
|
||||
// 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');
|
||||
if ($key_type == 'datetimegmt') {
|
||||
$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'), 'gmt');
|
||||
} else {
|
||||
$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');
|
||||
}
|
||||
} else {
|
||||
continue; // Value was not provided, we should not set it.
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user