// getUsers obtains user ids in a group.
function getUsers($group_id) {
$mdb2 = getConnection();
- $sql = "select id from tt_users where team_id = $group_id";
+ $sql = "select id from tt_users where group_id = $group_id";
$res = $mdb2->query($sql);
$users = array();
if (!is_a($res, 'PEAR_Error')) {
// The markTasksDeleted deletes task binds and marks the tasks as deleted for a group.
function markTasksDeleted($group_id) {
$mdb2 = getConnection();
- $sql = "select id from tt_tasks where team_id = $group_id";
+ $sql = "select id from tt_tasks where group_id = $group_id";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error')) return false;
// Now that we are done with subgroups, handle this group.
$users = $this->getUsers($group_id);
- // Iterate through team users and mark them as deleted.
+ // Iterate through group users and mark them as deleted.
foreach ($users as $one_user) {
if (!$this->markUserDeleted($one_user['id']))
return false;
$mdb2 = getConnection();
// Mark roles deleted.
- $sql = "update tt_roles set status = NULL where team_id = $group_id";
+ $sql = "update tt_roles set status = NULL where group_id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
// Mark projects deleted.
- $sql = "update tt_projects set status = NULL where team_id = $group_id";
+ $sql = "update tt_projects set status = NULL where group_id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
// Mark clients deleted.
- $sql = "update tt_clients set status = NULL where team_id = $group_id";
+ $sql = "update tt_clients set status = NULL where group_id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
// Mark invoices deleted.
- $sql = "update tt_invoices set status = NULL where team_id = $group_id";
+ $sql = "update tt_invoices set status = NULL where group_id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
// Mark custom fields deleted.
- $sql = "update tt_custom_fields set status = NULL where team_id = $group_id";
+ $sql = "update tt_custom_fields set status = NULL where group_id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
// Mark notifications deleted.
- $sql = "update tt_cron set status = NULL where team_id = $group_id";
+ $sql = "update tt_cron set status = NULL where group_id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
}
// updateGroup validates user input and updates the group with new information.
- function updateGroup($team_id, $fields) {
+ function updateGroup($group_id, $fields) {
if (!$this->validateGroupInfo($fields)) return false; // Can't continue as user input is invalid.
global $user;
if ($fields['old_group_name'] != $fields['new_group_name']) {
$name_part = 'name = '.$mdb2->quote($fields['new_group_name']);
$modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$mdb2->quote($user->id);
- $sql = 'update tt_groups set '.$name_part.$modified_part.' where id = '.$team_id;
+ $sql = 'update tt_groups set '.$name_part.$modified_part.' where id = '.$group_id;
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
}
else
$sql .= 'name ';
- $sql .= "from tt_clients where team_id = $user->team_id
+ $sql .= "from tt_clients where group_id = $user->group_id
and id = $client_id and (status = 1 or status = 0)";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
$mdb2 = getConnection();
$sql = "select id, name from tt_clients
- where team_id = $user->team_id and (status = 0 or status = 1) order by upper(name)";
+ where group_id = $user->group_id and (status = 0 or status = 1) order by upper(name)";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
while ($val = $res->fetchRow()) {
$mdb2 = getConnection();
global $user;
- $sql = "select id from tt_clients where team_id = $user->team_id and name = ".
+ $sql = "select id from tt_clients where group_id = $user->group_id and name = ".
$mdb2->quote($client_name)." and (status = 1 or status = 0)";
$res = $mdb2->query($sql);
$mdb2 = getConnection();
global $user;
- $sql = "select name, address from tt_clients where team_id = $user->team_id
+ $sql = "select name, address from tt_clients where group_id = $user->group_id
and id = $client_id and status is NULL";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
// Handle invoices.
if ($delete_client_entries) {
- $sql = "update tt_invoices set status = NULL where client_id = $id and team_id = $user->team_id";
+ $sql = "update tt_invoices set status = NULL where client_id = $id and group_id = $user->group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
return false;
// Handle users for client.
- $sql = 'update tt_users set status = NULL'.$modified_part." where client_id = $id and team_id = $user->team_id";
+ $sql = 'update tt_users set status = NULL'.$modified_part." where client_id = $id and group_id = $user->group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
// Mark client deleted.
- $sql = "update tt_clients set status = NULL where id = $id and team_id = $user->team_id";
+ $sql = "update tt_clients set status = NULL where id = $id and group_id = $user->group_id";
$affected = $mdb2->exec($sql);
return (!is_a($affected, 'PEAR_Error'));
}
global $user;
$mdb2 = getConnection();
- $team_id = (int) $fields['team_id'];
+ $group_id = (int) $fields['group_id'];
$name = $fields['name'];
$address = $fields['address'];
$tax = $fields['tax'];
$tax = str_replace(',', '.', $tax);
if ($tax == '') $tax = 0;
- $sql = "insert into tt_clients (team_id, name, address, tax, projects, status)
- values ($team_id, ".$mdb2->quote($name).", ".$mdb2->quote($address).", $tax, ".$mdb2->quote($comma_separated).", ".$mdb2->quote($status).")";
+ $sql = "insert into tt_clients (group_id, name, address, tax, projects, status)".
+ " values ($group_id, ".$mdb2->quote($name).", ".$mdb2->quote($address).", $tax, ".$mdb2->quote($comma_separated).", ".$mdb2->quote($status).")";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
// Update client properties in tt_clients table.
$comma_separated = implode(",", $projects); // This is a comma-separated list of associated project ids.
$sql = "update tt_clients set name = ".$mdb2->quote($name).", address = ".$mdb2->quote($address).
- ", tax = $tax, projects = ".$mdb2->quote($comma_separated).", status = $status where team_id = ".$user->team_id." and id = ".$id;
+ ", tax = $tax, projects = ".$mdb2->quote($comma_separated).", status = $status where group_id = ".$user->group_id." and id = ".$id;
$affected = $mdb2->exec($sql);
return (!is_a($affected, 'PEAR_Error'));
}
// The setMappedClient function is used during team import to change client_id value for tt_users to a mapped value.
- static function setMappedClient($team_id, $imported_id, $mapped_id)
+ static function setMappedClient($group_id, $imported_id, $mapped_id)
{
$mdb2 = getConnection();
- $sql = "update tt_users set client_id = $mapped_id where client_id = $imported_id and team_id = $team_id ";
+ $sql = "update tt_users set client_id = $mapped_id where client_id = $imported_id and group_id = $group_id ";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
// Do a query with inner join to get assigned projects.
$sql = "select p.id, p.name from tt_projects p
inner join tt_client_project_binds cpb on (cpb.client_id = $client_id and cpb.project_id = p.id)
- where p.team_id = $user->team_id and p.status = 1 order by p.name";
+ where p.group_id = $user->group_id and p.status = 1 order by p.name";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
while ($val = $res->fetchRow()) {
$sql = "select p.id, p.name from tt_projects p
inner join tt_client_project_binds cpb on (cpb.client_id = $client_id and cpb.project_id = p.id)
inner join tt_user_project_binds upb on (upb.user_id = $user_id and upb.project_id = p.id and upb.status = 1)
- where p.team_id = $user->team_id and p.status = 1 order by p.name";
+ where p.group_id = $user->group_id and p.status = 1 order by p.name";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
while ($val = $res->fetchRow()) {
{
$mdb2 = getConnection();
- $team_id = (int) $fields['team_id'];
+ $group_id = (int) $fields['group_id'];
$type = (int) $fields['type'];
$label = $fields['label'];
$required = (int) $fields['required'];
$status = $fields['status'];
- $sql = "insert into tt_custom_fields (team_id, type, label, required, status)
- values ($team_id, $type, ".$mdb2->quote($label).", $required, ".$mdb2->quote($status).")";
+ $sql = "insert into tt_custom_fields (group_id, type, label, required, status)".
+ " values ($group_id, $type, ".$mdb2->quote($label).", $required, ".$mdb2->quote($status).")";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
$this->userMap[$user_item['id']] = $key + 1;
// Prepare project map.
- $projects = ttTeamHelper::getAllProjects($user->team_id, true);
+ $projects = ttTeamHelper::getAllProjects($user->group_id, true);
foreach ($projects as $key=>$project_item)
$this->projectMap[$project_item['id']] = $key + 1;
// Prepare task map.
- $tasks = ttTeamHelper::getAllTasks($user->team_id, true);
+ $tasks = ttTeamHelper::getAllTasks($user->group_id, true);
foreach ($tasks as $key=>$task_item)
$this->taskMap[$task_item['id']] = $key + 1;
// Prepare client map.
- $clients = ttTeamHelper::getAllClients($user->team_id, true);
+ $clients = ttTeamHelper::getAllClients($user->group_id, true);
foreach ($clients as $key=>$client_item)
$this->clientMap[$client_item['id']] = $key + 1;
$this->invoiceMap[$invoice_item['id']] = $key + 1;
// Prepare custom fields map.
- $custom_fields = ttTeamHelper::getAllCustomFields($user->team_id);
+ $custom_fields = ttTeamHelper::getAllCustomFields($user->group_id);
foreach ($custom_fields as $key=>$custom_field)
$this->customFieldMap[$custom_field['id']] = $key + 1;
// Prepare custom field options map.
- $custom_field_options = ttTeamHelper::getAllCustomFieldOptions($user->team_id);
+ $custom_field_options = ttTeamHelper::getAllCustomFieldOptions($user->group_id);
foreach ($custom_field_options as $key=>$option)
$this->customFieldOptionMap[$option['id']] = $key + 1;
// Write user to project binds.
fwrite($file, "<user_project_binds>\n");
- $user_binds = ttTeamHelper::getUserToProjectBinds($user->team_id);
+ $user_binds = ttTeamHelper::getUserToProjectBinds($user->group_id);
foreach ($user_binds as $bind) {
$user_id = $this->userMap[$bind['user_id']];
$project_id = $this->projectMap[$bind['project_id']];
unset($custom_field_options);
// Write monthly quotas.
- $quotas = ttTeamHelper::getMonthlyQuotas($user->team_id);
+ $quotas = ttTeamHelper::getMonthlyQuotas($user->group_id);
fwrite($file, "<monthly_quotas>\n");
foreach ($quotas as $quota) {
fwrite($file, " <monthly_quota year=\"".$quota['year']."\" month=\"".$quota['month']."\" minutes=\"".$quota['minutes']."\"/>\n");
unset($records);
// Write custom field log.
- $custom_field_log = ttTeamHelper::getCustomFieldLog($user->team_id);
+ $custom_field_log = ttTeamHelper::getCustomFieldLog($user->group_id);
fwrite($file, "<custom_field_log>\n");
foreach ($custom_field_log as $entry) {
fwrite($file, " <custom_field_log_entry log_id=\"".$this->logMap[$entry['log_id']]."\" field_id=\"".$this->customFieldMap[$entry['field_id']]."\" option_id=\"".$this->customFieldOptionMap[$entry['option_id']]."\" status=\"".$entry['status']."\">\n");
unset($custom_field_log);
// Write expense items.
- $expense_items = ttTeamHelper::getExpenseItems($user->team_id);
+ $expense_items = ttTeamHelper::getExpenseItems($user->group_id);
fwrite($file, "<expense_items>\n");
foreach ($expense_items as $expense_item) {
fwrite($file, " <expense_item date=\"".$expense_item['date']."\" user_id=\"".$this->userMap[$expense_item['user_id']]."\" client_id=\"".$this->clientMap[$expense_item['client_id']]."\" project_id=\"".$this->projectMap[$expense_item['project_id']]."\" cost=\"".$expense_item['cost']."\" invoice_id=\"".$this->invoiceMap[$expense_item['invoice_id']]."\" paid=\"".$expense_item['paid']."\" status=\"".$expense_item['status']."\">\n");
// Write fav reports.
fwrite($file, "<fav_reports>\n");
- $fav_reports = ttTeamHelper::getFavReports($user->team_id);
+ $fav_reports = ttTeamHelper::getFavReports($user->group_id);
foreach ($fav_reports as $fav_report) {
$user_list = '';
if (strlen($fav_report['users']) > 0) {
$mdb2 = getConnection();
$result = array();
- $sql = "select * from tt_roles where team_id = $user->team_id";
+ $sql = "select * from tt_roles where group_id = $user->group_id";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
global $user;
$mdb2 = getConnection();
- $sql = "select u.*, r.rank from tt_users u left join tt_roles r on (u.role_id = r.id) where u.team_id = $user->team_id order by upper(u.name)"; // Note: deleted users are included.
+ $sql = "select u.*, r.rank from tt_users u left join tt_roles r on (u.role_id = r.id) where u.group_id = $user->group_id order by upper(u.name)"; // Note: deleted users are included.
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
var $canImport = true; // False if we cannot import data due to a login collision.
var $teamData = array(); // Array of team data such as team name, etc.
- var $team_id = null; // New team id we are importing. It is created during the import operation.
+ var $group_id = null; // New group id we are importing. It is created during the import operation.
var $roles = array(); // Array of arrays of role properties.
var $users = array(); // Array of arrays of user properties.
var $top_role_id = null; // Top manager role id on the new server.
// Now we can create a team.
if ($this->canImport) {
$this->top_role_id = ttRoleHelper::getRoleByRank(512, 0);
- $team_id = ttTeamHelper::insert(array(
+ $group_id = ttTeamHelper::insert(array(
'name' => $this->teamData['NAME'],
'currency' => $this->teamData['CURRENCY'],
'decimal_mark' => $this->teamData['DECIMAL_MARK'],
'lock_spec' => $this->teamData['LOCK_SPEC'],
'workday_minutes' => $this->teamData['WORKDAY_MINUTES'],
'config' => $this->teamData['CONFIG']));
- if ($team_id) {
- $this->team_id = $team_id;
+ if ($group_id) {
+ $this->group_id = $group_id;
// Create roles.
foreach ($this->roles as $key=>$role_item) {
$role_id = ttRoleHelper::insert(array(
- 'team_id' => $this->team_id,
+ 'group_id' => $this->group_id,
'name' => $role_item['NAME'],
'rank' => $role_item['RANK'],
'rights' => $role_item['RIGHTS'],
foreach ($this->users as $key=>$user_item) {
$role_id = $user_item['ROLE_ID'] === '0' ? $this->top_role_id : $this->roleMap[$user_item['ROLE_ID']]; // 0 (not null) means top manager role.
$user_id = ttUserHelper::insert(array(
- 'team_id' => $this->team_id,
+ 'group_id' => $this->group_id,
'role_id' => $role_id,
'client_id' => $user_item['CLIENT_ID'], // Note: NOT mapped value, replaced in CLIENT handler.
'name' => $user_item['NAME'],
if ($name == 'TASK' && $this->canImport) {
$this->taskMap[$this->currentElement['ID']] =
ttTaskHelper::insert(array(
- 'team_id' => $this->team_id,
+ 'group_id' => $this->group_id,
'name' => $this->currentElement['NAME'],
'description' => $this->currentElement['DESCRIPTION'],
'status' => $this->currentElement['STATUS']));
// Add a new project.
$this->projectMap[$this->currentElement['ID']] =
ttProjectHelper::insert(array(
- 'team_id' => $this->team_id,
+ 'group_id' => $this->group_id,
'name' => $this->currentElement['NAME'],
'description' => $this->currentElement['DESCRIPTION'],
'tasks' => $mapped_tasks,
$this->clientMap[$this->currentElement['ID']] =
ttClientHelper::insert(array(
- 'team_id' => $this->team_id,
+ 'group_id' => $this->group_id,
'name' => $this->currentElement['NAME'],
'address' => $this->currentElement['ADDRESS'],
'tax' => $this->currentElement['TAX'],
// Update client_id for tt_users to a mapped value.
// We did not do it during user insertion because clientMap was not ready then.
if ($this->currentElement['ID'] != $this->clientMap[$this->currentElement['ID']])
- ttClientHelper::setMappedClient($this->team_id, $this->currentElement['ID'], $this->clientMap[$this->currentElement['ID']]);
+ ttClientHelper::setMappedClient($this->group_id, $this->currentElement['ID'], $this->clientMap[$this->currentElement['ID']]);
}
if ($name == 'INVOICE' && $this->canImport) {
$this->invoiceMap[$this->currentElement['ID']] =
ttInvoiceHelper::insert(array(
- 'team_id' => $this->team_id,
+ 'group_id' => $this->group_id,
'name' => $this->currentElement['NAME'],
'date' => $this->currentElement['DATE'],
'client_id' => $this->clientMap[$this->currentElement['CLIENT_ID']],
}
if ($name == 'MONTHLY_QUOTA' && $this->canImport) {
- $this->insertMonthlyQuota($this->team_id, $this->currentElement['YEAR'], $this->currentElement['MONTH'], $this->currentElement['MINUTES']);
+ $this->insertMonthlyQuota($this->group_id, $this->currentElement['YEAR'], $this->currentElement['MONTH'], $this->currentElement['MINUTES']);
}
if ($name == 'LOG_ITEM' && $this->canImport) {
if ($name == 'CUSTOM_FIELD' && $this->canImport) {
$this->customFieldMap[$this->currentElement['ID']] =
ttCustomFieldHelper::insertField(array(
- 'team_id' => $this->team_id,
+ 'group_id' => $this->group_id,
'type' => $this->currentElement['TYPE'],
'label' => $this->currentElement['LABEL'],
'required' => $this->currentElement['REQUIRED'],
}
// insertMonthlyQuota - a helper function to insert a monthly quota.
- private function insertMonthlyQuota($team_id, $year, $month, $minutes) {
+ private function insertMonthlyQuota($group_id, $year, $month, $minutes) {
$mdb2 = getConnection();
- $sql = "INSERT INTO tt_monthly_quotas (team_id, year, month, minutes) values ($team_id, $year, $month, $minutes)";
+ $sql = "INSERT INTO tt_monthly_quotas (group_id, year, month, minutes) values ($group_id, $year, $month, $minutes)";
$affected = $mdb2->exec($sql);
return (!is_a($affected, 'PEAR_Error'));
}
{
$mdb2 = getConnection();
- $team_id = (int) $fields['team_id'];
+ $group_id = (int) $fields['group_id'];
$name = $fields['name'];
if (!$name) return false;
}
// Insert a new invoice record.
- $sql = "insert into tt_invoices (team_id, name, date, client_id $status_f)
- values($team_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id $status_v)";
+ $sql = "insert into tt_invoices (group_id, name, date, client_id $status_f)".
+ " values($group_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id $status_v)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
if ($user->isClient()) $client_part = " and client_id = $user->client_id";
- $sql = "select * from tt_invoices where id = $invoice_id and team_id = $user->team_id $client_part and status = 1";
+ $sql = "select * from tt_invoices where id = $invoice_id and group_id = $user->group_id $client_part and status = 1";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
if ($val = $res->fetchRow())
$mdb2 = getConnection();
global $user;
- $sql = "select id from tt_invoices where team_id = $user->team_id and name = ".$mdb2->quote($invoice_name)." and status = 1";
+ $sql = "select id from tt_invoices where group_id = $user->group_id and name = ".$mdb2->quote($invoice_name)." and status = 1";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
$val = $res->fetchRow();
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
- $sql = "update tt_invoices set status = NULL where id = $invoice_id and team_id = $user->team_id";
+ $sql = "update tt_invoices set status = NULL where id = $invoice_id and group_id = $user->group_id";
$affected = $mdb2->exec($sql);
return (!is_a($affected, 'PEAR_Error'));
}
if (isset($fields['project_id'])) $project_id = (int) $fields['project_id'];
// Create a new invoice record.
- $sql = "insert into tt_invoices (team_id, name, date, client_id)
- values($user->team_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id)";
+ $sql = "insert into tt_invoices (group_id, name, date, client_id)
+ values($user->group_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
$sql = "select c.id, c.cron_spec, c.report_id, c.email, c.cc, c.subject, c.report_condition, c.status, fr.name from tt_cron c
left join tt_fav_reports fr on (fr.id = c.report_id)
- where c.id = $id and c.team_id = $user->team_id";
+ where c.id = $id and c.group_id = $user->group_id";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
$val = $res->fetchRow();
$mdb2 = getConnection();
- $sql = "delete from tt_cron where id = $id and team_id = $user->team_id";
+ $sql = "delete from tt_cron where id = $id and group_id = $user->group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
{
$mdb2 = getConnection();
- $team_id = (int) $fields['team_id'];
+ $group_id = (int) $fields['group_id'];
$cron_spec = $fields['cron_spec'];
$next = (int) $fields['next'];
$report_id = (int) $fields['report_id'];
$report_condition = $fields['report_condition'];
$status = $fields['status'];
- $sql = "insert into tt_cron (team_id, cron_spec, next, report_id, email, cc, subject, report_condition, status)
- values ($team_id, ".$mdb2->quote($cron_spec).", $next, $report_id, ".$mdb2->quote($email).", ".$mdb2->quote($cc).", ".$mdb2->quote($subject).", ".$mdb2->quote($report_condition).", ".$mdb2->quote($status).")";
+ $sql = "insert into tt_cron (group_id, cron_spec, next, report_id, email, cc, subject, report_condition, status)
+ values ($group_id, ".$mdb2->quote($cron_spec).", $next, $report_id, ".$mdb2->quote($email).", ".$mdb2->quote($cc).", ".$mdb2->quote($subject).", ".$mdb2->quote($report_condition).", ".$mdb2->quote($status).")";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
$mdb2 = getConnection();
$notification_id = (int) $fields['id'];
- $team_id = (int) $fields['team_id'];
+ $group_id = (int) $fields['group_id'];
$cron_spec = $fields['cron_spec'];
$next = (int) $fields['next'];
$report_id = (int) $fields['report_id'];
$status = $fields['status'];
$sql = "update tt_cron set cron_spec = ".$mdb2->quote($cron_spec).", next = $next, report_id = $report_id, email = ".$mdb2->quote($email).", cc = ".$mdb2->quote($cc).", subject = ".$mdb2->quote($subject).", report_condition = ".$mdb2->quote($report_condition).", status = ".$mdb2->quote($status).
- " where id = $notification_id and team_id = $team_id";
+ " where id = $notification_id and group_id = $group_id";
$affected = $mdb2->exec($sql);
return (!is_a($affected, 'PEAR_Error'));
}
$mdb2 = getConnection();
$sql = "select id, name, cost from tt_predefined_expenses
- where id = $id and team_id = $user->team_id";
+ where id = $id and group_id = $user->group_id";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
$val = $res->fetchRow();
$mdb2 = getConnection();
- $sql = "delete from tt_predefined_expenses where id = $id and team_id = $user->team_id";
+ $sql = "delete from tt_predefined_expenses where id = $id and group_id = $user->group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
$mdb2 = getConnection();
- $team_id = (int) $fields['team_id'];
+ $group_id = (int) $fields['group_id'];
$name = $fields['name'];
$cost = $fields['cost'];
if ('.' != $user->decimal_mark)
$cost = str_replace($user->decimal_mark, '.', $cost);
- $sql = "insert into tt_predefined_expenses (team_id, name, cost)
- values ($team_id, ".$mdb2->quote($name).", ".$mdb2->quote($cost).")";
+ $sql = "insert into tt_predefined_expenses (group_id, name, cost)
+ values ($group_id, ".$mdb2->quote($name).", ".$mdb2->quote($cost).")";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
$mdb2 = getConnection();
$predefined_expense_id = (int) $fields['id'];
- $team_id = (int) $fields['team_id'];
+ $group_id = (int) $fields['group_id'];
$name = $fields['name'];
$cost = $fields['cost'];
if ('.' != $user->decimal_mark)
$cost = str_replace($user->decimal_mark, '.', $cost);
$sql = "update tt_predefined_expenses set name = ".$mdb2->quote($name).", cost = ".$mdb2->quote($cost).
- " where id = $predefined_expense_id and team_id = $team_id";
+ " where id = $predefined_expense_id and group_id = $group_id";
$affected = $mdb2->exec($sql);
return (!is_a($affected, 'PEAR_Error'));
}
// getAssignedProjects - returns an array of assigned projects.
static function getAssignedProjects($user_id)
{
- global $user;
+ global $user;
$result = array();
$mdb2 = getConnection();
// Do a query with inner join to get assigned projects.
$sql = "select p.id, p.name, p.tasks, upb.rate from tt_projects p
inner join tt_user_project_binds upb on (upb.user_id = $user_id and upb.project_id = p.id and upb.status = 1)
- where p.team_id = $user->team_id and p.status = 1 order by p.name";
+ where p.group_id = $user->group_id and p.status = 1 order by p.name";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
while ($val = $res->fetchRow()) {
$sql = "select p.id, upb.rate from tt_projects p
inner join tt_user_project_binds upb on (upb.user_id = $user_id and upb.project_id = p.id)
- where team_id = $user->team_id";
+ where group_id = $user->group_id";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
while ($val = $res->fetchRow()) {
$result = array();
$mdb2 = getConnection();
- $sql = "select id, name, tasks from tt_projects
- where team_id = $user->team_id and (status = 0 or status = 1) order by name";
+ $sql = "select id, name, tasks from tt_projects".
+ " where group_id = $user->group_id and (status = 0 or status = 1) order by name";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
$sql = "select p.id, p.name, p.tasks from tt_projects p
inner join tt_client_project_binds cpb on (cpb.client_id = $user->client_id and cpb.project_id = p.id)
- where p.team_id = $user->team_id and (p.status = 0 or p.status = 1)
+ where p.group_id = $user->group_id and (p.status = 0 or p.status = 1)
order by p.name";
$res = $mdb2->query($sql);
$mdb2 = getConnection();
- $sql = "select id, name, description, status, tasks from tt_projects where id = $id and team_id = $user->team_id and (status = 0 or status = 1)";
+ $sql = "select id, name, description, status, tasks from tt_projects where id = $id and group_id = $user->group_id and (status = 0 or status = 1)";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
$val = $res->fetchRow();
$mdb2 = getConnection();
global $user;
- $sql = "select id from tt_projects where team_id = $user->team_id and name = ".
+ $sql = "select id from tt_projects where group_id = $user->group_id and name = ".
$mdb2->quote($name)." and (status = 1 or status = 0)";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
// we'll fail right here and don't damage any other data.
// Mark project as deleted and remove associated tasks.
- $sql = "update tt_projects set status = NULL, tasks = NULL where id = $id and team_id = $user->team_id";
+ $sql = "update tt_projects set status = NULL, tasks = NULL where id = $id and group_id = $user->group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error') || 0 == $affected)
return false; // An error ocurred, or 0 rows updated.
{
$mdb2 = getConnection();
- $team_id = (int) $fields['team_id'];
+ $group_id = (int) $fields['group_id'];
$name = $fields['name'];
$description = $fields['description'];
$comma_separated = implode(',', $tasks); // This is a comma-separated list of associated task ids.
$status = $fields['status'];
- $sql = "insert into tt_projects (team_id, name, description, tasks, status)
- values ($team_id, ".$mdb2->quote($name).", ".$mdb2->quote($description).", ".$mdb2->quote($comma_separated).", ".$mdb2->quote($status).")";
+ $sql = "insert into tt_projects (group_id, name, description, tasks, status)
+ values ($group_id, ".$mdb2->quote($name).", ".$mdb2->quote($description).", ".$mdb2->quote($comma_separated).", ".$mdb2->quote($status).")";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
}
// Bind the project to tasks in tt_project_task_binds table.
- $all_tasks = ttTeamHelper::getAllTasks($team_id);
+ $all_tasks = ttTeamHelper::getAllTasks($group_id);
foreach ($all_tasks as $task) {
if(in_array($task['id'], $tasks)) {
$sql = "insert into tt_project_task_binds (project_id, task_id) values($last_id, ".$task['id'].")";
// Update project name, description, tasks and status in tt_projects table.
$comma_separated = implode(",", $tasks_to_bind); // This is a comma-separated list of associated task ids.
$sql = "update tt_projects set name = ".$mdb2->quote($name).", description = ".$mdb2->quote($description).
- ", tasks = ".$mdb2->quote($comma_separated).", status = $status where id = $project_id and team_id = $user->team_id";
+ ", tasks = ".$mdb2->quote($comma_separated).", status = $status where id = $project_id and group_id = $user->group_id";
$affected = $mdb2->exec($sql);
return (!is_a($affected, 'PEAR_Error'));
}
$created_ip = $mdb2->quote($_SERVER['REMOTE_ADDR']);
$values = "values($login, $password, $name, $this->group_id, $this->role_id, $email, $created, $created_ip)";
- $sql = 'insert into tt_users (login, password, name, team_id, role_id, email, created, created_ip) '.$values;
+ $sql = 'insert into tt_users (login, password, name, group_id, role_id, email, created, created_ip) '.$values;
$affected = $mdb2->exec($sql);
if (!is_a($affected, 'PEAR_Error')) {
$user_id = $mdb2->lastInsertID('tt_users', 'id');
}
// Update top manager.
- $sql = "update tt_users set created_by = $user_id where id = $user_id and team_id = $this->group_id";
+ $sql = "update tt_users set created_by = $user_id where id = $user_id and group_id = $this->group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) {
$this->err->add($i18n->get('error.db'));
// Add custom field.
$include_cf_1 = $bean->getAttribute('chcf_1') || 'cf_1' == $group_by_option;
if ($include_cf_1) {
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
$cf_1_type = $custom_fields->fields[0]['type'];
if ($cf_1_type == CustomFields::TYPE_TEXT) {
array_push($fields, 'cfl.value as cf_1');
// Add custom field.
$include_cf_1 = $report['show_custom_field_1'] || 'cf_1' == $group_by_option;
if ($include_cf_1) {
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
$cf_1_type = $custom_fields->fields[0]['type'];
if ($cf_1_type == CustomFields::TYPE_TEXT) {
array_push($fields, 'cfl.value as cf_1');
break;
case 'cf_1':
$group_field = 'cfo.value';
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT)
$group_join = 'left join tt_custom_field_log cfl on (l.id = cfl.log_id and cfl.status = 1) left join tt_custom_field_options cfo on (cfl.value = cfo.id) ';
elseif ($custom_fields->fields[0]['type'] == CustomFields::TYPE_DROPDOWN)
break;
case 'cf_1':
$group_field = 'cfo.value';
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
if ($custom_fields->fields[0]['type'] == CustomFields::TYPE_TEXT)
$group_join = 'left join tt_custom_field_log cfl on (l.id = cfl.log_id and cfl.status = 1) left join tt_custom_field_options cfo on (cfl.value = cfo.id) ';
elseif ($custom_fields->fields[0]['type'] == CustomFields::TYPE_DROPDOWN)
// Use custom fields plugin if it is enabled.
if ($user->isPluginEnabled('cf'))
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
// Define some styles to use in email.
$style_title = 'text-align: center; font-size: 15pt; font-family: Arial, Helvetica, sans-serif;';
// Use custom fields plugin if it is enabled.
if ($user->isPluginEnabled('cf'))
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
// Define some styles to use in email.
$style_title = 'text-align: center; font-size: 15pt; font-family: Arial, Helvetica, sans-serif;';
$mdb2 = getConnection();
$sql = "select id, name, description, rank, rights, status from tt_roles
- where id = $id and team_id = $user->team_id and (status = 0 or status = 1)";
+ where id = $id and group_id = $user->group_id and (status = 0 or status = 1)";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
$mdb2 = getConnection();
global $user;
- $sql = "select id from tt_roles where team_id = $user->team_id and name = ".
+ $sql = "select id from tt_roles where group_id = $user->group_id and name = ".
$mdb2->quote($role_name)." and (status = 1 or status = 0)";
$res = $mdb2->query($sql);
static function getTopManagerRoleID() {
$mdb2 = getConnection();
- $sql = "select id from tt_roles where team_id = 0 and rank = 512";
+ $sql = "select id from tt_roles where group_id = 0 and rank = 512";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
global $user;
$mdb2 = getConnection();
- $sql = "select rights from tt_roles where team_id = $user->team_id and id = $role_id";
+ $sql = "select rights from tt_roles where group_id = $user->group_id and id = $role_id";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
}
// getRoleByRank looks up a role by its rank.
- static function getRoleByRank($rank, $team_id) {
+ static function getRoleByRank($rank, $group_id) {
global $user;
$mdb2 = getConnection();
$rank = (int) $rank; // Cast to int just in case for better security.
- $sql = "select id from tt_roles where team_id = $team_id and rank = $rank and (status = 1 or status = 0)";
+ $sql = "select id from tt_roles where group_id = $group_id and rank = $rank and (status = 1 or status = 0)";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
if (isset($fields['status'])) $status_part = ', status = '.(int)$fields['status'];
if (isset($fields['rights'])) $rights_part = ', rights = '.$mdb2->quote($fields['rights']);
$parts = trim($name_part.$rank_part.$descr_part.$status_part.$rights_part, ',');
- $sql = "update tt_roles set $parts where id = $id and team_id = $user->team_id";
+ $sql = "update tt_roles set $parts where id = $id and group_id = $user->group_id";
$affected = $mdb2->exec($sql);
return (!is_a($affected, 'PEAR_Error'));
}
$mdb2 = getConnection();
// Mark the task as deleted.
- $sql = "update tt_roles set status = NULL where id = $role_id and team_id = $user->team_id";
+ $sql = "update tt_roles set status = NULL where id = $role_id and group_id = $user->group_id";
$affected = $mdb2->exec($sql);
return (!is_a($affected, 'PEAR_Error'));
}
{
$mdb2 = getConnection();
- $team_id = (int) $fields['team_id'];
+ $group_id = (int) $fields['group_id'];
$name = $fields['name'];
$rank = (int) $fields['rank'];
$description = $fields['description'];
$rights = $fields['rights'];
$status = $fields['status'];
- $sql = "insert into tt_roles (team_id, name, rank, description, rights, status)
- values ($team_id, ".$mdb2->quote($name).", $rank, ".$mdb2->quote($description).", ".$mdb2->quote($rights).", ".$mdb2->quote($status).")";
+ $sql = "insert into tt_roles (group_id, name, rank, description, rights, status)
+ values ($group_id, ".$mdb2->quote($name).", $rank, ".$mdb2->quote($description).", ".$mdb2->quote($rights).", ".$mdb2->quote($status).")";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
}
// createPredefinedRoles - creates a set of predefined roles for the team to use.
- static function createPredefinedRoles($team_id, $lang)
+ static function createPredefinedRoles($group_id, $lang)
{
// We need localized role names and a new I18n object to obtain them.
import('I18n');
$name = $mdb2->quote($i18n->get('role.user.label'));
$description = $mdb2->quote($i18n->get('role.user.description'));
$rights = $mdb2->quote($rights_user);
- $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($team_id, $name, $description, 4, $rights, 1)";
+ $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($group_id, $name, $description, 4, $rights, 1)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
$name = $mdb2->quote($i18n->get('role.client.label'));
$description = $mdb2->quote($i18n->get('role.client.description'));
$rights = $mdb2->quote($rights_client);
- $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($team_id, $name, $description, 16, $rights, 1)";
+ $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($group_id, $name, $description, 16, $rights, 1)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
$name = $mdb2->quote($i18n->get('role.comanager.label'));
$description = $mdb2->quote($i18n->get('role.comanager.description'));
$rights = $mdb2->quote($rights_comanager);
- $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($team_id, $name, $description, 68, $rights, 1)";
+ $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($group_id, $name, $description, 68, $rights, 1)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
$name = $mdb2->quote($i18n->get('role.manager.label'));
$description = $mdb2->quote($i18n->get('role.manager.description'));
$rights = $mdb2->quote($rights_manager);
- $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($team_id, $name, $description, 324, $rights, 1)";
+ $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($group_id, $name, $description, 324, $rights, 1)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
$name = $mdb2->quote($i18n->get('role.supervisor.label'));
$description = $mdb2->quote($i18n->get('role.supervisor.description'));
$rights = $mdb2->quote($rights_supervisor);
- $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($team_id, $name, $description, 12, $rights, 0)";
+ $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($group_id, $name, $description, 12, $rights, 0)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
$name = $mdb2->quote($i18n->get('role.user.label'));
$description = $mdb2->quote($i18n->get('role.user.description'));
$rights = $mdb2->quote($rights_user);
- $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($user->team_id, $name, $description, 4, $rights, 1)";
+ $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($user->group_id, $name, $description, 4, $rights, 1)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
$name = $mdb2->quote($i18n->get('role.client.label'));
$description = $mdb2->quote($i18n->get('role.client.description'));
$rights = $mdb2->quote($rights_client);
- $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($user->team_id, $name, $description, 16, $rights, 1)";
+ $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($user->group_id, $name, $description, 16, $rights, 1)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
$name = $mdb2->quote($i18n->get('role.comanager.label'));
$description = $mdb2->quote($i18n->get('role.comanager.description'));
$rights = $mdb2->quote($rights_comanager);
- $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($user->team_id, $name, $description, 68, $rights, 1)";
+ $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($user->group_id, $name, $description, 68, $rights, 1)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
$name = $mdb2->quote($i18n->get('role.manager.label'));
$description = $mdb2->quote($i18n->get('role.manager.description'));
$rights = $mdb2->quote($rights_manager);
- $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($user->team_id, $name, $description, 324, $rights, 1)";
+ $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($user->group_id, $name, $description, 324, $rights, 1)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
$name = $mdb2->quote($i18n->get('role.supervisor.label'));
$description = $mdb2->quote($i18n->get('role.supervisor.description'));
$rights = $mdb2->quote($rights_supervisor);
- $sql = "insert into tt_roles (team_id, name, description, rank, rights, status) values($user->team_id, $name, $description, 12, $rights, 0)";
+ $sql = "insert into tt_roles (group_id, name, description, rank, rights, status) values($user->group_id, $name, $description, 12, $rights, 0)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
$mdb2 = getConnection();
$sql = "select id, name, description, status from tt_tasks
- where id = $id and team_id = $user->team_id and (status = 0 or status = 1)";
+ where id = $id and group_id = $user->group_id and (status = 0 or status = 1)";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
// Do a query with inner join to get assigned projects.
$sql = "select p.id, p.name from tt_projects p
inner join tt_project_task_binds ptb on (ptb.project_id = p.id and ptb.task_id = $task_id)
- where p.team_id = $user->team_id and p.status = 1 order by p.name";
+ where p.group_id = $user->group_id and p.status = 1 order by p.name";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
while ($val = $res->fetchRow()) {
$mdb2 = getConnection();
global $user;
- $sql = "select id from tt_tasks where team_id = $user->team_id and name = ".
+ $sql = "select id from tt_tasks where group_id = $user->group_id and name = ".
$mdb2->quote($task_name)." and (status = 1 or status = 0)";
$res = $mdb2->query($sql);
// Delete project binds to this task from the tasks field in tt_projects table.
// Get projects where tasks is not NULL.
- $sql = "select id, tasks from tt_projects where team_id = $user->team_id and tasks is not NULL";
+ $sql = "select id, tasks from tt_projects where group_id = $user->group_id and tasks is not NULL";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error'))
return false;
{
$mdb2 = getConnection();
- $team_id = (int) $fields['team_id'];
+ $group_id = (int) $fields['group_id'];
$name = $fields['name'];
$description = $fields['description'];
$projects = $fields['projects'];
$status = $fields['status'];
- $sql = "insert into tt_tasks (team_id, name, description, status)
- values ($team_id, ".$mdb2->quote($name).", ".$mdb2->quote($description).", ".$mdb2->quote($status).")";
+ $sql = "insert into tt_tasks (group_id, name, description, status)
+ values ($group_id, ".$mdb2->quote($name).", ".$mdb2->quote($description).", ".$mdb2->quote($status).")";
$affected = $mdb2->exec($sql);
$last_id = 0;
if (is_a($affected, 'PEAR_Error'))
$projects = $fields['projects'];
$sql = "update tt_tasks set name = ".$mdb2->quote($name).", description = ".$mdb2->quote($description).
- ", status = $status where id = $task_id and team_id = $user->team_id";
+ ", status = $status where id = $task_id and group_id = $user->group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
die($affected->getMessage());
// We need to either delete or insert task id in all affected projects.
// Get all not deleted projects for team.
- $sql = "select id, tasks from tt_projects where team_id = $user->team_id and status is not NULL";
+ $sql = "select id, tasks from tt_projects where group_id = $user->group_id and status is not NULL";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error'))
die($res->getMessage());
class ttTeamHelper {
// The getUserCount function returns number of people in team.
- static function getUserCount($team_id) {
+ static function getUserCount($group_id) {
$mdb2 = getConnection();
- $sql = "select count(id) as cnt from tt_users where team_id = $team_id and status = 1";
+ $sql = "select count(id) as cnt from tt_users where group_id = $group_id and status = 1";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
$mdb2 = getConnection();
if (isset($options['getAllFields']))
- $sql = "select u.*, r.name as role_name, r.rank from tt_users u left join tt_roles r on (u.role_id = r.id) where u.team_id = $user->team_id and u.status = 1 order by upper(u.name)";
+ $sql = "select u.*, r.name as role_name, r.rank from tt_users u left join tt_roles r on (u.role_id = r.id) where u.group_id = $user->group_id and u.status = 1 order by upper(u.name)";
else
- $sql = "select id, name from tt_users where team_id = $user->team_id and status = 1 order by upper(name)";
+ $sql = "select id, name from tt_users where group_id = $user->group_id and status = 1 order by upper(name)";
$res = $mdb2->query($sql);
$user_list = array();
if (is_a($res, 'PEAR_Error'))
$mdb2 = getConnection();
// Obtain role id for the user we are swapping ourselves with.
- $sql = "select u.id, u.role_id from tt_users u left join tt_roles r on (u.role_id = r.id) where u.id = $user_id and u.team_id = $user->team_id and u.status = 1 and r.rank < $user->rank";
+ $sql = "select u.id, u.role_id from tt_users u left join tt_roles r on (u.role_id = r.id) where u.id = $user_id and u.group_id = $user->group_id and u.status = 1 and r.rank < $user->rank";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error'))
return false;
$modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$mdb2->quote($user->id);
// Promote user.
- $sql = "update tt_users set role_id = $user->role_id".$modified_part." where id = $user_id and team_id = $user->team_id";
+ $sql = "update tt_users set role_id = $user->role_id".$modified_part." where id = $user_id and group_id = $user->group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
// Demote self.
$role_id = $val['role_id'];
- $sql = "update tt_users set role_id = $role_id".$modified_part." where id = $user->id and team_id = $user->team_id";
+ $sql = "update tt_users set role_id = $role_id".$modified_part." where id = $user->id and group_id = $user->group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
global $user;
$mdb2 = getConnection();
- $sql = "select u.id, u.name, r.rank, r.rights from tt_users u left join tt_roles r on (u.role_id = r.id) where u.team_id = $user->team_id and u.status = 1 and r.rank < $user->rank order by upper(u.name)";
+ $sql = "select u.id, u.name, r.rank, r.rights from tt_users u left join tt_roles r on (u.role_id = r.id) where u.group_id = $user->group_id and u.status = 1 and r.rank < $user->rank order by upper(u.name)";
$res = $mdb2->query($sql);
$user_list = array();
if (is_a($res, 'PEAR_Error'))
static function getUsers() {
global $user;
$mdb2 = getConnection();
- $sql = "select id, name from tt_users where team_id = $user->team_id and (status = 1 or status = 0) order by upper(name)";
+ $sql = "select id, name from tt_users where group_id = $user->group_id and (status = 1 or status = 0) order by upper(name)";
$res = $mdb2->query($sql);
$user_list = array();
if (is_a($res, 'PEAR_Error'))
}
// The getInactiveUsers obtains all inactive users in a given team.
- static function getInactiveUsers($team_id, $all_fields = false) {
+ static function getInactiveUsers($group_id, $all_fields = false) {
$mdb2 = getConnection();
if ($all_fields)
- $sql = "select u.*, r.name as role_name from tt_users u left join tt_roles r on (u.role_id = r.id) where u.team_id = $team_id and u.status = 0 order by upper(u.name)";
+ $sql = "select u.*, r.name as role_name from tt_users u left join tt_roles r on (u.role_id = r.id) where u.group_id = $group_id and u.status = 0 order by upper(u.name)";
else
- $sql = "select id, name from tt_users where team_id = $team_id and status = 0 order by upper(name)";
+ $sql = "select id, name from tt_users where group_id = $group_id and status = 0 order by upper(name)";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// The getAllUsers obtains all users in a given team.
- static function getAllUsers($team_id, $all_fields = false) {
+ static function getAllUsers($group_id, $all_fields = false) {
$mdb2 = getConnection();
if ($all_fields)
- $sql = "select * from tt_users where team_id = $team_id order by upper(name)";
+ $sql = "select * from tt_users where group_id = $group_id order by upper(name)";
else
- $sql = "select id, name from tt_users where team_id = $team_id order by upper(name)";
+ $sql = "select id, name from tt_users where group_id = $group_id order by upper(name)";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// getActiveProjects - returns an array of active projects for team.
- static function getActiveProjects($team_id)
+ static function getActiveProjects($group_id)
{
$result = array();
$mdb2 = getConnection();
$sql = "select id, name, description, tasks from tt_projects
- where team_id = $team_id and status = 1 order by upper(name)";
+ where group_id = $group_id and status = 1 order by upper(name)";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// getInactiveProjects - returns an array of inactive projects for team.
- static function getInactiveProjects($team_id)
+ static function getInactiveProjects($group_id)
{
$result = array();
$mdb2 = getConnection();
$sql = "select id, name, description, tasks from tt_projects
- where team_id = $team_id and status = 0 order by upper(name)";
+ where group_id = $group_id and status = 0 order by upper(name)";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// The getAllProjects obtains all projects in a given team.
- static function getAllProjects($team_id, $all_fields = false) {
+ static function getAllProjects($group_id, $all_fields = false) {
$mdb2 = getConnection();
if ($all_fields)
- $sql = "select * from tt_projects where team_id = $team_id order by status, upper(name)";
+ $sql = "select * from tt_projects where group_id = $group_id order by status, upper(name)";
else
- $sql = "select id, name from tt_projects where team_id = $team_id order by status, upper(name)";
+ $sql = "select id, name from tt_projects where group_id = $group_id order by status, upper(name)";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// getActiveTasks - returns an array of active tasks for team.
- static function getActiveTasks($team_id)
+ static function getActiveTasks($group_id)
{
$result = array();
$mdb2 = getConnection();
- $sql = "select id, name, description from tt_tasks where team_id = $team_id and status = 1 order by upper(name)";
+ $sql = "select id, name, description from tt_tasks where group_id = $group_id and status = 1 order by upper(name)";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// getInactiveTasks - returns an array of inactive tasks for team.
- static function getInactiveTasks($team_id)
+ static function getInactiveTasks($group_id)
{
$result = array();
$mdb2 = getConnection();
$sql = "select id, name, description from tt_tasks
- where team_id = $team_id and status = 0 order by upper(name)";
+ where group_id = $group_id and status = 0 order by upper(name)";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// The getAllTasks obtains all tasks in a given team.
- static function getAllTasks($team_id, $all_fields = false) {
+ static function getAllTasks($group_id, $all_fields = false) {
$mdb2 = getConnection();
if ($all_fields)
- $sql = "select * from tt_tasks where team_id = $team_id order by status, upper(name)";
+ $sql = "select * from tt_tasks where group_id = $group_id order by status, upper(name)";
else
- $sql = "select id, name from tt_tasks where team_id = $team_id order by status, upper(name)";
+ $sql = "select id, name from tt_tasks where group_id = $group_id order by status, upper(name)";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
$result = array();
$mdb2 = getConnection();
- $sql = "select id, name, description, rank, rights from tt_roles where team_id = $user->team_id and rank < $user->rank and status = 1 order by rank";
+ $sql = "select id, name, description, rank, rights from tt_roles where group_id = $user->group_id and rank < $user->rank and status = 1 order by rank";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// getActiveRoles - returns an array of active roles for team.
- static function getActiveRoles($team_id)
+ static function getActiveRoles($group_id)
{
$result = array();
$mdb2 = getConnection();
- $sql = "select id, name, description, rank, rights from tt_roles where team_id = $team_id and status = 1 order by rank";
+ $sql = "select id, name, description, rank, rights from tt_roles where group_id = $group_id and status = 1 order by rank";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// getInactiveRoles - returns an array of inactive roles for team.
- static function getInactiveRoles($team_id)
+ static function getInactiveRoles($group_id)
{
$result = array();
$mdb2 = getConnection();
$sql = "select id, name, rank, description from tt_roles
- where team_id = $team_id and status = 0 order by rank";
+ where group_id = $group_id and status = 0 order by rank";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
$result = array();
$mdb2 = getConnection();
- $sql = "select id, name, description, rank, rights from tt_roles where team_id = $user->team_id and rank < $user->rank and status = 0 order by rank";
+ $sql = "select id, name, description, rank, rights from tt_roles where group_id = $user->group_id and rank < $user->rank and status = 0 order by rank";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// The getActiveClients returns an array of active clients for team.
- static function getActiveClients($team_id, $all_fields = false)
+ static function getActiveClients($group_id, $all_fields = false)
{
$result = array();
$mdb2 = getConnection();
if ($all_fields)
- $sql = "select * from tt_clients where team_id = $team_id and status = 1 order by upper(name)";
+ $sql = "select * from tt_clients where group_id = $group_id and status = 1 order by upper(name)";
else
- $sql = "select id, name from tt_clients where team_id = $team_id and status = 1 order by upper(name)";
+ $sql = "select id, name from tt_clients where group_id = $group_id and status = 1 order by upper(name)";
$res = $mdb2->query($sql);
$result = array();
}
// The getInactiveClients returns an array of inactive clients for team.
- static function getInactiveClients($team_id, $all_fields = false)
+ static function getInactiveClients($group_id, $all_fields = false)
{
$result = array();
$mdb2 = getConnection();
if ($all_fields)
- $sql = "select * from tt_clients where team_id = $team_id and status = 0 order by upper(name)";
+ $sql = "select * from tt_clients where group_id = $group_id and status = 0 order by upper(name)";
else
- $sql = "select id, name from tt_clients where team_id = $team_id and status = 0 order by upper(name)";
+ $sql = "select id, name from tt_clients where group_id = $group_id and status = 0 order by upper(name)";
$res = $mdb2->query($sql);
$result = array();
}
// The getAllClients obtains all clients in a given team.
- static function getAllClients($team_id, $all_fields = false) {
+ static function getAllClients($group_id, $all_fields = false) {
$mdb2 = getConnection();
if ($all_fields)
- $sql = "select * from tt_clients where team_id = $team_id order by status, upper(name)";
+ $sql = "select * from tt_clients where group_id = $group_id order by status, upper(name)";
else
- $sql = "select id, name from tt_clients where team_id = $team_id order by status, upper(name)";
+ $sql = "select id, name from tt_clients where group_id = $group_id order by status, upper(name)";
$res = $mdb2->query($sql);
$result = array();
$sql = "select i.id, i.name, i.date, i.client_id, i.status, c.name as client_name from tt_invoices i
left join tt_clients c on (c.id = i.client_id)
- where i.status = 1 and i.team_id = $user->team_id $client_part order by i.name";
+ where i.status = 1 and i.group_id = $user->group_id $client_part order by i.name";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
$result = array();
$mdb2 = getConnection();
- $sql = "select * from tt_invoices where team_id = $user->team_id";
+ $sql = "select * from tt_invoices where group_id = $user->group_id";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// The getRecentInvoices returns an array of recent invoices (max 3) for a client.
- static function getRecentInvoices($team_id, $client_id)
+ static function getRecentInvoices($group_id, $client_id)
{
global $user;
$sql = "select i.id, i.name from tt_invoices i
left join tt_clients c on (c.id = i.client_id)
- where i.team_id = $team_id and i.status = 1 and c.id = $client_id
+ where i.group_id = $group_id and i.status = 1 and c.id = $client_id
order by i.id desc limit 3";
$res = $mdb2->query($sql);
$result = array();
}
// getUserToProjectBinds - obtains all user to project binds for a team.
- static function getUserToProjectBinds($team_id) {
+ static function getUserToProjectBinds($group_id) {
$mdb2 = getConnection();
$result = array();
- $sql = "select * from tt_user_project_binds where user_id in (select id from tt_users where team_id = $team_id) order by user_id, status, project_id";
+ $sql = "select * from tt_user_project_binds where user_id in (select id from tt_users where group_id = $group_id) order by user_id, status, project_id";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// The getAllCustomFields obtains all custom fields in a given team.
- static function getAllCustomFields($team_id) {
+ static function getAllCustomFields($group_id) {
$mdb2 = getConnection();
- $sql = "select * from tt_custom_fields where team_id = $team_id order by status";
+ $sql = "select * from tt_custom_fields where group_id = $group_id order by status";
$res = $mdb2->query($sql);
$result = array();
}
// The getAllCustomFieldOptions obtains all custom field options in a given team.
- static function getAllCustomFieldOptions($team_id) {
+ static function getAllCustomFieldOptions($group_id) {
$mdb2 = getConnection();
- $sql = "select * from tt_custom_field_options where field_id in (select id from tt_custom_fields where team_id = $team_id) order by id";
+ $sql = "select * from tt_custom_field_options where field_id in (select id from tt_custom_fields where group_id = $group_id) order by id";
$res = $mdb2->query($sql);
$result = array();
}
// The getCustomFieldLog obtains all custom field log entries for a given team.
- static function getCustomFieldLog($team_id) {
+ static function getCustomFieldLog($group_id) {
$mdb2 = getConnection();
- $sql = "select * from tt_custom_field_log where field_id in (select id from tt_custom_fields where team_id = $team_id) order by id";
+ $sql = "select * from tt_custom_field_log where field_id in (select id from tt_custom_fields where group_id = $group_id) order by id";
$res = $mdb2->query($sql);
$result = array();
}
// getFavReports - obtains all favorite reports for all users in team.
- static function getFavReports($team_id) {
+ static function getFavReports($group_id) {
$mdb2 = getConnection();
$result = array();
- $sql = "select * from tt_fav_reports where user_id in (select id from tt_users where team_id = $team_id)";
+ $sql = "select * from tt_fav_reports where user_id in (select id from tt_users where group_id = $group_id)";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// getExpenseItems - obtains all expense items for all users in team.
- static function getExpenseItems($team_id) {
+ static function getExpenseItems($group_id) {
$mdb2 = getConnection();
$result = array();
- $sql = "select * from tt_expense_items where user_id in (select id from tt_users where team_id = $team_id)";
+ $sql = "select * from tt_expense_items where user_id in (select id from tt_users where group_id = $group_id)";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// getPredefinedExpenses - obtains predefined expenses for team.
- static function getPredefinedExpenses($team_id) {
+ static function getPredefinedExpenses($group_id) {
global $user;
$replaceDecimalMark = ('.' != $user->decimal_mark);
$mdb2 = getConnection();
$result = array();
- $sql = "select id, name, cost from tt_predefined_expenses where team_id = $team_id";
+ $sql = "select id, name, cost from tt_predefined_expenses where group_id = $group_id";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// getNotifications - obtains notification descriptions for team.
- static function getNotifications($team_id) {
+ static function getNotifications($group_id) {
$mdb2 = getConnection();
$result = array();
$sql = "select c.id, c.cron_spec, c.email, c.report_condition, fr.name from tt_cron c
left join tt_fav_reports fr on (fr.id = c.report_id)
- where c.team_id = $team_id and c.status = 1 and fr.status = 1";
+ where c.group_id = $group_id and c.status = 1 and fr.status = 1";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// getMonthlyQuotas - obtains monthly quotas for team.
- static function getMonthlyQuotas($team_id) {
+ static function getMonthlyQuotas($group_id) {
$mdb2 = getConnection();
$result = array();
- $sql = "select year, month, minutes from tt_monthly_quotas where team_id = $team_id";
+ $sql = "select year, month, minutes from tt_monthly_quotas where group_id = $group_id";
$res = $mdb2->query($sql);
$result = array();
if (!is_a($res, 'PEAR_Error')) {
}
// The markDeleted function marks the team and everything in it as deleted.
- static function markDeleted($team_id) {
+ static function markDeleted($group_id) {
// Iterate through team users and mark them as deleted.
- $users = ttTeamHelper::getAllUsers($team_id);
+ $users = ttTeamHelper::getAllUsers($group_id);
foreach ($users as $one_user) {
if (!ttUserHelper::markDeleted($one_user['id'])) return false;
}
// Mark tasks deleted.
- if (!ttTeamHelper::markTasksDeleted($team_id)) return false;
+ if (!ttTeamHelper::markTasksDeleted($group_id)) return false;
$mdb2 = getConnection();
// Mark roles deleted.
- $sql = "update tt_roles set status = NULL where team_id = $team_id";
+ $sql = "update tt_roles set status = NULL where group_id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
// Mark projects deleted.
- $sql = "update tt_projects set status = NULL where team_id = $team_id";
+ $sql = "update tt_projects set status = NULL where group_id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
// Mark clients deleted.
- $sql = "update tt_clients set status = NULL where team_id = $team_id";
+ $sql = "update tt_clients set status = NULL where group_id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
// Mark custom fields deleted.
- $sql = "update tt_custom_fields set status = NULL where team_id = $team_id";
+ $sql = "update tt_custom_fields set status = NULL where group_id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
// Mark group deleted.
- $sql = "update tt_groups set status = NULL where id = $team_id";
+ $sql = "update tt_groups set status = NULL where id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
}
// The getTeamDetails function returns team details.
- static function getTeamDetails($team_id) {
+ static function getTeamDetails($group_id) {
$result = array();
$mdb2 = getConnection();
$sql = "select t.name as team_name, u.id as manager_id, u.name as manager_name, u.login as manager_login, u.email as manager_email
from tt_groups t
- inner join tt_users u on (u.team_id = t.id)
+ inner join tt_users u on (u.group_id = t.id)
inner join tt_roles r on (r.id = u.role_id and r.rank = 512)
- where t.id = $team_id";
+ where t.id = $group_id";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
$affected = $mdb2->exec($sql);
if (!is_a($affected, 'PEAR_Error')) {
- $team_id = $mdb2->lastInsertID('tt_groups', 'id');
- return $team_id;
+ $group_id = $mdb2->lastInsertID('tt_groups', 'id');
+ return $group_id;
}
return false;
}
// The update function updates team information.
- static function update($team_id, $fields)
+ static function update($group_id, $fields)
{
global $user;
$mdb2 = getConnection();
$sql = "update tt_groups set $name_part $currency_part $lang_part $decimal_mark_part
$date_format_part $time_format_part $week_start_part $tracking_mode_part $task_required_part $record_type_part
- $bcc_email_part $plugins_part $config_part $lock_spec_part $workday_minutes_part $modified_part where id = $team_id";
+ $bcc_email_part $plugins_part $config_part $lock_spec_part $workday_minutes_part $modified_part where id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
$count = 0;
if (!is_a($res, 'PEAR_Error')) {
while ($val = $res->fetchRow()) {
- $team_id = $val['id'];
- if (ttTeamHelper::isTeamActive($team_id) == false) {
+ $group_id = $val['id'];
+ if (ttTeamHelper::isTeamActive($group_id) == false) {
$count++;
- $inactive_teams[] = $team_id;
+ $inactive_teams[] = $group_id;
// Limit the array size for perfomance by allowing this operation on small chunks only.
if ($count >= 100) break;
}
}
// The isTeamActive determines if a team is using Time Tracker or abandoned it.
- static function isTeamActive($team_id) {
+ static function isTeamActive($group_id) {
$users = array();
$mdb2 = getConnection();
- $sql = "select id from tt_users where team_id = $team_id";
+ $sql = "select id from tt_users where group_id = $group_id";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error')) die($res->getMessage());
while ($val = $res->fetchRow()) {
}
// The delete function permanently deletes all data for a team.
- static function delete($team_id) {
+ static function delete($group_id) {
$mdb2 = getConnection();
// Delete users.
- $sql = "select id from tt_users where team_id = $team_id";
+ $sql = "select id from tt_users where group_id = $group_id";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error')) return false;
while ($val = $res->fetchRow()) {
}
// Delete tasks.
- if (!ttTeamHelper::deleteTasks($team_id)) return false;
+ if (!ttTeamHelper::deleteTasks($group_id)) return false;
// Delete client to project binds.
- $sql = "delete from tt_client_project_binds where client_id in (select id from tt_clients where team_id = $team_id)";
+ $sql = "delete from tt_client_project_binds where client_id in (select id from tt_clients where group_id = $group_id)";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
// Delete projects.
- $sql = "delete from tt_projects where team_id = $team_id";
+ $sql = "delete from tt_projects where group_id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
// Delete clients.
- $sql = "delete from tt_clients where team_id = $team_id";
+ $sql = "delete from tt_clients where group_id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
// Delete invoices.
- $sql = "delete from tt_invoices where team_id = $team_id";
+ $sql = "delete from tt_invoices where group_id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
// Delete custom fields.
- if (!ttTeamHelper::deleteCustomFields($team_id)) return false;
+ if (!ttTeamHelper::deleteCustomFields($group_id)) return false;
// Delete roles.
- $sql = "delete from tt_roles where team_id = $team_id";
+ $sql = "delete from tt_roles where group_id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
// Delete group.
- $sql = "delete from tt_groups where id = $team_id";
+ $sql = "delete from tt_groups where id = $group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error')) return false;
}
// The markTasksDeleted deletes task binds and marks the tasks as deleted for a team.
- static function markTasksDeleted($team_id) {
+ static function markTasksDeleted($group_id) {
$mdb2 = getConnection();
- $sql = "select id from tt_tasks where team_id = $team_id";
+ $sql = "select id from tt_tasks where group_id = $group_id";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error')) return false;
}
// The deleteTasks deletes all tasks and task binds for an inactive team.
- static function deleteTasks($team_id) {
+ static function deleteTasks($group_id) {
$mdb2 = getConnection();
- $sql = "select id from tt_tasks where team_id = $team_id";
+ $sql = "select id from tt_tasks where group_id = $group_id";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error')) return false;
}
// The deleteCustomFields cleans up tt_custom_field_log, tt_custom_field_options and tt_custom_fields tables for an inactive team.
- static function deleteCustomFields($team_id) {
+ static function deleteCustomFields($group_id) {
$mdb2 = getConnection();
- $sql = "select id from tt_custom_fields where team_id = $team_id";
+ $sql = "select id from tt_custom_fields where group_id = $group_id";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error')) return false;
$plugins = implode(',', $plugin_array);
if ($plugins != $user->plugins) {
- if (!ttTeamHelper::update($user->team_id, array('name' => $user->team,'plugins' => $plugins)))
+ if (!ttTeamHelper::update($user->group_id, array('name' => $user->team,'plugins' => $plugins)))
return false;
$user->plugins = $plugins;
}
var $login = null; // User login.
var $name = null; // User name.
var $id = null; // User id.
- var $team_id = null; // Team id.
+ var $group_id = null; // Group id.
var $role_id = null; // Role id.
var $role_name = null; // Role name.
var $rank = null; // User role rank.
$mdb2 = getConnection();
- $sql = "SELECT u.id, u.login, u.name, u.team_id, u.role_id, r.rank, r.name as role_name, r.rights, u.client_id, u.email, t.name as team_name,
+ $sql = "SELECT u.id, u.login, u.name, u.group_id, u.role_id, r.rank, r.name as role_name, r.rights, u.client_id, u.email, t.name as team_name,
t.currency, t.lang, t.decimal_mark, t.date_format, t.time_format, t.week_start,
t.tracking_mode, t.project_required, t.task_required, t.record_type,
t.bcc_email, t.plugins, t.config, t.lock_spec, t.workday_minutes, t.custom_logo
- FROM tt_users u LEFT JOIN tt_groups t ON (u.team_id = t.id) LEFT JOIN tt_roles r on (r.id = u.role_id) WHERE ";
+ FROM tt_users u LEFT JOIN tt_groups t ON (u.group_id = t.id) LEFT JOIN tt_roles r on (r.id = u.role_id) WHERE ";
if ($id)
$sql .= "u.id = $id";
else
$this->login = $val['login'];
$this->name = $val['name'];
$this->id = $val['id'];
- $this->team_id = $val['team_id'];
+ $this->group_id = $val['group_id'];
$this->role_id = $val['role_id'];
$this->role_name = $val['role_name'];
$this->rights = explode(',', $val['rights']);
// Do a query with inner join to get assigned projects.
$sql = "select p.id, p.name, p.description, p.tasks, upb.rate from tt_projects p
inner join tt_user_project_binds upb on (upb.user_id = ".$this->getActiveUser()." and upb.project_id = p.id and upb.status = 1)
- where p.team_id = $this->team_id and p.status = 1 order by p.name";
+ where p.group_id = $this->group_id and p.status = 1 order by p.name";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
while ($val = $res->fetchRow()) {
if (isset($options['max_rank']) || $skipClients || isset($options['include_role']))
$left_joins .= ' left join tt_roles r on (u.role_id = r.id)';
- $where_part = " where u.team_id = $this->team_id";
+ $where_part = " where u.group_id = $this->group_id";
if (isset($options['status']))
$where_part .= ' and u.status = '.(int)$options['status'];
else
$sql = "select u.id, u.name, u.login, u.role_id, u.status, u.rate, u.email from tt_users u".
" left join tt_roles r on (u.role_id = r.id)".
- " where u.id = $user_id and u.team_id = $this->team_id and u.status is not null".
+ " where u.id = $user_id and u.group_id = $this->group_id and u.status is not null".
" and (r.rank < $this->rank or (r.rank = $this->rank and u.id = $this->id))"; // Users with lesser roles or self.
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
if($hash)
$password = 'md5('.$password.')';
$email = isset($fields['email']) ? $fields['email'] : '';
- $team_id = (int) $fields['team_id'];
+ $group_id = (int) $fields['group_id'];
$rate = str_replace(',', '.', isset($fields['rate']) ? $fields['rate'] : 0);
if($rate == '')
$rate = 0;
$created_ip_v = ', '.$mdb2->quote($_SERVER['REMOTE_ADDR']);
$created_by_v = ', '.$mdb2->quote($user->id);
- $sql = "insert into tt_users (name, login, password, team_id, role_id, client_id, rate, email, created, created_ip, created_by $status_f) values (".
+ $sql = "insert into tt_users (name, login, password, group_id, role_id, client_id, rate, email, created, created_ip, created_by $status_f) values (".
$mdb2->quote($fields['name']).", ".$mdb2->quote($fields['login']).
- ", $password, $team_id, ".$mdb2->quote($fields['role_id']).", ".$mdb2->quote($fields['client_id']).", $rate, ".$mdb2->quote($email).", now() $created_ip_v $created_by_v $status_v)";
+ ", $password, $group_id, ".$mdb2->quote($fields['role_id']).", ".$mdb2->quote($fields['client_id']).", $rate, ".$mdb2->quote($email).", now() $created_ip_v $created_by_v $status_v)";
$affected = $mdb2->exec($sql);
// Now deal with project assignment.
// otherwise de-activate the bind (set its status to inactive). This will keep the bind
// and its rate in database for reporting.
- $all_projects = ttTeamHelper::getAllProjects($user->team_id);
+ $all_projects = ttTeamHelper::getAllProjects($user->group_id);
$assigned_projects = isset($fields['projects']) ? $fields['projects'] : array();
foreach($all_projects as $p) {
return false;
// Mark user as deleted.
- $sql = "update tt_users set status = NULL where id = $user_id and team_id = ".$user->team_id;
+ $sql = "update tt_users set status = NULL where id = $user_id and group_id = ".$user->group_id;
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
} elseif ($user->isManager()) {
- $user_count = ttTeamHelper::getUserCount($user->team_id);
+ $user_count = ttTeamHelper::getUserCount($user->group_id);
// Marking deleted a manager with active users is not allowed.
if (($user_id == $user->id) && ($user_count > 1))
if (1 == $user_count) {
// Mark tasks deleted.
- if (!ttTeamHelper::markTasksDeleted($user->team_id))
+ if (!ttTeamHelper::markTasksDeleted($user->group_id))
return false;
// Mark projects deleted.
- $sql = "update tt_projects set status = NULL where team_id = $user->team_id";
+ $sql = "update tt_projects set status = NULL where group_id = $user->group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
// Mark clients deleted.
- $sql = "update tt_clients set status = NULL where team_id = $user->team_id";
+ $sql = "update tt_clients set status = NULL where group_id = $user->group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
// Mark custom fields deleted.
- $sql = "update tt_custom_fields set status = NULL where team_id = $user->team_id";
+ $sql = "update tt_custom_fields set status = NULL where group_id = $user->group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
// Mark team deleted.
- $sql = "update tt_groups set status = NULL where id = $user->team_id";
+ $sql = "update tt_groups set status = NULL where id = $user->group_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
return false;
// Mark user as deleted.
- $sql = "update tt_users set status = NULL where id = $user_id and team_id = ".$user->team_id;
+ $sql = "update tt_users set status = NULL where id = $user_id and group_id = ".$user->group_id;
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
$custom_field_1 = null;
if ($user->isPluginEnabled('cf')) {
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
$cf_1_type = $custom_fields->fields[0]['type'];
if ($cf_1_type == CustomFields::TYPE_TEXT) {
$custom_field_1 = ', cfl.value as cf_1_value';
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.17.80.4199 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.17.81.4200 | 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>
exit();
}
-$team_id = (int)$request->getParameter('id');
-$team_details = ttTeamHelper::getTeamDetails($team_id);
+$group_id = (int)$request->getParameter('id');
+$team_details = ttTeamHelper::getTeamDetails($group_id);
$team_name = $team_details['team_name'];
$form = new Form('teamForm');
-$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$team_id));
+$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$group_id));
$form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->get('label.delete')));
$form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->get('button.cancel')));
if ($request->getParameter('btn_delete')) {
import('ttAdmin');
$admin = new ttAdmin();
- $result = $admin->markGroupDeleted($team_id);
+ $result = $admin->markGroupDeleted($group_id);
if ($result) {
header('Location: admin_teams.php');
exit();
exit();
}
-$team_id = $request->getParameter('id');
-$team_details = ttTeamHelper::getTeamDetails($team_id);
+$group_id = $request->getParameter('id');
+$team_details = ttTeamHelper::getTeamDetails($group_id);
if ($request->isPost()) {
$cl_team_name = trim($request->getParameter('team_name'));
$form->addInput(array('type'=>'password','maxlength'=>'30','name'=>'password2','value'=>$cl_password2));
}
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_email','value'=>$cl_manager_email));
-$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$team_id));
+$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$group_id));
$form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save')));
$form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->get('button.cancel')));
import('ttAdmin');
$admin = new ttAdmin($err);
- $result = $admin->updateGroup($team_id, $fields);
+ $result = $admin->updateGroup($group_id, $fields);
if ($result) {
header('Location: admin_teams.php');
exit();
exit();
}
-$projects = ttTeamHelper::getActiveProjects($user->team_id);
+$projects = ttTeamHelper::getActiveProjects($user->group_id);
if ($request->isPost()) {
$cl_name = trim($request->getParameter('name'));
if ($err->no()) {
if (!ttClientHelper::getClientByName($cl_name)) {
if (ttClientHelper::insert(array(
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'name' => $cl_name,
'address' => $cl_address,
'tax' => $cl_tax,
$cl_id = (int) $request->getParameter('id');
-$projects = ttTeamHelper::getActiveProjects($user->team_id);
+$projects = ttTeamHelper::getActiveProjects($user->group_id);
if ($request->isPost()) {
$cl_name = trim($request->getParameter('name'));
if ($request->getParameter('btn_copy')) {
if (!ttClientHelper::getClientByName($cl_name)) {
if (ttClientHelper::insert(array(
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'name' => $cl_name,
'address' => $cl_address,
'tax' => $cl_tax,
exit();
}
-$smarty->assign('active_clients', ttTeamHelper::getActiveClients($user->team_id, true));
-$smarty->assign('inactive_clients', ttTeamHelper::getInactiveClients($user->team_id, true));
+$smarty->assign('active_clients', ttTeamHelper::getActiveClients($user->group_id, true));
+$smarty->assign('inactive_clients', ttTeamHelper::getInactiveClients($user->group_id, true));
$smarty->assign('title', $i18n->get('title.clients'));
$smarty->assign('content_page_name', 'clients.tpl');
$smarty->display('index.tpl');
setChange("RENAME TABLE `tt_teams` TO `tt_groups`");
setChange("ALTER TABLE `tt_monthly_quotas` DROP FOREIGN KEY FK_TT_TEAM_CONSTRAING");
setChange("UPDATE `tt_site_config` SET param_value = '1.17.80', modified = now() where param_name = 'version_db' and param_value = '1.17.79'");
+ setChange("ALTER TABLE `tt_roles` CHANGE `team_id` `group_id` int(11) NOT NULL");
+ setChange("ALTER TABLE `tt_users` CHANGE `team_id` `group_id` int(11) NOT NULL");
+ setChange("ALTER TABLE `tt_projects` CHANGE `team_id` `group_id` int(11) NOT NULL");
+ setChange("ALTER TABLE `tt_tasks` CHANGE `team_id` `group_id` int(11) NOT NULL");
+ setChange("ALTER TABLE `tt_invoices` CHANGE `team_id` `group_id` int(11) NOT NULL");
+ setChange("ALTER TABLE `tt_cron` CHANGE `team_id` `group_id` int(11) NOT NULL");
+ setChange("ALTER TABLE `tt_clients` CHANGE `team_id` `group_id` int(11) NOT NULL");
+ setChange("ALTER TABLE `tt_custom_fields` CHANGE `team_id` `group_id` int(11) NOT NULL");
+ setChange("ALTER TABLE `tt_predefined_expenses` CHANGE `team_id` `group_id` int(11) NOT NULL");
+ setChange("ALTER TABLE `tt_monthly_quotas` CHANGE `team_id` `group_id` int(11) NOT NULL");
+ setChange("UPDATE `tt_site_config` SET param_value = '1.17.81', modified = now() where param_name = 'version_db' and param_value = '1.17.80'");
}
if ($_POST["cleanup"]) {
// Dropdown for clients in MODE_TIME. Use all active clients.
if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
$form->addInput(array('type'=>'combobox',
'onchange'=>'fillProjectDropdown(this.value);',
'name'=>'client',
// Dropdown for clients if the clients plugin is enabled.
if ($user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
// We need an array of assigned project ids to do some trimming.
foreach($project_list as $project)
$projects_assigned_to_user[] = $project['id'];
}
}
// If predefined expenses are configured, add controls to select an expense and quantity.
-$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->team_id);
+$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->group_id);
if ($predefined_expenses) {
$form->addInput(array('type'=>'combobox',
'onchange'=>'recalculateCost();',
// Dropdown for clients in MODE_TIME. Use all active clients.
if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
$form->addInput(array('type'=>'combobox',
'onchange'=>'fillProjectDropdown(this.value);',
'name'=>'client',
// Dropdown for clients if the clients plugin is enabled.
if ($user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
// We need an array of assigned project ids to do some trimming.
foreach($project_list as $project)
$projects_assigned_to_user[] = $project['id'];
}
}
// If predefined expenses are configured, add controls to select an expense and quantity.
-$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->team_id);
+$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->group_id);
if ($predefined_expenses) {
$form->addInput(array('type'=>'combobox',
'onchange'=>'recalculateCost();',
$config .= ',uncompleted_indicators';
$config = trim($config, ',');
- $update_result = ttTeamHelper::update($user->team_id, array(
+ $update_result = ttTeamHelper::update($user->group_id, array(
'name' => $cl_team,
'currency' => $cl_currency,
'lang' => $cl_lang,
import('ttUser');
$user = new ttUser(null, $auth->getUserId());
if ($user->custom_logo) {
- $smarty->assign('custom_logo', 'images/'.$user->team_id.'.png');
- $smarty->assign('mobile_custom_logo', '../images/'.$user->team_id.'.png');
+ $smarty->assign('custom_logo', 'images/'.$user->group_id.'.png');
+ $smarty->assign('mobile_custom_logo', '../images/'.$user->group_id.'.png');
}
$smarty->assign('user', $user);
// Dropdown for clients if the clients plugin is enabled.
if ($user->isPluginEnabled('cl')) {
- $clients = ttTeamHelper::getActiveClients($user->team_id);
+ $clients = ttTeamHelper::getActiveClients($user->group_id);
$form->addInput(array('type'=>'combobox','name'=>'client','style'=>'width: 250px;','data'=>$clients,'datakeys'=>array('id','name'),'value'=>$cl_client,'empty'=>array(''=>$i18n->get('dropdown.select'))));
}
// Dropdown for projects.
if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
- $projects = ttTeamHelper::getActiveProjects($user->team_id);
+ $projects = ttTeamHelper::getActiveProjects($user->group_id);
$form->addInput(array('type'=>'combobox','name'=>'project','style'=>'width: 250px;','data'=>$projects,'datakeys'=>array('id','name'),'value'=>$cl_project,'empty'=>array(''=>$i18n->get('dropdown.all'))));
}
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'number','style'=>'width: 250px;','value'=>$cl_number));
if (!ttValidCronSpec($cl_lock_spec)) $err->add($i18n->get('error.field'), $i18n->get('label.schedule'));
if ($err->no()) {
- if (ttTeamHelper::update($user->team_id, array(
+ if (ttTeamHelper::update($user->group_id, array(
'name' => $user->team,
'lock_spec' => $cl_lock_spec))) {
header('Location: profile_edit.php');
exit();
}
-$projects = ttTeamHelper::getActiveProjects($user->team_id);
+$projects = ttTeamHelper::getActiveProjects($user->group_id);
if ($request->isPost()) {
$cl_name = trim($request->getParameter('name'));
if ($err->no()) {
if (!ttClientHelper::getClientByName($cl_name)) {
if (ttClientHelper::insert(array(
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'name' => $cl_name,
'address' => $cl_address,
'tax' => $cl_tax,
$cl_id = (int) $request->getParameter('id');
-$projects = ttTeamHelper::getActiveProjects($user->team_id);
+$projects = ttTeamHelper::getActiveProjects($user->group_id);
if ($request->isPost()) {
$cl_name = trim($request->getParameter('name'));
if ($request->getParameter('btn_copy')) {
if (!ttClientHelper::getClientByName($cl_name)) {
if (ttClientHelper::insert(array(
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'name' => $cl_name,
'address' => $cl_address,
'tax' => $cl_tax,
exit();
}
-$smarty->assign('active_clients', ttTeamHelper::getActiveClients($user->team_id, true));
-$smarty->assign('inactive_clients', ttTeamHelper::getInactiveClients($user->team_id, true));
+$smarty->assign('active_clients', ttTeamHelper::getActiveClients($user->group_id, true));
+$smarty->assign('inactive_clients', ttTeamHelper::getInactiveClients($user->group_id, true));
$smarty->assign('title', $i18n->get('title.clients'));
$smarty->assign('content_page_name', 'mobile/clients.tpl');
$smarty->display('mobile/index.tpl');
// Dropdown for clients in MODE_TIME. Use all active clients.
if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
$form->addInput(array('type'=>'combobox',
'onchange'=>'fillProjectDropdown(this.value);',
'name'=>'client',
// Dropdown for clients if the clients plugin is enabled.
if ($user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
// We need an array of assigned project ids to do some trimming.
foreach($project_list as $project)
$projects_assigned_to_user[] = $project['id'];
}
}
// If predefined expenses are configured, add controls to select an expense and quantity.
-$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->team_id);
+$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->group_id);
if ($predefined_expenses) {
$form->addInput(array('type'=>'combobox',
'onchange'=>'recalculateCost();',
// Dropdown for clients in MODE_TIME. Use all active clients.
if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
$form->addInput(array('type'=>'combobox',
'onchange'=>'fillProjectDropdown(this.value);',
'name'=>'client',
// Dropdown for clients if the clients plugin is enabled.
if ($user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
// We need an array of assigned project ids to do some trimming.
foreach($project_list as $project)
$projects_assigned_to_user[] = $project['id'];
}
}
// If predefined expenses are configured, add controls to select an expense and quantity.
-$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->team_id);
+$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->group_id);
if ($predefined_expenses) {
$form->addInput(array('type'=>'combobox',
'onchange'=>'recalculateCost();',
foreach ($users as $user_item)
$all_users[$user_item['id']] = $user_item['name'];
-$tasks = ttTeamHelper::getActiveTasks($user->team_id);
+$tasks = ttTeamHelper::getActiveTasks($user->group_id);
foreach ($tasks as $task_item)
$all_tasks[$task_item['id']] = $task_item['name'];
if ($err->no()) {
if (!ttProjectHelper::getProjectByName($cl_name)) {
if (ttProjectHelper::insert(array(
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'name' => $cl_name,
'description' => $cl_description,
'users' => $cl_users,
foreach ($users as $user_item)
$all_users[$user_item['id']] = $user_item['name'];
-$tasks = ttTeamHelper::getActiveTasks($user->team_id);
+$tasks = ttTeamHelper::getActiveTasks($user->group_id);
foreach ($tasks as $task_item)
$all_tasks[$task_item['id']] = $task_item['name'];
if ($request->getParameter('btn_copy')) {
if (!ttProjectHelper::getProjectByName($cl_name)) {
if (ttProjectHelper::insert(array(
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'name' => $cl_name,
'description' => $cl_description,
'users' => $cl_users,
// End of access checks.
if($user->can('manage_projects')) {
- $active_projects = ttTeamHelper::getActiveProjects($user->team_id);
- $inactive_projects = ttTeamHelper::getInactiveProjects($user->team_id);
+ $active_projects = ttTeamHelper::getActiveProjects($user->group_id);
+ $inactive_projects = ttTeamHelper::getInactiveProjects($user->group_id);
} else
$active_projects = $user->getAssignedProjects();
}
// End of access checks.
-$projects = ttTeamHelper::getActiveProjects($user->team_id);
+$projects = ttTeamHelper::getActiveProjects($user->group_id);
if ($request->isPost()) {
$cl_name = trim($request->getParameter('name'));
if ($err->no()) {
if (!ttTaskHelper::getTaskByName($cl_name)) {
if (ttTaskHelper::insert(array(
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'name' => $cl_name,
'description' => $cl_description,
'status' => ACTIVE,
}
// End of access checks.
-$projects = ttTeamHelper::getActiveProjects($user->team_id);
+$projects = ttTeamHelper::getActiveProjects($user->group_id);
if ($request->isPost()) {
$cl_name = trim($request->getParameter('name'));
if ($request->getParameter('btn_copy')) {
if (!ttTaskHelper::getTaskByName($cl_name)) {
if (ttTaskHelper::insert(array(
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'name' => $cl_name,
'description' => $cl_description,
'status' => $cl_status,
}
// End of access checks.
-$smarty->assign('active_tasks', ttTeamHelper::getActiveTasks($user->team_id));
-$smarty->assign('inactive_tasks', ttTeamHelper::getInactiveTasks($user->team_id));
+$smarty->assign('active_tasks', ttTeamHelper::getActiveTasks($user->group_id));
+$smarty->assign('inactive_tasks', ttTeamHelper::getInactiveTasks($user->group_id));
$smarty->assign('title', $i18n->get('title.tasks'));
$smarty->assign('content_page_name', 'mobile/tasks.tpl');
$smarty->display('mobile/index.tpl');
// Use custom fields plugin if it is enabled.
if ($user->isPluginEnabled('cf')) {
require_once('../plugins/CustomFields.class.php');
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
$smarty->assign('custom_fields', $custom_fields);
}
// Dropdown for clients in MODE_TIME. Use all active clients.
if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
$form->addInput(array('type'=>'combobox',
'onchange'=>'fillProjectDropdown(this.value);',
'name'=>'client',
// Dropdown for clients if the clients plugin is enabled.
if ($user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
// We need an array of assigned project ids to do some trimming.
foreach($project_list as $project)
$projects_assigned_to_user[] = $project['id'];
}
if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
- $task_list = ttTeamHelper::getActiveTasks($user->team_id);
+ $task_list = ttTeamHelper::getActiveTasks($user->group_id);
$form->addInput(array('type'=>'combobox',
'name'=>'task',
'style'=>'width: 250px;',
// Use custom fields plugin if it is enabled.
if ($user->isPluginEnabled('cf')) {
require_once('../plugins/CustomFields.class.php');
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
$smarty->assign('custom_fields', $custom_fields);
}
// Dropdown for clients in MODE_TIME. Use all active clients.
if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
$form->addInput(array('type'=>'combobox',
'onchange'=>'fillProjectDropdown(this.value);',
'name'=>'client',
// Dropdown for clients if the clients plugin is enabled.
if ($user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
// We need an array of assigned project ids to do some trimming.
foreach($project_list as $project)
$projects_assigned_to_user[] = $project['id'];
}
if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
- $task_list = ttTeamHelper::getActiveTasks($user->team_id);
+ $task_list = ttTeamHelper::getActiveTasks($user->group_id);
$form->addInput(array('type'=>'combobox',
'name'=>'task',
'style'=>'width: 250px;',
// Use custom fields plugin if it is enabled.
if ($user->isPluginEnabled('cf')) {
require_once('../plugins/CustomFields.class.php');
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
$smarty->assign('custom_fields', $custom_fields);
}
// Dropdown for clients in MODE_TIME. Use all active clients.
if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
$form->addInput(array('type'=>'combobox',
'onchange'=>'fillProjectDropdown(this.value);',
'name'=>'client',
// Dropdown for clients if the clients plugin is enabled.
if ($user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
// We need an array of assigned project ids to do some trimming.
foreach($project_list as $project)
$projects_assigned_to_user[] = $project['id'];
}
if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
- $task_list = ttTeamHelper::getActiveTasks($user->team_id);
+ $task_list = ttTeamHelper::getActiveTasks($user->group_id);
$form->addInput(array('type'=>'combobox',
'name'=>'task',
'style'=>'width: 250px;',
@include('plugins/limit/user_add.php');
if ($user->isPluginEnabled('cl'))
- $clients = ttTeamHelper::getActiveClients($user->team_id);
+ $clients = ttTeamHelper::getActiveClients($user->group_id);
$assigned_projects = array();
if ($request->isPost()) {
$form->addInput(array('type'=>'floatfield','maxlength'=>'10','name'=>'rate','format'=>'.2','value'=>$cl_rate));
-$projects = ttTeamHelper::getActiveProjects($user->team_id);
+$projects = ttTeamHelper::getActiveProjects($user->group_id);
// Define classes for the projects table.
class NameCellRenderer extends DefaultCellRenderer {
'login' => $cl_login,
'password' => $cl_password1,
'rate' => $cl_rate,
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'role_id' => $cl_role_id,
'client_id' => $cl_client_id,
'projects' => $assigned_projects,
// End of access checks.
if ($user->isPluginEnabled('cl'))
- $clients = ttTeamHelper::getActiveClients($user->team_id);
+ $clients = ttTeamHelper::getActiveClients($user->group_id);
-$projects = ttTeamHelper::getActiveProjects($user->team_id);
+$projects = ttTeamHelper::getActiveProjects($user->group_id);
$assigned_projects = array();
if ($request->isPost()) {
$active_users = ttTeamHelper::getActiveUsers(array('getAllFields'=>true));
if($user->canManageTeam()) {
$can_delete_manager = (1 == count($active_users));
- $inactive_users = ttTeamHelper::getInactiveUsers($user->team_id, true);
+ $inactive_users = ttTeamHelper::getInactiveUsers($user->group_id, true);
}
// Check if the team is set to show indicators for uncompleted time entries.
#
CREATE TABLE `tt_roles` (
`id` int(11) NOT NULL auto_increment, # Role id. Identifies roles for all groups on the server.
- `team_id` int(11) NOT NULL, # Team id the role is defined for.
+ `group_id` int(11) NOT NULL, # Group id the role is defined for.
`name` varchar(80) default NULL, # Role name - custom role name. In case we are editing a
# predefined role (USER, etc.), we can rename the role here.
`description` varchar(255) default NULL, # Role description.
);
# Create an index that guarantees unique active and inactive role ranks in each group.
-create unique index role_idx on tt_roles(team_id, rank, status);
+create unique index role_idx on tt_roles(group_id, rank, status);
# Insert site-wide roles - site administrator and top manager.
-INSERT INTO `tt_roles` (`team_id`, `name`, `rank`, `rights`) VALUES (0, 'Site administrator', 1024, 'administer_site');
-INSERT INTO `tt_roles` (`team_id`, `name`, `rank`, `rights`) VALUES (0, 'Top manager', 512, 'track_own_time,track_own_expenses,view_own_reports,view_own_charts,view_own_invoices,view_own_projects,manage_own_settings,view_users,track_time,track_expenses,view_reports,view_charts,override_punch_mode,override_own_punch_mode,override_date_lock,override_own_date_lock,swap_roles,approve_timesheets,manage_own_account,manage_users,manage_projects,manage_tasks,manage_custom_fields,manage_clients,manage_invoices,manage_features,manage_basic_settings,manage_advanced_settings,manage_roles,export_data,manage_subgroups');
+INSERT INTO `tt_roles` (`group_id`, `name`, `rank`, `rights`) VALUES (0, 'Site administrator', 1024, 'administer_site');
+INSERT INTO `tt_roles` (`group_id`, `name`, `rank`, `rights`) VALUES (0, 'Top manager', 512, 'track_own_time,track_own_expenses,view_own_reports,view_own_charts,view_own_invoices,view_own_projects,manage_own_settings,view_users,track_time,track_expenses,view_reports,view_charts,override_punch_mode,override_own_punch_mode,override_date_lock,override_own_date_lock,swap_roles,approve_timesheets,manage_own_account,manage_users,manage_projects,manage_tasks,manage_custom_fields,manage_clients,manage_invoices,manage_features,manage_basic_settings,manage_advanced_settings,manage_roles,export_data,manage_subgroups');
#
`login` varchar(50) COLLATE utf8_bin NOT NULL, # user login
`password` varchar(50) default NULL, # password hash
`name` varchar(100) default NULL, # user name
- `team_id` int(11) NOT NULL, # team id
+ `group_id` int(11) NOT NULL, # group id
`role_id` int(11) default NULL, # role id
`client_id` int(11) default NULL, # client id for "client" user role
`rate` float(6,2) NOT NULL default '0.00', # default hourly rate
# Create admin account with password 'secret'. Admin is a superuser, who can create teams.
DELETE from `tt_users` WHERE login = 'admin';
-INSERT INTO `tt_users` (`login`, `password`, `name`, `team_id`, `role_id`) VALUES ('admin', md5('secret'), 'Admin', '0', (select id from tt_roles where rank = 1024));
+INSERT INTO `tt_users` (`login`, `password`, `name`, `group_id`, `role_id`) VALUES ('admin', md5('secret'), 'Admin', '0', (select id from tt_roles where rank = 1024));
#
#
CREATE TABLE `tt_projects` (
`id` int(11) NOT NULL auto_increment, # project id
- `team_id` int(11) NOT NULL, # team id
+ `group_id` int(11) NOT NULL, # group id
`name` varchar(80) COLLATE utf8_bin NOT NULL, # project name
`description` varchar(255) default NULL, # project description
`tasks` text default NULL, # comma-separated list of task ids associated with this project
PRIMARY KEY (`id`)
);
-# Create an index that guarantees unique active and inactive projects per team.
-create unique index project_idx on tt_projects(team_id, name, status);
+# Create an index that guarantees unique active and inactive projects per group.
+create unique index project_idx on tt_projects(group_id, name, status);
#
#
CREATE TABLE `tt_tasks` (
`id` int(11) NOT NULL auto_increment, # task id
- `team_id` int(11) NOT NULL, # team id
+ `group_id` int(11) NOT NULL, # group id
`name` varchar(80) COLLATE utf8_bin NOT NULL, # task name
`description` varchar(255) default NULL, # task description
`status` tinyint(4) default 1, # task status
PRIMARY KEY (`id`)
);
-# Create an index that guarantees unique active and inactive tasks per team.
-create unique index task_idx on tt_tasks(team_id, name, status);
+# Create an index that guarantees unique active and inactive tasks per group.
+create unique index task_idx on tt_tasks(group_id, name, status);
#
#
CREATE TABLE `tt_invoices` (
`id` int(11) NOT NULL auto_increment, # invoice id
- `team_id` int(11) NOT NULL, # team id
+ `group_id` int(11) NOT NULL, # group id
`name` varchar(80) COLLATE utf8_bin NOT NULL, # invoice name
`date` date NOT NULL, # invoice date
`client_id` int(11) NOT NULL, # client id
);
# Create an index that guarantees unique invoice names per team.
-create unique index name_idx on tt_invoices(team_id, name, status);
+create unique index name_idx on tt_invoices(group_id, name, status);
#
#
CREATE TABLE `tt_cron` (
`id` int(11) NOT NULL auto_increment, # entry id
- `team_id` int(11) NOT NULL, # team id
+ `group_id` int(11) NOT NULL, # group id
`cron_spec` varchar(255) NOT NULL, # cron specification, "0 1 * * *" for "daily at 01:00"
`last` int(11) default NULL, # UNIX timestamp of when job was last run
`next` int(11) default NULL, # UNIX timestamp of when to run next job
#
CREATE TABLE `tt_clients` (
`id` int(11) NOT NULL AUTO_INCREMENT, # client id
- `team_id` int(11) NOT NULL, # team id
+ `group_id` int(11) NOT NULL, # group id
`name` varchar(80) COLLATE utf8_bin NOT NULL, # client name
`address` varchar(255) default NULL, # client address
`tax` float(6,2) default '0.00', # applicable tax for this client
);
# Create an index that guarantees unique active and inactive clients per team.
-create unique index client_name_idx on tt_clients(team_id, name, status);
+create unique index client_name_idx on tt_clients(group_id, name, status);
#
#
CREATE TABLE `tt_custom_fields` (
`id` int(11) NOT NULL auto_increment, # custom field id
- `team_id` int(11) NOT NULL, # team id
+ `group_id` int(11) NOT NULL, # group id
`type` tinyint(4) NOT NULL default 0, # custom field type (text or dropdown)
`label` varchar(32) NOT NULL default '', # custom field label
`required` tinyint(4) default 0, # whether this custom field is mandatory for time records
#
CREATE TABLE `tt_predefined_expenses` (
`id` int(11) NOT NULL auto_increment, # predefined expense id
- `team_id` int(11) NOT NULL, # team id
+ `group_id` int(11) NOT NULL, # group id
`name` varchar(255) NOT NULL, # predefined expense name, such as mileage
`cost` decimal(10,2) default '0.00', # cost for one unit
PRIMARY KEY (`id`)
# This table keeps monthly work hour quotas for groups.
#
CREATE TABLE `tt_monthly_quotas` (
- `team_id` int(11) NOT NULL, # group id
+ `group_id` int(11) NOT NULL, # group id
`year` smallint(5) UNSIGNED NOT NULL, # quota year
`month` tinyint(3) UNSIGNED NOT NULL, # quota month
`minutes` int(11) default NULL, # quota in minutes in specified month and year
- PRIMARY KEY (`team_id`,`year`,`month`)
+ PRIMARY KEY (`group_id`,`year`,`month`)
);
PRIMARY KEY (`param_name`)
);
-INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.17.80', now()); # TODO: change when structure changes.
+INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.17.81', now()); # TODO: change when structure changes.
$next = tdCron::getNextOccurrence($cl_cron_spec, mktime());
if (ttNotificationHelper::insert(array(
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'cron_spec' => $cl_cron_spec,
'next' => $next,
'report_id' => $cl_fav_report,
if (ttNotificationHelper::update(array(
'id' => $notification_id,
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'cron_spec' => $cl_cron_spec,
'next' => $next,
'report_id' => $cl_fav_report,
}
} else {
$form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->get('button.add')));
- $notifications = ttTeamHelper::getNotifications($user->team_id);
+ $notifications = ttTeamHelper::getNotifications($user->group_id);
}
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
$smarty->assign('i18n', $i18n->keys);
}
if ($user->custom_logo) {
- $smarty->assign('custom_logo', 'images/'.$user->team_id.'.png');
- $smarty->assign('mobile_custom_logo', '../images/'.$user->team_id.'.png');
+ $smarty->assign('custom_logo', 'images/'.$user->group_id.'.png');
+ $smarty->assign('mobile_custom_logo', '../images/'.$user->group_id.'.png');
}
$smarty->assign('user', $user);
}
var $options = array(); // Array of options for a dropdown custom field.
// Constructor.
- function __construct($team_id) {
+ function __construct($group_id) {
$mdb2 = getConnection();
// Get fields.
- $sql = "select id, type, label, required from tt_custom_fields where team_id = $team_id and status = 1 and type > 0";
+ $sql = "select id, type, label, required from tt_custom_fields where group_id = $group_id and status = 1 and type > 0";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
while ($val = $res->fetchRow()) {
$field_id = CustomFields::getFieldIdForOption($id);
// First make sure that the field is ours.
- $sql = "select team_id from tt_custom_fields where id = $field_id";
+ $sql = "select group_id from tt_custom_fields where id = $field_id";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error'))
return false;
$val = $res->fetchRow();
- if ($user->team_id != $val['team_id'])
+ if ($user->group_id != $val['group_id'])
return false;
// Delete log entries with this option.
$options = array();
// First make sure that the field is ours.
- $sql = "select team_id from tt_custom_fields where id = $field_id";
+ $sql = "select group_id from tt_custom_fields where id = $field_id";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error'))
return false;
$val = $res->fetchRow();
- if ($user->team_id != $val['team_id'])
+ if ($user->group_id != $val['group_id'])
return false;
// Get options.
$field_id = CustomFields::getFieldIdForOption($id);
// First make sure that the field is ours.
- $sql = "select team_id from tt_custom_fields where id = $field_id";
+ $sql = "select group_id from tt_custom_fields where id = $field_id";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error'))
return false;
$val = $res->fetchRow();
- if ($user->team_id != $val['team_id'])
+ if ($user->group_id != $val['group_id'])
return false;
// Get option name.
$mdb2 = getConnection();
$fields = array();
- $sql = "select id, type, label from tt_custom_fields where team_id = $user->team_id and status = 1 and type > 0";
+ $sql = "select id, type, label from tt_custom_fields where group_id = $user->group_id and status = 1 and type > 0";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
while ($val = $res->fetchRow()) {
global $user;
$mdb2 = getConnection();
- $sql = "select label, type, required from tt_custom_fields where id = $id and team_id = $user->team_id";
+ $sql = "select label, type, required from tt_custom_fields where id = $id and group_id = $user->group_id";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
$val = $res->fetchRow();
static function insertField($field_name, $field_type, $required) {
global $user;
$mdb2 = getConnection();
- $sql = "insert into tt_custom_fields (team_id, type, label, required, status) values($user->team_id, $field_type, ".$mdb2->quote($field_name).", $required, 1)";
+ $sql = "insert into tt_custom_fields (group_id, type, label, required, status) values($user->group_id, $field_type, ".$mdb2->quote($field_name).", $required, 1)";
$affected = $mdb2->exec($sql);
return (!is_a($affected, 'PEAR_Error'));
}
static function updateField($id, $name, $type, $required) {
global $user;
$mdb2 = getConnection();
- $sql = "update tt_custom_fields set label = ".$mdb2->quote($name).", type = $type, required = $required where id = $id and team_id = $user->team_id";
+ $sql = "update tt_custom_fields set label = ".$mdb2->quote($name).", type = $type, required = $required where id = $id and group_id = $user->group_id";
$affected = $mdb2->exec($sql);
return (!is_a($affected, 'PEAR_Error'));
}
$mdb2 = getConnection();
// First make sure that the field is ours so that we can safely delete it.
- $sql = "select team_id from tt_custom_fields where id = $field_id";
+ $sql = "select group_id from tt_custom_fields where id = $field_id";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error'))
return false;
$val = $res->fetchRow();
- if ($user->team_id != $val['team_id'])
+ if ($user->group_id != $val['group_id'])
return false;
// Mark log entries as deleted.
return false;
// Delete the field.
- $sql = "delete from tt_custom_fields where id = $field_id and team_id = $user->team_id";
+ $sql = "delete from tt_custom_fields where id = $field_id and group_id = $user->group_id";
$affected = $mdb2->exec($sql);
return (!is_a($affected, 'PEAR_Error'));
}
class MonthlyQuota {
var $db; // Database connection.
- var $team_id; // Team id.
+ var $group_id; // Group id.
function __construct() {
$this->db = getConnection();
global $user;
- $this->team_id = $user->team_id;
+ $this->group_id = $user->group_id;
}
// update - deletes a quota, then inserts a new one.
public function update($year, $month, $minutes) {
- $team_id = $this->team_id;
- $deleteSql = "DELETE FROM tt_monthly_quotas WHERE year = $year AND month = $month AND team_id = $team_id";
+ $group_id = $this->group_id;
+ $deleteSql = "DELETE FROM tt_monthly_quotas WHERE year = $year AND month = $month AND group_id = $group_id";
$this->db->exec($deleteSql);
if ($minutes){
- $insertSql = "INSERT INTO tt_monthly_quotas (team_id, year, month, minutes) values ($team_id, $year, $month, $minutes)";
+ $insertSql = "INSERT INTO tt_monthly_quotas (group_id, year, month, minutes) values ($group_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) {
- $team_id = $this->team_id;
- $sql = "SELECT minutes FROM tt_monthly_quotas WHERE year = $year AND month = $month AND team_id = $team_id";
+ $group_id = $this->group_id;
+ $sql = "SELECT minutes FROM tt_monthly_quotas WHERE year = $year AND month = $month AND group_id = $group_id";
$reader = $this->db->query($sql);
if (is_a($reader, 'PEAR_Error')) {
return false;
// getMany - returns an array of quotas for a given year for team.
private function getMany($year){
- $team_id = $this->team_id;
- $sql = "SELECT month, minutes FROM tt_monthly_quotas WHERE year = $year AND team_id = $team_id";
+ $group_id = $this->group_id;
+ $sql = "SELECT month, minutes FROM tt_monthly_quotas WHERE year = $year AND group_id = $group_id";
$result = array();
$res = $this->db->query($sql);
if (is_a($res, 'PEAR_Error')) {
if (!ttValidFloat($cl_cost)) $err->add($i18n->get('error.field'), $i18n->get('label.cost'));
if ($err->no()) {
if (ttPredefinedExpenseHelper::insert(array(
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'name' => $cl_name,
'cost' => $cl_cost))) {
header('Location: predefined_expenses.php');
if ($err->no()) {
if (ttPredefinedExpenseHelper::update(array(
'id' => $predefined_expense_id,
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'name' => $cl_name,
'cost' => $cl_cost))) {
header('Location: predefined_expenses.php');
}
} else {
$form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->get('button.add')));
- $predefinedExpenses = ttTeamHelper::getPredefinedExpenses($user->team_id);
+ $predefinedExpenses = ttTeamHelper::getPredefinedExpenses($user->group_id);
}
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
foreach ($users as $user_item)
$all_users[$user_item['id']] = $user_item['name'];
-$tasks = ttTeamHelper::getActiveTasks($user->team_id);
+$tasks = ttTeamHelper::getActiveTasks($user->group_id);
foreach ($tasks as $task_item)
$all_tasks[$task_item['id']] = $task_item['name'];
if ($err->no()) {
if (!ttProjectHelper::getProjectByName($cl_name)) {
if (ttProjectHelper::insert(array(
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'name' => $cl_name,
'description' => $cl_description,
'users' => $cl_users,
foreach ($users as $user_item)
$all_users[$user_item['id']] = $user_item['name'];
-$tasks = ttTeamHelper::getActiveTasks($user->team_id);
+$tasks = ttTeamHelper::getActiveTasks($user->group_id);
foreach ($tasks as $task_item)
$all_tasks[$task_item['id']] = $task_item['name'];
if ($request->getParameter('btn_copy')) {
if (!ttProjectHelper::getProjectByName($cl_name)) {
if (ttProjectHelper::insert(array(
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'name' => $cl_name,
'description' => $cl_description,
'users' => $cl_users,
// End of access checks.
if($user->can('manage_projects')) {
- $active_projects = ttTeamHelper::getActiveProjects($user->team_id);
- $inactive_projects = ttTeamHelper::getInactiveProjects($user->team_id);
+ $active_projects = ttTeamHelper::getActiveProjects($user->group_id);
+ $inactive_projects = ttTeamHelper::getInactiveProjects($user->group_id);
} else
$active_projects = $user->getAssignedProjects();
// Handle workday hours.
$workday_minutes = ttTimeHelper::postedDurationToMinutes($request->getParameter('workdayHours'));
if ($workday_minutes != $user->workday_minutes) {
- if (!ttTeamHelper::update($user->team_id, array('name'=>$user->team,'workday_minutes'=>$workday_minutes)))
+ if (!ttTeamHelper::update($user->group_id, array('name'=>$user->team,'workday_minutes'=>$workday_minutes)))
$err->add($i18n->get('error.db'));
}
// Use custom fields plugin if it is enabled.
if ($user->isPluginEnabled('cf')) {
require_once('plugins/CustomFields.class.php');
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
$smarty->assign('custom_fields', $custom_fields);
}
// Controls for "Assign to invoice" block.
if ($client_id && $bean->getAttribute('chinvoice') && ('no_grouping' == $bean->getAttribute('group_by')) && !$user->isClient()) {
// Client is selected and we are displaying the invoice column.
- $recent_invoices = ttTeamHelper::getRecentInvoices($user->team_id, $client_id);
+ $recent_invoices = ttTeamHelper::getRecentInvoices($user->group_id, $client_id);
if ($recent_invoices) {
$assign_invoice_select_options = array('1'=>$i18n->get('dropdown.all'),'2'=>$i18n->get('dropdown.select'));
$form->addInput(array('type'=>'combobox',
// Use custom fields plugin if it is enabled.
if ($user->isPluginEnabled('cf')) {
require_once('plugins/CustomFields.class.php');
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
$smarty->assign('custom_fields', $custom_fields);
}
'datakeys'=>array('id','name'),
'empty'=>array(''=>$i18n->get('dropdown.all'))));
if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
- $task_list = ttTeamHelper::getActiveTasks($user->team_id);
+ $task_list = ttTeamHelper::getActiveTasks($user->group_id);
$form->addInput(array('type'=>'combobox',
'name'=>'task',
'style'=>'width: 250px;',
if ($cl_rank >= $user->rank || $cl_rank < 0) $err->add($i18n->get('error.field'), $i18n->get('form.roles.rank'));
if ($err->no()) {
- $existing_role = ttRoleHelper::getRoleByRank($cl_rank, $user->team_id);
+ $existing_role = ttRoleHelper::getRoleByRank($cl_rank, $user->group_id);
if (!$existing_role) {
// Insert a role with default user rights.
if (ttRoleHelper::insert(array(
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'name' => $cl_name,
'rank' => $cl_rank,
'description' => $cl_description,
}
// End of access checks.
-$projects = ttTeamHelper::getActiveProjects($user->team_id);
+$projects = ttTeamHelper::getActiveProjects($user->group_id);
if ($request->isPost()) {
$cl_name = trim($request->getParameter('name'));
if ($err->no()) {
if (!ttTaskHelper::getTaskByName($cl_name)) {
if (ttTaskHelper::insert(array(
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'name' => $cl_name,
'description' => $cl_description,
'status' => ACTIVE,
}
// End of access checks.
-$projects = ttTeamHelper::getActiveProjects($user->team_id);
+$projects = ttTeamHelper::getActiveProjects($user->group_id);
if ($request->isPost()) {
$cl_name = trim($request->getParameter('name'));
if ($request->getParameter('btn_copy')) {
if (!ttTaskHelper::getTaskByName($cl_name)) {
if (ttTaskHelper::insert(array(
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'name' => $cl_name,
'description' => $cl_description,
'status' => $cl_status,
}
// End of access checks.
-$smarty->assign('active_tasks', ttTeamHelper::getActiveTasks($user->team_id));
-$smarty->assign('inactive_tasks', ttTeamHelper::getInactiveTasks($user->team_id));
+$smarty->assign('active_tasks', ttTeamHelper::getActiveTasks($user->group_id));
+$smarty->assign('inactive_tasks', ttTeamHelper::getInactiveTasks($user->group_id));
$smarty->assign('title', $i18n->get('title.tasks'));
$smarty->assign('content_page_name', 'tasks.tpl');
$smarty->display('index.tpl');
// Use custom fields plugin if it is enabled.
if ($user->isPluginEnabled('cf')) {
require_once('plugins/CustomFields.class.php');
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
$smarty->assign('custom_fields', $custom_fields);
}
// Dropdown for clients in MODE_TIME. Use all active clients.
if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
$form->addInput(array('type'=>'combobox',
'onchange'=>'fillProjectDropdown(this.value);',
'name'=>'client',
// Dropdown for clients if the clients plugin is enabled.
if ($user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
// We need an array of assigned project ids to do some trimming.
foreach($project_list as $project)
$projects_assigned_to_user[] = $project['id'];
}
if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
- $task_list = ttTeamHelper::getActiveTasks($user->team_id);
+ $task_list = ttTeamHelper::getActiveTasks($user->group_id);
$form->addInput(array('type'=>'combobox',
'name'=>'task',
'style'=>'width: 250px;',
// Use custom fields plugin if it is enabled.
if ($user->isPluginEnabled('cf')) {
require_once('plugins/CustomFields.class.php');
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
$smarty->assign('custom_fields', $custom_fields);
}
// Dropdown for clients in MODE_TIME. Use all active clients.
if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
$form->addInput(array('type'=>'combobox',
'onchange'=>'fillProjectDropdown(this.value);',
'name'=>'client',
// Dropdown for clients if the clients plugin is enabled.
if ($user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
// We need an array of assigned project ids to do some trimming.
foreach($project_list as $project)
$projects_assigned_to_user[] = $project['id'];
}
if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
- $task_list = ttTeamHelper::getActiveTasks($user->team_id);
+ $task_list = ttTeamHelper::getActiveTasks($user->group_id);
$form->addInput(array('type'=>'combobox',
'name'=>'task',
'style'=>'width: 250px;',
// Use custom fields plugin if it is enabled.
if ($user->isPluginEnabled('cf')) {
require_once('plugins/CustomFields.class.php');
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
}
// Report settings are stored in session bean before we get here.
// Use custom fields plugin if it is enabled.
if ($user->isPluginEnabled('cf')) {
require_once('plugins/CustomFields.class.php');
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
}
// Report settings are stored in session bean before we get here.
$pdf = new ttPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// If custom logo file exists - set it.
-if (file_exists('images/'.$user->team_id.'.png'))
- $pdf->SetImageFile('images/'.$user->team_id.'.png');
+if (file_exists('images/'.$user->group_id.'.png'))
+ $pdf->SetImageFile('images/'.$user->group_id.'.png');
// Set page word for the footer.
$pdf->SetPageWord($i18n->get('label.page'));
@include('plugins/limit/user_add.php');
if ($user->isPluginEnabled('cl'))
- $clients = ttTeamHelper::getActiveClients($user->team_id);
+ $clients = ttTeamHelper::getActiveClients($user->group_id);
$assigned_projects = array();
if ($request->isPost()) {
$form->addInput(array('type'=>'floatfield','maxlength'=>'10','name'=>'rate','format'=>'.2','value'=>$cl_rate));
-$projects = ttTeamHelper::getActiveProjects($user->team_id);
+$projects = ttTeamHelper::getActiveProjects($user->group_id);
// Define classes for the projects table.
class NameCellRenderer extends DefaultCellRenderer {
'login' => $cl_login,
'password' => $cl_password1,
'rate' => $cl_rate,
- 'team_id' => $user->team_id,
+ 'group_id' => $user->group_id,
'role_id' => $cl_role_id,
'client_id' => $cl_client_id,
'projects' => $assigned_projects,
// End of access checks.
if ($user->isPluginEnabled('cl'))
- $clients = ttTeamHelper::getActiveClients($user->team_id);
+ $clients = ttTeamHelper::getActiveClients($user->group_id);
-$projects = ttTeamHelper::getActiveProjects($user->team_id);
+$projects = ttTeamHelper::getActiveProjects($user->group_id);
$assigned_projects = array();
if ($request->isPost()) {
// Use custom fields plugin if it is enabled.
if ($user->isPluginEnabled('cf')) {
require_once('plugins/CustomFields.class.php');
- $custom_fields = new CustomFields($user->team_id);
+ $custom_fields = new CustomFields($user->group_id);
$smarty->assign('custom_fields', $custom_fields);
}
// Dropdown for clients in MODE_TIME. Use all active clients.
if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
$form->addInput(array('type'=>'combobox',
'onchange'=>'fillProjectDropdown(this.value);',
'name'=>'client',
// Dropdown for clients if the clients plugin is enabled.
if ($user->isPluginEnabled('cl')) {
- $active_clients = ttTeamHelper::getActiveClients($user->team_id, true);
+ $active_clients = ttTeamHelper::getActiveClients($user->group_id, true);
// We need an array of assigned project ids to do some trimming.
foreach($project_list as $project)
$projects_assigned_to_user[] = $project['id'];
}
if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
- $task_list = ttTeamHelper::getActiveTasks($user->team_id);
+ $task_list = ttTeamHelper::getActiveTasks($user->group_id);
$form->addInput(array('type'=>'combobox',
'name'=>'task',
'style'=>'width: 250px;',