disabled shift and time off overlap check

This commit is contained in:
2025-12-15 15:22:25 +01:00
parent e8811c71f5
commit 772114487d

View File

@@ -289,40 +289,40 @@ try {
$userId = $(Get-MgUser -Filter "UserPrincipalName eq '$email' or proxyAddresses/any(c:c eq 'smtp:$email')").Id $userId = $(Get-MgUser -Filter "UserPrincipalName eq '$email' or proxyAddresses/any(c:c eq 'smtp:$email')").Id
# ---| TIME OFF AND SHIFT OVERLAP CHECK |--- # ---| TIME OFF AND SHIFT OVERLAP CHECK |---
if(Invoke-HasTimeOff -UID $userId -timeoff $timeoff_today -mail $email) { # if(Invoke-HasTimeOff -UID $userId -timeoff $timeoff_today -mail $email) {
if(Invoke-HasShift -UID $userId -shifts $shifts_today -mail $email) { # if(Invoke-HasShift -UID $userId -shifts $shifts_today -mail $email) {
Write-Debug("{0} {1}: {2} has approved time-off and a shift, checking overlap..." -f $dayDate.Date, $dayDate.DayOfWeek, $email) # Write-Debug("{0} {1}: {2} has approved time-off and a shift, checking overlap..." -f $dayDate.Date, $dayDate.DayOfWeek, $email)
#
# ---| IDENTIFY SHIFT AND TIME OFF VARIABLES |--- # # ---| IDENTIFY SHIFT AND TIME OFF VARIABLES |---
foreach($shift in $shifts_today) { # foreach($shift in $shifts_today) {
if($shift.UserId -eq $userId) { # if($shift.UserId -eq $userId) {
$overlap_shift = $shift # $overlap_shift = $shift
} # }
} # }
foreach($timeoff in $timeoff_today) { # foreach($timeoff in $timeoff_today) {
if($timeoff.UserId -eq $userId) { # if($timeoff.UserId -eq $userId) {
$overlap_timeoff = $timeoff # $overlap_timeoff = $timeoff
} # }
} # }
if(($null -eq $overlap_shift) -or ($null -eq $overlap_timeoff)) { # if(($null -eq $overlap_shift) -or ($null -eq $overlap_timeoff)) {
Write-Debug("{0} {1}: {2} couldn't find the specific shift or time off, ignoring..." -f $dayDate.Date, $dayDate.DayOfWeek, $email) # Write-Debug("{0} {1}: {2} couldn't find the specific shift or time off, ignoring..." -f $dayDate.Date, $dayDate.DayOfWeek, $email)
continue # continue
} # }
#
# ---| OVERLAP CHECK |--- # # ---| OVERLAP CHECK |---
if($overlap_shift.SharedShift.StartDateTime.ToString("yyyy-MM-dd HH:mm") -ge $overlap_timeoff.SharedTimeOff.StartDateTime.ToString("yyyy-MM-dd HH:mm")) { # if($overlap_shift.SharedShift.StartDateTime.ToString("yyyy-MM-dd HH:mm") -ge $overlap_timeoff.SharedTimeOff.StartDateTime.ToString("yyyy-MM-dd HH:mm")) {
Write-Debug("{0} {1}: {2} today's shift starts after today's time off starts..." -f $dayDate.Date, $dayDate.DayOfWeek, $email) # Write-Debug("{0} {1}: {2} today's shift starts after today's time off starts..." -f $dayDate.Date, $dayDate.DayOfWeek, $email)
if($overlap_shift.SharedShift.StartDateTime.ToString("yyyy-MM-dd HH:mm") -lt $overlap_timeoff.SharedTimeOff.EndDateTime.ToString("yyyy-MM-dd HH:mm")) { # if($overlap_shift.SharedShift.StartDateTime.ToString("yyyy-MM-dd HH:mm") -lt $overlap_timeoff.SharedTimeOff.EndDateTime.ToString("yyyy-MM-dd HH:mm")) {
Write-Debug("{0} {1}: {2} today's shift starts before today's time off ends... overlap found" -f $dayDate.Date, $dayDate.DayOfWeek, $email) # Write-Debug("{0} {1}: {2} today's shift starts before today's time off ends... overlap found" -f $dayDate.Date, $dayDate.DayOfWeek, $email)
Remove-Shift -shift $overlap_shift -teamID $team.Id -removal_email $email # Remove-Shift -shift $overlap_shift -teamID $team.Id -removal_email $email
$allshifts = $allshifts | Where-Object { $_.SharedShift.Id -ne $overlap_shift.SharedShift.Id } # $allshifts = $allshifts | Where-Object { $_.SharedShift.Id -ne $overlap_shift.SharedShift.Id }
} # }
else { # else {
Write-Debug("{0} {1}: {2} today's shift starts after today's time off ends... no overlap" -f $dayDate.Date, $dayDate.DayOfWeek, $email) # Write-Debug("{0} {1}: {2} today's shift starts after today's time off ends... no overlap" -f $dayDate.Date, $dayDate.DayOfWeek, $email)
} # }
} # }
} # }
} # }
# ---| RLCZ MAINTENANCE PLANNER |--- # ---| RLCZ MAINTENANCE PLANNER |---
#if($dayDate.DayOfWeek -eq 'Wednesday') { #if($dayDate.DayOfWeek -eq 'Wednesday') {