weekend on call shifts
This commit is contained in:
@@ -1529,6 +1529,18 @@ class _ScheduleGeneratorPanelState
|
||||
startMinute: 0,
|
||||
duration: const Duration(hours: 8),
|
||||
);
|
||||
// Weekend Saturday on_call: 5PM (17:00) to 8AM (08:00) next day = 15 hours
|
||||
templates['on_call_saturday'] = _ShiftTemplate(
|
||||
startHour: 17,
|
||||
startMinute: 0,
|
||||
duration: const Duration(hours: 15),
|
||||
);
|
||||
// Weekend Sunday on_call: 5PM (17:00) to 7AM (07:00) next day = 14 hours
|
||||
templates['on_call_sunday'] = _ShiftTemplate(
|
||||
startHour: 17,
|
||||
startMinute: 0,
|
||||
duration: const Duration(hours: 14),
|
||||
);
|
||||
// Default normal shift (8am-5pm = 9 hours)
|
||||
templates['normal'] = _ShiftTemplate(
|
||||
startHour: 8,
|
||||
@@ -1684,14 +1696,7 @@ class _ScheduleGeneratorPanelState
|
||||
final pmUserId = itStaff.isEmpty
|
||||
? null
|
||||
: itStaff[pmBaseIndex % itStaff.length].id;
|
||||
final nextWeekPmUserId = itStaff.isEmpty
|
||||
? null
|
||||
: itStaff[(pmBaseIndex + 1) % itStaff.length].id;
|
||||
final pmRelievers = _buildRelievers(pmBaseIndex, itStaff);
|
||||
final nextWeekRelievers = itStaff.isEmpty
|
||||
? <String>[]
|
||||
: _buildRelievers((pmBaseIndex + 1) % itStaff.length, itStaff);
|
||||
var weekendNormalOffset = 0;
|
||||
|
||||
for (
|
||||
var day = weekStart;
|
||||
@@ -1706,32 +1711,53 @@ class _ScheduleGeneratorPanelState
|
||||
final dayIsRamadan = isApproximateRamadan(day);
|
||||
|
||||
if (isWeekend) {
|
||||
// Weekend: only IT Staff get normal + on_call (rotating)
|
||||
if (itStaff.isNotEmpty) {
|
||||
final normalIndex =
|
||||
(amBaseIndex + pmBaseIndex + weekendNormalOffset) %
|
||||
itStaff.length;
|
||||
_tryAddDraft(
|
||||
draft,
|
||||
existing,
|
||||
templates,
|
||||
'normal',
|
||||
itStaff[normalIndex].id,
|
||||
day,
|
||||
const [],
|
||||
);
|
||||
weekendNormalOffset += 1;
|
||||
}
|
||||
if (nextWeekPmUserId != null) {
|
||||
_tryAddDraft(
|
||||
draft,
|
||||
existing,
|
||||
templates,
|
||||
'on_call',
|
||||
nextWeekPmUserId,
|
||||
day,
|
||||
nextWeekRelievers,
|
||||
);
|
||||
final isSaturday = day.weekday == DateTime.saturday;
|
||||
if (isSaturday) {
|
||||
// Saturday: AM person gets normal shift, PM person gets weekend on_call
|
||||
if (amUserId != null) {
|
||||
_tryAddDraft(
|
||||
draft,
|
||||
existing,
|
||||
templates,
|
||||
'normal',
|
||||
amUserId,
|
||||
day,
|
||||
const [],
|
||||
);
|
||||
}
|
||||
if (pmUserId != null) {
|
||||
_tryAddDraft(
|
||||
draft,
|
||||
existing,
|
||||
templates,
|
||||
'on_call_saturday',
|
||||
pmUserId,
|
||||
day,
|
||||
pmRelievers,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Sunday: PM person gets both normal and weekend on_call
|
||||
if (pmUserId != null) {
|
||||
_tryAddDraft(
|
||||
draft,
|
||||
existing,
|
||||
templates,
|
||||
'normal',
|
||||
pmUserId,
|
||||
day,
|
||||
const [],
|
||||
);
|
||||
_tryAddDraft(
|
||||
draft,
|
||||
existing,
|
||||
templates,
|
||||
'on_call_sunday',
|
||||
pmUserId,
|
||||
day,
|
||||
pmRelievers,
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Weekday: IT Staff rotate AM/PM/on_call
|
||||
|
||||
Reference in New Issue
Block a user