add overnight shift creation feature flag
This commit is contained in:
parent
95fc3fa0e5
commit
ead2b1582b
|
@ -28,6 +28,8 @@ function admin_shifts()
|
||||||
$change_hours = [];
|
$change_hours = [];
|
||||||
$title = '';
|
$title = '';
|
||||||
$shifttype_id = null;
|
$shifttype_id = null;
|
||||||
|
// When true: creates a shift beginning at the last shift change hour and ending at the first shift change hour
|
||||||
|
$shift_over_midnight = true;
|
||||||
|
|
||||||
// Locations laden
|
// Locations laden
|
||||||
$rooms = Rooms();
|
$rooms = Rooms();
|
||||||
|
@ -127,6 +129,7 @@ function admin_shifts()
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(__('Please split the shift-change hours by colons.'));
|
error(__('Please split the shift-change hours by colons.'));
|
||||||
}
|
}
|
||||||
|
$shift_over_midnight = $request->has('shift_over_midnight');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
|
@ -220,7 +223,7 @@ function admin_shifts()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Chronologisch absteigend sortieren
|
// Chronologisch absteigend sortieren (WHY???)
|
||||||
usort($change_hours, function ($a, $b) {
|
usort($change_hours, function ($a, $b) {
|
||||||
return str_replace(':', '', $a) > str_replace(':', '', $b) ? -1 : 1;
|
return str_replace(':', '', $a) > str_replace(':', '', $b) ? -1 : 1;
|
||||||
});
|
});
|
||||||
|
@ -263,6 +266,7 @@ function admin_shifts()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($shift_over_midnight || $day == parse_date('Y-m-d H:i', date('Y-m-d', $shift_end) . ' 00:00')) {
|
||||||
$shifts[] = [
|
$shifts[] = [
|
||||||
'start' => $shift_start,
|
'start' => $shift_start,
|
||||||
'end' => $shift_end,
|
'end' => $shift_end,
|
||||||
|
@ -270,9 +274,13 @@ function admin_shifts()
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'shifttype_id' => $shifttype_id
|
'shifttype_id' => $shifttype_id
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$shift_start = $shift_end;
|
$shift_start = $shift_end;
|
||||||
$change_index = ($change_index + count($change_hours) - 1) % count($change_hours);
|
$change_index--;
|
||||||
|
if($change_index < 0) {
|
||||||
|
$change_index = count($change_hours) - 1;
|
||||||
|
}
|
||||||
} while ($shift_end < $end);
|
} while ($shift_end < $end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,6 +439,11 @@ function admin_shifts()
|
||||||
$request->has('change_hours')
|
$request->has('change_hours')
|
||||||
? $request->input('input')
|
? $request->input('input')
|
||||||
: '00, 04, 08, 10, 12, 14, 16, 18, 20, 22'
|
: '00, 04, 08, 10, 12, 14, 16, 18, 20, 22'
|
||||||
|
),
|
||||||
|
form_checkbox(
|
||||||
|
'shift_over_midnight',
|
||||||
|
__('Create a shift over midnight.'),
|
||||||
|
$shift_over_midnight
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
div('col-md-6', [
|
div('col-md-6', [
|
||||||
|
|
Loading…
Reference in New Issue