summaryrefslogtreecommitdiff
path: root/includes/model/Shifts_model.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2017-12-12 21:57:57 +0100
committermsquare <msquare@notrademark.de>2017-12-12 21:57:57 +0100
commitff94df53d69234ae2625462a76926e131ade05b7 (patch)
treeb5ee27bd8461a06a2b7e082faa48c6fa66fc560f /includes/model/Shifts_model.php
parentd5631297dc42c06b1695fdb6f65d2b6a4b04c633 (diff)
finish basic public dashboard
Diffstat (limited to 'includes/model/Shifts_model.php')
-rw-r--r--includes/model/Shifts_model.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php
index 1fc7fe89..b0d82a5b 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -27,6 +27,29 @@ function Shifts_by_angeltype($angeltype) {
}
/**
+ * Returns every shift with needed angels in the given time range.
+ */
+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`
+ ", [
+ $start,
+ $end
+ ]);
+ $free_shifts = [];
+ foreach ($shifts as $shift) {
+ $free_shifts[] = Shift($shift['SID']);
+ }
+ return $free_shifts;
+}
+
+/**
* Returns all shifts with a PSID (from frab import)
*/
function Shifts_from_frab() {