From 02649cd1c0f39d44fd21e0ddc9f5e5eb428409c8 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sat, 4 Aug 2018 18:58:36 +0000 Subject: [PATCH] Fixed a bug in sql query for work units calculation. --- WEB-INF/lib/ttReportHelper.class.php | 23 +++++++++++------------ WEB-INF/templates/footer.tpl | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index 28a0bc54..4fb5ca1f 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -394,7 +394,7 @@ class ttReportHelper { static function getSubtotals($bean, $options) { global $user; - $group_by_option = $bean->getAttribute('group_by'); + $group_by_option = $options['group_by']; if ('no_grouping' == $group_by_option) return null; $mdb2 = getConnection(); @@ -434,12 +434,12 @@ class ttReportHelper { } $where = ttReportHelper::getWhere($options); - if ($bean->getAttribute('chcost')) { + if ($options['show_cost']) { if (MODE_TIME == $user->tracking_mode) { if ($group_by_option != 'user') $left_join = 'left join tt_users u on (l.user_id = u.id)'; $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time"; - if ($bean->getAttribute('chunits')) { + if ($options['show_work_units']) { if ($user->unit_totals_only) $sql .= ", if (sum(l.billable * time_to_sec(l.duration)/60) < $user->first_unit_threshold, 0, ceil(sum(l.billable * time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; else @@ -589,15 +589,14 @@ class ttReportHelper { if (MODE_TIME == $user->tracking_mode) { if ($group_by_option != 'user') $left_join = 'left join tt_users u on (l.user_id = u.id)'; - $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time"; - if ($options['show_work_units']) { - if ($user->unit_totals_only) - $sql .= ", if (sum(l.billable * time_to_sec(l.duration)/60) < $user->first_unit_threshold, 0, ceil(sum(l.billable * time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; - else - $sql .= ", sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; - } - $sql .= ", sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; - $sql .= ", sum(cast(l.billable * coalesce(u.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10, 2))) as cost, + $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time"; + if ($options['show_work_units']) { + if ($user->unit_totals_only) + $sql .= ", if (sum(l.billable * time_to_sec(l.duration)/60) < $user->first_unit_threshold, 0, ceil(sum(l.billable * time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + else + $sql .= ", sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units"; + } + $sql .= ", sum(cast(l.billable * coalesce(u.rate, 0) * time_to_sec(l.duration)/3600 as decimal(10, 2))) as cost, null as expenses from tt_log l $group_join $left_join $where group by $group_field"; } else { diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 27bbebd3..766f8737 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.97.4314 | Copyright © Anuko | +  Anuko Time Tracker 1.17.98.4315 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1