Skip to content

Commit

Permalink
#417 [TimeSheet] fix: various change after test
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Jul 20, 2023
1 parent a381421 commit 0cfca3c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions class/timesheet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ class TimeSheet extends SaturneObject
'fk_user_creat' => ['type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'picto' => 'user', 'enabled' => 1, 'position' => 160, 'notnull' => 1, 'visible' => 0, 'foreignkey' => 'user.rowid'],
'fk_user_modif' => ['type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'picto' => 'user', 'enabled' => 1, 'position' => 170, 'notnull' => 0, 'visible' => 0, 'foreignkey' => 'user.rowid'],
'fk_user_assign' => ['type' => 'integer:User:user/class/user.class.php:1:(t.employee:=:1:AND:t.fk_soc:IS:NULL:AND:t.statut:=:1)', 'label' => 'UserAssign', 'picto' => 'user', 'enabled' => 1, 'position' => 90, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'validate' => 1, 'foreignkey' => 'user.rowid'],
'fk_project' => ['type' => 'integer:Project:projet/class/project.class.php:1', 'label' => 'Project', 'picto' => 'company', 'enabled' => '$conf->project->enabled', 'position' => 80, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'validate' => 1, 'foreignkey' => 'projet.rowid'],
'fk_soc' => ['type' => 'integer:Societe:societe/class/societe.class.php:1', 'label' => 'ThirdParty', 'picto' => 'project', 'enabled' => '$conf->societe->enabled', 'position' => 120, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'validate' => 1, 'foreignkey' => 'societe.rowid'],
'fk_project' => ['type' => 'integer:Project:projet/class/project.class.php:1', 'label' => 'Project', 'picto' => 'project', 'enabled' => '$conf->project->enabled', 'position' => 80, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'validate' => 1, 'foreignkey' => 'projet.rowid'],
'fk_soc' => ['type' => 'integer:Societe:societe/class/societe.class.php:1', 'label' => 'ThirdParty', 'picto' => 'company', 'enabled' => '$conf->societe->enabled', 'position' => 120, 'notnull' => 0, 'visible' => 1, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'validate' => 1, 'foreignkey' => 'societe.rowid'],
];

/**
Expand Down
2 changes: 1 addition & 1 deletion langs/fr_FR/dolisirh.lang
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ ErrorServiceTime = Le temps du(des) service(s) est nul
SetupDefaultDataNotCreated = Vous n'avez pas créé les données par défaut de DOLISIRH
HowToSetupDefaultData = Pour configurer les données par défaut de DOLISIRH, veuillez cliquer sur ce lien :
ConfigDefaultData = Configuration des données par défaut de DOLISIRH
EnableDoliSIRH = Veuillez activer le module DoliSIRH pour accéder à cette page
EnableDolisirh = Veuillez activer le module DoliSIRH pour accéder à cette page



Expand Down
4 changes: 3 additions & 1 deletion lib/dolisirh_timespent.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function load_time_spent_on_tasks_within_range(int $timestampStart, int $timesta
$timeSpentOnTasks = ['days' => 0, 'hours' => 0, 'minutes' => 0, 'total' => 0];
$timeSpentList = $task->fetchAllTimeSpent($userTmp, 'AND (ptt.task_date >= "' . $db->idate($timestampStart) . '" AND ptt.task_date < "' . $db->idate($timestampEnd) . '")');
if (is_array($timeSpentList) && !empty($timeSpentList)) {
$workingDays = [];
foreach ($timeSpentList as $timeSpent) {
$hours = floor($timeSpent->timespent_duration / 3600);
$minutes = floor($timeSpent->timespent_duration / 60);
Expand All @@ -120,9 +121,10 @@ function load_time_spent_on_tasks_within_range(int $timestampStart, int $timesta
$timeSpentOnTasks[$timeSpent->fk_task]['task_label'] = $timeSpent->task_label;

$timeSpentOnTasks[$timeSpent->fk_task][dol_print_date($timeSpent->timespent_date, 'day')] += $timeSpent->timespent_duration;
$workingDays[$timeSpent->timespent_date] = 1;
}
}
$timeSpentOnTasks['days'] = count($daysAvailable);
$timeSpentOnTasks['days'] = is_array($workingDays) && !empty($workingDays) ? count($workingDays) : 0;
}

return $timeSpentOnTasks;
Expand Down
7 changes: 3 additions & 4 deletions view/timesheet/timesheet_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@

// Due to Dolibarr issue in common field add we do substract 12 hours in timestamp.
$firstDayToShow = $object->date_start - 12 * 3600;
$lastDayToShow = $object->date_end - 12 * 3600;
$lastDayToShow = $object->date_end - 12 * 3600;

$startDate = dol_print_date($firstDayToShow, 'dayreduceformat');
$endDate = dol_print_date($lastDayToShow, 'dayreduceformat');
Expand Down Expand Up @@ -628,7 +628,6 @@

// Working hours.
$workingTime = $timeSpendingInfos['spent'];

if ($plannedWorkingTime['days'] > $workingTime['days']) {
$morecssDays = colorStringToArray($conf->global->DOLISIRH_EXCEEDED_TIME_SPENT_COLOR);
} elseif ($plannedWorkingTime['days'] < $workingTime['days']){
Expand All @@ -639,9 +638,9 @@

print '<tr class="liste_total"><td class="liste_total">';
print $langs->trans('Total');
print '<span class="opacitymediumbycolor"> - ';
print '<span class="opacitymediumbycolor"> - ';
print $langs->trans('ConsumedWorkingHoursMonth', $startDate, $endDate);
print ' : <strong>'.convertSecondToTime($workingTime['total'], 'allhourmin') . '</strong>';
print ' : <strong>' . convertSecondToTime($workingTime['total'], 'allhourmin') . '</strong>';
print '<span>' . ' - ' . $langs->trans('ConsumedWorkingDayMonth') . ' <strong style="color:' . 'rgb(' . $morecssDays[0] . ',' . $morecssDays[1] . ',' . $morecssDays[2] . ');' . '">';
print $workingTime['days'] . '</strong></span>';
print '</span>';
Expand Down

0 comments on commit 0cfca3c

Please sign in to comment.