bring back filtering by occupancy

This commit is contained in:
msquare 2016-12-29 15:33:21 +01:00
parent 51eb22a1c6
commit b8ebd23f6d
2 changed files with 7 additions and 10 deletions

View File

@ -347,14 +347,15 @@ function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter) {
foreach ($shifts as $shift) { foreach ($shifts as $shift) {
$needed_angels_count = 0; $needed_angels_count = 0;
foreach ($needed_angeltypes[$shift['SID']] as $needed_angeltype) { foreach ($needed_angeltypes[$shift['SID']] as $needed_angeltype) {
$needed_angels_count += $needed_angeltype['count'];
}
$taken = 0; $taken = 0;
foreach ($shift_entries[$shift['SID']] as $shift_entry) { foreach ($shift_entries[$shift['SID']] as $shift_entry) {
if ($shift_entry['freeloaded'] == 0) { if ($needed_angeltype['angel_type_id'] == $shift_entry['TID'] && $shift_entry['freeloaded'] == 0) {
$taken ++; $taken ++;
} }
} }
$needed_angels_count += max(0, $needed_angeltype['count'] - $taken);
}
if (in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled()) && $taken < $needed_angels_count) { if (in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled()) && $taken < $needed_angels_count) {
$filtered_shifts[] = $shift; $filtered_shifts[] = $shift;
} }

View File

@ -251,10 +251,6 @@ function Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entrie
function Shift_signup_allowed($signup_user, $shift, $angeltype, $user_angeltype = null, $user_shifts = null, $needed_angeltype, $shift_entries) { function Shift_signup_allowed($signup_user, $shift, $angeltype, $user_angeltype = null, $user_shifts = null, $needed_angeltype, $shift_entries) {
global $user, $privileges; global $user, $privileges;
// if($shift['SID']==1907) {
// print_r(Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries));
// }
if (in_array('user_shifts_admin', $privileges)) { if (in_array('user_shifts_admin', $privileges)) {
return Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries); return Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries);
} }