• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/Service/Timeline/Item/Activity/Call.php
  • Класс: Bitrix\Crm\Service\Timeline\Item\Activity\Call
  • Вызов: Call::getButtons
public function getButtons(): array
{
	$communication = $this->getAssociatedEntityModel()->get('COMMUNICATION') ?? [];

	$nearestWorkday = (new WorkTime())->detectNearestWorkDateTime(3, 1);
	$scheduleButton = (new Button(Loc::getMessage('CRM_TIMELINE_BUTTON_CALL_SCHEDULE'), Button::TYPE_SECONDARY))
		->setAction((new JsEvent('Call:Schedule'))
			->addActionParamInt('activityId', $this->getActivityId())
			->addActionParamString('scheduleDate', $nearestWorkday->toString())
			->addActionParamInt('scheduleTs', $nearestWorkday->getTimestamp()))
	;
	$doneButton = (new Button(Loc::getMessage('CRM_TIMELINE_BUTTON_CALL_COMPLETE'), Button::TYPE_PRIMARY))
		->setAction($this->getCompleteAction())
	;

	switch ($this->fetchDirection())
	{
		case CCrmActivityDirection::Incoming:
			if ($this->isMissedCall())
			{
				if (!empty($communication))
				{
					$buttons['callButton'] = $this->getCallButton(
						$communication,
						$this->isScheduled() ? Button::TYPE_PRIMARY : Button::TYPE_SECONDARY
					);
				}

				if ($this->isScheduled())
				{
					$buttons['scheduleButton'] = $scheduleButton;
				}

				return $buttons ?? [];
			}

			if ($this->isScheduled())
			{
				return $this->isPlanned()
					? ['doneButton' => $doneButton]
					: [
						'doneButton' => $doneButton,
						'scheduleButton' => $scheduleButton,
					];
			}

			return empty($communication)
				? []
				: ['callButton' => $this->getCallButton($communication, Button::TYPE_SECONDARY)];
		case CCrmActivityDirection::Outgoing:
			$callButton = $this->getCallButton(
				$communication,
				$this->isScheduled() ? Button::TYPE_PRIMARY : Button::TYPE_SECONDARY
			);

			return empty($communication) ? [] : ['callButton' => $callButton];
	}

	return [];
}