|
|
@ -326,16 +326,44 @@ function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter) {
|
|
|
|
$needed_angeltypes[$shift['SID']] = [];
|
|
|
|
$needed_angeltypes[$shift['SID']] = [];
|
|
|
|
$shift_entries[$shift['SID']] = [];
|
|
|
|
$shift_entries[$shift['SID']] = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($shift_entries_source as $shift_entry) {
|
|
|
|
|
|
|
|
if (isset($shift_entries[$shift_entry['SID']])) {
|
|
|
|
|
|
|
|
$shift_entries[$shift_entry['SID']][] = $shift_entry;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
foreach ($needed_angeltypes_source as $needed_angeltype) {
|
|
|
|
foreach ($needed_angeltypes_source as $needed_angeltype) {
|
|
|
|
|
|
|
|
if (isset($needed_angeltypes[$needed_angeltype['SID']])) {
|
|
|
|
$needed_angeltypes[$needed_angeltype['SID']][] = $needed_angeltype;
|
|
|
|
$needed_angeltypes[$needed_angeltype['SID']][] = $needed_angeltype;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach ($shift_entries_source as $shift_entry) {
|
|
|
|
|
|
|
|
$shift_entries[$shift_entry['SID']][] = $shift_entry;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
unset($needed_angeltypes_source);
|
|
|
|
unset($needed_angeltypes_source);
|
|
|
|
unset($shift_entries_source);
|
|
|
|
unset($shift_entries_source);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled()) && in_array(ShiftsFilter::FILLED_FILLED, $shiftsFilter->getFilled())) {
|
|
|
|
return new ShiftCalendarRenderer($shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
|
|
|
|
return new ShiftCalendarRenderer($shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$filtered_shifts = [];
|
|
|
|
|
|
|
|
foreach ($shifts as $shift) {
|
|
|
|
|
|
|
|
$needed_angels_count = 0;
|
|
|
|
|
|
|
|
foreach ($needed_angeltypes[$shift['SID']] as $needed_angeltype) {
|
|
|
|
|
|
|
|
$needed_angels_count += $needed_angeltype['count'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$taken = 0;
|
|
|
|
|
|
|
|
foreach ($shift_entries[$shift['SID']] as $shift_entry) {
|
|
|
|
|
|
|
|
if ($shift_entry['freeloaded'] == 0) {
|
|
|
|
|
|
|
|
$taken ++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled()) && $taken < $needed_angels_count) {
|
|
|
|
|
|
|
|
$filtered_shifts[] = $shift;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (in_array(ShiftsFilter::FILLED_FILLED, $shiftsFilter->getFilled()) && $taken >= $needed_angels_count) {
|
|
|
|
|
|
|
|
$filtered_shifts[] = $shift;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new ShiftCalendarRenderer($filtered_shifts, $needed_angeltypes, $shift_entries, $shiftsFilter);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|