$this->currency = $val['currency'];
$this->plugins = $val['plugins'];
$this->lock_spec = $val['lock_spec'];
- /*
$this->workday_minutes = $val['workday_minutes'];
+ /*
$this->custom_logo = $val['custom_logo'];
*/
$this->config = $val['config'];
// Handle localized fractional hours.
global $user;
- $localizedPattern = '/^(\d{1,3})?['.$user->decimal_mark.'][0-9]{1,4}h?$/';
+ $localizedPattern = '/^(\d{1,3})?['.$user->getDecimalMark().'][0-9]{1,4}h?$/';
if (preg_match($localizedPattern, $duration )) { // decimal values like .5, 1.25h, ... .. 999.9999h (or with comma)
- if ($user->decimal_mark == ',')
+ if ($user->getDecimalMark() == ',')
$duration = str_replace (',', '.', $duration);
$minutes = (int)round(60 * floatval($duration));
// getRecords - returns time records for a user for a given date.
static function getRecords($user_id, $date) {
global $user;
+ $mdb2 = getConnection();
+
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
+
$sql_time_format = "'%k:%i'"; // 24 hour format.
- if ('%I:%M %p' == $user->time_format)
+ if ('%I:%M %p' == $user->getTimeFormat())
$sql_time_format = "'%h:%i %p'"; // 12 hour format for MySQL TIME_FORMAT function.
- $result = array();
- $mdb2 = getConnection();
-
$client_field = null;
if ($user->isPluginEnabled('cl'))
$client_field = ", c.name as client";
if ($user->isPluginEnabled('cl'))
$left_joins .= " left join tt_clients c on (l.client_id = c.id)";
+ $result = array();
$sql = "select l.id as id, TIME_FORMAT(l.start, $sql_time_format) as start,
TIME_FORMAT(sec_to_time(time_to_sec(l.start) + time_to_sec(l.duration)), $sql_time_format) as finish,
TIME_FORMAT(l.duration, '%k:%i') as duration, p.name as project, t.name as task, l.comment, l.billable, l.invoice_id $client_field
from tt_log l
$left_joins
- where l.date = '$date' and l.user_id = $user_id and l.status = 1
+ where l.date = '$date' and l.user_id = $user_id and l.group_id = $group_id and l.org_id = $org_id and l.status = 1
order by l.start, l.id";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
return ($this->behalfGroup ? $this->behalfGroup->lock_spec : $this->lock_spec);
}
+ // getWorkdayMinutes returns workday_minutes for active group.
+ function getWorkdayMinutes() {
+ return ($this->behalfGroup ? $this->behalfGroup->workday_minutes : $this->workday_minutes);
+ }
+
// getConfig returns config string for active group.
function getConfig() {
return ($this->behalfGroup ? $this->behalfGroup->config : $this->config);
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.18.29.4630 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.29.4631 | 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>
// update - deletes a quota, then inserts a new one.
public function update($year, $month, $minutes) {
- $deleteSql = "DELETE FROM tt_monthly_quotas WHERE year = $year AND month = $month AND group_id = $this->group_id";
+ $deleteSql = "delete from tt_monthly_quotas".
+ " where year = $year and month = $month and group_id = $this->group_id and org_id = $this->org_id";
$this->db->exec($deleteSql);
if ($minutes){
- $insertSql = "INSERT INTO tt_monthly_quotas (group_id, org_id, year, month, minutes)".
+ $insertSql = "insert into tt_monthly_quotas (group_id, org_id, year, month, minutes)".
" values ($this->group_id, $this->org_id, $year, $month, $minutes)";
$affected = $this->db->exec($insertSql);
return (!is_a($affected, 'PEAR_Error'));
// getSingle - obtains a quota for a single month.
private function getSingle($year, $month) {
- $sql = "SELECT minutes FROM tt_monthly_quotas WHERE year = $year AND month = $month AND group_id = $this->group_id";
+ $sql = "select minutes from tt_monthly_quotas".
+ " where year = $year and month = $month and group_id = $this->group_id and org_id = $this->org_id";
$reader = $this->db->query($sql);
if (is_a($reader, 'PEAR_Error')) {
return false;
// If we did not find a record, return a calculated monthly quota.
$numWorkdays = $this->getNumWorkdays($month, $year);
global $user;
- return $numWorkdays * $user->workday_minutes;
+ return $numWorkdays * $user->getWorkdayMinutes();
}
// getMany - returns an array of quotas for a given year for group.
private function getMany($year){
- $sql = "SELECT month, minutes FROM tt_monthly_quotas WHERE year = $year AND group_id = $this->group_id";
+ $sql = "select month, minutes from tt_monthly_quotas".
+ " where year = $year and group_id = $this->group_id and org_id = $this->org_id";
$result = array();
$res = $this->db->query($sql);
if (is_a($res, 'PEAR_Error')) {
}
global $user;
- $localizedPattern = '/^([0-9]{1,3})?['.$user->decimal_mark.'][0-9]{1,4}h?$/';
+ $localizedPattern = '/^([0-9]{1,3})?['.$user->getDecimalMark().'][0-9]{1,4}h?$/';
if (preg_match($localizedPattern, $value )) { // decimal values like 000.5, 999.25h, ... .. 999.9999h (or with comma)
return true;
}
}
global $user;
- $localizedPattern = '/^([0-9]{1,3})?['.$user->decimal_mark.'][0-9]{1,4}h?$/';
+ $localizedPattern = '/^([0-9]{1,3})?['.$user->getDecimalMark().'][0-9]{1,4}h?$/';
if (preg_match($localizedPattern, $value )) { // decimal values like 000.5, 999.25h, ... .. 999.9999h (or with comma)
// Strip optional h in the end.
$value = trim($value, 'h');
- if ($user->decimal_mark == ',')
+ if ($user->getDecimalMark() == ',')
$value = str_replace(',', '.', $value);
return (float) $value;
}
// Handle workday hours.
$workday_minutes = ttTimeHelper::postedDurationToMinutes($request->getParameter('workdayHours'));
- if ($workday_minutes != $user->workday_minutes) {
+ if ($workday_minutes != $user->getWorkdayMinutes()) {
if (!$user->updateGroup(array('workday_minutes'=>$workday_minutes)))
$err->add($i18n->get('error.db'));
}
// Get monthly quotas for the entire year.
$monthsData = $quota->get($selectedYear);
-$workdayHours = ttTimeHelper::toAbsDuration($user->workday_minutes, true);
+$workdayHours = ttTimeHelper::toAbsDuration($user->getWorkdayMinutes(), true);
$form = new Form('monthlyQuotasForm');
$form->addInput(array('type'=>'text', 'name'=>'workdayHours', 'value'=>$workdayHours, 'style'=>'width:60px'));