• Модуль: timeman
  • Путь к файлу: ~/bitrix/modules/timeman/lib/update/timemanversion19converter.php
  • Класс: BitrixTimemanUpdateTimemanVersion19Converter
  • Вызов: TimemanVersion19Converter::deleteOldSchedules
private function deleteOldSchedules()
{
	if ((int)Option::get(self::$moduleId, 'converter19isOldSchedulesDeleted', 0) === 1)
	{
		return;
	}
	$idsToDelete = array_column(
		DependencyManager::getInstance()
			->getScheduleRepository()
			->getActiveSchedulesQuery()
			->addSelect('ID')
			->exec()
			->fetchAll(),
		'ID'
	);
	foreach ($idsToDelete as $id)
	{
		$res = DependencyManager::getInstance()
			->getScheduleService()
			->delete($id);
		Application::getConnection()
			->query("UPDATE
				b_timeman_entries
				SET TIMESTAMP_X = TIMESTAMP_X,
				SCHEDULE_ID = 0,
				SHIFT_ID = 0
				WHERE SCHEDULE_ID = $id"
			);
		if ($this->isMaxExecutionSecondsExceeded())
		{
			throw new MaximumExecutionSecondsExceededException();
		}
	}
	Option::set(self::$moduleId, 'converter19isOldSchedulesDeleted', 1);
}