• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/crm.php
  • Класс: BitrixImOpenLinesCrm
  • Вызов: Crm::setSessionClosed
public function setSessionClosed($params = []): Result
{
	$result = new Result();
	$result->setResult(false);
	$fields = $this->getFields();
	$session = $fields->getSession();

	if (!empty($session))
	{
		$activityId = $session->getData('CRM_ACTIVITY_ID');

		if(!empty($activityId))
		{
			$updateParams = ['COMPLETED' => 'Y'];

			if(!empty($params['DATE_CLOSE']))
			{
				$updateParams['DATE_CLOSE'] = $params['DATE_CLOSE'];
			}
			else
			{
				$updateParams['DATE_CLOSE'] = new BitrixMainTypeDateTime();
			}

			$resultUpdate = Activity::update($activityId, $updateParams);

			if($resultUpdate->isSuccess())
			{
				$result->setResult(true);
			}
			else
			{
				$result->addErrors($resultUpdate->getErrors());
			}
		}
	}
	else
	{
		$result->addError(new Error(Loc::getMessage('IMOL_CRM_ERROR_NO_SESSION'), self::ERROR_IMOL_NO_SESSION, __METHOD__));
	}

	return $result;
}