summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2013-12-09 17:28:22 +0100
committerPhilip Häusler <msquare@notrademark.de>2013-12-09 17:28:22 +0100
commita0ec1130a695f327e537bbb89588a75793969828 (patch)
treeea67d92f32120a9ceea0e4dc266616dbe2abaffa
parent3bc9d09f7aecb5f5b15bb1f28e11316d37551f3f (diff)
needed angeltypes corrected loading by room or special needs
-rw-r--r--includes/model/NeededAngelTypes_model.php23
1 files changed, 16 insertions, 7 deletions
diff --git a/includes/model/NeededAngelTypes_model.php b/includes/model/NeededAngelTypes_model.php
index 8cd857b6..9e86c5a6 100644
--- a/includes/model/NeededAngelTypes_model.php
+++ b/includes/model/NeededAngelTypes_model.php
@@ -10,20 +10,29 @@ function NeededAngelTypes_by_shift($shift) {
SELECT `NeededAngelTypes`.*, `AngelTypes`.`name`, `AngelTypes`.`restricted`
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id`
- WHERE (`shift_id`=" . sql_escape($shift['SID']) . "
- OR `room_id`=" . sql_escape($shift['RID']) . ")
+ WHERE `shift_id`=" . sql_escape($shift['SID']) . "
AND `count` > 0
ORDER BY `room_id` DESC
");
if ($needed_angeltypes_source === false)
return false;
-
- $needed_angeltypes_merged = array();
- foreach ($needed_angeltypes_source as $angeltype)
- $needed_angeltypes_merged[$angeltype['id']] = $angeltype;
+
+ // Use settings from room
+ if (count($needed_angeltypes_source) == 0) {
+ $needed_angeltypes_source = sql_select("
+ SELECT `NeededAngelTypes`.*, `AngelTypes`.`name`, `AngelTypes`.`restricted`
+ FROM `NeededAngelTypes`
+ JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id`
+ WHERE `room_id`=" . sql_escape($shift['RID']) . "
+ AND `count` > 0
+ ORDER BY `room_id` DESC
+ ");
+ if ($needed_angeltypes_source === false)
+ return false;
+ }
$needed_angeltypes = array();
- foreach ($needed_angeltypes_merged as $angeltype) {
+ foreach ($needed_angeltypes_source as $angeltype) {
$shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['id']);
if ($shift_entries === false)
return false;