From d73d760b53e8cd06f66bdd9ee8fca5f63b5135dc Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 5 May 2025 14:26:14 +0200 Subject: [PATCH] FIX Hour and min were lost when editing a past event. --- htdocs/comm/action/card.php | 16 ++++++++++------ htdocs/core/class/html.form.class.php | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index c8355cf03be..c5f4fb3d2ea 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -885,8 +885,16 @@ if (empty($reshook) && $action == 'update' && $usercancreate) { $datep = dol_mktime(0, 0, 0, GETPOSTINT("apmonth"), GETPOSTINT("apday"), GETPOSTINT("apyear"), $tzforfullday ? $tzforfullday : 'tzuserrel'); $datef = dol_mktime(23, 59, 59, GETPOSTINT("p2month"), GETPOSTINT("p2day"), GETPOSTINT("p2year"), $tzforfullday ? $tzforfullday : 'tzuserrel'); } else { - $datep = dol_mktime(GETPOSTINT("aphour"), GETPOSTINT("apmin"), GETPOSTINT("apsec"), GETPOSTINT("apmonth"), GETPOSTINT("apday"), GETPOSTINT("apyear"), 'tzuserrel'); - $datef = dol_mktime(GETPOSTINT("p2hour"), GETPOSTINT("p2min"), GETPOSTINT("apsec"), GETPOSTINT("p2month"), GETPOSTINT("p2day"), GETPOSTINT("p2year"), 'tzuserrel'); + if (!GETPOSTISSET('ap') && !GETPOSTISSET('aphour') && !GETPOSTISSET('apmin')) { // If date fields are disabled, we keep old value + $datep = $object->datep; + } else { + $datep = dol_mktime(GETPOSTINT("aphour"), GETPOSTINT("apmin"), GETPOSTINT("apsec"), GETPOSTINT("apmonth"), GETPOSTINT("apday"), GETPOSTINT("apyear"), 'tzuserrel'); + } + if (!GETPOSTISSET('p2') && !GETPOSTISSET('p2hour') && !GETPOSTISSET('p2min')) { // If date fields are disabled, we keep old value + $datef = $object->datef; + } else { + $datef = dol_mktime(GETPOSTINT("p2hour"), GETPOSTINT("p2min"), GETPOSTINT("apsec"), GETPOSTINT("p2month"), GETPOSTINT("p2day"), GETPOSTINT("p2year"), 'tzuserrel'); + } } //set end date to now if percentage is set to 100 and end date not set $datef = (!$datef && $percentage == 100) ? dol_now() : $datef; @@ -2138,10 +2146,6 @@ if ($id > 0 && $action != 'create') { // Date start - end print ''; - /*print ''.$langs->trans("DateActionStart").''; - print ' - '; - print 'type_code == 'AC_RDV' ? ' class="fieldrequired"' : '').'>'.$langs->trans("DateActionEnd").''; - */ print ''; $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 2, ($caneditdateorowner ? 0 : 1), 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel'); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8799c78b705..9b1a585f3a3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7655,7 +7655,7 @@ class Form $retstring .= ''; } $retstring .= ''; - //if ($m && empty($conf->dol_optimize_smallscreen)) $retstring .= ":"; + if ($m) { $retstring .= ":"; }