X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttChartHelper.class.php;h=528fcdb0a4e8ac2b782fae5c616ceb04c7aec71b;hb=75a1eedb8977b8f2db459128bab9aaf367e3b58b;hp=fef7729df84d09f278e9afd8f8641a1e33ff3fdc;hpb=1c55a7cab4f66d3f8d5ba7717e01c5e8256a269a;p=timetracker.git diff --git a/WEB-INF/lib/ttChartHelper.class.php b/WEB-INF/lib/ttChartHelper.class.php index fef7729d..528fcdb0 100644 --- a/WEB-INF/lib/ttChartHelper.class.php +++ b/WEB-INF/lib/ttChartHelper.class.php @@ -63,7 +63,7 @@ class ttChartHelper { $q_period = ''; if ($period != null) { - $q_period = " and date >= '".$period->getBeginDate(DB_DATEFORMAT)."' and date <= '".$period->getEndDate(DB_DATEFORMAT)."'"; + $q_period = " and date >= '".$period->getStartDate(DB_DATEFORMAT)."' and date <= '".$period->getEndDate(DB_DATEFORMAT)."'"; } if (CHART_PROJECTS == $chart_type) { // Data for projects. @@ -77,7 +77,7 @@ class ttChartHelper { where l.status = 1 and l.duration > 0 and l.user_id = $user_id $q_period group by l.task_id"; } elseif (CHART_CLIENTS == $chart_type) { // Data for clients. - $sql = "select coalesce(c.name, 'NULL') as name, sum(time_to_sec(l.duration)) as time from tt_log l + $sql = "select c.name as name, sum(time_to_sec(l.duration)) as time from tt_log l left join tt_clients c on (c.id = l.client_id) where l.status = 1 and l.duration > 0 and l.user_id = $user_id $q_period group by l.client_id"; } @@ -132,4 +132,39 @@ class ttChartHelper { return $result; } + + // adjustType - adjust chart type to something that is available for a group. + static function adjustType($requested_type) { + global $user; + $tracking_mode = $user->getTrackingMode(); + $client_option = $user->isPluginEnabled('cl'); + + // We have 3 possible options for chart tyep: projects, tasks, or clients. + // Deal with each one individually. + + if ($requested_type == CHART_PROJECTS) { + if ($tracking_mode == MODE_PROJECTS || $tracking_mode == MODE_PROJECTS_AND_TASKS) + return CHART_PROJECTS; + else if ($client_option) + return CHART_CLIENTS; + } + + if ($requested_type == CHART_TASKS) { + if ($tracking_mode == MODE_PROJECTS_AND_TASKS) + return CHART_TASKS; + if ($tracking_mode == MODE_PROJECTS) + return CHART_PROJECTS; + else if ($client_option) + return CHART_CLIENTS; + } + + if ($requested_type == CHART_CLIENTS) { + if ($client_option) + return CHART_CLIENTS; + else if ($tracking_mode == MODE_PROJECTS || ($tracking_mode == MODE_PROJECTS_AND_TASKS)) + return CHART_PROJECTS; + } + + return CHART_PROJECTS; + } }