Skip to content

Commit

Permalink
Add employees filter on Vacation Management
Browse files Browse the repository at this point in the history
Merge pull request #558 from Igalia/add-employees-filter
  • Loading branch information
jaragunde authored Feb 3, 2022
2 parents 24f1cd5 + 7e7743f commit 8d43ec9
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 10 deletions.
6 changes: 6 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ functionality to PhpReport
*/
define('ALL_USERS_GROUP', 'staff');

/**
* @name EMPLOYEES_GROUP
* @global string users group used for retrieving all active employees
*/
define('EMPLOYEES_GROUP', 'staff');

/**
* @name USER_GROUPS
* @global string all user groups for displaying on the interfaces as
Expand Down
10 changes: 10 additions & 0 deletions docs/admin/ldap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ PhpReport::
*/
define('ALL_USERS_GROUP', 'staff');

You can also define a group to display only active employees based on
its respective LDAP group:

/**
* @name EMPLOYEES_GROUP
* @global string users group used for retrieving all active employees
*/
define('EMPLOYEES_GROUP', 'employees');

And in this line you must indicate a list with the names of the user groups that
will have some meaning for PhpReport::

Expand Down
4 changes: 2 additions & 2 deletions model/facade/UsersFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ static function GetAllUsers() {

}

static function GetAllActiveUsers() {
$action = new GetAllActiveUsersAction();
static function GetAllActiveUsers($filterEmployees = false) {
$action = new GetAllActiveUsersAction($filterEmployees);
return $action->execute();
}

Expand Down
19 changes: 13 additions & 6 deletions model/facade/action/GetAllActiveUsersAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,21 @@
include_once(PHPREPORT_ROOT . '/model/dao/DAOFactory.php');
include_once(PHPREPORT_ROOT . '/util/ConfigurationParametersManager.php');

class GetAllActiveUsersAction extends Action{
public function __construct() {
$this->preActionParameter="GET_ALL_ACTIVE_USERS_PREACTION";
$this->postActionParameter="GET_ALL_ACTIVE_USERS_POSTACTION";
class GetAllActiveUsersAction extends Action
{
public function __construct($filterEmployees = false)
{
$this->preActionParameter = "GET_ALL_ACTIVE_USERS_PREACTION";
$this->postActionParameter = "GET_ALL_ACTIVE_USERS_POSTACTION";
$this->filterEmployees = $filterEmployees;
}

protected function doExecute() {
protected function doExecute()
{
$groupDAO = DAOFactory::getUserGroupDAO();
return $groupDAO->getUsersByUserGroupName(ConfigurationParametersManager::getParameter("ALL_USERS_GROUP"));
$group = $this->filterEmployees ?
ConfigurationParametersManager::getParameter("EMPLOYEES_GROUP") :
ConfigurationParametersManager::getParameter("ALL_USERS_GROUP");
return $groupDAO->getUsersByUserGroupName($group);
}
}
2 changes: 1 addition & 1 deletion web/js/holidayManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ var app = new Vue({
}
},
async fetchUsers() {
const url = `services/getAllUsersService.php?active=true`;
const url = `services/getAllUsersService.php?active=true&filterEmployees=true`;
const res = await fetch(url, {
method: 'GET',
mode: 'same-origin',
Expand Down
3 changes: 2 additions & 1 deletion web/services/getAllUsersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

$sid = $_GET['sid'] ?? NULL;
$active = $_GET['active'] ?? NULL;
$filterEmployees = $_GET['filterEmployees'] ?? false;

do {
/* We check authentication and authorization */
Expand All @@ -53,7 +54,7 @@

if ($active == "true")
{
$users = UsersFacade::GetAllActiveUsers();
$users = UsersFacade::GetAllActiveUsers($filterEmployees);
}
else
{
Expand Down

0 comments on commit 8d43ec9

Please sign in to comment.