From d9ef3e94c49d9b5e8c7532efc8b460c3e1135fdd Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Mon, 26 Mar 2018 15:12:52 +0000 Subject: [PATCH] Fixed reports to include users of lesser roles only. --- WEB-INF/lib/ttUser.class.php | 5 ++++- WEB-INF/templates/footer.tpl | 2 +- reports.php | 31 ++++++++++++++++++------------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index d58a7167..f9edc8cc 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -262,7 +262,10 @@ class ttUser { $left_joins .= ' left join tt_roles r on (u.role_id = r.id)'; $where_part = " where u.team_id = $this->team_id"; - if (isset($options['status'])) $where_part .= ' and u.status = '.(int)$options['status']; + if (isset($options['status'])) + $where_part .= ' and u.status = '.(int)$options['status']; + else + $where_part .= ' and u.status is not null'; if ($includeSelf) { $where_part .= " and (u.id = $this->id || r.rank <= ".(int)$options['max_rank'].')'; } else { diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index ab703fb7..4b5b36f6 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.72.4174 | Copyright © Anuko | +  Anuko Time Tracker 1.17.73.4175 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/reports.php b/reports.php index 3a7367e7..59f3c0f9 100644 --- a/reports.php +++ b/reports.php @@ -122,16 +122,6 @@ $form->addInput(array('type'=>'combobox', 'data'=>$include_options, 'empty'=>array(''=>$i18n->get('dropdown.all')))); -if ($user->canManageTeam() && $user->isPluginEnabled('ps')) { - $form->addInput(array('type'=>'combobox', - 'name'=>'paid_status', - 'style'=>'width: 250px;', - 'data'=>array('1'=>$i18n->get('dropdown.paid'),'2'=>$i18n->get('dropdown.not_paid')), - 'empty'=>array(''=>$i18n->get('dropdown.all')) - )); -} - - // Add invoiced / not invoiced selector. $invoice_options = array('1'=>$i18n->get('form.reports.include_invoiced'), '2'=>$i18n->get('form.reports.include_not_invoiced')); @@ -141,11 +131,26 @@ $form->addInput(array('type'=>'combobox', 'data'=>$invoice_options, 'empty'=>array(''=>$i18n->get('dropdown.all')))); +if ($user->canManageTeam() && $user->isPluginEnabled('ps')) { + $form->addInput(array('type'=>'combobox', + 'name'=>'paid_status', + 'style'=>'width: 250px;', + 'data'=>array('1'=>$i18n->get('dropdown.paid'),'2'=>$i18n->get('dropdown.not_paid')), + 'empty'=>array(''=>$i18n->get('dropdown.all')) + )); +} + $user_list = array(); -if ($user->canManageTeam() || $user->isClient()) { +if ($user->can('view_reports') || $user->isClient()) { // Prepare user and assigned projects arrays. - if ($user->canManageTeam()) - $users = ttTeamHelper::getUsers(); // Active and inactive users for managers. + if ($user->can('view_reports')) { + // $users = ttTeamHelper::getUsers(); // Active and inactive users for managers. + if ($user->can('view_own_reports')) + $options = array('max_rank'=>$user->rank-1,'include_self'=>true); + else + $options = array('max_rank'=>$user->rank-1); + $users = $user->getUsers($options); // Active and inactive users for managers. + } elseif ($user->isClient()) $users = ttTeamHelper::getUsersForClient(); // Active and inactive users for clients. -- 2.20.1