Compare commits
2 Commits
bfaa8e50c7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 87c66c6485 | |||
| ee32d8600b |
14
shifts.ps1
14
shifts.ps1
@@ -153,6 +153,10 @@ $response = Invoke-RestMethod $authUri -Method 'POST' -Body $body
|
|||||||
|
|
||||||
$token = $response.access_token
|
$token = $response.access_token
|
||||||
|
|
||||||
|
$headers_holiday = @{}
|
||||||
|
|
||||||
|
$headers_holiday.Add("Accept", "application/json")
|
||||||
|
|
||||||
Import-Module Microsoft.Graph.Teams
|
Import-Module Microsoft.Graph.Teams
|
||||||
Connect-MgGraph -AccessToken $($token | ConvertTo-SecureString -AsPlainText -Force) >> $null
|
Connect-MgGraph -AccessToken $($token | ConvertTo-SecureString -AsPlainText -Force) >> $null
|
||||||
|
|
||||||
@@ -225,6 +229,14 @@ try {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ---| HOLIDAY CHECK |---
|
||||||
|
$holiday_response = (Invoke-WebRequest -Uri "https://svatky.steelants.cz/api/$($dayDate.ToString('yyyy-MM-dd'))" -Method GET -Headers $headers_holiday) | ConvertFrom-Json
|
||||||
|
|
||||||
|
if($holiday_response.isPublicHoliday) {
|
||||||
|
Write-Debug("{0} {1}: skipping holiday" -f $dayDate, $dayDate.DayOfWeek)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
# ---| NEW DAY INIT |---
|
# ---| NEW DAY INIT |---
|
||||||
$ds_shift_inplace = $false
|
$ds_shift_inplace = $false
|
||||||
$ho_emails = $schedule.($dayDate.DayOfWeek.ToString().ToLower()).'ho'
|
$ho_emails = $schedule.($dayDate.DayOfWeek.ToString().ToLower()).'ho'
|
||||||
@@ -380,7 +392,7 @@ try {
|
|||||||
# ---| ON-SITE SHIFT CHECK |---
|
# ---| ON-SITE SHIFT CHECK |---
|
||||||
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 "white" -teamID $team.id -mail $email
|
||||||
$allshifts += [Object[]] $newshift
|
$allshifts += [Object[]] $newshift
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user