diff options
author | msquare <msquare@notrademark.de> | 2017-11-24 12:01:19 +0100 |
---|---|---|
committer | msquare <msquare@notrademark.de> | 2017-11-24 12:01:19 +0100 |
commit | 928e707015fa5b9b3e2dd52c9493552ae1218911 (patch) | |
tree | ef7e9f297b9f3581361279cda45e46d0778b58c2 /includes/model/Shifts_model.php | |
parent | d8476f244dd0ee1bccaab53f123fa12f2a9c9501 (diff) |
add shift calendar to angeltype view
Diffstat (limited to 'includes/model/Shifts_model.php')
-rw-r--r-- | includes/model/Shifts_model.php | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index ef02aaab..8a1b69f9 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -5,6 +5,29 @@ use Engelsystem\ShiftsFilter; use Engelsystem\ShiftSignupState; /** + * @param array $angeltype + * @return array + */ +function Shifts_by_angeltype($angeltype) { + return DB::select(' + SELECT DISTINCT `Shifts`.* FROM `Shifts` + JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id` = `Shifts`.`SID` + WHERE `NeededAngelTypes`.`angel_type_id` = ? + AND `NeededAngelTypes`.`count` > 0 + AND `Shifts`.`PSID` IS NULL + + UNION + + SELECT DISTINCT `Shifts`.* FROM `Shifts` + JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`room_id` = `Shifts`.`RID` + WHERE `NeededAngelTypes`.`angel_type_id` = ? + AND `NeededAngelTypes`.`count` > 0 + AND NOT `Shifts`.`PSID` IS NULL + ', [$angeltype['id'], $angeltype['id']]); +} + + +/** * @param array $room * @return array */ @@ -24,7 +47,7 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) FROM `Shifts` JOIN `Room` USING (`RID`) JOIN `ShiftTypes` ON `ShiftTypes`.`id` = `Shifts`.`shifttype_id` - JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID` + JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id` = `Shifts`.`SID` WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ') AND `start` BETWEEN ? AND ? AND `NeededAngelTypes`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ') |