Fixed reports to include users of lesser roles only.
authorNik Okuntseff <support@anuko.com>
Mon, 26 Mar 2018 15:12:52 +0000 (15:12 +0000)
committerNik Okuntseff <support@anuko.com>
Mon, 26 Mar 2018 15:12:52 +0000 (15:12 +0000)
WEB-INF/lib/ttUser.class.php
WEB-INF/templates/footer.tpl
reports.php

index d58a716..f9edc8c 100644 (file)
@@ -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 {
index ab703fb..4b5b36f 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.17.72.4174 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.17.73.4175 | Copyright &copy; <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>
index 3a7367e..59f3c0f 100644 (file)
@@ -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.