$ar = New-Object System.Security.AccessControl.FileSystemAccessRule($group, @('Read', 'ReadAndExecute'),
'ContainerInherit,ObjectInherit', 'None', 'Allow')
# Получаете список папок
Get-ChildItem -Directory -Recurse $Path | Foreach-Object {
# Получаете по ним ACL
$acl = $_.GetAccessControl('Access')
# Сравниваете с нужным
if (-not ($acl.Access.IdentityReference -eq $group)) {
# Добавляете если надо
$acl.SetAccessRule($ar)
$_.SetAccessControl($acl)
}
}
WITH RECURSIVE
cte AS ( SELECT CAST(DATE_FORMAT(@range_from, '%Y-%m-01') AS DATE) month_start,
LAST_DAY(@range_from) month_end
UNION ALL
SELECT month_start + INTERVAL 1 MONTH,
LAST_DAY(month_start + INTERVAL 1 MONTH)
FROM cte
WHERE month_start < DATE_FORMAT(@range_till, '%Y-%m-01')
)
SELECT cte.month_start, COUNT(employee.id) employees_amount
FROM cte
LEFT JOIN employee ON employee.date_employment <= cte.month_end
AND ( employee.date_dismissal >= cte.month_start
OR employee.date_dismissal IS NULL )
GROUP BY 1;
WITH cte AS ( SELECT *,
LAG(`datetime`) OVER (PARTITION BY login ORDER BY `datetime`) lag_datetime,
LAG(event) OVER (PARTITION BY login ORDER BY `datetime`) lag_event
FROM history )
SELECT login, SUM(TIMESTAMPDIFF(MINUTE, lag_datetime, `datetime`)) duration
FROM cte
WHERE (event, lag_event) = (2,1)
GROUP BY login;
function translit($value) {
$converter = [
'%D0%B0' => 'a',
'%D0%B1' => 'b',
'%D0%B2' => 'v',
'%D0%B3' => 'g',
'%D0%B4' => 'd',
'%D0%B5' => 'e',
'%D1%91' => 'e',
'%D0%B6' => 'zh',
'%D0%B7' => 'z',
'%D0%B8' => 'i',
'%D0%B9' => 'y',
'%D0%BA' => 'k',
'%D0%BB' => 'l',
'%D0%BC' => 'm',
'%D0%BD' => 'n',
'%D0%BE' => 'o',
'%D0%BF' => 'p',
'%D1%80' => 'r',
'%D1%81' => 's',
'%D1%82' => 't',
'%D1%83' => 'u',
'%D1%84' => 'f',
'%D1%85' => 'h',
'%D1%86' => 'c',
'%D1%87' => 'ch',
'%D1%88' => 'sh',
'%D1%89' => 'sch',
'%D1%8C' => '',
'%D1%8B' => 'y',
'%D1%8A' => '',
'%D1%8D' => 'e',
'%D1%8E' => 'yu',
'%D1%8F' => 'ya',
];
$decodedKeys = array_map(function($encodedKey) {
return urldecode($encodedKey);
}, array_keys($converter));
$converter = array_combine($decodedKeys, array_values($converter));
return strtr($value, $converter);
}