fixed duplicate shifts under certain circumstances
This commit is contained in:
16
shifts.ps1
16
shifts.ps1
@@ -56,7 +56,7 @@ function Set-Shift {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($script:noplan -eq $false) {
|
if($script:noplan -eq $false) {
|
||||||
$newShift = New-MgTeamScheduleShift -TeamId $teamID -BodyParameter $params -Headers @{ "MS-APP-ACTS-AS" = $userIdAdmin }
|
$newshift = New-MgTeamScheduleShift -TeamId $teamID -BodyParameter $params -Headers @{ "MS-APP-ACTS-AS" = $userIdAdmin }
|
||||||
Write-Debug("{0} {1}: setting {2}'s shift - {3} {4}-{5}" -f $dayDate.Date, $dayDate.DayOfWeek, $mail, $shiftName, $StartDate, $EndDate)
|
Write-Debug("{0} {1}: setting {2}'s shift - {3} {4}-{5}" -f $dayDate.Date, $dayDate.DayOfWeek, $mail, $shiftName, $StartDate, $EndDate)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -65,7 +65,7 @@ function Set-Shift {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $newShift
|
return $newshift
|
||||||
}
|
}
|
||||||
|
|
||||||
function Remove-Shift {
|
function Remove-Shift {
|
||||||
@@ -166,7 +166,7 @@ $schedule = Get-Content -Path "./config.json" -Raw | ConvertFrom-Json
|
|||||||
|
|
||||||
# ---| ALL MEMBERS SPECIFIED IN THE SCHEDULE |---
|
# ---| ALL MEMBERS SPECIFIED IN THE SCHEDULE |---
|
||||||
$allemails = $schedule.PSObject.Properties | ForEach-Object {
|
$allemails = $schedule.PSObject.Properties | ForEach-Object {
|
||||||
if ($_.Name -in @("monday", "tuesday", "wednesday", "thursday", "friday")) {
|
if ($_.Name -in @("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")) {
|
||||||
$_.Value.PSObject.Properties | ForEach-Object {
|
$_.Value.PSObject.Properties | ForEach-Object {
|
||||||
if ($_.Name -in @("ds", "ho", "os", "ns")) {
|
if ($_.Name -in @("ds", "ho", "os", "ns")) {
|
||||||
if ($_.Name -eq "os") {
|
if ($_.Name -eq "os") {
|
||||||
@@ -364,7 +364,7 @@ try {
|
|||||||
# ---| OFFICE DAY SHIFT |---
|
# ---| OFFICE DAY SHIFT |---
|
||||||
else {
|
else {
|
||||||
$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "Office - Denní směna" -StartDate $dateStart -EndDate $dateEnd -color "purple" -teamID $team.id -mail $email
|
$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "Office - Denní směna" -StartDate $dateStart -EndDate $dateEnd -color "purple" -teamID $team.id -mail $email
|
||||||
$allshifts += [Object[]] $newShift
|
$allshifts += [Object[]] $newshift
|
||||||
$ds_shift_inplace = $true
|
$ds_shift_inplace = $true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -411,7 +411,7 @@ try {
|
|||||||
# ---| OFFICE DAY SHIFT |---
|
# ---| OFFICE DAY SHIFT |---
|
||||||
else {
|
else {
|
||||||
$newshift = Set-Shift -userId $futureds_id -groupID $group.id -shiftName "Office - Denní směna" -StartDate $dateStart -EndDate $dateEnd -color "purple" -teamID $team.id -mail $futureds_email
|
$newshift = Set-Shift -userId $futureds_id -groupID $group.id -shiftName "Office - Denní směna" -StartDate $dateStart -EndDate $dateEnd -color "purple" -teamID $team.id -mail $futureds_email
|
||||||
$allshifts += [Object[]] $newShift
|
$allshifts += [Object[]] $newshift
|
||||||
$ds_shift_inplace = $true
|
$ds_shift_inplace = $true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -435,7 +435,7 @@ try {
|
|||||||
# ---| OFFICE DAY SHIFT |---
|
# ---| OFFICE DAY SHIFT |---
|
||||||
else {
|
else {
|
||||||
$newshift = Set-Shift -userId $futureds_id -groupID $group.id -shiftName "Office - Denní směna" -StartDate $dateStart -EndDate $dateEnd -color "purple" -teamID $team.id -mail $futureds_email
|
$newshift = Set-Shift -userId $futureds_id -groupID $group.id -shiftName "Office - Denní směna" -StartDate $dateStart -EndDate $dateEnd -color "purple" -teamID $team.id -mail $futureds_email
|
||||||
$allshifts += [Object[]] $newShift
|
$allshifts += [Object[]] $newshift
|
||||||
$ds_shift_inplace = $true
|
$ds_shift_inplace = $true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -489,7 +489,7 @@ try {
|
|||||||
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_today -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
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -506,7 +506,7 @@ try {
|
|||||||
# ---| HOME-OFFICE CHECK |---
|
# ---| HOME-OFFICE CHECK |---
|
||||||
if($email -in $ho_emails) {
|
if($email -in $ho_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 "Home office" -StartDate $dateStart -EndDate $dateEnd -color "pink" -teamID $team.id -mail $email
|
$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "Home Office" -StartDate $dateStart -EndDate $dateEnd -color "pink" -teamID $team.id -mail $email
|
||||||
$allshifts += [Object[]] $newshift
|
$allshifts += [Object[]] $newshift
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user