}
return false;
}
+
// getReport - returns a report identified by its id.
// TODO: get rid of this function by encapsulating all cron related tasks in its own class.
// Because cron works for all orgs and we want this class to always work in context of
if (!$bean->getAttribute('chtotalsonly')) $bean->setAttribute('chtotalsonly', 0);
- $users_in_bean = $bean->getAttribute('users');
- if ($users_in_bean && is_array($users_in_bean)) {
- $users = join(',', $users_in_bean);
+ $active_users_in_bean = $bean->getAttribute('users_active');
+ if ($active_users_in_bean && is_array($active_users_in_bean)) {
+ $users = join(',', $active_users_in_bean);
+ }
+ $inactive_users_in_bean = $bean->getAttribute('users_inactive');
+ if ($inactive_users_in_bean && is_array($inactive_users_in_bean)) {
+ if ($users) $users .= ',';
+ $users .= join(',', $inactive_users_in_bean);
}
+
if ($bean->getAttribute('start_date')) {
$dt = new DateAndTime($user->getDateFormat(), $bean->getAttribute('start_date'));
$from = $dt->toString(DB_DATEFORMAT);
$bean->setAttribute('invoice', $val['invoice']);
$bean->setAttribute('paid_status', $val['paid_status']);
$bean->setAttribute('timesheet', $val['timesheet']);
- $bean->setAttribute('users', explode(',', $val['users']));
+ $bean->setAttribute('users_active', explode(',', $val['users']));
+ $bean->setAttribute('users_inactive', explode(',', $val['users']));
$bean->setAttribute('period', $val['period']);
if ($val['period_start']) {
$dt = new DateAndTime(DB_DATEFORMAT, $val['period_start']);
}
// The getUsersForClient obtains all active and inactive users in a group that are relevant to a client.
- static function getUsersForClient() {
+ static function getUsersForClient($options) {
global $user;
$mdb2 = getConnection();
$group_id = $user->getGroup();
$org_id = $user->org_id;
+ if (isset($options['status']))
+ $where_part = 'where u.status = '.(int)$options['status'];
+ else
+ $where_part = 'where u.status is not null';
+
$sql = "select u.id, u.name from tt_user_project_binds upb".
" inner join tt_client_project_binds cpb on (upb.project_id = cpb.project_id and cpb.client_id = $user->client_id)".
" inner join tt_users u on (u.id = upb.user_id and u.group_id = $group_id and u.org_id = $org_id)".
- " where (u.status = 1 or u.status = 0)".
- " group by u.id".
- " order by upper(u.name)";
+ " $where_part group by u.id order by upper(u.name)";
$res = $mdb2->query($sql);
$user_list = array();
if (is_a($res, 'PEAR_Error'))
if ($user->isPluginEnabled('ap') && $user->isClient() && !$user->can('view_client_unapproved'))
$options['approved'] = 1; // Restrict clients to approved records only.
$options['timesheet'] = $bean->getAttribute('timesheet');
- if (is_array($bean->getAttribute('users'))) $options['users'] = join(',', $bean->getAttribute('users'));
+
+ $active_users_in_bean = $bean->getAttribute('users_active');
+ if ($active_users_in_bean && is_array($active_users_in_bean)) {
+ $users = join(',', $active_users_in_bean);
+ }
+ $inactive_users_in_bean = $bean->getAttribute('users_inactive');
+ if ($inactive_users_in_bean && is_array($inactive_users_in_bean)) {
+ if ($users) $users .= ',';
+ $users .= join(',', $inactive_users_in_bean);
+ }
+ if ($users) $options['users'] = $users;
+
$options['period'] = $bean->getAttribute('period');
$options['period_start'] = $bean->getAttribute('start_date');
$options['period_end'] = $bean->getAttribute('end_date');
global $user;
// Check users.
- $users_in_bean = $bean->getAttribute('users');
- if (is_array($users_in_bean)) {
+ $active_users_in_bean = $bean->getAttribute('users_active');
+ $inactive_users_in_bean = $bean->getAttribute('users_inactive');
+ if (is_array($active_users_in_bean) || is_array($inactive_users_in_bean)) {
$users_in_group = ttGroupHelper::getUsers();
foreach ($users_in_group as $user_in_group) {
$valid_ids[] = $user_in_group['id'];
}
- foreach ($users_in_bean as $user_in_bean) {
+ foreach ($active_users_in_bean as $user_in_bean) {
+ if (!in_array($user_in_bean, $valid_ids)) {
+ return false;
+ }
+ }
+ foreach ($inactive_users_in_bean as $user_in_bean) {
if (!in_array($user_in_bean, $valid_ids)) {
return false;
}
$left_joins = null;
if (isset($options['max_rank']) || $skipClients || isset($options['include_role']))
- $left_joins .= ' left join tt_roles r on (u.role_id = r.id)';
+ $left_joins .= ' left join tt_roles r on (u.role_id = r.id)';
$where_part = " where u.org_id = $org_id and u.group_id = $group_id";
if (isset($options['status']))
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.19.0.4959 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.19.1.4960 | 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>
</table>
</td>
</tr>
-{if $show_users}
+{if $show_active_users}
<tr>
- <td colspan="3"><b>{$i18n.label.users}</b></td>
+ <td colspan="3"><b>{$i18n.form.users.active_users}</b></td>
</tr>
<tr>
- <td colspan="3">{$forms.reportForm.users.control}</td>
+ <td colspan="3">{$forms.reportForm.users_active.control}</td>
+ </tr>
+{/if}
+{if $show_inactive_users}
+ <tr>
+ <td colspan="3"><b>{$i18n.form.users.inactive_users}</b></td>
+ </tr>
+ <tr>
+ <td colspan="3">{$forms.reportForm.users_inactive.control}</td>
</tr>
{/if}
<tr>
if ($user->can('view_reports') || $user->can('view_all_reports')) {
$rank = $user->getMaxRankForGroup($user->getGroup());
if ($user->can('view_all_reports')) $max_rank = MAX_RANK;
- if ($user->can('view_own_reports'))
- $options = array('max_rank'=>$max_rank,'include_self'=>true);
- else
- $options = array('max_rank'=>$max_rank);
- $users = $user->getUsers($options); // Active and inactive users.
+ if ($user->can('view_own_reports')) {
+ $options_active = array('max_rank'=>$max_rank,'include_self'=>true,'status'=>ACTIVE);
+ $options_inactive = array('max_rank'=>$max_rank,'include_self'=>true,'status'=>INACTIVE);
+ } else {
+ $options_active = array('max_rank'=>$max_rank,'status'=>ACTIVE);
+ $options_inactive = array('max_rank'=>$max_rank,'status'=>INACTIVE);
+ }
+ $active_users = $user->getUsers($options_active);
+ $inactive_users = $user->getUsers($options_inactive);
+ }
+ elseif ($user->isClient()) {
+ $options_active = array('status'=>ACTIVE);
+ $options_inactive = array('status'=>INACTIVE);
+ $active_users = ttGroupHelper::getUsersForClient($options_active);
+ $inactive_users = ttGroupHelper::getUsersForClient($options_inactive);
}
- elseif ($user->isClient())
- $users = ttGroupHelper::getUsersForClient(); // Active and inactive users for clients.
- foreach ($users as $single_user) {
- $user_list[$single_user['id']] = $single_user['name'];
+ foreach ($active_users as $single_user) {
+ $user_list_active[$single_user['id']] = $single_user['name'];
$projects = ttProjectHelper::getAssignedProjects($single_user['id']);
if ($projects) {
foreach ($projects as $single_project) {
}
}
}
- $row_count = ceil(count($user_list)/3);
+ $row_count = ceil(count($user_list_active)/3);
$form->addInput(array('type'=>'checkboxgroup',
- 'name'=>'users',
- 'data'=>$user_list,
+ 'name'=>'users_active',
+ 'data'=>$user_list_active,
+ 'layout'=>'V',
+ 'groupin'=>$row_count,
+ 'style'=>'width: 100%;'));
+
+ foreach ($inactive_users as $single_user) {
+ $user_list_inactive[$single_user['id']] = $single_user['name'];
+ $projects = ttProjectHelper::getAssignedProjects($single_user['id']);
+ if ($projects) {
+ foreach ($projects as $single_project) {
+ $assigned_projects[$single_user['id']][] = $single_project['id'];
+ }
+ }
+ }
+ $row_count = ceil(count($user_list_inactive)/3);
+ $form->addInput(array('type'=>'checkboxgroup',
+ 'name'=>'users_inactive',
+ 'data'=>$user_list_inactive,
'layout'=>'V',
'groupin'=>$row_count,
'style'=>'width: 100%;'));
if ($request->isGet() && !$bean->isSaved()) {
// No previous form data were found in session. Use the following default values.
- $form->setValueByElement('users', array_keys($user_list));
+ $form->setValueByElement('users_active', array_keys($user_list_active));
$period = new Period(INTERVAL_THIS_MONTH, new DateAndTime($user->getDateFormat()));
$form->setValueByElement('start_date', $period->getStartDate());
$form->setValueByElement('end_date', $period->getEndDate());
ttFavReportHelper::loadReport($bean);
// If user selected no favorite report - mark all user checkboxes (most probable scenario).
- if ($bean->getAttribute('favorite_report') == -1)
- $form->setValueByElement('users', array_keys($user_list));
+ if ($bean->getAttribute('favorite_report') == -1) {
+ $form->setValueByElement('users_active', array_keys($user_list_active));
+ $form->setValueByElement('users_inactive', false);
+ }
// Save form data in session for future use.
$bean->saveBean();
$smarty->assign('show_paid_status', $showPaidStatus);
$smarty->assign('show_timesheet_dropdown', $showTimesheetDropdown);
$smarty->assign('show_timesheet_checkbox', $showTimesheetCheckbox);
-$smarty->assign('show_users', $showUsers);
+$smarty->assign('show_active_users', $showUsers && $active_users);
+$smarty->assign('show_inactive_users', $showUsers && $inactive_users);
$smarty->assign('show_start', $showStart);
$smarty->assign('show_finish', $showFinish);
$smarty->assign('show_work_units', $showWorkUnits);