summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2016-12-29 15:33:21 +0100
committermsquare <msquare@notrademark.de>2016-12-29 15:33:21 +0100
commitb8ebd23f6df8317a2b091335640ddd89de8cc55b (patch)
tree7190acd8b0ed5cbab945e978a23d583ef6694342
parent51eb22a1c651ffabd10d772b7e06ec05c46c5b86 (diff)
bring back filtering by occupancy
-rw-r--r--includes/controller/users_controller.php13
-rw-r--r--includes/model/Shifts_model.php4
2 files changed, 7 insertions, 10 deletions
diff --git a/includes/controller/users_controller.php b/includes/controller/users_controller.php
index e891f85d..64f725de 100644
--- a/includes/controller/users_controller.php
+++ b/includes/controller/users_controller.php
@@ -347,13 +347,14 @@ function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter) {
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 ++;
+ $taken = 0;
+ foreach ($shift_entries[$shift['SID']] as $shift_entry) {
+ if ($needed_angeltype['angel_type_id'] == $shift_entry['TID'] && $shift_entry['freeloaded'] == 0) {
+ $taken ++;
+ }
}
+
+ $needed_angels_count += max(0, $needed_angeltype['count'] - $taken);
}
if (in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled()) && $taken < $needed_angels_count) {
$filtered_shifts[] = $shift;
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php
index a9a1cd7f..29156423 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -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) {
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)) {
return Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries);
}