blob: 81ce2d5f7f14378bc15fb46bc784563f59a90e2c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<?php
/**
* Returns all needed angeltypes and already taken needs.
*
* @param shiftID id of shift
*/
function NeededAngelTypes_by_shift($shiftId) {
$needed_angeltypes_source = sql_select("
SELECT `NeededAngelTypes`.*, `AngelTypes`.`name`, `AngelTypes`.`restricted`
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id`
WHERE `shift_id`=" . sql_escape($shiftId) . "
AND `count` > 0
ORDER BY `room_id` DESC
");
if ($needed_angeltypes_source === false)
return false;
// 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($shiftId) . "
AND `count` > 0
ORDER BY `room_id` DESC
");
if ($needed_angeltypes_source === false)
return false;
}
$needed_angeltypes = array();
foreach ($needed_angeltypes_source as $angeltype) {
$shift_entries = ShiftEntries_by_shift_and_angeltype($shiftId, $angeltype['angel_type_id']);
if ($shift_entries === false)
return false;
$angeltype['taken'] = count($shift_entries);
$needed_angeltypes[] = $angeltype;
}
return $needed_angeltypes;
}
?>
|