Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
basepersonalize.php
1<?php
2
4
5use Bitrix;
7
8abstract class BasePersonalize
9{
10 private const COMMA = ',';
11
12 public static function getMap()
13 {
14 return [
15 'NAME' => [
16 'CONTACT.NAME',
17 'LEAD.TITLE',
18 'COMPANY.TITLE'
19 ],
20 'ID' => [
21 'CONTACT.ID',
22 'LEAD.ID',
23 'COMPANY.ID'
24 ],
25 'EMAIL' => [
26 'CONTACT.EMAIL',
27 'LEAD.EMAIL',
28 'COMPANY.EMAIL'
29 ],
30 'PHONE' => [
31 'CONTACT.PHONE',
32 'LEAD.PHONE',
33 'COMPANY.PHONE'
34 ],
35 ];
36 }
37 public static function getEntityFields($entityType)
38 {
39 \Bitrix\Main\Localization\Loc::loadMessages(
40 $_SERVER['DOCUMENT_ROOT'].BX_ROOT.'/components/bitrix/crm.'.strtolower($entityType).'.edit/component.php'
41 );
42
43 $arResult = [];
44
45 $arResult += static::getAssignedByFields();
46
47 $ar = \CCrmFieldMulti::GetEntityTypeList();
48 foreach ($ar as $typeId => $arFields)
49 {
50 foreach ($arFields as $valueType => $valueName)
51 {
52 $arResult[$typeId.'_'.$valueType] = [
53 'Name' => $valueName,
54 'Type' => 'string',
55 "Filterable" => true,
56 "Editable" => false,
57 "Required" => false,
58 ];
59 }
60 }
61
62 return $arResult;
63 }
64
65 protected static function getAssignedByFields()
66 {
67 \Bitrix\Main\Localization\Loc::loadMessages(
68 $_SERVER['DOCUMENT_ROOT'].BX_ROOT.'/modules/crm/classes/general/crm_document.php'
69 );
70
71 return [
72 'ASSIGNED_BY.EMAIL' => [
73 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_EMAIL'),
74 'Type' => 'string',
75 ],
76 'ASSIGNED_BY.WORK_PHONE' => [
77 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_WORK_PHONE'),
78 'Type' => 'string',
79 ],
80 'ASSIGNED_BY.PERSONAL_MOBILE' => [
81 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_PERSONAL_MOBILE'),
82 'Type' => 'string',
83 ],
84 'ASSIGNED_BY.UF_PHONE_INNER' => [
85 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_UF_PHONE_INNER'),
86 'Type' => 'string',
87 ],
88
89 'ASSIGNED_BY.LOGIN' => [
90 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_LOGIN'),
91 'Type' => 'string',
92 ],
93 'ASSIGNED_BY.ACTIVE' => [
94 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_ACTIVE'),
95 'Type' => 'bool',
96 ],
97 'ASSIGNED_BY.LAST_NAME' => [
98 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_LAST_NAME'),
99 'Type' => 'string',
100 ],
101 'ASSIGNED_BY.NAME' => [
102 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_NAME'),
103 'Type' => 'string',
104 ],
105 'ASSIGNED_BY.SECOND_NAME' => [
106 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_SECOND_NAME'),
107 'Type' => 'string',
108 ],
109 'ASSIGNED_BY.WORK_POSITION' => [
110 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_WORK_POSITION'),
111 'Type' => 'string',
112 ],
113 'ASSIGNED_BY.PERSONAL_WWW' => [
114 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_PERSONAL_WWW'),
115 'Type' => 'string',
116 ],
117 'ASSIGNED_BY.PERSONAL_CITY' => [
118 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_PERSONAL_CITY'),
119 'Type' => 'string',
120 ],
121 'ASSIGNED_BY.UF_SKYPE' => [
122 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_UF_SKYPE'),
123 'Type' => 'string',
124 ],
125 'ASSIGNED_BY.UF_TWITTER' => [
126 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_UF_TWITTER'),
127 'Type' => 'string',
128 ],
129 'ASSIGNED_BY.UF_FACEBOOK' => [
130 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_UF_FACEBOOK'),
131 'Type' => 'string',
132 ],
133 'ASSIGNED_BY.UF_LINKEDIN' => [
134 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_UF_LINKEDIN'),
135 'Type' => 'string',
136 ],
137 'ASSIGNED_BY.UF_XING' => [
138 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_UF_XING'),
139 'Type' => 'string',
140 ],
141 'ASSIGNED_BY.UF_WEB_SITES' => [
142 'Name' => GetMessage('CRM_DOCUMENT_FIELD_ASSIGNED_BY_UF_WEB_SITES'),
143 'Type' => 'string',
144 ],
145 ];
146 }
147
148 public static function isFactoryBased(string $entityType): bool
149 {
150 return \CCrmOwnerType::isUseFactoryBasedApproach(\CCrmOwnerType::ResolveID($entityType));
151 }
152
165 public static function getData(
166 string $entityType,
167 array $entityIds,
168 array $usedFields = ['*'],
169 string $sortBy = 'id',
170 string $sortOrder = 'asc'
171 )
172 {
173 if(empty($usedFields))
174 {
175 return [];
176 }
177
178 \Bitrix\Main\Localization\Loc::loadMessages(
179 $_SERVER['DOCUMENT_ROOT'].BX_ROOT.'/modules/crm/classes/general/crm_fields.php'
180 );
181
182 $entityType = ucfirst(strtolower($entityType));
183 $className = 'CCrm'.$entityType;
184 $dbDocumentList = $className::GetListEx(
185 [],
186 [
187 "__CONDITIONS" => [
188 [
189 "SQL" => "L.ID IN (".implode(",", $entityIds).")"
190 ]
191 ],
192 "CHECK_PERMISSIONS" => "N"
193 ],
194 false,
195 false,
196 array_merge(
197 $usedFields,
198 ['UF_*', 'ASSIGNED_BY_ID']
199 )
200 );
201 $data = [];
202 while (($objDocument = $dbDocumentList->Fetch()) !== false)
203 {
204 $assignedByID = isset($objDocument['ASSIGNED_BY_ID'])? intval($objDocument['ASSIGNED_BY_ID']) : 0;
205
206 if ($assignedByID > 0)
207 {
208 self::addAssignedByFieldsValue($assignedByID, $objDocument);
209 }
210
211 self::addAddressFieldsValue($entityType, $usedFields, $objDocument);
212 self::addMultiFieldsValue($usedFields, $entityType, $objDocument);
213 self::addUserFieldsValue($className, $objDocument);
214
215 //communications
216 $typeId = \CCrmOwnerType::ResolveID($entityType);
217 $objDocument += static::getCommunicationFieldsValues($typeId, $objDocument['ID']);
218
219 $data[$objDocument['ID']] = $objDocument;
220 }
221
222 return $data;
223 }
224
229 private static function addAddressFieldsValue($entityType, $usedFields, &$objDocument)
230 {
231 $rqAddr = new Bitrix\Crm\RequisiteAddress();
232
233 $res = $rqAddr->getList(
234 array(
235 'filter' => array(
236 'ENTITY_TYPE_ID' => \CCrmOwnerType::Requisite,
237 'ANCHOR_TYPE_ID' => \CCrmOwnerType::ResolveID($entityType),
238 'ANCHOR_ID' => $objDocument['ID']
239 ),
240 'select' => array(
241 'ADDRESS_TYPE_ID' => 'TYPE_ID',
242 'ADDRESS' => 'ADDRESS_1',
243 'ADDRESS_2',
244 'ADDRESS_CITY' => 'CITY',
245 'ADDRESS_POSTAL_CODE' => 'POSTAL_CODE',
246 'ADDRESS_REGION' => 'REGION',
247 'ADDRESS_PROVINCE' => 'PROVINCE',
248 'ADDRESS_COUNTRY' => 'COUNTRY',
249 'ADDRESS_COUNTRY_CODE' => 'COUNTRY_CODE'
250 )
251 )
252 )->fetchAll();
253
254 if(!$res)
255 {
256 return;
257 }
258
259 foreach ($res as $addresses)
260 {
261 if(
262 (int)$addresses['ADDRESS_TYPE_ID'] === (int)\Bitrix\Crm\EntityAddressType::Primary
263 )
264 {
265 foreach ($addresses as $key => $address)
266 {
267 $objDocument[$key] = $address;
268 }
269 }
270 if(isset($usedFields[strtoupper($entityType).'.ADDRESS_LEGAL']) &&
271 (int)$addresses['ADDRESS_TYPE_ID'] === \Bitrix\Crm\EntityAddressType::Registered)
272 {
273 $objDocument['ADDRESS_LEGAL'] = self::buildAddress($entityType, $addresses);
274 }
275 }
276 }
277
278 private static function buildAddress($entityType,$address)
279 {
280 $entityAddressClassName = '\\Bitrix\\Crm\\'.ucfirst(strtolower($entityType)).'Address';
281 return Bitrix\Crm\Format\AddressFormatter::getSingleInstance()->formatTextComma(
282 $entityAddressClassName::mapEntityFields(
283 [
284 'ADDRESS' => $address['ADDRESS'],
285 'ADDRESS_2' => $address['ADDRESS_2'],
286 'ADDRESS_CITY' => $address['ADDRESS_CITY'],
287 'ADDRESS_REGION' => $address['ADDRESS_REGION'],
288 'ADDRESS_PROVINCE' => $address['ADDRESS_PROVINCE'],
289 'ADDRESS_POSTAL_CODE' => $address['ADDRESS_POSTAL_CODE'],
290 'ADDRESS_COUNTRY' => $address['ADDRESS_COUNTRY'],
291 'ADDRESS_LOC_ADDR_ID' => $address['ADDRESS_COUNTRY']
292 ]
293 )
294 );
295 }
296
302 private static function addMultiFieldsValue($usedFields, $entityType, &$objDocument)
303 {
304 $userMultiFields = \CCrmFieldMulti::GetAllEntityFields($entityType, $objDocument['ID']);
305
306 foreach ($usedFields as $usedField)
307 {
308 self::checkUsedField($usedField, $entityType, $objDocument);
309 $splitedField = explode('_', $usedField);
310
311 if(
312 in_array($splitedField[0], ['PHONE', 'IM', 'EMAIL', 'WEB'])
313 && isset($userMultiFields[$splitedField[0]])
314 )
315 {
316 foreach ($userMultiFields[$splitedField[0]] as $field)
317 {
318 if(!isset($splitedField[1]))
319 {
320 $objDocument[$usedField] = $field['VALUE'];
321 continue;
322 }
323
324 if($field['VALUE_TYPE'] === $splitedField[1])
325 {
326 $objDocument[$usedField] = $field['VALUE'];
327 }
328 }
329 }
330 }
331 }
332
337 private static function addUserFieldsValue($className, &$objDocument)
338 {
339 $userFieldsList = $className::GetUserFields();
340
341 if (is_array($userFieldsList))
342 {
343 static::processUserFieldValues($userFieldsList, $objDocument);
344 }
345 }
346
347 protected static function processUserFieldValues(array $userFieldsSettings, array &$userFieldValues): void
348 {
349 foreach ($userFieldsSettings as $userFieldName => $userFieldParams)
350 {
351 $fieldTypeID = isset($userFieldParams['USER_TYPE'])? $userFieldParams['USER_TYPE']['USER_TYPE_ID']
352 : '';
353 $isFieldMultiple = isset($userFieldParams['MULTIPLE']) && $userFieldParams['MULTIPLE'] === 'Y';
354 $fieldSettings = isset($userFieldParams['SETTINGS'])? $userFieldParams['SETTINGS'] : [];
355
356 if (isset($userFieldValues[$userFieldName]))
357 {
358 $fieldValue = $userFieldValues[$userFieldName];
359 }
360 elseif (isset($fieldSettings['DEFAULT_VALUE']))
361 {
362 $fieldValue = $fieldSettings['DEFAULT_VALUE'];
363 }
364
365 if ($fieldTypeID === 'employee')
366 {
367 if (!$isFieldMultiple)
368 {
369 $userFieldValues[$userFieldName] = $fieldValue;
370 }
371 elseif (is_array($fieldValue))
372 {
373 $userFieldValues[$userFieldName] = [];
374 foreach ($fieldValue as $value)
375 {
376 $userFieldValues[$userFieldName][] = $value;
377 }
378 }
379 }
380 elseif ($fieldTypeID === 'boolean')
381 {
382 $userFieldValues[$userFieldName] = self::getBool($fieldValue)? 'Y' : 'N';
383 }
384 }
385 }
386
387 private static function getBool($value)
388 {
389 if (empty($value) || $value === 'false' || is_int($value) && ($value == 0) || (mb_strtoupper($value) == 'N'))
390 {
391 return false;
392 }
393
394 return (bool)$value;
395 }
400 protected static function addAssignedByFieldsValue($assignedByID, &$objDocument)
401 {
402 if ($assignedByID < 1)
403 {
404 return;
405 }
406
407 $dbUsers = \CUser::GetList(
408 'id',
409 'asc',
410 ['ID' => $assignedByID],
411 [
412 'SELECT' => [
413 'UF_SKYPE',
414 'UF_TWITTER',
415 'UF_FACEBOOK',
416 'UF_LINKEDIN',
417 'UF_XING',
418 'UF_WEB_SITES',
419 'UF_PHONE_INNER',
420 ],
421 'FIELDS' => [
422 'EMAIL',
423 'WORK_PHONE',
424 'PERSONAL_MOBILE',
425 'LOGIN',
426 'ACTIVE',
427 'NAME',
428 'LAST_NAME',
429 'SECOND_NAME',
430 'WORK_POSITION',
431 'PERSONAL_WWW',
432 'PERSONAL_CITY',
433 ],
434 ]
435 );
436
437 $arUser = is_object($dbUsers)? $dbUsers->Fetch() : null;
438 $objDocument['ASSIGNED_BY.EMAIL'] = is_array($arUser)? $arUser['EMAIL'] : '';
439 $objDocument['ASSIGNED_BY.WORK_PHONE'] = is_array($arUser)? $arUser['WORK_PHONE'] : '';
440 $objDocument['ASSIGNED_BY.PERSONAL_MOBILE'] = is_array($arUser)? $arUser['PERSONAL_MOBILE'] : '';
441
442 $objDocument['ASSIGNED_BY.LOGIN'] = is_array($arUser)? $arUser['LOGIN'] : '';
443 $objDocument['ASSIGNED_BY.ACTIVE'] = is_array($arUser)? $arUser['ACTIVE'] : '';
444 $objDocument['ASSIGNED_BY.NAME'] = is_array($arUser)? $arUser['NAME'] : '';
445 $objDocument['ASSIGNED_BY.LAST_NAME'] = is_array($arUser)? $arUser['LAST_NAME'] : '';
446 $objDocument['ASSIGNED_BY.SECOND_NAME'] = is_array($arUser)? $arUser['SECOND_NAME'] : '';
447 $objDocument['ASSIGNED_BY.WORK_POSITION'] = is_array($arUser)? $arUser['WORK_POSITION'] : '';
448 $objDocument['ASSIGNED_BY.PERSONAL_WWW'] = is_array($arUser)? $arUser['PERSONAL_WWW'] : '';
449 $objDocument['ASSIGNED_BY.PERSONAL_CITY'] = is_array($arUser)? $arUser['PERSONAL_CITY'] : '';
450 $objDocument['ASSIGNED_BY.UF_SKYPE'] = is_array($arUser)? $arUser['UF_SKYPE'] : '';
451 $objDocument['ASSIGNED_BY.UF_TWITTER'] = is_array($arUser)? $arUser['UF_TWITTER'] : '';
452 $objDocument['ASSIGNED_BY.UF_FACEBOOK'] = is_array($arUser)? $arUser['UF_FACEBOOK'] : '';
453 $objDocument['ASSIGNED_BY.UF_LINKEDIN'] = is_array($arUser)? $arUser['UF_LINKEDIN'] : '';
454 $objDocument['ASSIGNED_BY.UF_XING'] = is_array($arUser)? $arUser['UF_XING'] : '';
455 $objDocument['ASSIGNED_BY.UF_WEB_SITES'] = is_array($arUser)? $arUser['UF_WEB_SITES'] : '';
456 $objDocument['ASSIGNED_BY.UF_PHONE_INNER'] = is_array($arUser)? $arUser['UF_PHONE_INNER'] : '';
457 }
458
464 private static function checkUsedField($usedField, $entityType, &$objDocument)
465 {
466 switch ($usedField)
467 {
468 case 'FULL_ADDRESS':
469 $objDocument['FULL_ADDRESS'] = self::buildAddress($entityType, $objDocument);
470 break;
471 case 'BANKING_DETAILS':
472 $requisites = Bitrix\Crm\EntityRequisite::getSingleInstance()
473 ->getList(
474 [
475 'filter' => [
476 '=ENTITY_TYPE_ID' => \CCrmOwnerType::ResolveID($entityType),
477 '=ENTITY_ID' => $objDocument['ID']
478 ],
479 'select' => ['ID'],
480 'limit' => '1'
481 ]
482 )->fetch();
483 $titleMap = Bitrix\Crm\EntityBankDetail::getSingleInstance()->getRqFieldTitleMap();
484
485 $details = Bitrix\Crm\EntityBankDetail::getByOwners(
486 \CCrmOwnerType::Requisite, [$requisites['ID']]
487 );
488 $objDocument['BANKING_DETAILS'] = '';
489 $tmpDetails = [];
490 if($details[$requisites['ID']])
491 {
492 foreach ($details[$requisites['ID']] as $detail)
493 {
494 foreach ($titleMap as $key => $title)
495 {
496 if(isset($title[$detail['COUNTRY_ID']]))
497 {
498 $tmpDetails[] =
499 $title[$detail['COUNTRY_ID']] . ': ' . $detail[$key];
500 }
501 }
502 }
503 }
504
505 $objDocument['BANKING_DETAILS'] = implode(self::COMMA, $tmpDetails);
506 break;
507 case 'MODIFY_BY_ID':
508 case 'CREATED_BY_ID':
509 if ($objDocument[$usedField] > 1)
510 {
511 $dbUsers = \CUser::GetList(
512 '',
513 '',
514 ['ID' => $objDocument[$usedField]],
515 [
516 'FIELDS' => [
517 'NAME',
518 'LAST_NAME'
519 ]
520 ]
521 );
522
523 $arUser = is_object($dbUsers)? $dbUsers->Fetch() : null;
524 $objDocument[$usedField] =
525 is_array($arUser)? implode(" ", [
526 $arUser['NAME'],
527 $arUser['LAST_NAME']
528 ]
529 ) : '';
530
531 }
532
533 break;
534 case 'CONTACT_ID':
535 $contactID = \Bitrix\Crm\Binding\ContactCompanyTable::getCompanyContactIDs($objDocument['ID']);
536 $contact = \CCrmContact::GetByID(
537 $contactID[0]
538 );
539 if(!empty($contact))
540 {
541 $objDocument['CONTACT_ID'] = implode(" ", [
542 $contact['NAME'],
543 $contact['LAST_NAME']
544 ]
545 );
546 }
547 break;
548 case 'COMPANY_ID':
549 $objDocument['COMPANY_ID'] = \CCrmCompany::GetByID(
550 $objDocument['COMPANY_ID']
551 )['TITLE'];
552 break;
553 case 'COMPANY_IDS':
554 $contactCompany = "\Bitrix\Crm\Binding\ContactCompanyTable";
555 $companies = $contactCompany::getContactCompanyIDs(
556 $objDocument['ID']
557 );
558
559 $companiesTitle = [];
560 foreach ($companies as $company)
561 {
562 $companiesTitle[] = \CCrmCompany::GetByID(
563 $company
564 )['TITLE'];
565 }
566 $objDocument['COMPANY_IDS'] = implode(', ', $companiesTitle);
567 break;
568 case 'IS_RETURN_CUSTOMER':
569 case 'ASSIGNED_BY.ACTIVE':
570 case 'OPENED':
571 case 'EXPORT':
572 $objDocument[$usedField] = $objDocument[$usedField] === 'Y'
573 ? GetMessage('CRM_FIELDS_TYPE_B_VALUE_YES') : GetMessage('CRM_FIELDS_TYPE_B_VALUE_NO');
574 break;
575 case 'HONORIFIC':
576 $honorifics = \CCrmStatus::GetStatus('HONORIFIC');
577 $objDocument['HONORIFIC'] = $honorifics[$objDocument['HONORIFIC']]['NAME'];
578 break;
579 case 'ORIGINATOR_ID':
583 $originator = \CCrmExternalSale::GetList([],[
584 ['=ID' => $objDocument['ORIGINATOR_ID']]
585 ])->Fetch();
586
587 if(isset($originator[0]))
588 {
589 $objDocument['ORIGINATOR_ID'] = $originator[0]['NAME'];
590 }
591 break;
592 case 'INDUSTRY':
593 $sources = \CCrmStatus::GetStatus('INDUSTRY');
594 $objDocument['INDUSTRY'] = $sources[$objDocument['INDUSTRY']]['NAME'];
595 break;
596 case 'SOURCE_ID':
597 $sources = \CCrmStatus::GetStatus('SOURCE');
598 $objDocument['SOURCE_ID'] = $sources[$objDocument['SOURCE_ID']]['NAME'];
599 break;
600 case 'COMPANY_TYPE':
601 $types = \CCrmStatus::GetStatus('COMPANY_TYPE');
602 $objDocument['COMPANY_TYPE'] = $types[$objDocument['COMPANY_TYPE']]['NAME'];
603 break;
604 case 'TYPE_ID':
605 $types = \CCrmStatus::GetStatus('CONTACT_TYPE');
606 $objDocument['TYPE_ID'] = $types[$objDocument['TYPE_ID']]['NAME'];
607 break;
608 case 'STATUS_ID':
609 $statuses = \CCrmStatus::GetStatus('STATUS');
610 $objDocument['STATUS_ID'] = $statuses[$objDocument['STATUS_ID']]['NAME'];
611 break;
612 case 'EMPLOYEES':
613 $employees = \CCrmStatus::GetStatus('EMPLOYEES');
614 $objDocument['EMPLOYEES'] = $employees[$objDocument['EMPLOYEES']]['NAME'];
615 break;
616 }
617 }
618
628 protected static function getCommunicationFieldsValues($typeId, $ids)
629 {
630 $callId = Bitrix\Crm\Activity\Provider\Call::getId();
631 $emailId = Bitrix\Crm\Activity\Provider\Email::getId();
632 $olId = Bitrix\Crm\Activity\Provider\OpenLine::getId();
633 $webFormId = Bitrix\Crm\Activity\Provider\WebForm::getId();
634
635 $callDate = $emailDate = $olDate = $webFormDate = null;
636
637 $ormRes = \Bitrix\Crm\ActivityTable::getList(
638 [
639 'select' => ['END_TIME', 'PROVIDER_ID'],
640 'filter' => [
641 '=COMPLETED' => 'Y',
642 '@PROVIDER_ID' => [$callId, $emailId, $olId, $webFormId],
643 '=BINDINGS.OWNER_TYPE_ID' => $typeId,
644 '@BINDINGS.OWNER_ID' => $ids,
645 ],
646 'order' => ['END_TIME' => 'DESC']
647 ]
648 );
649
650 while ($row = $ormRes->fetch())
651 {
652 if ($callDate === null)
653 {
654 if ($row['PROVIDER_ID'] === $callId)
655 {
656 $callDate = $row['END_TIME'];
657 }
658 }
659 if ($emailDate === null)
660 {
661 if ($row['PROVIDER_ID'] === $emailId)
662 {
663 $emailDate = $row['END_TIME'];
664 }
665 }
666 if ($olDate === null)
667 {
668 if ($row['PROVIDER_ID'] === $olId)
669 {
670 $olDate = $row['END_TIME'];
671 }
672 }
673 if ($webFormDate === null)
674 {
675 if ($row['PROVIDER_ID'] === $webFormId)
676 {
677 $webFormDate = $row['END_TIME'];
678 }
679 }
680
681 if ($callDate !== null && $emailDate !== null && $olDate !== null && $webFormDate !== null)
682 {
683 break;
684 }
685 }
686
687 return [
688 'COMMUNICATIONS.LAST_CALL_DATE' => (string)$callDate,
689 'COMMUNICATIONS.LAST_EMAIL_DATE' => (string)$emailDate,
690 'COMMUNICATIONS.LAST_OL_DATE' => (string)$olDate,
691 'COMMUNICATIONS.LAST_FORM_DATE' => (string)$webFormDate,
692 ];
693 }
694}
static processUserFieldValues(array $userFieldsSettings, array &$userFieldValues)
static getData(string $entityType, array $entityIds, array $usedFields=[' *'], string $sortBy='id', string $sortOrder='asc')