FIX count of open day when date and start are not open should be 0

This commit is contained in:
Laurent Destailleur 2020-05-07 17:21:27 +02:00
parent d6887f3ca4
commit 0cd05887ce
2 changed files with 12 additions and 2 deletions

View File

@ -896,15 +896,23 @@ function num_open_day($timestampStart, $timestampEnd, $inhour = 0, $lastday = 0,
if ($timestampStart < $timestampEnd) if ($timestampStart < $timestampEnd)
{ {
$numdays = num_between_day($timestampStart, $timestampEnd, $lastday); $numdays = num_between_day($timestampStart, $timestampEnd, $lastday);
$numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday); $numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday);
$nbOpenDay = $numdays - $numholidays; $nbOpenDay = $numdays - $numholidays;
$nbOpenDay.= " " . $langs->trans("Days"); $nbOpenDay.= ' '.$langs->trans("Days");
if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); if ($inhour == 1 && $nbOpenDay <= 3) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
} }
elseif ($timestampStart == $timestampEnd) elseif ($timestampStart == $timestampEnd)
{ {
$numholidays = 0;
if ($lastday) {
$numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday);
if ($numholidays == 1) return 0;
}
$nbOpenDay=$lastday; $nbOpenDay=$lastday;
if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort"); if ($inhour == 1) $nbOpenDay = $nbOpenDay*24 . $langs->trans("HourShort");
return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday)); return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
} }

View File

@ -1291,7 +1291,9 @@ else
if ($includesunday) $htmlhelp.='<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday")); if ($includesunday) $htmlhelp.='<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday"));
print $form->textwithpicto($langs->trans('NbUseDaysCP'), $htmlhelp); print $form->textwithpicto($langs->trans('NbUseDaysCP'), $htmlhelp);
print '</td>'; print '</td>';
print '<td>'.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).'</td>'; print '<td>';
print num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday);
print '</td>';
print '</tr>'; print '</tr>';
if ($object->statut == Holiday::STATUS_REFUSED) if ($object->statut == Holiday::STATUS_REFUSED)