oprava duplicitní směny po nalezení náhradníka, oprava zkrácení směny den po RLCZ maintenanci
This commit is contained in:
50
shifts.ps1
50
shifts.ps1
@@ -111,7 +111,7 @@ function Invoke-HasShiftorTimeOff {
|
|||||||
|
|
||||||
foreach ($shift in $shifts) {
|
foreach ($shift in $shifts) {
|
||||||
if($shift.UserId -eq $UID) {
|
if($shift.UserId -eq $UID) {
|
||||||
Write-Debug("{0} {1}: {2} has a shift or time off at this time" -f $dayDate, $dayDate.DayOfWeek, $mail)
|
Write-Debug("{0} {1}: {2} has a shift or time off at this time: {3} {4} {5}" -f $dayDate, $dayDate.DayOfWeek, $mail, $shift.SharedShift.Notes, $shift.SharedShift.StartDateTime, $shift.SharedShift.EndDateTime)
|
||||||
return $true
|
return $true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ function Invoke-HasShiftorTimeOff {
|
|||||||
|
|
||||||
foreach ($toff in $timeoff) {
|
foreach ($toff in $timeoff) {
|
||||||
if($toff.UserId -eq $UID) {
|
if($toff.UserId -eq $UID) {
|
||||||
Write-Debug("{0} {1}: {2} has a shift or time off at this time" -f $dayDate, $dayDate.DayOfWeek, $mail)
|
Write-Debug("{0} {1}: {2} has a shift or time off at this time: {3} {4}" -f $dayDate, $dayDate.DayOfWeek, $mail, $toff.SharedTimeOff.StartDateTime, $Toff.SharedTimeOff.EndDateTime)
|
||||||
return $true
|
return $true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ Connect-MgGraph -AccessToken $($token | ConvertTo-SecureString -AsPlainText -For
|
|||||||
|
|
||||||
#$today = (Get-Date).Date
|
#$today = (Get-Date).Date
|
||||||
#$today = $today_old.AddYears(2)
|
#$today = $today_old.AddYears(2)
|
||||||
$today = Get-Date -Day 1 -Month 2 -Year 2027 -Hour 9 -Minute 00 -Second 00 -Millisecond 00
|
$today = Get-Date -Day 25 -Month 1 -Year 2027 -Hour 9 -Minute 00 -Second 00 -Millisecond 00
|
||||||
|
|
||||||
$schedule = Get-Content -Path "./config.json" -Raw | ConvertFrom-Json
|
$schedule = Get-Content -Path "./config.json" -Raw | ConvertFrom-Json
|
||||||
|
|
||||||
@@ -189,6 +189,36 @@ try {
|
|||||||
|
|
||||||
#$timeoff_today = $timeoff_all | Where-Object -Property Date -eq -Value $(Get-Date -Day 20 -Month 1 -Year 2027).Date
|
#$timeoff_today = $timeoff_all | Where-Object -Property Date -eq -Value $(Get-Date -Day 20 -Month 1 -Year 2027).Date
|
||||||
|
|
||||||
|
#$spec_day = Get-Date -Day 27 -Month 1 -Year 2027 -Hour 9 -Minute 00 -Second 00 -Millisecond 00
|
||||||
|
|
||||||
|
#$rl_dateStart = $(get-date -Day $spec_day.Day -Month $spec_day.Month -Year $spec_day.Year -Hour 18 -Minute 00 -Second 00).AddHours(-1)
|
||||||
|
#$rl_dateEnd = $(get-date -Day $spec_day.Day -Month $spec_day.Month -Year $spec_day.Year -Hour 23 -Minute 00 -Second 00).AddHours(-1)
|
||||||
|
|
||||||
|
#if (($dayDate.IsDaylightSavingTime()) -eq $true) {
|
||||||
|
# $rl_dateStart = $rl_dateStart.AddHours(-1)
|
||||||
|
# $rl_dateEnd = $rl_dateEnd.AddHours(-1)
|
||||||
|
#}
|
||||||
|
|
||||||
|
#$params = @{
|
||||||
|
# UserId = $userId = $(Get-MgUser -Filter "UserPrincipalName eq 'jiri.kotlan@itego.cz' or proxyAddresses/any(c:c eq 'smtp:jiri.kotlan@itego.cz')").Id
|
||||||
|
# schedulingGroupId = $group.Id
|
||||||
|
# sharedShift = @{
|
||||||
|
# notes = ("RLCZ")
|
||||||
|
# startDateTime = [System.DateTime]::Parse($rl_dateStart.ToString("yyyy-MM-dd'T'HH:mm:ssZ"))
|
||||||
|
# endDateTime = [System.DateTime]::Parse($rl_dateEnd.ToString("yyyy-MM-dd'T'HH:mm:ssZ"))
|
||||||
|
# theme = "yellow"
|
||||||
|
# }
|
||||||
|
#}
|
||||||
|
|
||||||
|
#New-MgTeamScheduleShift -TeamId $team.Id -BodyParameter $params -Headers @{ "MS-APP-ACTS-AS" = $userIdAdmin }
|
||||||
|
|
||||||
|
#return
|
||||||
|
|
||||||
|
#$headers = @{
|
||||||
|
# "MS-APP-ACTS-AS" = $userIdAdmin
|
||||||
|
# "Prefer" = "no-notification"
|
||||||
|
#}
|
||||||
|
|
||||||
|
|
||||||
#if ($clear) {
|
#if ($clear) {
|
||||||
# foreach ($shift in $allshifts) {
|
# foreach ($shift in $allshifts) {
|
||||||
@@ -235,8 +265,12 @@ try {
|
|||||||
$_.schedulingGroupId -eq $group.Id -and $_.SharedShift.StartDateTime.ToString("yyyy-MM-dd HH:mm") -ge $dateStart.ToString("yyyy-MM-dd HH:mm") -and $_.SharedShift.EndDateTime.ToString("yyyy-MM-dd HH:mm") -le $dateEnd.ToString("yyyy-MM-dd HH:mm")
|
$_.schedulingGroupId -eq $group.Id -and $_.SharedShift.StartDateTime.ToString("yyyy-MM-dd HH:mm") -ge $dateStart.ToString("yyyy-MM-dd HH:mm") -and $_.SharedShift.EndDateTime.ToString("yyyy-MM-dd HH:mm") -le $dateEnd.ToString("yyyy-MM-dd HH:mm")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#$timeoff_today = [Object[]] $timeoff_all | Where-Object -Filter {
|
||||||
|
# ($_.SharedTimeOff.StartDateTime.Date -eq $dateStart.Date -or $_.SharedTimeOff.EndDateTime.Date -eq $dateEnd.Date)
|
||||||
|
#}
|
||||||
|
|
||||||
$timeoff_today = [Object[]] $timeoff_all | Where-Object -Filter {
|
$timeoff_today = [Object[]] $timeoff_all | Where-Object -Filter {
|
||||||
($_.SharedTimeOff.StartDateTime.Date -eq $dateStart.Date -or $_.SharedTimeOff.EndDateTime.Date -eq $dateEnd.Date)
|
($_.SharedTimeOff.EndDateTime.Date -eq $dateEnd.Date)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tohle jsou všechny způsoby co jsem zkoušel, nikdy to nematchne, nikdy to nevidí dovolenou
|
# Tohle jsou všechny způsoby co jsem zkoušel, nikdy to nematchne, nikdy to nevidí dovolenou
|
||||||
@@ -363,6 +397,10 @@ try {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$shifts_today = [Object[]] $allshifts | Where-Object -Filter {
|
||||||
|
$_.schedulingGroupId -eq $group.Id -and $_.SharedShift.StartDateTime.ToString("yyyy-MM-dd HH:mm") -ge $dateStart.ToString("yyyy-MM-dd HH:mm") -and $_.SharedShift.EndDateTime.ToString("yyyy-MM-dd HH:mm") -le $dateEnd.ToString("yyyy-MM-dd HH:mm")
|
||||||
|
}
|
||||||
|
|
||||||
if($email -in $os_emails) {
|
if($email -in $os_emails) {
|
||||||
if((Invoke-HasShiftorTimeOff -UID $userId -shifts $shifts_today -timeoff $timeoff_today -mail $email) -eq $false) {
|
if((Invoke-HasShiftorTimeOff -UID $userId -shifts $shifts_today -timeoff $timeoff_today -mail $email) -eq $false) {
|
||||||
$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "On-site" -StartDate $dateStart -EndDate $dateEnd -color "gray" -teamID $team.id -mail $email
|
$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "On-site" -StartDate $dateStart -EndDate $dateEnd -color "gray" -teamID $team.id -mail $email
|
||||||
@@ -381,7 +419,7 @@ try {
|
|||||||
$rlcz_shifts = [Object[]] $allshifts | Where-Object -Filter { $_.schedulingGroupId -eq $group.Id -and $_.SharedShift.Notes -eq "RLCZ" -and ($_.SharedShift.StartDateTime.Date -eq $yesterday.Date -or $_.SharedShift.EndDateTime.Date -eq $yesterday.Date) }
|
$rlcz_shifts = [Object[]] $allshifts | Where-Object -Filter { $_.schedulingGroupId -eq $group.Id -and $_.SharedShift.Notes -eq "RLCZ" -and ($_.SharedShift.StartDateTime.Date -eq $yesterday.Date -or $_.SharedShift.EndDateTime.Date -eq $yesterday.Date) }
|
||||||
|
|
||||||
if (Invoke-HasShift -UID $userId -shifts $rlcz_shifts -mail $email) {
|
if (Invoke-HasShift -UID $userId -shifts $rlcz_shifts -mail $email) {
|
||||||
if((Invoke-HasShiftorTimeOff -UID $userId -shifts $shifts_today -timeoff $timeoff_toda -mail $email) -eq $false) {
|
if((Invoke-HasShiftorTimeOff -UID $userId -shifts $shifts_today -timeoff $timeoff_today -mail $email) -eq $false) {
|
||||||
if($email -in $ho_emails) {
|
if($email -in $ho_emails) {
|
||||||
$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "Home office" -StartDate $dateStart -EndDate $dateEnd.AddHours($rlcz_shift_reduction) -color "pink" -teamID $team.id -mail $email
|
$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "Home office" -StartDate $dateStart -EndDate $dateEnd.AddHours($rlcz_shift_reduction) -color "pink" -teamID $team.id -mail $email
|
||||||
$allshifts += [Object[]] $newshift
|
$allshifts += [Object[]] $newshift
|
||||||
@@ -405,8 +443,6 @@ try {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if((Invoke-HasShiftorTimeOff -UID $userId -shifts $shifts_today -timeoff $timeoff_today -mail $email) -eq $false) {
|
if((Invoke-HasShiftorTimeOff -UID $userId -shifts $shifts_today -timeoff $timeoff_today -mail $email) -eq $false) {
|
||||||
$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "Office" -StartDate $dateStart -EndDate $dateEnd -color "blue" -teamID $team.id -mail $email
|
$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "Office" -StartDate $dateStart -EndDate $dateEnd -color "blue" -teamID $team.id -mail $email
|
||||||
$allshifts += [Object[]] $newshift
|
$allshifts += [Object[]] $newshift
|
||||||
|
Reference in New Issue
Block a user