Skip to content

Commit

Permalink
Evarisk#616 [Dashboard] add: name on graph and widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-kilyan committed Oct 17, 2024
1 parent d9c5df5 commit 6fe5a0f
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions class/dolisirhdashboard.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,39 @@ public function getColorRange(int $key): string
*/
public function load_dashboard(): array
{
global $langs;
global $langs, $user;

$confName = 'DOLISIRH_DASHBOARD_CONFIG';
$dashboardConfig = json_decode($user->conf->$confName);
$array = ['timesheet' => ['graphs' => [], 'lists' => [], 'disabledGraphs' => []]];

$timeSpendingInfos = self::getTimeSpendingInfos();
$timeSpentReport = self::getTimeSpentReport();
$timeSpentCurrentMonthByTaskAndProject = self::getTimeSpentCurrentMonthByTaskAndProject();
$globalTimeCurrentMonthByTaskAndProject = self::getTimeSpentCurrentMonthByTaskAndProject(1);

$array['timesheet']['widgets'] = [
0 => [
'title' => $langs->transnoentities('TimeSpent'),
'label' => [$timeSpendingInfos['planned']['label'], $timeSpendingInfos['passed']['label'], $timeSpendingInfos['spent']['label'], $timeSpendingInfos['difference']['label']],
'content' => [$timeSpendingInfos['planned']['content'], $timeSpendingInfos['passed']['content'], $timeSpendingInfos['spent']['content'], $timeSpendingInfos['difference']['content']],
'picto' => 'fas fa-clock',
'widgetName' => $langs->transnoentities('TimeSpent')
],
];

$array['timesheet']['graphs'] = [$timeSpentReport, $timeSpentCurrentMonthByTaskAndProject, $globalTimeCurrentMonthByTaskAndProject];
if (empty($dashboardConfig->graphs->TimeSpentReportByFiscalYear->hide)) {
$array['timesheet']['graphs'][] = self::getTimeSpentReport();
} else {
$array['timesheet']['disabledGraphs']['TimeSpentReportByFiscalYear'] = $langs->transnoentities('TimeSpentReportByFiscalYear');
}
if (empty($dashboardConfig->graphs->GlobalTimeCurrentMonthByTaskAndProject->hide)) {
$array['timesheet']['graphs'][] = self::getTimeSpentCurrentMonthByTaskAndProject();
} else {
$array['timesheet']['disabledGraphs']['GlobalTimeCurrentMonthByTaskAndProject'] = $langs->transnoentities('GlobalTimeCurrentMonthByTaskAndProject');
}
if (empty($dashboardConfig->graphs->TimeSpentCurrentMonthByTaskAndProject->hide)) {
$array['timesheet']['graphs'][] = self::getTimeSpentCurrentMonthByTaskAndProject(1);
} else {
$array['timesheet']['disabledGraphs']['TimeSpentCurrentMonthByTaskAndProject'] = $langs->transnoentities('TimeSpentCurrentMonthByTaskAndProject');
}

return $array;
}
Expand Down Expand Up @@ -179,6 +195,7 @@ public function getTimeSpentReport(): array

// Graph Title parameters
$array['title'] = $langs->transnoentities('TimeSpentReportByFiscalYear') . ' ' . $year . ' - ' . ($year + 1);
$array['name'] = 'TimeSpentReportByFiscalYear';
$array['picto'] = 'clock';

// Graph parameters
Expand Down Expand Up @@ -266,6 +283,7 @@ public function getTimeSpentCurrentMonthByTaskAndProject(int $showNotConsumedWor

// Graph Title parameters
$array['title'] = $langs->transnoentities(($showNotConsumedWorkingHours > 0 ? 'GlobalTimeCurrentMonthByTaskAndProject' : 'TimeSpentCurrentMonthByTaskAndProject'), dol_print_date(dol_mktime(0, 0, 0, $month, date('d'), $year), '%B %Y'));
$array['name'] = ($showNotConsumedWorkingHours > 0 ? 'GlobalTimeCurrentMonthByTaskAndProject' : 'TimeSpentCurrentMonthByTaskAndProject');
$array['picto'] = 'projecttask';

// Graph parameters
Expand Down

0 comments on commit 6fe5a0f

Please sign in to comment.