19 private ?
string $guestName;
28 $this->eventId = $eventId;
30 $this->guestName = $guestName;
46 if (!$this->isAvailable())
52 'SUBJECT' => $activityName,
53 'DESCRIPTION' => $description,
54 'RESPONSIBLE_ID' => $this->link->getOwnerId(),
55 'CALENDAR_EVENT_ID' => $this->eventId,
56 'BINDINGS' => $this->getBindings(),
57 'SETTINGS' => $this->getSettings(),
58 'END_TIME' => $eventStart,
61 return (
new \
Bitrix\Crm\Activity\Provider\CalendarSharing())
62 ->createActivity(\
Bitrix\Crm\Activity\Provider\CalendarSharing::PROVIDER_TYPE_ID, $fields)
73 if (!$this->isAvailable())
78 $activity = \CCrmActivity::GetByCalendarEventId($this->eventId,
false);
89 $crmStatus = ActivityHandler::SHARING_STATUS_MEETING_NOT_HELD;
92 $crmStatus = ActivityHandler::SHARING_STATUS_CANCELED_BY_MANAGER;
95 $crmStatus = ActivityHandler::SHARING_STATUS_CANCELED_BY_CLIENT;
99 (
new ActivityHandler($activity, $activity[
'OWNER_TYPE_ID'], $activity[
'OWNER_ID']))
100 ->completeWithStatus($crmStatus);
113 if (!$this->isAvailable())
118 $activity = \CCrmActivity::GetByCalendarEventId($this->eventId,
false);
125 (
new ActivityHandler($activity, $activity[
'OWNER_TYPE_ID'], $activity[
'OWNER_ID']))
126 ->updateDeadline($deadline)
135 private function isAvailable(): bool
137 return Loader::includeModule(
'crm') ===
true
138 && \Bitrix\Crm\Integration\Calendar\Helper::isSharingCrmAvaible()
145 private function getBindings(): array
148 $entityTypeId =
null;
150 switch ($this->link->getObjectType())
153 $entityTypeId = \CCrmOwnerType::Deal;
158 'OWNER_TYPE_ID' => $entityTypeId,
159 'OWNER_ID' => $this->link->getObjectId(),
162 if ($this->link->getContactType() && $this->link->getContactId())
165 'OWNER_TYPE_ID' => $this->link->getContactType(),
166 'OWNER_ID' => $this->link->getContactId(),
176 private function getSettings(): array
180 if ($this->link->getContactType() && $this->link->getContactId())
183 'CONTACT_TYPE_ID' => $this->link->getContactType(),
184 'CONTACT_ID' => $this->link->getContactId(),
187 elseif ($this->guestName)
190 'GUEST_NAME' => $this->guestName,
194 $result[
'LINK_ID'] = $this->link->getId();