• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/tracker.php
  • Класс: BitrixImOpenLinesTracker
  • Вызов: Tracker::cancelLeadContactCompany
protected function cancelLeadContactCompany($chatId, $sessionId, $entityType, $params)
{
	$crm = new Crm();

	/*foreach ($params as $entityId => $entityIdValue)
	{
		foreach ($entityIdValue as $action => $actionValue)
		{
			$updateCrm = true;

			if ($action == self::ACTION_CREATE)
			{
				$entityData = BitrixImOpenLinesCrmCommon::get($entityType, $entityId);

				$currentTime = new BitrixMainTypeDateTime();
				$entityTime = new BitrixMainTypeDateTime($entityData['DATE_CREATE']);
				$entityTime->add('1 DAY');
				if ($currentTime < $entityTime)
				{
					BitrixImOpenLinesCrmCommon::delete($entityType, $entityId);

					$chat = new Chat($chatId);
					$chat->updateFieldData([Chat::FIELD_SESSION => [
						'CRM' => 'N',
						'CRM_ENTITY_TYPE' => Crm::ENTITY_NONE,
						'CRM_ENTITY_ID' => 0
					]]);

					ModelSessionTable::update($sessionId, Array(
						'CRM' => 'N',
						'CRM_CREATE' => 'N',
						'CRM_ENTITY_TYPE' => Crm::ENTITY_NONE,
						'CRM_ENTITY_ID' => 0
					));

					$updateCrm = false;
				}
			}

			if($updateCrm)
			{
				foreach ($actionValue as $fieldId => $fieldIdValue)
				{
					if($fieldId == self::FIELD_ID_FM)
					{
						foreach ($fieldIdValue as $fieldType => $fieldTypeValue)
						{
							foreach ($fieldTypeValue as $value)
							{
								BitrixImOpenLinesCrmCommon::deleteMultiField($entityType, $entityId, $fieldType, $value);
							}
						}
					}
					else
					{
						$updateFields = array();

						foreach ($fieldIdValue as $fieldType => $fieldTypeValue)
						{
							foreach ($fieldTypeValue as $value)
							{
								if($fieldId == Crm::FIELDS_CONTACT)
								{
									$contactIDs = array();

									if($entityType == Crm::ENTITY_LEAD)
									{
										$contactIDs = LeadContactTable::getLeadContactIDs($entityId);
									}
									elseif($entityType == Crm::ENTITY_COMPANY)
									{
										$contactIDs = ContactCompanyTable::getCompanyContactIDs($entityId);
									}

									foreach ($contactIDs as $key => $id)
									{
										if($id == $value)
										{
											unset($contactIDs[$key]);
										}
									}

									$updateFields[$fieldId] = $contactIDs;
								}
								else
								{
									$updateFields[$fieldId] = '';
								}
							}
						}

						if(!empty($updateFields))
						{
							BitrixImOpenLinesCrmCommon::update(
								$entityType,
								$entityId,
								$updateFields
							);
						}
					}
				}
			}
		}
	}*/
}