1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
querydata.php
См. документацию.
1<?php
8
9namespace Bitrix\Sender\Integration\Crm\Connectors;
10
11use Bitrix\Main\DB\Result;
12use Bitrix\Main\Entity;
13use Bitrix\Main\Localization\Loc;
14use Bitrix\Sender\Recipient;
15use Bitrix\Sender\UI\PageNavigation;
16
17Loc::loadMessages(__FILE__);
18
24{
33 public static function getUnionizedQuery(array $queries, $dataTypeId = null, PageNavigation $nav = null)
34 {
35 foreach ($queries as $query)
36 {
37 self::prepare($query, $dataTypeId);
38 }
39
40 $query = array_pop($queries);
41 foreach ($queries as $unionQuery)
42 {
43 $query->unionAll($unionQuery);
44 }
45
46 if ($nav)
47 {
48 if (empty($queries))
49 {
50 $query->setOffset($nav->getOffset());
51 $query->setLimit($nav->getLimit());
52 }
53 else
54 {
55 $query->setUnionOffset($nav->getOffset());
56 $query->setUnionLimit($nav->getLimit());
57 }
58 }
59
60 return $query;
61 }
62
69 public static function getUnionizedData(Entity\Query $query)
70 {
71 return self::exec($query);
72 }
73
74 private static function prepare(Entity\Query $query, $dataTypeId = null)
75 {
77 foreach ($fields as $alias => $field)
78 {
79 if (is_numeric($alias))
80 {
81 $alias = '';
82 }
83
84 $query->addGroup('ID');
85 $query->addSelect($field, $alias);
86 }
87
88 return Helper::prepareQuery($query, $dataTypeId);
89 }
90
91 private static function exec(Entity\Query $query)
92 {
93 $result = $query->exec();
94 $result->addFetchDataModifier(
95 function ($data)
96 {
97 {
98 if (isset($data['EMAIL_MAILING']) && $data['EMAIL_MAILING'])
99 {
100 $data['EMAIL'] = $data['EMAIL_MAILING'];
101 }
102 elseif (isset($data['EMAIL_HOME']) && $data['EMAIL_HOME'])
103 {
104 $data['EMAIL'] = $data['EMAIL_HOME'];
105 }
106 else if (isset($data['EMAIL_WORK']) && $data['EMAIL_WORK'])
107 {
108 $data['EMAIL'] = $data['EMAIL_WORK'];
109 }
110 }
111
112 {
113 if (isset($data['PHONE_MAILING']) && $data['PHONE_MAILING'])
114 {
115 $data['PHONE'] = $data['PHONE_MAILING'];
116 }
117 elseif (isset($data['PHONE_MOBILE']) && $data['PHONE_MOBILE'])
118 {
119 $data['PHONE'] = $data['PHONE_MOBILE'];
120 }
121 else if (isset($data['PHONE_WORK']) && $data['PHONE_WORK'])
122 {
123 $data['PHONE'] = $data['PHONE_WORK'];
124 }
125 }
126
127 return $data;
128 }
129 );
130
131 return $result;
132 }
133
141 public static function getData(Entity\Query $query, $dataTypeId = null)
142 {
143 self::prepare($query, $dataTypeId);
144 return self::exec($query);
145 }
146
147 protected static function getSelectFields($dataTypeId = null)
148 {
149 $fields = array();
150
151 $map = array(
152 Recipient\Type::EMAIL => array('EMAIL'), //array('EMAIL_HOME', 'EMAIL_WORK'),
153 Recipient\Type::PHONE => array('PHONE'), //array('PHONE_WORK', 'PHONE_MOBILE'),
154 Recipient\Type::IM => array('IM' => 'IMOL'),
155 Recipient\Type::CRM_CONTACT_ID => array('CRM_CONTACT_ID'),
156 Recipient\Type::CRM_COMPANY_ID => array('CRM_COMPANY_ID'),
157 );
158 if ($dataTypeId)
159 {
160 if (isset($map[$dataTypeId]))
161 {
162 $fields = $map[$dataTypeId];
163 }
164 }
165 else
166 {
167 $fields = call_user_func_array('array_merge', array_values($map));
168 }
169
170 return $fields;
171 }
172}
static getData(Entity\Query $query, $dataTypeId=null)
Определения querydata.php:141
static getUnionizedQuery(array $queries, $dataTypeId=null, PageNavigation $nav=null)
Определения querydata.php:33
static getSelectFields($dataTypeId=null)
Определения querydata.php:147
static getUnionizedData(Entity\Query $query)
Определения querydata.php:69
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$query
Определения get_search.php:11
$map
Определения config.php:5
Определения ufield.php:9
Определения chain.php:3
Определения agent.php:8
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$fields
Определения yandex_run.php:501