Skip to content
Snippets Groups Projects
Verified Commit 91481115 authored by Damien's avatar Damien
Browse files

FEAT #11907 TIME 1:05 Calculate priority with working days

parent 5a24d653
No related branches found
No related tags found
No related merge requests found
......@@ -180,6 +180,35 @@ class IndexingController
$diff = $processLimitDate->diff($now);
$diff = $diff->format("%a");
$workingDays = ParameterModel::getById(['id' => 'workingDays', 'select' => ['param_value_int']]);
if (!empty($workingDays['param_value_int'])) {
$hollidays = [
'01-01',
'01-05',
'08-05',
'14-07',
'15-08',
'01-11',
'11-11',
'25-12'
];
if (function_exists('easter_date')) {
$hollidays[] = date('d-m', easter_date() + 86400);
}
$diffUpdated = 0;
for ($i = 1; $i <= $diff; $i++) {
$tmpDate = $now;
$tmpDate->add(new \DateInterval("P{$i}D"));
if (in_array($tmpDate->format('N'), [6, 7]) || in_array($tmpDate->format('d-m'), $hollidays)) {
continue;
}
++$diffUpdated;
}
$diff = $diffUpdated;
}
$priority = PriorityModel::get(['select' => ['id'], 'where' => ['delays >= ?'], 'data' => [$diff], 'orderBy' => ['delays'], 'limit' => 1]);
if (empty($priority)) {
$priority = PriorityModel::get(['select' => ['id'], 'orderBy' => ['delays DESC'], 'limit' => 1]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment