diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 67ebeb4d081..9b08c3542d5 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -1083,7 +1083,7 @@ class Conf extends stdClass $this->global->MAIN_MAX_DECIMALS_SHOWN = 8; } - // Non working days + // Non working days by default if not set in setup if (!isset($this->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY)) { $this->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY = 1; } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index c2f60c5cebe..ef9f2e25021 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2644,11 +2644,12 @@ class Project extends CommonObject /** * Method for calculating weekly hours worked and generating a report + * * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ public function createWeeklyReport() { - global $mysoc, $user; + global $mysoc, $user, $langs; $now = dol_now(); $nowDate = dol_getdate($now, true); @@ -2689,19 +2690,32 @@ class Project extends CommonObject } else { $reportContent = "Weekly time report from $startDate to $endDate

"; $reportContent .= ''; - $reportContent .= ''; + $reportContent .= ''; - $weekendEnabled = 0; $to = ''; $nbMailSend = 0; $error = 0; $errors_to = ''; while ($obj = $this->db->fetch_object($resql)) { $to = $obj->email; + + $weekendEnabled = 0; $numHolidays = num_public_holiday($lastWeekStartTS, $lastWeekEndTS, $mysoc->country_code, 1); - if (getDolGlobalString('MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY') && getDolGlobalString('MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY')) { - $numHolidays -= 2; - $weekendEnabled = 2; + if (getDolGlobalString('MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY')) { + $numHolidays -= 1; + $weekendEnabled += 1; + } + if (getDolGlobalString('MAIN_NON_WORKING_DAYS_INCLUDE_TUESDAY')) { + $numHolidays -= 1; + $weekendEnabled += 1; + } + if (getDolGlobalString('MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY')) { + $numHolidays -= 1; + $weekendEnabled += 1; + } + if (getDolGlobalString('MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY')) { + $numHolidays -= 1; + $weekendEnabled += 1; } $dailyHours = $obj->weeklyhours / (7 - $weekendEnabled);
Nom d\'utilisateurTemps saisi (heures)Temps travaillé par semaine (heures)
'.$langs->trans("User").'Temps saisi (heures)Temps travaillé par semaine (heures)