Skip to content

Commit

Permalink
#370 [Lib] fix: getDolGlobalInt and dolisirh_num_between_day
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Jul 13, 2023
1 parent acd6672 commit 5ead6aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
7 changes: 1 addition & 6 deletions lib/dolisirh_function.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,7 @@ function dolisirh_num_between_day(int $timestampStart, int$timestampEnd, int $la
{
$daysNumber = 0;
if ($timestampStart <= $timestampEnd) {
if ($lastDay == 1) {
$bit = 0;
} else {
$bit = 1;
}
$daysNumber = (int) round(($timestampEnd - $timestampStart) / (60 * 60 * 24)) + 1 - $bit;
$daysNumber = (int) round(($timestampEnd - $timestampStart) / (60 * 60 * 24)) + 1 - abs($lastDay - 1);
}

return $daysNumber;
Expand Down
10 changes: 5 additions & 5 deletions lib/dolisirh_timespent.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ function timespent_prepare_head(string $mode, User $fkUser): array
$param .= '&search_user_id=' . $fkUser->id;
}

if (!getDolGlobalInt($conf->global->PROJECT_DISABLE_TIMESHEET_PERMONTH)) {
if (!getDolGlobalInt('PROJECT_DISABLE_TIMESHEET_PERMONTH')) {
$head[$h][0] = DOL_URL_ROOT . '/custom/dolisirh/view/timespent_range.php?view_mode=month' . $param;
$head[$h][1] = $langs->trans('InputPerMonth');
$head[$h][2] = 'inputpermonth';
$h++;
}

if (!getDolGlobalInt($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK)) {
if (!getDolGlobalInt('PROJECT_DISABLE_TIMESHEET_PERWEEK')) {
$head[$h][0] = DOL_URL_ROOT . '/custom/dolisirh/view/timespent_range.php?view_mode=week' . $param;
$head[$h][1] = $langs->trans('InputPerWeek');
$head[$h][2] = 'inputperweek';
$h++;
}

if (!getDolGlobalInt($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME)) {
if (!getDolGlobalInt('PROJECT_DISABLE_TIMESHEET_PERTIME')) {
$head[$h][0] = DOL_URL_ROOT.'/custom/dolisirh/view/timespent_range.php?view_mode=day' . $param;
$head[$h][1] = $langs->trans('InputPerDay');
$head[$h][2] = 'inputperday';
Expand Down Expand Up @@ -581,12 +581,12 @@ function task_lines_within_range(int &$inc, int $timestampStart, int $timestampE
}

if (empty($oldProjectForBreak)) {
$oldProjectForBreak = (!getDolGlobalInt($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break.
$oldProjectForBreak = (!getDolGlobalInt('PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT') ? 0 : -1); // 0 = start break, -1 = never break.
}

$restrictBefore = null;

if (getDolGlobalInt($conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS)) {
if (getDolGlobalInt('PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS')) {
$restrictBefore = dol_time_plus_duree(dol_now(), - $conf->global->PROJECT_TIMESHEET_PREVENT_AFTER_MONTHS, 'm');
}

Expand Down

0 comments on commit 5ead6aa

Please sign in to comment.