needed angeltypes corrected loading by room or special needs

This commit is contained in:
Philip Häusler 2013-12-09 17:28:22 +01:00
parent 3bc9d09f7a
commit a0ec1130a6
1 changed files with 16 additions and 7 deletions

View File

@ -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;