Skip to content

Commit 97e14ca

Browse files
authored
[#510] Add Holiday Management view
At the moment this view is read-only and will only display the booked holidays. Merge pull request #512 from anarute/holiday-management
2 parents a442973 + 1dfd547 commit 97e14ca

21 files changed

+676
-8
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ config/config.defaults
2121

2222
# Composer dependencies
2323
vendor
24+
25+
# do not ignore vue.js and v-calendar files
26+
!web/vuejs/*.min.js

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ help:
3939
rm footer
4040

4141
minify:
42-
for i in `find -name *.min.js`; do rm $$i; done
43-
for i in `find -name *.js` ; do \
42+
for i in `find -name "*.min.js" -not -path "*web/vuejs/*"`; do rm $$i; done
43+
for i in `find -name "*.js" -not -path "*web/vuejs/*"` ; do \
4444
#extract file name to be used in the uglify output \
4545
FILE=`basename -s .js $$i`; \
4646
DIR=`dirname $$i`; \
@@ -49,7 +49,7 @@ minify:
4949
--source-map "filename=$${FILE}.min.js.map" -c -m; \
5050
cd -; \
5151
done
52-
for i in `find web -name *.php`; do \
52+
for i in `find web -name "*.php" -not -path "*web/holidayManagement.php"`; do \
5353
#revert any previous minification changes \
5454
sed 's/<script src="\(.*\).min.js">/<script src="\1.js">/' $$i > tmp; \
5555
#modify script tags to link the minified file \

config/permissions.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
'/services/createTasksService.php', '/services/deleteTasksService.php',
4444
'/services/updateTasksService.php',
4545
'/services/getTasksFiltered.php', '/userTasksReport.php',
46+
//holidays management
47+
'/services/getHolidays.php',
48+
'/holidayManagement.php',
4649
//templates
4750
'/services/createTemplatesService.php', '/services/getUserTemplatesService.php',
4851
'/services/deleteTemplatesService.php',
@@ -59,7 +62,7 @@
5962
'/services/createTaskSectionsService.php', '/services/deleteTaskSectionsService.php',
6063
//reports
6164
'/projectDetailsReport.php', '/viewUserDetails.php', '/projectDetails.php', '/viewWorkingHoursResultsReport.php',
62-
'/services/getExtraHoursReportService.php','/services/getPendingHolidayHoursService.php',
65+
'/services/getExtraHoursReportService.php', '/services/getPendingHolidayHoursService.php',
6366
'/services/getProjectTtypeReportService.php', '/services/getProjectUserCustomerReportJsonService.php',
6467
'/services/getProjectUserCustomerReportService.php', '/services/getProjectUserStoryReportService.php',
6568
'/services/getUserProjectCustomerReportJsonService.php', '/services/getUsersProjectsReportService.php',
@@ -70,8 +73,8 @@
7073
'/services/getAllCitiesService.php', '/services/getProjectService.php', '/services/getProjectsService.php',
7174
'/services/getAllSectorsService.php', '/services/getAllAreasService.php',
7275
'/services/getAllExtraHourVOsService.php', '/services/getAllCitiesService.php',
73-
'/services/getUserGoalsService.php', '/services/createUserGoalsService.php', '/services/updateUserGoalsService.php',
74-
'/services/deleteUserGoalsService.php',
76+
'/services/getUserGoalsService.php', '/services/createUserGoalsService.php', '/services/updateUserGoalsService.php',
77+
'/services/deleteUserGoalsService.php',
7578
//user management screen (read only)
7679
'/viewUsers.php',
7780
'/services/getUserHourCostHistoriesService.php', '/services/getUserAreaHistoriesService.php',
@@ -122,7 +125,8 @@
122125
//system settings
123126
'/settings.php',
124127
//API test
125-
'/APITest.php')
128+
'/APITest.php'
129+
)
126130
);
127131

128132
/** Extra permissions array

model/dao/ProjectDAO/PostgreSQLProjectDAO.php

+12
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,18 @@ public function getAllCustom($active = False, $orderField = 'id') {
568568
return $this->customExecute($sql);
569569
}
570570

571+
public function getByDescription(string $desc): ?int
572+
{
573+
$sql = "SELECT * FROM project WHERE description='" . $desc . "'";
574+
575+
$res = pg_query($this->connect, $sql);
576+
if ($res == NULL) throw new SQLQueryErrorException(pg_last_error());
577+
578+
$resultAux = @pg_fetch_array($res);
579+
580+
return $resultAux['id'] ?? NULL;
581+
}
582+
571583
/** Project partial updater for PostgreSQL.
572584
*
573585
* This function updates only some fields of the data of a Project by its {@link ProjectVO}, reading

model/dao/ProjectDAO/ProjectDAO.php

+2
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ public abstract function getByCustomerUserLogin($customerId = NULL, $userLogin =
258258
*/
259259
public abstract function getAllCustom($active = False, $orderField = 'id');
260260

261+
public abstract function getByDescription(string $description): ?int;
262+
261263
/** Project partial updater.
262264
*
263265
* This function updates only some fields of the data of a Project by its {@link ProjectVO}, reading

model/dao/TaskDAO/PostgreSQLTaskDAO.php

+29
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,35 @@ public function getVacations(UserVO $userVO, DateTime $initDate = NULL, DateTime
655655

656656
}
657657

658+
public function getVacationsDates(UserVO $userVO, int $projectId = NULL, DateTime $initDate = NULL, DateTime $endDate = NULL): array
659+
{
660+
if (is_null($projectId)) {
661+
return [];
662+
}
663+
664+
$sql = "SELECT _date FROM task WHERE projectid=" . $projectId . " AND usrid=" . $userVO->getId();
665+
666+
if (!is_null($initDate)) {
667+
$sql .= " AND _date >=" . DBPostgres::formatDate($initDate);
668+
if (!is_null($endDate))
669+
$sql .= " AND _date <=" . DBPostgres::formatDate($endDate);
670+
}
671+
672+
$sql .= " ORDER BY _date";
673+
674+
$res = pg_query($this->connect, $sql);
675+
if ($res == NULL) throw new SQLQueryErrorException(pg_last_error());
676+
677+
$result = array();
678+
for ($i = 0; $i < pg_num_rows($res); $i++) {
679+
$result[] = @pg_fetch_array($res)['_date'];
680+
}
681+
682+
if (empty($result))
683+
return [];
684+
return $result;
685+
}
686+
658687
/** Task partial updater for PostgreSQL.
659688
*
660689
* This function updates only some fields of the data of a Task using a

model/dao/TaskDAO/TaskDAO.php

+2
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ public abstract function getProjectUserWeeklyWorkingHours(ProjectVO $project, Da
283283
*/
284284
public abstract function getVacations(UserVO $userVO, DateTime $initDate = NULL, DateTime $endDate = NULL);
285285

286+
public abstract function getVacationsDates(UserVO $userVO, int $projectId = NULL, DateTime $initDate = NULL, DateTime $endDate = NULL): array;
287+
286288
/** Task partial updater for PostgreSQL.
287289
*
288290
* This function updates only some fields of the data of a Task using a

model/facade/ProjectsFacade.php

+8
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,14 @@ static function GetProjectUsers($projectId) {
264264

265265
}
266266

267+
static function GetProjectByDescription(string $description) {
268+
269+
$action = new GetProjectByDescriptionAction($description);
270+
271+
return $action->execute();
272+
273+
}
274+
267275
/** Update Project Function
268276
*
269277
* This function is used for updating a Project.

model/facade/UsersFacade.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright (C) 2009 Igalia, S.L. <[email protected]>
3+
* Copyright (C) 2009-2021 Igalia, S.L. <[email protected]>
44
*
55
* This file is part of PhpReport.
66
*
@@ -38,6 +38,7 @@
3838
include_once(PHPREPORT_ROOT . '/model/facade/action/UpdateUserAction.php');
3939
include_once(PHPREPORT_ROOT . '/model/facade/action/ExtraHoursReportAction.php');
4040
include_once(PHPREPORT_ROOT . '/model/facade/action/GetPendingHolidayHoursAction.php');
41+
include_once(PHPREPORT_ROOT . '/model/facade/action/GetScheduledHolidaysAction.php');
4142
include_once(PHPREPORT_ROOT . '/model/facade/action/CreateCustomEventAction.php');
4243
include_once(PHPREPORT_ROOT . '/model/facade/action/DeleteCustomEventAction.php');
4344
include_once(PHPREPORT_ROOT . '/model/facade/action/UpdateCustomEventAction.php');
@@ -260,6 +261,15 @@ static function GetPendingHolidayHours(DateTime $init, DateTime $end, UserVO $us
260261

261262
}
262263

264+
265+
static function GetScheduledHolidays(DateTime $init, DateTime $end, UserVO $user = NULL) {
266+
267+
$action = new GetScheduledHolidaysAction($init, $end, $user);
268+
269+
return $action->execute();
270+
271+
}
272+
263273
/** User retriever by Project Iteration Function
264274
*
265275
* This function retrieves the Users assigned to the same Area as a Project Iteration with id <var>$iterationid</var> today.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/*
3+
* Copyright (C) 2021 Igalia, S.L. <[email protected]>
4+
*
5+
* This file is part of PhpReport.
6+
*
7+
* PhpReport is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* PhpReport is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with PhpReport. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
22+
include_once(PHPREPORT_ROOT . '/model/facade/action/Action.php');
23+
include_once(PHPREPORT_ROOT . '/model/dao/DAOFactory.php');
24+
25+
class GetProjectByDescriptionAction extends Action
26+
{
27+
28+
public function __construct(string $description)
29+
{
30+
$this->description = $description;
31+
$this->preActionParameter = "GET_PROJECT_BY_DESCRIPTION_PREACTION";
32+
$this->postActionParameter = "GET_PROJECTS_BY_DESCRIPTION_POSTACTION";
33+
}
34+
35+
protected function doExecute()
36+
{
37+
$dao = DAOFactory::getProjectDAO();
38+
return $dao->getByDescription($this->description);
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
/*
3+
* Copyright (C) 2021 Igalia, S.L. <[email protected]>
4+
*
5+
* This file is part of PhpReport.
6+
*
7+
* PhpReport is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* PhpReport is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with PhpReport. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
include_once(PHPREPORT_ROOT . '/model/facade/action/Action.php');
22+
include_once(PHPREPORT_ROOT . '/model/dao/DAOFactory.php');
23+
include_once(PHPREPORT_ROOT . '/model/vo/UserVO.php');
24+
include_once(PHPREPORT_ROOT . '/util/ConfigurationParametersManager.php');
25+
26+
27+
class GetScheduledHolidaysAction extends Action
28+
{
29+
30+
private UserVO $user;
31+
private DateTime $init;
32+
private DateTime $end;
33+
34+
public function __construct(DateTime $init, DateTime $end, UserVO $user = NULL)
35+
{
36+
$this->init = $init;
37+
$this->end = $end;
38+
$this->user = $user;
39+
$this->preActionParameter = "GET_SCHEDULED_HOLIDAYS_PREACTION";
40+
$this->postActionParameter = "GET_SCHEDULED_HOLIDAYS_POSTACTION";
41+
}
42+
43+
protected function doExecute(): array
44+
{
45+
46+
$taskDao = DAOFactory::getTaskDAO();
47+
$userDao = DAOFactory::getUserDAO();
48+
$projectDao = DAOFactory::getProjectDAO();
49+
50+
if (is_null($this->user)) {
51+
return [];
52+
}
53+
54+
// The User can be identified by either the id or the login
55+
if (is_null($this->user->getLogin())) {
56+
if (!is_null($this->user->getId()))
57+
$this->user = $userDao->getById($this->user->getId());
58+
} else
59+
if (is_null($this->user->getId()))
60+
$this->user = $userDao->getByUserLogin($this->user->getLogin());
61+
62+
$projectId = $projectDao->getByDescription(ConfigurationParametersManager::getParameter('VACATIONS_PROJECT'));
63+
$reportInit = $this->init;
64+
$reportEnd = $this->end;
65+
66+
$vacations = $taskDao->getVacationsDates($this->user, $projectId, $reportInit, $reportEnd);
67+
68+
return $vacations;
69+
}
70+
}

0 commit comments

Comments
 (0)