return false;
}
- // insert - inserts a time record into log table. Does not deal with custom fields.
+ // insert - inserts a time record into tt_log table. Does not deal with custom fields.
static function insert($fields)
{
global $user;
$mdb2 = getConnection();
$user_id = $fields['user_id'];
+ $group_id = $fields['group_id'];
$date = $fields['date'];
$start = $fields['start'];
$finish = $fields['finish'];
if (!$paid) $paid = 0;
if ($duration) {
- $sql = "insert into tt_log (user_id, date, duration, client_id, project_id, task_id, invoice_id, comment, billable, paid, created, created_ip, created_by $status_f) ".
- "values ($user_id, ".$mdb2->quote($date).", '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable, $paid $created_v $status_v)";
+ $sql = "insert into tt_log (user_id, group_id, date, duration, client_id, project_id, task_id, invoice_id, comment, billable, paid, created, created_ip, created_by $status_f) ".
+ "values ($user_id, ".$mdb2->quote($group_id).", ".$mdb2->quote($date).", '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable, $paid $created_v $status_v)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
if ($duration === false) $duration = 0;
if (!$duration && ttTimeHelper::getUncompleted($user_id)) return false;
- $sql = "insert into tt_log (user_id, date, start, duration, client_id, project_id, task_id, invoice_id, comment, billable, paid, created, created_ip, created_by $status_f) ".
- "values ($user_id, ".$mdb2->quote($date).", '$start', '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable, $paid $created_v $status_v)";
+ $sql = "insert into tt_log (user_id, group_id, date, start, duration, client_id, project_id, task_id, invoice_id, comment, billable, paid, created, created_ip, created_by $status_f) ".
+ "values ($user_id, ".$mdb2->quote($group_id).", ".$mdb2->quote($date).", '$start', '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable, $paid $created_v $status_v)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
var $rank = null; // User role rank.
var $client_id = null; // Client id for client user role.
var $behalf_id = null; // User id, on behalf of whom we are working.
+ var $behalf_group_id = null; // Group id, on behalf of which we are working.
var $behalf_name = null; // User name, on behalf of whom we are working.
+ var $behalf_group = null; // Group name, on behalf of which we are working.
var $email = null; // User email.
var $lang = null; // Language.
var $decimal_mark = null; // Decimal separator.
$this->unit_totals_only = $config->getDefinedValue('unit_totals_only');
}
- // Set "on behalf" id and name.
+ // Set "on behalf" id and name (user).
if (isset($_SESSION['behalf_id'])) {
$this->behalf_id = $_SESSION['behalf_id'];
$this->behalf_name = $_SESSION['behalf_name'];
}
+ // Set "on behalf" id and name (group).
+ if (isset($_SESSION['behalf_group_id'])) {
+ $this->behalf_group_id = $_SESSION['behalf_group_id'];
+ $this->behalf_group = $_SESSION['behalf_group'];
+ }
}
}
return ($this->behalf_id ? $this->behalf_id : $this->id);
}
+ // The getActiveGroup returns group id on behalf of which the current user is operating.
+ function getActiveGroup() {
+ return ($this->behalf_group_id ? $this->behalf_group_id : $this->group_id);
+ }
+
// can - determines whether user has a right to do something.
function can($do_something) {
return in_array($do_something, $this->rights);