Timesheet - fix inconsistencies in which sums were shown as you change the time filter

(fixes #21497)
This commit is contained in:
nathangray 2017-05-23 15:32:49 -06:00
parent c542be543f
commit 2e57ee9dac

View File

@ -496,11 +496,12 @@ class timesheet_ui extends timesheet_bo
function get_rows(&$query_in,&$rows,&$readonlys,$id_only=false) function get_rows(&$query_in,&$rows,&$readonlys,$id_only=false)
{ {
$this->show_sums = false; $this->show_sums = false;
$end_date = false;
// Date filter // Date filter
$end_date = $query_in['enddate'] ? $query_in['enddate'] : false; if($query_in['filter'] === 'custom')
if($end_date || $query_in['filter'] === 'custom')
{ {
$end_date = $query_in['enddate'] ? $query_in['enddate'] : false;
$query_in['startdate'] = $query_in['startdate'] ? $query_in['startdate'] : 1; $query_in['startdate'] = $query_in['startdate'] ? $query_in['startdate'] : 1;
} }
$date_filter = $this->date_filter($query_in['filter'],$query_in['startdate'],$end_date); $date_filter = $this->date_filter($query_in['filter'],$query_in['startdate'],$end_date);
@ -530,14 +531,14 @@ class timesheet_ui extends timesheet_bo
case 'Saturday': $week_end_day = 'Friday'; break; case 'Saturday': $week_end_day = 'Friday'; break;
} }
$filter_start_day = date('l',$query_in['startdate']+12*60*60); $filter_start_day = date('l',$query_in['startdate']+12*60*60);
$filter_end_day = $query_in['enddate'] ? date('l',$query_in['enddate']+12*60*60) : false; $filter_end_day = $end_date ? date('l',$end_date+12*60*60) : false;
//echo "<p align=right>prefs: $week_start_day - $week_end_day, filter: $filter_start_day - $filter_end_day</p>\n"; //echo "<p align=right>prefs: $week_start_day - $week_end_day, filter: $filter_start_day - $filter_end_day</p>\n";
if ($filter_start_day == $week_start_day && (!$filter_end_day || $filter_end_day == $week_end_day)) if ($filter_start_day == $week_start_day && (!$filter_end_day || $filter_end_day == $week_end_day))
{ {
$this->show_sums[] = 'week'; $this->show_sums[] = 'week';
} }
// show day-sums, if range <= 5 weeks // show day-sums, if range <= 5 weeks
if (!$query_in['enddate'] || $query_in['enddate'] - $query_in['startdate'] < 36*24*60*60) if (!$end_date || $end_date - $query_in['startdate'] < 36*24*60*60)
{ {
$this->show_sums[] = 'day'; $this->show_sums[] = 'day';
} }