static function getWhere($options) {
global $user;
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
+
// Prepare dropdown parts.
$dropdown_parts = '';
if ($options['client_id'])
if ($user->can('view_reports') || $user->can('view_all_reports') || $user->isClient())
$user_list_part = " and l.user_id in ($userlist)";
else
- $user_list_part = " and l.user_id = ".$user->id;
- $user_list_part .= " and l.group_id = ".$user->getGroup();
+ $user_list_part = " and l.user_id = ".$user->getUser();
+ $user_list_part .= " and l.group_id = $group_id and l.org_id = $org_id";
// Prepare sql query part for where.
+ $dateFormat = $user->getDateFormat();
if ($options['period'])
- $period = new Period($options['period'], new DateAndTime($user->date_format));
+ $period = new Period($options['period'], new DateAndTime($dateFormat));
else {
$period = new Period();
$period->setPeriod(
- new DateAndTime($user->date_format, $options['period_start']),
- new DateAndTime($user->date_format, $options['period_end']));
+ new DateAndTime($dateFormat, $options['period_start']),
+ new DateAndTime($dateFormat, $options['period_end']));
}
$where = " where l.status = 1 and l.date >= '".$period->getStartDate(DB_DATEFORMAT)."' and l.date <= '".$period->getEndDate(DB_DATEFORMAT)."'".
" $user_list_part $dropdown_parts";
}
// getTimeForDay - gets total time for a user for a specific date.
- static function getTimeForDay($user_id, $date) {
+ static function getTimeForDay($date) {
+ global $user;
$mdb2 = getConnection();
- $sql = "select sum(time_to_sec(duration)) as sm from tt_log where user_id = $user_id and date = '$date' and status = 1";
+ $user_id = $user->getUser();
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
+
+ $sql = "select sum(time_to_sec(duration)) as sm from tt_log".
+ " where user_id = $user_id and group_id = $group_id and org_id = $org_id and date = '$date' and status = 1";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
$val = $res->fetchRow();
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.18.30.4643 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.30.4644 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
$smarty->assign('next_date', $next_date);
$smarty->assign('prev_date', $prev_date);
$smarty->assign('time_records', ttTimeHelper::getRecords($user_id, $cl_date));
-$smarty->assign('day_total', ttTimeHelper::getTimeForDay($user_id, $cl_date));
+$smarty->assign('day_total', ttTimeHelper::getTimeForDay($cl_date));
$smarty->assign('client_list', $client_list);
$smarty->assign('project_list', $project_list);
$smarty->assign('task_list', $task_list);
$smarty->assign('time_records', ttTimeHelper::getRecords($user->getUser(), $cl_date));
-$smarty->assign('day_total', ttTimeHelper::getTimeForDay($user->getUser(), $cl_date));
+$smarty->assign('day_total', ttTimeHelper::getTimeForDay($cl_date));
$smarty->assign('client_list', $client_list);
$smarty->assign('project_list', $project_list);
$smarty->assign('task_list', $task_list);
$smarty->assign('selected_date', $selected_date);
$smarty->assign('week_total', $week_total);
-$smarty->assign('day_total', ttTimeHelper::getTimeForDay($user_id, $cl_date));
+$smarty->assign('day_total', ttTimeHelper::getTimeForDay($cl_date));
$smarty->assign('time_records', ttTimeHelper::getRecords($user_id, $cl_date));
$smarty->assign('client_list', $client_list);
$smarty->assign('project_list', $project_list);