From 63e5361ac71ce6ffa67a3eb0587896ee0c9ef718 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Mon, 24 Jul 2023 17:27:08 +0200 Subject: [PATCH] #442 [Dashboard] add: display year with SOCIETE_FISCAL_MONTH_START interval --- class/dolisirhdashboard.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/class/dolisirhdashboard.class.php b/class/dolisirhdashboard.class.php index a1f9db5..a8877cb 100644 --- a/class/dolisirhdashboard.class.php +++ b/class/dolisirhdashboard.class.php @@ -170,10 +170,15 @@ public function getTimeSpentReport(): array $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START; $userID = GETPOSTISSET('search_userid') ? GETPOST('search_userid', 'int') : $user->id; + $month = GETPOSTISSET('search_month') ? GETPOST('search_month', 'int') : date('m'); $year = GETPOSTISSET('search_year') ? GETPOST('search_year', 'int') : date('Y'); + if ($month < $startmonth) { + $year--; + } + // Graph Title parameters - $array['title'] = $langs->transnoentities('TimeSpentReportByFiscalYear'); + $array['title'] = $langs->transnoentities('TimeSpentReportByFiscalYear') . ' ' . $year . ' - ' . ($year + 1); $array['picto'] = 'clock'; // Graph parameters @@ -198,7 +203,7 @@ public function getTimeSpentReport(): array $workingHours = $workinghours->fetchCurrentWorkingHours($userID, 'user'); for ($i = 1; $i < 13; $i++) { - $firstdaytoshow = dol_get_first_day($year, $i); + $firstdaytoshow = dol_get_first_day((($startmonth <= $i) ? $year : $year + 1), $i); $lastdayofmonth = strtotime(date('Y-m-t', $firstdaytoshow)); $currentMonth = date('m', dol_now());