- Модуль: imopenlines
- Путь к файлу: ~/bitrix/modules/imopenlines/lib/automaticaction/worktime.php
- Класс: BitrixImOpenLinesAutomaticActionWorkTime
- Вызов: WorkTime::isWorkTimeLine
public function isWorkTimeLine(): bool
{
$result = true;
if ($this->config['WORKTIME_ENABLE'] != 'N')
{
$timezone = !empty($this->config["WORKTIME_TIMEZONE"]) ? new DateTimeZone($this->config["WORKTIME_TIMEZONE"]) : null;
$numberDate = new DateTime(null, null, $timezone);
if (!empty($this->config['WORKTIME_DAYOFF']))
{
if (!is_array($this->config['WORKTIME_DAYOFF']))
{
$this->config['WORKTIME_DAYOFF'] = explode(',', $this->config['WORKTIME_DAYOFF']);
}
$allWeekDays = [
'MO' => 1,
'TU' => 2,
'WE' => 3,
'TH' => 4,
'FR' => 5,
'SA' => 6,
'SU' => 7
];
$currentWeekDay = $numberDate->format('N');
foreach($this->config['WORKTIME_DAYOFF'] as $day)
{
if ($currentWeekDay == $allWeekDays[$day])
{
$result = false;
break;
}
}
}
if ($result && !empty($this->config['WORKTIME_HOLIDAYS']))
{
if (!is_array($this->config['WORKTIME_HOLIDAYS']))
{
$this->config['WORKTIME_HOLIDAYS'] = explode(',', $this->config['WORKTIME_HOLIDAYS']);
}
$currentDay = $numberDate->format('d.m');
foreach($this->config['WORKTIME_HOLIDAYS'] as $holiday)
{
if ($currentDay == $holiday)
{
$result = false;
break;
}
}
}
if ($result)
{
$currentTime = $numberDate->format('G.i');
if (!($currentTime >= $this->config['WORKTIME_FROM'] && $currentTime <= $this->config['WORKTIME_TO']))
{
$result = false;
}
}
}
return $result;
}