diff options
author | msquare <msquare@notrademark.de> | 2017-12-14 19:18:08 +0100 |
---|---|---|
committer | msquare <msquare@notrademark.de> | 2017-12-14 19:19:04 +0100 |
commit | 35be25a78642039aba49ad5d6e80ad8ca89a2b1f (patch) | |
tree | c23e4cfd64ffe2788bf3a3471118d87835dea0c6 /includes/model/Shifts_model.php | |
parent | 952dc6921acb275de74dd33be2ecb01986bfdd49 (diff) |
fix dashboard using needed angeltypes from room config too for frab shifts
Diffstat (limited to 'includes/model/Shifts_model.php')
-rw-r--r-- | includes/model/Shifts_model.php | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index b0d82a5b..2a77fd35 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -32,14 +32,26 @@ function Shifts_by_angeltype($angeltype) { function Shifts_free($start, $end) { $shifts = Db::select(" - SELECT * - FROM `Shifts` - WHERE (`end` > ? AND `start` < ?) - AND (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`) - > (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0) - ORDER BY `start` + SELECT * FROM ( + SELECT * + FROM `Shifts` + WHERE (`end` > ? AND `start` < ?) + AND (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`) + > (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0) + + UNION + + SELECT * + FROM `Shifts` + WHERE (`end` > ? AND `start` < ?) + AND (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`) + > (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0) + ) as `tmp` + ORDER BY `tmp`.`start` ", [ $start, + $end, + $start, $end ]); $free_shifts = []; |