• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/Service/Timeline/Item/Activity/Payment.php
  • Класс: Bitrix\Crm\Service\Timeline\Item\Activity\Payment
  • Вызов: Payment::getOpenPaymentAction
private function getOpenPaymentAction(): ?Action
{
	$contextEntityTypeId = $this->getContext()->getEntityTypeId();

	/**
	 * Currently Order, Payment and Shipment pages are forced to work in \CCrmOwnerType::Order context
	 * which makes it impossible to show any links to these entities in this context
	 */
	if ($contextEntityTypeId === \CCrmOwnerType::Order)
	{
		return null;
	}

	// @todo @see \Bitrix\Crm\Service\Timeline\Item\Mixin\HasPaymentDetailsContentBlock
	if ($this->isPaymentsEnabledForContextEntity())
	{
		$ownerTypeId = $this->getContext()->getEntityTypeId();

		$payment = $this->getPayment();
		$formattedDate = $payment ? ConvertTimeStamp($payment->getField('DATE_BILL')->getTimestamp()) : null;
		$accountNumber = $payment ? $payment->getField('ACCOUNT_NUMBER') : null;

		return
			(new JsEvent('SalescenterApp:Start'))
				->addActionParamString(
					'mode',
					$ownerTypeId === \CCrmOwnerType::Deal
						? 'payment_delivery'
						: 'payment'
				)
				->addActionParamInt(
					'orderId',
					$this->getAssociatedEntityModel()->get('OWNER_ID')
				)
				->addActionParamInt(
					'paymentId',
					$this->getAssociatedEntityModel()->get('ASSOCIATED_ENTITY_ID')
				)
				->addActionParamInt(
					'ownerTypeId',
					$ownerTypeId
				)
				->addActionParamInt(
					'ownerId',
					$this->getContext()->getEntityId()
				)
				->addActionParamString(
					'formattedDate',
					$formattedDate,
				)
				->addActionParamString(
					'accountNumber',
					$accountNumber,
				)
				->addActionParamString(
					'analyticsLabel',
					\CCrmOwnerType::isUseDynamicTypeBasedApproach($ownerTypeId)
						? 'crmDealTimelineSmsResendPaymentSlider'
						: 'crmDynamicTypeTimelineSmsResendPaymentSlider'
				)
		;
	}

	$detailLink = EntityLinkBuilder::getInstance()->getPaymentDetailsLink(
		$this->getAssociatedEntityModel()->get('ID')
	);
	if ($detailLink && !$this->isItemAboutCurrentEntity())
	{
		return new Action\Redirect(new Uri($detailLink));
	}

	return null;
}