Booked Scheduler Community Support
February 26, 2020, 07:00:23 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Admin Filter Users by Group  (Read 3726 times)
digicrat
Newbie
*

Karma: 0
Posts: 7


« on: July 17, 2018, 12:24:35 AM »

This modification adds a dropdown menu to the Users management page to filter by group. 

Note that there is a slight bug in that the selected value for the dropdown is not restored - it wasn't important enough for me to figure out how to fix that yet.

Quote
diff --git a/Pages/Admin/ManageUsersPage.php b/Pages/Admin/ManageUsersPage.php
index 1fd8c95..903b45f 100644
--- a/Pages/Admin/ManageUsersPage.php
+++ b/Pages/Admin/ManageUsersPage.php
@@ -296,6 +296,21 @@ class ManageUsersPage extends ActionPage implements IManageUsersPage
    }
 
    /**
+    * @return int
+    */
+   public function GetGroupId()
+   {
+      $id = $this->GetQuerystring(QueryStringKeys::GROUP_ID);
+      if (empty($id))
+      {
+         $id = $this->GetForm(FormKeys::PK);
+      }
+
+      return $id;
+   }
+
+
+   /**
     * @param BookableResource[] $resources
     * @return void
     */
diff --git a/Presenters/Admin/ManageUsersPresenter.php b/Presenters/Admin/ManageUsersPresenter.php
index 6f35061..ccb37bf 100644
--- a/Presenters/Admin/ManageUsersPresenter.php
+++ b/Presenters/Admin/ManageUsersPresenter.php
@@ -192,6 +192,9 @@ class ManageUsersPresenter extends ActionPresenter implements IManageUsersPresen
             $userList = $this->userRepository->GetList(1, 1, null, null,
                 new SqlFilterEquals(ColumnNames::USER_ID, $this->page->GetUserId()));
         }
+   elseif ($this->page->GetGroupId() != null) {
+                $userList = $this->groupRepository->GetUsersInGroup($this->page->GetGroupId(), 1, 100);
+   }
         else {
             $userList = $this->userRepository->GetList($this->page->GetPageNumber(), $this->page->GetPageSize(),
                 $this->page->GetSortField(),
diff --git a/Web/scripts/admin/user.js b/Web/scripts/admin/user.js
index 9283728..daba43f 100644
--- a/Web/scripts/admin/user.js
+++ b/Web/scripts/admin/user.js
@@ -7,6 +7,7 @@ function UserManagement(opts) {
 
       userAutocomplete: $('#userSearch'),
       filterStatusId: $('#filterStatusId'),
+           filterGroupId: $('#filterGroupId'),
 
       permissionsDialog: $('#permissionsDialog'),
       passwordDialog: $('#passwordDialog'),
@@ -124,6 +125,11 @@ function UserManagement(opts) {
          window.location.href = options.filterUrl + statusid;
       });
 
+      elements.filterGroupId.change(function () {
+         var gid = $(this).val();
+         window.location.href = options.filterUrl + elements.filterStatusId.val() + "&gid=" + gid;
+      });
+
       elements.addedGroups.delegate('div', 'click', function (e) {
          e.preventDefault();
          $('#removeGroupId').val($(this).attr('groupId'));
@@ -400,4 +406,4 @@ function UserManagement(opts) {
    var deleteUser = function () {
       elements.deleteDialog.modal('show');
    };
-}
\ No newline at end of file
+}
diff --git a/tpl/Admin/manage_users.tpl b/tpl/Admin/manage_users.tpl
index ac47521..40d48e1 100644
--- a/tpl/Admin/manage_users.tpl
+++ b/tpl/Admin/manage_users.tpl
@@ -70,8 +70,13 @@ along with Booked Scheduler.  If not, see <http://www.gnu.org/licenses/>.
                 {html_options selected=$FilterStatusId options=$statusDescriptions}
             </select>
         </div>
-        <div class="col-xs-6">
-            &nbsp;
+        <div class="form-group col-xs-2">
+            <label for="filterGroupId">{translate key=Group}</label>
+            <select id="filterGroupId" class="form-control">
+            <option selected>All</option>
+                  {object_html_options selected=$GroupStatusId options=$Groups label=Name key=Id}
+            </select>
+
         </div>
         <div class="clearfix"></div>
     </form>
Logged
jeammaslo
Newbie
*

Karma: 0
Posts: 2


WWW
« Reply #1 on: December 24, 2019, 11:43:49 PM »

The feeling of me now is very glad to be with everyone here.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2006-2007, Simple Machines Valid XHTML 1.0! Valid CSS!