diff --git a/shifts.ps1 b/shifts.ps1 index f608e94..77f006f 100644 --- a/shifts.ps1 +++ b/shifts.ps1 @@ -289,40 +289,40 @@ try { $userId = $(Get-MgUser -Filter "UserPrincipalName eq '$email' or proxyAddresses/any(c:c eq 'smtp:$email')").Id # ---| TIME OFF AND SHIFT OVERLAP CHECK |--- - if(Invoke-HasTimeOff -UID $userId -timeoff $timeoff_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) - - # ---| IDENTIFY SHIFT AND TIME OFF VARIABLES |--- - foreach($shift in $shifts_today) { - if($shift.UserId -eq $userId) { - $overlap_shift = $shift - } - } - foreach($timeoff in $timeoff_today) { - if($timeoff.UserId -eq $userId) { - $overlap_timeoff = $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) - continue - } - - # ---| OVERLAP CHECK |--- - 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) - 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) - Remove-Shift -shift $overlap_shift -teamID $team.Id -removal_email $email - $allshifts = $allshifts | Where-Object { $_.SharedShift.Id -ne $overlap_shift.SharedShift.Id } - } - else { - Write-Debug("{0} {1}: {2} today's shift starts after today's time off ends... no overlap" -f $dayDate.Date, $dayDate.DayOfWeek, $email) - } - } - } - } + # if(Invoke-HasTimeOff -UID $userId -timeoff $timeoff_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) + # + # # ---| IDENTIFY SHIFT AND TIME OFF VARIABLES |--- + # foreach($shift in $shifts_today) { + # if($shift.UserId -eq $userId) { + # $overlap_shift = $shift + # } + # } + # foreach($timeoff in $timeoff_today) { + # if($timeoff.UserId -eq $userId) { + # $overlap_timeoff = $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) + # continue + # } + # + # # ---| OVERLAP CHECK |--- + # 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) + # 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) + # Remove-Shift -shift $overlap_shift -teamID $team.Id -removal_email $email + # $allshifts = $allshifts | Where-Object { $_.SharedShift.Id -ne $overlap_shift.SharedShift.Id } + # } + # else { + # 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 |--- #if($dayDate.DayOfWeek -eq 'Wednesday') {