DealExist::expose

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. DealExist
  4. expose
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/recurring/entity/item/dealexist.php
  • Класс: Bitrix\Crm\Recurring\Entity\Item\DealExist
  • Вызов: DealExist::expose
public function expose($recalculate = false)
{
	$result = new Main\Result();
	if ($this->isChanged())
	{
		$result->addError(new Main\Error('Error exposing. Recurring deal was changed. Need to save changes before exposing.'));
		return $result;
	}

	if (empty($this->templateFields))
	{
		$r = $this->fillTemplateFields();
		if (!$r->isSuccess())
		{
			return $r;
		}
	}

	$fields = $this->prepareDealFieldsBeforeExpose($this->templateFields);
	$addResult = $this->addExposingDeal($fields);
	if ($addResult->isSuccess())
	{
		$newDealId = $addResult->getId();
		$result->setData(['NEW_DEAL_ID' => $newDealId]);

		$this->onAfterDealExpose($newDealId, $fields);

		$this->setFieldNoDemand('COUNTER_REPEAT', (int)$this->recurringFields['COUNTER_REPEAT'] + 1);
		$this->setFieldNoDemand('LAST_EXECUTION', new Date());

		if ($recalculate)
		{
			$this->setFieldNoDemand("NEXT_EXECUTION", $this->calculateNextExecutionDate());
			if (!$this->isActive())
			{
				$this->deactivate();
			}
			else
			{
				$this->setFieldNoDemand("ACTIVE", 'Y');
			}
		}

		$this->save();
	}
	else
	{
		$result->addErrors($addResult->getErrors());
	}

	return $result;
}

Добавить комментарий