}
// getTimeForMonth - gets total time for a user for a given month.
- static function getTimeForMonth($user_id, $date){
+ static function getTimeForMonth($date) {
+ global $user;
import('Period');
$mdb2 = getConnection();
+ $user_id = $user->getUser();
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
+
$period = new Period(INTERVAL_THIS_MONTH, $date);
- $sql = "select sum(time_to_sec(duration)) as sm from tt_log where user_id = $user_id and date >= '".$period->getStartDate(DB_DATEFORMAT)."' and date <= '".$period->getEndDate(DB_DATEFORMAT)."' and status = 1";
+ $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 >= '".$period->getStartDate(DB_DATEFORMAT)."' and date <= '".$period->getEndDate(DB_DATEFORMAT)."' 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.4646 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.30.4647 | 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>
require_once('plugins/MonthlyQuota.class.php');
$quota = new MonthlyQuota();
$month_quota_minutes = $quota->get($selected_date->mYear, $selected_date->mMonth);
- $month_total = ttTimeHelper::getTimeForMonth($user_id, $selected_date);
+ $month_total = ttTimeHelper::getTimeForMonth($selected_date);
$minutes_left = $month_quota_minutes - ttTimeHelper::toMinutes($month_total);
$smarty->assign('month_total', $month_total);
require_once('plugins/MonthlyQuota.class.php');
$quota = new MonthlyQuota();
$month_quota = $quota->get($selected_date->mYear, $selected_date->mMonth);
- $month_total = ttTimeHelper::getTimeForMonth($user->getUser(), $selected_date);
+ $month_total = ttTimeHelper::getTimeForMonth($selected_date);
$minutes_left = round(60*$month_quota) - ttTimeHelper::toMinutes($month_total);
$smarty->assign('month_total', $month_total);