From 0cd05887ce95de5496924a941a92f31155a0ed2e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 May 2020 17:21:27 +0200 Subject: [PATCH] FIX count of open day when date and start are not open should be 0 --- htdocs/core/lib/date.lib.php | 10 +++++++++- htdocs/holiday/card.php | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 123e3297f11..56dfee3988c 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -896,15 +896,23 @@ function num_open_day($timestampStart, $timestampEnd, $inhour = 0, $lastday = 0, if ($timestampStart < $timestampEnd) { $numdays = num_between_day($timestampStart, $timestampEnd, $lastday); + $numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday); $nbOpenDay = $numdays - $numholidays; - $nbOpenDay.= " " . $langs->trans("Days"); + $nbOpenDay.= ' '.$langs->trans("Days"); if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); } elseif ($timestampStart == $timestampEnd) { + $numholidays = 0; + if ($lastday) { + $numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday); + if ($numholidays == 1) return 0; + } + $nbOpenDay=$lastday; + if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); } diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 9cc287cd28a..6dd218255e5 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1291,7 +1291,9 @@ else if ($includesunday) $htmlhelp.='
'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday")); print $form->textwithpicto($langs->trans('NbUseDaysCP'), $htmlhelp); print ''; - print ''.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).''; + print ''; + print num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); + print ''; print ''; if ($object->statut == Holiday::STATUS_REFUSED)