Fixes
This commit is contained in:
@@ -222,22 +222,30 @@ try {
|
||||
}
|
||||
|
||||
Write-Debug ("Shifts {0}, TimeOff: {1}" -f $shifts_today.length, $timeoff_today.length)
|
||||
$ds_covered = $false;
|
||||
|
||||
$userEmailToIdHashtable = @{}
|
||||
$userEmailNotAvailable = @()
|
||||
|
||||
foreach ($email in $allemails) {
|
||||
$userId = $(Get-MgUser -Filter "UserPrincipalName eq '$email' or proxyAddresses/any(c:c eq 'smtp:$email')").Id
|
||||
$userEmailToIdHashtable[$email] = $userId
|
||||
|
||||
if ($userId -in $shifts_today.UserId) {
|
||||
$userEmailNotAvailable += $email
|
||||
Write-Debug ("{0} has Manual Shift" -f $email)
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($userId -in $timeoff_today.UserId) {
|
||||
$userEmailNotAvailable += $email
|
||||
Write-Debug ("{0} has TimeOff" -f $email)
|
||||
continue;
|
||||
}
|
||||
|
||||
#NoShift
|
||||
if ($email -in $ns_emails) {
|
||||
$userEmailNotAvailable += $email
|
||||
Write-Debug ("{0} has NULL Shift " -f $email)
|
||||
continue
|
||||
}
|
||||
@@ -255,15 +263,31 @@ try {
|
||||
Write-Debug ("{0} has Denní HO" -f $email)
|
||||
#$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "Home Office - Denní směna" -StartDate $dateStart -EndDate $dateEnd -color "purple" -teamID $team.id -mail $ds_email
|
||||
#$allshifts += [Object[]] $newshift
|
||||
$ds_covered = $true;
|
||||
continue
|
||||
}
|
||||
elseif ($email -eq $ds_email) {
|
||||
Write-Debug ("{0} has Denní" -f $email)
|
||||
#$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "Denní směna" -StartDate $dateStart -EndDate $dateEnd -color "purple" -teamID $team.id -mail $ds_email
|
||||
#$allshifts += [Object[]] $newshift
|
||||
$ds_covered = $true;
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
$timeoff_today = [Object[]] $timeoff_all | Where-Object -Filter {
|
||||
($_.SharedTimeOff.StartDateTime.Date -eq $dateStart.Date -or $_.SharedTimeOff.EndDateTime.Date -eq $dateEnd.Date)
|
||||
}
|
||||
|
||||
foreach ($email in ($allemails | Where-Object -Filter {$_ -notin $userEmailNotAvailable} | Where-Object -Filter {$userEmailToIdHashtable[$_] -notin $timeoff_today.UserId})) {
|
||||
if (($ds_covered -eq $false)) {
|
||||
$ds_covered = $true;
|
||||
Write-Debug ("{0} has backup Denní" -f $email)
|
||||
#$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "Office" -StartDate $dateStart -EndDate $dateEnd -color "purple" -teamID $team.id -mail $ds_email
|
||||
#$allshifts += [Object[]] $newshift
|
||||
continue
|
||||
}
|
||||
|
||||
Write-Debug ("{0} has Office" -f $email)
|
||||
#$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "Office" -StartDate $dateStart -EndDate $dateEnd -color "purple" -teamID $team.id -mail $ds_email
|
||||
#$allshifts += [Object[]] $newshift
|
||||
|
Reference in New Issue
Block a user