|
|
@ -10,20 +10,29 @@ function NeededAngelTypes_by_shift($shift) {
|
|
|
|
SELECT `NeededAngelTypes`.*, `AngelTypes`.`name`, `AngelTypes`.`restricted`
|
|
|
|
SELECT `NeededAngelTypes`.*, `AngelTypes`.`name`, `AngelTypes`.`restricted`
|
|
|
|
FROM `NeededAngelTypes`
|
|
|
|
FROM `NeededAngelTypes`
|
|
|
|
JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id`
|
|
|
|
JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id`
|
|
|
|
WHERE (`shift_id`=" . sql_escape($shift['SID']) . "
|
|
|
|
WHERE `shift_id`=" . sql_escape($shift['SID']) . "
|
|
|
|
OR `room_id`=" . sql_escape($shift['RID']) . ")
|
|
|
|
|
|
|
|
AND `count` > 0
|
|
|
|
AND `count` > 0
|
|
|
|
ORDER BY `room_id` DESC
|
|
|
|
ORDER BY `room_id` DESC
|
|
|
|
");
|
|
|
|
");
|
|
|
|
if ($needed_angeltypes_source === false)
|
|
|
|
if ($needed_angeltypes_source === false)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
$needed_angeltypes_merged = array();
|
|
|
|
// Use settings from room
|
|
|
|
foreach ($needed_angeltypes_source as $angeltype)
|
|
|
|
if (count($needed_angeltypes_source) == 0) {
|
|
|
|
$needed_angeltypes_merged[$angeltype['id']] = $angeltype;
|
|
|
|
$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();
|
|
|
|
$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']);
|
|
|
|
$shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['id']);
|
|
|
|
if ($shift_entries === false)
|
|
|
|
if ($shift_entries === false)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|