1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
sale_report_helper.php
См. документацию.
1<?php
2
3if (!CModule::IncludeModule('report'))
4 return;
5if (!CModule::IncludeModule('currency'))
6 return;
7
11
13{
14 // names of base entities for report construction (name with 0 index is default)
15 private static $owners = array();
16
17 private static $fInit = false;
18 private static $fOwnersInit = false;
19 protected static $fDecimalQuant = false;
20
21 protected static $iblockSite = array();
22 protected static $sitelist = array();
23 protected static $defaultSiteId = '';
24 protected static $siteCookieId = '';
25
26 protected static $statuslist = array();
27 protected static $paySystemList = array();
28 protected static $deliveryList = array();
29 protected static $catalogSections = array();
30 protected static $catalogs = array();
31 protected static $productStores = array();
32 protected static $genders = array();
33 protected static $personTypes = array();
34 protected static $weightOptions = array();
35 protected static $priceTypes = array();
36 protected static $bUsePriceTypesColumns = false;
37 protected static $currencies = array();
38 protected static $reportCurrencyId = null;
39 protected static $siteCurrencyId = '';
40
41 private static function localUpdate_17_5_0()
42 {
43 $res = \Bitrix\Report\ReportTable::getList(
44 array(
45 'select' => array('ID', 'TITLE', 'SETTINGS'),
46 'filter' => array(
47 '=OWNER_ID' => 'sale_SaleProduct',
48 '=CREATED_BY' => $GLOBALS['USER']->GetID(),
49 '=MARK_DEFAULT' => 7
50 )
51 )
52 );
53 while ($row = $res->fetch())
54 {
55 $id = (int)$row['ID'];
56 $title = $row['TITLE'];
57 if (is_string($title) && $title <> '')
58 {
59 $titleMsg = GetMessage('SALE_REPORT_DEFAULT_MOST_EXPECTED_GOODS');
60 if ($title === $titleMsg && is_string($row['SETTINGS']) && $row['SETTINGS'] <> '')
61 {
62 $settings = unserialize($row['SETTINGS'], ['allowed_classes' => false]);
63 if (is_array($settings))
64 {
65 $needUpdate = false;
66 $aliasMap = array(0 => 0, 1 => 1, 2 => 5, 3 => 8);
67 foreach ($aliasMap as $aliasNum => $msgNum)
68 {
69 if (isset($settings['select'][$aliasNum]['alias'])
70 && is_string($settings['select'][$aliasNum]['alias'])
71 && $settings['select'][$aliasNum]['alias'] <> '')
72 {
73 $alias = $settings['select'][$aliasNum]['alias'];
74 $aliasMsg = GetMessage('SALE_REPORT_DEFAULT_MOST_EXPECTED_GOODS_ALIAS_'.$msgNum);
75 if (is_string($aliasMsg) && $aliasMsg <> '' && $alias !== $aliasMsg)
76 {
77 $settings['select'][$aliasNum]['alias'] = $aliasMsg;
78 $needUpdate = true;
79 }
80 }
81 }
82 if ($needUpdate)
83 {
84 Bitrix\Report\ReportTable::update($id, array('SETTINGS' => serialize($settings)));
85 }
86 }
87 }
88 }
89 }
90
91 CUserOptions::DeleteOption('sale', '~SALE_REPORT_NEED_UPDATE_17_5_0');
92 }
93
94 private static function localUpdate()
95 {
96 $updateCodes = array('~SALE_REPORT_NEED_UPDATE_17_5_0');
97
98 $needUpdate = array();
99 foreach ($updateCodes as $updateCode)
100 {
101 if (\Bitrix\Main\Config\Option::get('sale', $updateCode, 'N') === 'Y'
102 || CUserOptions::GetOption('sale', $updateCode) === 'Y')
103 {
104 $needUpdate[] = $updateCode;
105 }
106 }
107
108 foreach ($needUpdate as $updateCode)
109 {
110 switch ($updateCode)
111 {
112 case '~SALE_REPORT_NEED_UPDATE_17_5_0';
113 self::localUpdate_17_5_0();
114 break;
115 }
116 }
117 }
118
119 public static function init()
120 {
121 IncludeModuleLangFile(__FILE__);
122
123 if (!self::$fInit)
124 {
125 self::$fInit = true;
126
127 self::localUpdate();
128
129 self::$siteCookieId = md5('SALE_REPORT_SITE_ID');
130
131 // Initializing list of sites.
132 $result = Bitrix\Main\SiteTable::getList(array('select' => array('LID', 'DEF', 'NAME')));
133 $i = 0;
134 while ($row = $result->fetch())
135 {
136 self::$sitelist[$row['LID']] = $row['NAME'];
137 if (++$i === 1) self::$defaultSiteId = $row['LID'];
138 else if ($row['DEF'] === 'Y') self::$defaultSiteId = $row['LID'];
139 self::$weightOptions[$row['LID']] = array(
140 'unit' => COption::GetOptionString('sale', 'weight_unit', null, $row['LID']),
141 'koef' => COption::GetOptionInt('sale', 'weight_koef', null, $row['LID'])
142 );
143 }
144 unset($i, $row, $result);
145
146 // hack, add virtual ID field into StatusLang entity for filtering
147 $statusEntity = Entity\Base::getInstance('\Bitrix\Sale\Internals\StatusLang');
148 if ($statusEntity instanceof \Bitrix\Main\Entity\Base)
149 {
150 $statusEntity->addField(
151 array(
152 'data_type' => 'string',
153 'expression' => array('%s', 'STATUS_ID')
154 ),
155 'ID'
156 );
157 }
158 unset($statusEntity);
159
160 // hack, add virtual REPS_ORDER field into Shipment entity for filtering system records
161 $shipmentEntity = Entity\Base::getInstance('\Bitrix\Sale\Internals\Shipment');
162 if ($shipmentEntity instanceof \Bitrix\Main\Entity\Base)
163 {
164 $shipmentEntity->addField(
165 array(
166 'data_type' => 'Order',
167 'reference' => array(
168 '=ref.ID' => 'this.ORDER_ID',
169 '!=this.SYSTEM' => array('?', 'Y')
170 )
171 ),
172 'REPS_ORDER'
173 );
174 }
175 unset($shipmentEntity);
176
177 // Initializing list of statuses of orders.
178 $result = Bitrix\Sale\Internals\StatusLangTable::getList(array(
179 'select' => array('STATUS_ID', 'NAME'),
180 'filter' => array('=LID' => LANGUAGE_ID)
181 ));
182 while ($row = $result->fetch())
183 {
184 self::$statuslist[$row['STATUS_ID']] = $row['NAME'];
185 }
186 unset($row, $result);
187
188 self::$genders = array('M' => GetMessage('USER_MALE'), 'F' => GetMessage('USER_FEMALE'));
189
190 // Initializing list of person types.
191 $result = Bitrix\Sale\Internals\PersonTypeTable::getList(array(
192 'select' => array('ID', 'LID', 'NAME')/*,
193 'filter' => array('=ACTIVE', 'Y')*/
194 ));
195 while ($row = $result->fetch())
196 {
197 self::$personTypes[$row['ID']] = array('LID' => $row['LID'], 'NAME' => $row['NAME']);
198 }
199 unset($row, $result);
200
201 // Initializing list of pay systems of orders.
203 'select' => array('ID', 'NAME')/*,
204 'filter' => array('=ACTIVE', 'Y')*/
205 ));
206 while ($row = $result->fetch())
207 {
208 self::$paySystemList[$row['ID']] = array('value' => $row['NAME'], 'site_id' => '');
209 }
210 unset($row, $result);
211
212 // Initializing list of services and methods of delivery.
213 $result = \Bitrix\Sale\Delivery\Services\Table::getList(array(
214 'select' => array('ID', 'NAME')/*,
215 'filter' => array('=ACTIVE', 'Y')*/
216 ));
217 while ($row = $result->fetch())
218 {
219 self::$deliveryList[$row['ID']] = array('value' => $row['NAME'], 'site_id' => '');
220 }
221 unset($row, $result);
222
223 // Obtaining table of correspondences of iblocks to sites.
224 $result = Bitrix\Iblock\IblockSiteTable::getList();
225 while ($row = $result->fetch()) self::$iblockSite[$row['SITE_ID']][] = $row['IBLOCK_ID'];
226 unset($row, $result);
227
228 // Obtaining the list of iblocks which are directories and filling
229 // a property $catalogSections with sections of these units.
230 $ent = new CCatalog();
231 $result = $ent->GetList();
232 while ($ibRow = $result->Fetch())
233 {
234 // Obtaining list of sections of the catalog.
235 self::$catalogs[] = $ibRow;
236 $path = array();
237 $curLevel = $prevLevel = 0;
238 $sections = CIBlockSection::GetTreeList(array('=IBLOCK_ID'=>$ibRow['IBLOCK_ID']), array('ID', 'IBLOCK_ID', 'NAME', 'DEPTH_LEVEL', 'LEFT_MARGIN'));
239 $row = null;
240 while($row = $sections->GetNext())
241 {
242 // Formation of an array of identifiers of current and parent sections.
243 $curLevel = $row['DEPTH_LEVEL'];
244 for ($i = 0; $i <= $prevLevel - $curLevel; $i++) array_pop($path);
245 array_push($path, $row['ID']);
246 $prevLevel = $curLevel;
247
248 self::$catalogSections[$row['ID']] = array(
249 'name' => ltrim(str_repeat(' . ', $curLevel).$row['NAME']),
250 'path' => $path,
251 'catalog' => array(
252 'ID' => $ibRow['ID'],
253 'NAME' => $ibRow['NAME']
254 )
255 );
256 }
257 }
258 unset($ent, $ibRow, $row, $sections, $result);
259
260 // Initialization of the list of warehouses.
261 $result = Bitrix\Catalog\StoreTable::getList(array('select' => array('ID', 'TITLE')));
262 while ($row = $result->fetch())
263 {
264 self::$productStores[$row['ID']] = $row['TITLE'];
265 }
266 unset($row, $result);
267
268 // Getting currencies
269 $obj = new CCurrency();
270 $result = $obj->GetList('', '', LANGUAGE_ID);
271 while($row = $result->Fetch())
272 {
273 self::$currencies[$row['CURRENCY']] = array(
274 'name' => $row['FULL_NAME']
275 );
276 }
277 unset($row, $result, $obj);
278
279 // Getting types of prices
280 $obj = new CCatalogGroup();
281 $result = $obj->GetListEx(array('SORT'), array(), false, false, array('ID', 'NAME', 'BASE', 'NAME_LANG'));
282 while($row = $result->Fetch())
283 {
284 self::$priceTypes[$row['ID']] = array(
285 'name' => (empty($row['NAME_LANG'])) ? $row['NAME'] : $row['NAME_LANG'],
286 'base' => ($row['BASE'] === 'Y') ? true : false
287 );
288 }
289 unset($row, $result, $obj);
290
291 // Getting option, which means, it is necessary to display a fractional quantity of goods of no.
292 self::$fDecimalQuant = COption::GetOptionString('sale', 'QUANTITY_FACTORIAL') == 'Y';
293
295 }
296 }
297
298 public static function isInitialized()
299 {
300 return self::$fInit;
301 }
302
303 public static function initOwners()
304 {
305 if (!self::$fOwnersInit)
306 {
307 self::$fOwnersInit = true;
312 }
313
314 }
315
316 public static function getSiteList()
317 {
318 return self::$sitelist;
319 }
320
321 public static function getWeightOptions()
322 {
323 return self::$weightOptions;
324 }
325
326 public static function getPriceTypes()
327 {
328 return self::$priceTypes;
329 }
330
331 public static function setSelectedPriceTypes($arSelected)
332 {
333 $bSelected = false;
334 reset(self::$priceTypes);
335 $basePriceTypeKey = key(self::$priceTypes);
336 foreach (self::$priceTypes as $priceTypeKey => $priceTypeInfo)
337 {
338 if ($priceTypeInfo['base'] === true) $basePriceTypeKey = $priceTypeKey;
339 if (in_array($priceTypeKey, $arSelected, true))
340 {
341 self::$priceTypes[$priceTypeKey]['selected'] = true;
342 $bSelected = true;
343 }
344 }
345 if (!$bSelected) self::$priceTypes[$basePriceTypeKey]['selected'] = true;
346 }
347
348 public static function getCurrencies()
349 {
350 return self::$currencies;
351 }
352
353 public static function setSelectedCurrency($currencyId)
354 {
355 $currenciesIds = array_keys(self::$currencies);
356 if (in_array($currencyId, $currenciesIds, true))
357 {
358 self::$currencies[$currencyId]['selected'] = true;
359 self::$reportCurrencyId = $currencyId;
360 }
361 else
362 {
363 self::$currencies[$currenciesIds[0]]['selected'] = true;
364 self::$reportCurrencyId = $currenciesIds[0];
365 }
366 }
367
368 public static function setSiteCurrencyId($currencyId)
369 {
370 self::$siteCurrencyId = $currencyId;
371 }
372
373 public static function getSiteCurrencyId()
374 {
375 return self::$siteCurrencyId;
376 }
377
378 public static function getReportCurrencyId()
379 {
380 return self::$reportCurrencyId;
381 }
382
383 public static function getSiteCookieId()
384 {
385 return self::$siteCookieId;
386 }
387
388 public static function getStatusList()
389 {
390 return self::$statuslist;
391 }
392
393 public static function getGenders()
394 {
395 return self::$genders;
396 }
397
398 public static function getPersonTypes()
399 {
400 return self::$personTypes;
401 }
402
403 public static function getDefaultSiteId()
404 {
405 return self::$defaultSiteId;
406 }
407
408 public static function isCatalogCorrespondsDefSite($catalogId)
409 {
410 $result = false;
412 if (in_array($catalogId, self::$iblockSite[$siteId])) $result = true;
413 return $result;
414 }
415
416 public static function getDefaultSiteWeightUnits()
417 {
418 return self::$weightOptions[self::$defaultSiteId]['unit'];
419 }
420
421 public static function getDefaultSiteWeightDivider()
422 {
423 return self::$weightOptions[self::$defaultSiteId]['koef'];
424 }
425
426 public static function setDefaultSiteId($siteId)
427 {
428 self::$defaultSiteId = $siteId;
429 }
430
431 public static function getPaySystemList()
432 {
433 return self::$paySystemList;
434 }
435
436 public static function getDeliveryList()
437 {
438 return self::$deliveryList;
439 }
440
441 protected static function addOwner($ownerName)
442 {
443 if (!in_array($ownerName, self::$owners)) self::$owners[] = $ownerName;
444 }
445
446 public static function getOwners()
447 {
448 IncludeModuleLangFile(__FILE__);
449
450 return self::$owners;
451 }
452
453 public static function getCatalogSections()
454 {
455 return self::$catalogSections;
456 }
457
458 public static function getProductStores()
459 {
460 return self::$productStores;
461 }
462
463 public static function getHelperByOwner($ownerId)
464 {
465 return 'CSaleReport'.mb_substr($ownerId, mb_strlen(SALE_REPORT_OWNER_ID) + 1).'Helper';
466 }
467
468 public static function getDefaultReports()
469 {
470 IncludeModuleLangFile(__FILE__);
471
472 $reports = array(
473 '12.0.0' => array(
474 array(
475 'owner' => 'sale_SaleBasket',
476 'title' => GetMessage('SALE_REPORT_DEFAULT_LEFT_BASKETS'),
477 'description' => GetMessage('SALE_REPORT_DEFAULT_LEFT_BASKETS_DESCR'),
478 'mark_default' => 1,
479 'settings' => unserialize('a:7:{s:6:"entity";s:10:"SaleBasket";s:6:"period";a:2:{s:4:"type";'.
480 's:5:"month";s:5:"value";N;}s:6:"select";a:7:{i:10;a:1:{s:4:"name";s:8:"FUSER_ID";}i:1;'.
481 'a:1:{s:4:"name";s:21:"FUSER.USER.SHORT_NAME";}i:2;a:1:{s:4:"name";s:16:"FUSER.USER.EMAIL";'.
482 '}i:6;a:3:{s:4:"name";s:8:"QUANTITY";s:5:"alias";s:14:"xxxxxxxxxxxxxx";s:4:"aggr";s:3:"SUM";'.
483 '}i:7;a:3:{s:4:"name";s:13:"SUMMARY_PRICE";s:5:"alias";s:17:"xxxxxxxxxxxxxxxxx";s:4:"aggr";'.
484 's:3:"SUM";}i:4;a:3:{s:4:"name";s:8:"DATE_INS";s:5:"alias";s:13:"xxxxxxxxxxxxx";s:4:"aggr";'.
485 's:3:"MIN";}i:5;a:3:{s:4:"name";s:8:"DATE_UPD";s:5:"alias";s:14:"xxxxxxxxxxxxxx";s:4:"aggr";'.
486 's:3:"MAX";}}s:6:"filter";a:1:{i:0;a:3:{i:0;a:5:{s:4:"type";s:5:"field";s:4:"name";'.
487 's:8:"ORDER_ID";s:7:"compare";s:5:"EQUAL";s:5:"value";s:1:"0";s:10:"changeable";s:1:"0";}i:1;'.
488 'a:5:{s:4:"type";s:5:"field";s:4:"name";s:31:"FUSER.USER.UserGroup:USER.GROUP";s:7:"compare";'.
489 's:5:"EQUAL";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}s:5:"LOGIC";s:3:"AND";}}s:4:"sort";'.
490 'i:7;s:9:"sort_type";s:4:"DESC";s:5:"limit";N;}'
491 )
492 ),
493 array(
494 'owner' => 'sale_SaleBasket',
495 'title' => GetMessage('SALE_REPORT_DEFAULT_GOODS_PROFIT'),
496 'description' => GetMessage('SALE_REPORT_DEFAULT_GOODS_PROFIT_DESCR'),
497 'mark_default' => 2,
498 'settings' => unserialize('a:7:{s:6:"entity";s:10:"SaleBasket";s:6:"period";a:2:{s:4:"type";'.
499 's:3:"all";s:5:"value";N;}s:6:"select";a:7:{i:1;a:1:{s:4:"name";s:10:"PRODUCT_ID";}i:2;'.
500 'a:1:{s:4:"name";s:4:"NAME";}i:14;a:2:{s:4:"name";s:16:"PRODUCT.QUANTITY";s:5:"alias";'.
501 's:14:"xxxxxxxxxxxxxx";}i:3;a:3:{s:4:"name";s:8:"ORDER_ID";s:5:"alias";'.
502 's:14:"xxxxxxxxxxxxxx";s:4:"aggr";s:14:"COUNT_DISTINCT";}i:5;a:3:{s:4:"name";s:8:"QUANTITY";'.
503 's:5:"alias";s:20:"xxxxxxxxxxxxxxxxxxxx";s:4:"aggr";s:3:"SUM";}i:4;a:3:{s:4:"name";'.
504 's:5:"PRICE";s:5:"alias";s:19:"xxxxxxxxxxxxxxxxxxx";s:4:"aggr";s:3:"AVG";}i:6;a:3:{s:4:"name";'.
505 's:13:"SUMMARY_PRICE";s:5:"alias";s:5:"xxxxx";s:4:"aggr";s:3:"SUM";}}s:6:"filter";a:1:{i:0;'.
506 'a:6:{i:0;a:5:{s:4:"type";s:5:"field";s:4:"name";s:11:"ORDER.PAYED";s:7:"compare";s:5:"EQUAL";'.
507 's:5:"value";s:4:"true";s:10:"changeable";s:1:"0";}i:1;a:5:{s:4:"type";s:5:"field";s:4:"name";'.
508 's:23:"ORDER.DATE_INSERT_SHORT";s:7:"compare";s:16:"GREATER_OR_EQUAL";s:5:"value";s:8:"-29 days";'.
509 's:10:"changeable";s:1:"1";}i:2;a:5:{s:4:"type";s:5:"field";s:4:"name";'.
510 's:23:"ORDER.DATE_INSERT_SHORT";s:7:"compare";s:13:"LESS_OR_EQUAL";s:5:"value";s:5:"1 day";'.
511 's:10:"changeable";s:1:"1";}i:3;a:5:{s:4:"type";s:5:"field";s:4:"name";s:4:"NAME";'.
512 's:7:"compare";s:8:"CONTAINS";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}i:4;'.
513 'a:5:{s:4:"type";s:5:"field";s:4:"name";s:33:"PRODUCT.GoodsSection:PRODUCT.SECT";'.
514 's:7:"compare";s:5:"EQUAL";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}s:5:"LOGIC";'.
515 's:3:"AND";}}s:4:"sort";i:6;s:9:"sort_type";s:4:"DESC";s:5:"limit";N;}'
516 )
517 ),
518 array(
519 'owner' => 'sale_SaleProduct',
520 'title' => GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES'),
521 'description' => GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES_DESCR'),
522 'mark_default' => 3,
523 'settings' => unserialize('a:7:{s:6:"entity";s:11:"SaleProduct";s:6:"period";a:2:{s:4:"type";'.
524 's:3:"all";s:5:"value";N;}s:6:"select";a:5:{i:0;a:1:{s:4:"name";s:2:"ID";}i:2;a:1:{s:4:"name";'.
525 's:4:"NAME";}i:1;a:2:{s:4:"name";s:8:"QUANTITY";s:5:"alias";s:7:"xxxxxxx";}i:3;'.
526 'a:2:{s:4:"name";s:22:"PRICE_IN_SITE_CURRENCY";s:5:"alias";s:4:"xxxx";}i:5;a:2:{s:4:"name";'.
527 's:30:"SUMMARY_PRICE_IN_SITE_CURRENCY";s:5:"alias";s:15:"xxxxxxxxxxxxxxx";}}s:6:"filter";'.
528 'a:1:{i:0;a:10:{i:0;a:5:{s:4:"type";s:5:"field";s:4:"name";s:4:"NAME";s:7:"compare";'.
529 's:8:"CONTAINS";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}i:1;a:5:{s:4:"type";s:5:"field";'.
530 's:4:"name";s:51:"IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION";s:7:"compare";'.
531 's:5:"EQUAL";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}i:2;a:5:{s:4:"type";s:5:"field";'.
532 's:4:"name";s:8:"QUANTITY";s:7:"compare";s:16:"GREATER_OR_EQUAL";s:5:"value";s:0:"";'.
533 's:10:"changeable";s:1:"1";}i:3;a:5:{s:4:"type";s:5:"field";s:4:"name";s:8:"QUANTITY";'.
534 's:7:"compare";s:13:"LESS_OR_EQUAL";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}i:4;'.
535 'a:5:{s:4:"type";s:5:"field";s:4:"name";s:22:"PRICE_IN_SITE_CURRENCY";s:7:"compare";'.
536 's:16:"GREATER_OR_EQUAL";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}i:5;a:5:{s:4:"type";'.
537 's:5:"field";s:4:"name";s:22:"PRICE_IN_SITE_CURRENCY";s:7:"compare";s:13:"LESS_OR_EQUAL";'.
538 's:5:"value";s:0:"";s:10:"changeable";s:1:"1";}i:6;a:5:{s:4:"type";s:5:"field";s:4:"name";'.
539 's:30:"SUMMARY_PRICE_IN_SITE_CURRENCY";s:7:"compare";s:16:"GREATER_OR_EQUAL";s:5:"value";'.
540 's:0:"";s:10:"changeable";s:1:"1";}i:7;a:5:{s:4:"type";s:5:"field";s:4:"name";'.
541 's:30:"SUMMARY_PRICE_IN_SITE_CURRENCY";s:7:"compare";s:13:"LESS_OR_EQUAL";s:5:"value";s:0:"";'.
542 's:10:"changeable";s:1:"1";}i:8;a:5:{s:4:"type";s:5:"field";s:4:"name";s:6:"ACTIVE";'.
543 's:7:"compare";s:5:"EQUAL";s:5:"value";s:4:"true";s:10:"changeable";s:1:"1";}s:5:"LOGIC";'.
544 's:3:"AND";}}s:4:"sort";i:1;s:9:"sort_type";s:3:"ASC";s:5:"limit";N;}'
545 )
546 ),
547 array(
548 'owner' => 'sale_SaleOrder',
549 'title' => GetMessage('SALE_REPORT_DEFAULT_BEST_CLIENTS'),
550 'description' => GetMessage('SALE_REPORT_DEFAULT_BEST_CLIENTS_DESCR'),
551 'mark_default' => 4,
552 'settings' => unserialize(
553 'a:7:{s:6:"entity";s:9:"SaleOrder";s:6:"period";a:2:{s:4:"type";s:5:"month";s:5:"value";N;}'.
554 's:6:"select";a:7:{i:7;a:1:{s:4:"name";s:7:"USER.ID";}i:6;a:1:{s:4:"name";'.
555 's:15:"USER.SHORT_NAME";}i:0;a:3:{s:4:"name";s:2:"ID";s:5:"alias";s:14:"xxxxxxxxxxxxxx";'.
556 's:4:"aggr";s:14:"COUNT_DISTINCT";}i:2;a:3:{s:4:"name";s:14:"PRODUCTS_QUANT";s:5:"alias";'.
557 's:14:"xxxxxxxxxxxxxx";s:4:"aggr";s:3:"SUM";}i:3;a:3:{s:4:"name";s:12:"DISCOUNT_ALL";'.
558 's:5:"alias";s:15:"xxxxxxxxxxxxxxx";s:4:"aggr";s:3:"SUM";}i:14;a:3:{s:4:"name";'.
559 's:15:"SUM_PAID_FORREP";s:5:"alias";s:13:"xxxxxxxxxxxxx";s:4:"aggr";s:3:"AVG";}i:5;'.
560 'a:3:{s:4:"name";s:15:"SUM_PAID_FORREP";s:5:"alias";s:16:"xxxxxxxxxxxxxxxx";s:4:"aggr";'.
561 's:3:"SUM";}}s:6:"filter";a:1:{i:0;a:4:{i:0;a:5:{s:4:"type";s:5:"field";s:4:"name";'.
562 's:4:"USER";s:7:"compare";s:5:"EQUAL";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}i:1;'.
563 'a:5:{s:4:"type";s:5:"field";s:4:"name";s:25:"USER.UserGroup:USER.GROUP";s:7:"compare";'.
564 's:5:"EQUAL";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}i:2;a:5:{s:4:"type";'.
565 's:5:"field";s:4:"name";s:5:"PAYED";s:7:"compare";s:5:"EQUAL";s:5:"value";s:4:"true";'.
566 's:10:"changeable";s:1:"1";}s:5:"LOGIC";s:3:"AND";}}s:4:"sort";i:5;s:9:"sort_type";'.
567 's:4:"DESC";s:5:"limit";N;}'
568 )
569 ),
570 array(
571 'owner' => 'sale_User',
572 'title' => GetMessage('SALE_REPORT_DEFAULT_NEW_CLIENTS'),
573 'description' => GetMessage('SALE_REPORT_DEFAULT_NEW_CLIENTS_DESCR'),
574 'mark_default' => 5,
575 'settings' => unserialize('a:7:{s:6:"entity";s:16:"Bitrix\Main\User";s:6:"period";a:2:{s:4:"type";s:5:"month";'.
576 's:5:"value";N;}s:6:"select";a:7:{i:11;a:1:{s:4:"name";s:14:"DATE_REG_SHORT";}i:0;'.
577 'a:3:{s:4:"name";s:2:"ID";s:5:"alias";s:18:"xxxxxxxxxxxxxxxxxx";s:4:"aggr";'.
578 's:14:"COUNT_DISTINCT";}i:3;a:3:{s:4:"name";s:35:"Bitrix\Sale\Internals\Order:USER.ID";s:5:"alias";'.
579 's:14:"xxxxxxxxxxxxxx";s:4:"aggr";s:14:"COUNT_DISTINCT";}i:4;a:3:{s:4:"name";'.
580 's:45:"Bitrix\Sale\Internals\Order:USER.DISCOUNT_ALL";s:5:"alias";s:15:"xxxxxxxxxxxxxxx";'.
581 's:4:"aggr";s:3:"SUM";}i:9;a:3:{s:4:"name";s:38:"Bitrix\Sale\Internals\Order:USER.PRICE";'.
582 's:5:"alias";s:13:"xxxxxxxxxxxxx";s:4:"aggr";s:3:"AVG";}i:5;a:3:{s:4:"name";'.
583 's:38:"Bitrix\Sale\Internals\Order:USER.PRICE";s:5:"alias";s:16:"xxxxxxxxxxxxxxxx";s:4:"aggr";'.
584 's:3:"SUM";}i:6;a:3:{s:4:"name";s:48:"Bitrix\Sale\Internals\Order:USER.SUM_PAID_FORREP";'.
585 's:5:"alias";s:8:"xxxxxxxx";s:4:"aggr";s:3:"SUM";}}s:6:"filter";a:1:{i:0;a:2:{i:0;'.
586 'a:5:{s:4:"type";s:5:"field";s:4:"name";s:20:"UserGroup:USER.GROUP";s:7:"compare";'.
587 's:5:"EQUAL";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}s:5:"LOGIC";s:3:"AND";}}'.
588 's:4:"sort";i:11;s:9:"sort_type";s:4:"DESC";s:5:"limit";N;}'
589 )
590 ),
591 array(
592 'owner' => 'sale_SaleOrder',
593 'title' => GetMessage('SALE_REPORT_DEFAULT_SALES'),
594 'description' => GetMessage('SALE_REPORT_DEFAULT_SALES_DESCR'),
595 'mark_default' => 6,
596 'settings' => unserialize('a:7:{s:6:"entity";s:9:"SaleOrder";s:6:"period";a:2:{s:4:"type";'.
597 's:5:"month";s:5:"value";N;}s:6:"select";a:8:{i:1;a:2:{s:4:"name";s:17:"DATE_INSERT_SHORT";'.
598 's:5:"alias";s:4:"xxxx";}i:0;a:3:{s:4:"name";s:2:"ID";s:5:"alias";s:14:"xxxxxxxxxxxxxx";'.
599 's:4:"aggr";s:14:"COUNT_DISTINCT";}i:13;a:3:{s:4:"name";s:14:"PRODUCTS_QUANT";s:5:"alias";'.
600 's:13:"xxxxxxxxxxxxx";s:4:"aggr";s:3:"SUM";}i:2;a:3:{s:4:"name";s:9:"TAX_VALUE";'.
601 's:5:"alias";s:6:"xxxxxx";s:4:"aggr";s:3:"SUM";}i:3;a:3:{s:4:"name";s:14:"PRICE_DELIVERY";'.
602 's:5:"alias";s:8:"xxxxxxxx";s:4:"aggr";s:3:"SUM";}i:4;a:3:{s:4:"name";s:12:"DISCOUNT_ALL";'.
603 's:5:"alias";s:6:"xxxxxx";s:4:"aggr";s:3:"SUM";}i:5;a:3:{s:4:"name";s:5:"PRICE";'.
604 's:5:"alias";s:16:"xxxxxxxxxxxxxxxx";s:4:"aggr";s:3:"SUM";}i:6;a:3:{s:4:"name";'.
605 's:15:"SUM_PAID_FORREP";s:5:"alias";s:8:"xxxxxxxx";s:4:"aggr";s:3:"SUM";}}s:6:"filter";'.
606 'a:1:{i:0;a:2:{i:0;a:5:{s:4:"type";s:5:"field";s:4:"name";'.
607 's:25:"USER.UserGroup:USER.GROUP";s:7:"compare";s:5:"EQUAL";s:5:"value";s:0:"";'.
608 's:10:"changeable";s:1:"1";}s:5:"LOGIC";s:3:"AND";}}s:4:"sort";i:1;s:9:"sort_type";'.
609 's:4:"DESC";s:5:"limit";N;}'
610 )
611 ),
612 array(
613 'owner' => 'sale_SaleProduct',
614 'title' => GetMessage('SALE_REPORT_DEFAULT_MOST_EXPECTED_GOODS'),
615 'description' => GetMessage('SALE_REPORT_DEFAULT_MOST_EXPECTED_GOODS_DESCR'),
616 'mark_default' => 7,
617 'settings' => unserialize('a:10:{s:6:"entity";s:29:"Bitrix\\Sale\\Internals\\Product";'.
618 's:6:"period";a:2:{s:4:"type";s:5:"month";s:5:"value";N;}s:6:"select";a:4:{i:0;a:2:{'.
619 's:4:"name";s:2:"ID";s:5:"alias";s:9:"xxxxxxxxx";}i:1;a:2:{s:4:"name";s:4:"NAME";s:5:"alias";'.
620 's:19:"xxxxxxxxxxxxxxxxxxx";}i:2;a:3:{s:4:"name";s:31:"SUBSCRIPTIONS_IN_PERIOD_BY_SHOP";'.
621 's:5:"alias";s:15:"xxxxxxxxxxxxxxx";s:4:"aggr";s:3:"SUM";}i:3;a:3:{s:4:"name";'.
622 's:22:"PRICE_IN_SITE_CURRENCY";s:5:"alias";s:15:"xxxxxxxxxxxxxxx";s:4:"aggr";s:3:"SUM";}}'.
623 's:6:"filter";a:1:{i:0;a:6:{i:0;a:5:{s:4:"type";s:5:"field";s:4:"name";'.
624 's:31:"SUBSCRIPTIONS_IN_PERIOD_BY_SHOP";s:7:"compare";s:7:"GREATER";s:5:"value";s:1:"0";'.
625 's:10:"changeable";s:1:"0";}i:1;a:5:{s:4:"type";s:5:"field";s:4:"name";s:4:"NAME";'.
626 's:7:"compare";s:8:"CONTAINS";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}i:2;a:5:{'.
627 's:4:"type";s:5:"field";s:4:"name";s:51:"IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION";'.
628 's:7:"compare";s:5:"EQUAL";s:5:"value";a:1:{i:0;s:0:"";}s:10:"changeable";s:1:"1";}i:3;a:5:{'.
629 's:4:"type";s:5:"field";s:4:"name";s:22:"PRICE_IN_SITE_CURRENCY";s:7:"compare";'.
630 's:16:"GREATER_OR_EQUAL";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}i:4;a:5:{s:4:"type";'.
631 's:5:"field";s:4:"name";s:22:"PRICE_IN_SITE_CURRENCY";s:7:"compare";s:13:"LESS_OR_EQUAL";'.
632 's:5:"value";s:0:"";s:10:"changeable";s:1:"1";}s:5:"LOGIC";s:3:"AND";}}s:4:"sort";i:0;'.
633 's:9:"sort_type";s:3:"ASC";s:5:"limit";N;s:12:"red_neg_vals";b:0;s:13:"grouping_mode";b:0;'.
634 's:5:"chart";N;}'
635 )
636 ),
637 array(
638 'owner' => 'sale_SaleProduct',
639 'title' => GetMessage('SALE_REPORT_DEFAULT_MOST_VIEWED_GOODS'),
640 'description' => GetMessage('SALE_REPORT_DEFAULT_MOST_VIEWED_GOODS_DESCR'),
641 'mark_default' => 8,
642 'settings' => unserialize('a:7:{s:6:"entity";s:11:"SaleProduct";s:6:"period";a:2:{s:4:"type";'.
643 's:5:"month";s:5:"value";N;}s:6:"select";a:7:{i:0;a:1:{s:4:"name";s:2:"ID";}i:1;'.
644 'a:1:{s:4:"name";s:4:"NAME";}i:7;a:2:{s:4:"name";s:23:"VIEWS_IN_PERIOD_BY_SHOP";s:5:"alias";'.
645 's:10:"xxxxxxxxxx";}i:8;a:2:{s:4:"name";s:24:"ORDERS_IN_PERIOD_BY_SHOP";s:5:"alias";'.
646 's:18:"xxxxxxxxxxxxxxxxxx";}i:14;a:1:{s:4:"name";s:10:"CONVERSION";}i:12;a:2:{s:4:"name";'.
647 's:32:"SALED_PRODUCTS_IN_PERIOD_BY_SHOP";s:5:"alias";s:7:"xxxxxxx";}i:5;a:2:{s:4:"name";'.
648 's:22:"PRICE_IN_SITE_CURRENCY";s:5:"alias";s:15:"xxxxxxxxxxxxxxx";}}s:6:"filter";a:1:{i:0;'.
649 'a:7:{i:0;a:5:{s:4:"type";s:5:"field";s:4:"name";s:4:"NAME";s:7:"compare";'.
650 's:8:"CONTAINS";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}i:1;a:5:{s:4:"type";s:5:"field";'.
651 's:4:"name";s:51:"IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION";s:7:"compare";'.
652 's:5:"EQUAL";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}i:2;a:5:{s:4:"type";s:5:"field";'.
653 's:4:"name";s:10:"CONVERSION";s:7:"compare";s:16:"GREATER_OR_EQUAL";s:5:"value";s:0:"";'.
654 's:10:"changeable";s:1:"1";}i:3;a:5:{s:4:"type";s:5:"field";s:4:"name";s:23:"VIEWS_IN_PERIOD_BY_SHOP";'.
655 's:7:"compare";s:16:"GREATER_OR_EQUAL";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}i:4;'.
656 'a:5:{s:4:"type";s:5:"field";s:4:"name";s:22:"PRICE_IN_SITE_CURRENCY";s:7:"compare";'.
657 's:16:"GREATER_OR_EQUAL";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}i:5;a:5:{s:4:"type";'.
658 's:5:"field";s:4:"name";s:6:"ACTIVE";s:7:"compare";s:5:"EQUAL";s:5:"value";s:4:"true";'.
659 's:10:"changeable";s:1:"0";}s:5:"LOGIC";s:3:"AND";}}s:4:"sort";i:7;s:9:"sort_type";s:4:"DESC";'.
660 's:5:"limit";N;}'
661 )
662 )
663 ),
664 '12.5.0' => array(
665 array(
666 'owner' => 'sale_SaleProduct',
667 'title' => GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES__12_5'),
668 'description' => '',
669 'mark_default' => 9,
670 'settings' => unserialize('a:11:{s:6:"entity";s:29:"Bitrix\Sale\Internals\Product";s:6:"period";'.
671 'a:2:{s:4:"type";s:5:"month";s:5:"value";N;}s:6:"select";a:6:{i:2;a:4:{s:4:"name";'.
672 's:56:"IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION.NAME";'.
673 's:5:"alias";s:9:"xxxxxxxxx";s:4:"aggr";s:12:"GROUP_CONCAT";s:8:"grouping";'.
674 'b:1;}i:8;a:2:{s:4:"name";s:15:"NAME_WITH_IDENT";s:8:"grouping";b:1;}i:12;'.
675 'a:3:{s:4:"name";s:34:"ARRIVED_PRODUCTS_IN_PERIOD_BY_SHOP";s:5:"alias";s:6:"xxxxxx";'.
676 's:17:"grouping_subtotal";b:1;}i:6;a:3:{s:4:"name";s:35:"CONSUMED_PRODUCTS_IN_PERIOD_BY_SHOP";'.
677 's:5:"alias";s:6:"xxxxxx";s:17:"grouping_subtotal";b:1;}i:3;a:3:{s:4:"name";'.
678 's:8:"QUANTITY";s:5:"alias";s:16:"xxxxxxxx xxxxxxx";s:17:"grouping_subtotal";'.
679 'b:1;}i:11;a:1:{s:4:"name";s:22:"PRICE_IN_SITE_CURRENCY";}}s:6:"filter";'.
680 'a:1:{i:0;a:3:{i:0;a:5:{s:4:"type";s:5:"field";s:4:"name";s:6:"ACTIVE";s:7:"compare";'.
681 's:5:"EQUAL";s:5:"value";s:4:"true";s:10:"changeable";s:1:"0";}i:1;a:5:{s:4:"type";'.
682 's:5:"field";s:4:"name";s:51:"IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION";'.
683 's:7:"compare";s:5:"EQUAL";s:5:"value";a:1:{i:0;s:0:"";}s:10:"changeable";'.
684 's:1:"1";}s:5:"LOGIC";s:3:"AND";}}s:4:"sort";i:8;s:9:"sort_type";s:3:"ASC";'.
685 's:5:"limit";N;s:12:"red_neg_vals";b:1;s:13:"grouping_mode";b:1;s:5:"chart";'.
686 'N;s:6:"mobile";a:1:{s:7:"enabled";b:1;}}')
687 ),
688 array(
689 'owner' => 'sale_SaleProduct',
690 'title' => GetMessage('SALE_REPORT_DEFAULT_PRICE_LIST__12_5'),
691 'description' => '',
692 'mark_default' => 10,
693 'settings' => unserialize('a:12:{s:6:"entity";s:29:"Bitrix\Sale\Internals\Product";s:6:"period";'.
694 'a:2:{s:4:"type";s:5:"month";s:5:"value";N;}s:6:"select";a:2:{i:4;a:4:{s:4:"name";'.
695 's:56:"IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION.NAME";'.
696 's:5:"alias";s:9:"xxxxxxxxx";s:4:"aggr";s:12:"GROUP_CONCAT";s:8:"grouping";'.
697 'b:1;}i:12;a:2:{s:4:"name";s:15:"NAME_WITH_IDENT";s:8:"grouping";b:1;}}s:6:"filter";'.
698 'a:1:{i:0;a:3:{i:0;a:5:{s:4:"type";s:5:"field";s:4:"name";s:6:"ACTIVE";s:7:"compare";'.
699 's:5:"EQUAL";s:5:"value";s:4:"true";s:10:"changeable";s:1:"0";}i:1;a:5:{s:4:"type";'.
700 's:5:"field";s:4:"name";s:51:"IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION";'.
701 's:7:"compare";s:5:"EQUAL";s:5:"value";a:1:{i:0;s:0:"";}s:10:"changeable";'.
702 's:1:"1";}s:5:"LOGIC";s:3:"AND";}}s:4:"sort";i:12;s:9:"sort_type";s:3:"ASC";'.
703 's:5:"limit";N;s:12:"red_neg_vals";b:1;s:13:"grouping_mode";b:1;s:11:"helper_spec";'.
704 'a:1:{s:5:"ucspt";b:1;}s:5:"chart";N;s:6:"mobile";a:1:{s:7:"enabled";b:1;}}')
705 ),
706 array(
707 'owner' => 'sale_SaleBasket',
708 'title' => GetMessage('SALE_REPORT_DEFAULT_GOODS_PROFIT__12_5'),
709 'description' => '',
710 'mark_default' => 11,
711 'settings' => unserialize('a:11:{s:6:"entity";s:28:"Bitrix\Sale\Internals\Basket";s:6:"period";'.
712 'a:2:{s:4:"type";s:5:"month";s:5:"value";N;}s:6:"select";a:6:{i:6;a:2:{s:4:"name";'.
713 's:15:"NAME_WITH_IDENT";s:8:"grouping";b:1;}i:7;a:4:{s:4:"name";s:8:"QUANTITY";'.
714 's:5:"alias";s:10:"xxxxxxxxxx";s:4:"aggr";s:3:"SUM";s:17:"grouping_subtotal";'.
715 'b:1;}i:5;a:4:{s:4:"name";s:13:"SUMMARY_PRICE";s:5:"alias";s:16:"xxxxxxxxx xxxxxx";'.
716 's:4:"aggr";s:3:"SUM";s:17:"grouping_subtotal";b:1;}i:9;a:4:{s:4:"name";'.
717 's:24:"SUMMARY_PURCHASING_PRICE";s:5:"alias";s:13:"xxxxxxxxxxxxx";s:4:"aggr";s:3:"SUM";'.
718 's:17:"grouping_subtotal";b:1;}i:10;a:4:{s:4:"name";s:12:"GROSS_PROFIT";s:5:"alias";'.
719 's:15:"xxxxxxx xxxxxxx";s:4:"aggr";s:3:"SUM";s:17:"grouping_subtotal";b:1;}i:11;'.
720 'a:4:{s:4:"name";s:13:"PROFITABILITY";s:5:"alias";s:18:"xxxxxxxxxxxxxx (%)";s:4:"aggr";'.
721 's:3:"AVG";s:17:"grouping_subtotal";b:1;}}s:6:"filter";a:1:{i:0;a:4:{i:0;a:5:{s:4:"type";'.
722 's:5:"field";s:4:"name";s:11:"ORDER.PAYED";s:7:"compare";s:5:"EQUAL";s:5:"value";'.
723 's:4:"true";s:10:"changeable";s:1:"0";}i:1;a:5:{s:4:"type";s:5:"field";s:4:"name";'.
724 's:4:"NAME";s:7:"compare";s:8:"CONTAINS";s:5:"value";s:0:"";s:10:"changeable";'.
725 's:1:"1";}i:2;a:5:{s:4:"type";s:5:"field";s:4:"name";s:33:"PRODUCT.GoodsSection:PRODUCT.SECT";'.
726 's:7:"compare";s:5:"EQUAL";s:5:"value";a:1:{i:0;s:0:"";}s:10:"changeable";'.
727 's:1:"1";}s:5:"LOGIC";s:3:"AND";}}s:4:"sort";i:6;s:9:"sort_type";s:3:"ASC";'.
728 's:5:"limit";N;s:12:"red_neg_vals";b:1;s:13:"grouping_mode";b:1;s:5:"chart";'.
729 'a:4:{s:7:"display";b:1;s:4:"type";s:3:"pie";s:8:"x_column";i:6;s:9:"y_columns";'.
730 'a:1:{i:0;i:10;}}s:6:"mobile";a:1:{s:7:"enabled";b:1;}}')
731 ),
732 array(
733 'owner' => 'sale_SaleBasket',
734 'title' => GetMessage('SALE_REPORT_DEFAULT_CLIENTS_PROFIT__12_5'),
735 'description' => '',
736 'mark_default' => 12,
737 'settings' => unserialize('a:11:{s:6:"entity";s:28:"Bitrix\Sale\Internals\Basket";s:6:"period";'.
738 'a:2:{s:4:"type";s:5:"month";s:5:"value";N;}s:6:"select";a:7:{i:9;a:2:{s:4:"name";'.
739 's:21:"FUSER.USER.SHORT_NAME";s:8:"grouping";b:1;}i:6;a:2:{s:4:"name";s:15:"NAME_WITH_IDENT";'.
740 's:8:"grouping";b:1;}i:7;a:4:{s:4:"name";s:8:"QUANTITY";s:5:"alias";s:10:"xxxxxxxxxx";'.
741 's:4:"aggr";s:3:"SUM";s:17:"grouping_subtotal";b:1;}i:5;a:4:{s:4:"name";s:13:"SUMMARY_PRICE";'.
742 's:5:"alias";s:16:"xxxxxxxxx xxxxxx";s:4:"aggr";s:3:"SUM";s:17:"grouping_subtotal";'.
743 'b:1;}i:15;a:4:{s:4:"name";s:24:"SUMMARY_PURCHASING_PRICE";s:5:"alias";s:13:"xxxxxxxxxxxxx";'.
744 's:4:"aggr";s:3:"SUM";s:17:"grouping_subtotal";b:1;}i:13;a:4:{s:4:"name";'.
745 's:12:"GROSS_PROFIT";s:5:"alias";s:15:"xxxxxxx xxxxxxx";s:4:"aggr";s:3:"SUM";'.
746 's:17:"grouping_subtotal";b:1;}i:14;a:4:{s:4:"name";s:13:"PROFITABILITY";'.
747 's:5:"alias";s:18:"xxxxxxxxxxxxxx (%)";s:4:"aggr";s:3:"AVG";s:17:"grouping_subtotal";'.
748 'b:1;}}s:6:"filter";a:1:{i:0;a:6:{i:0;a:5:{s:4:"type";s:5:"field";s:4:"name";'.
749 's:11:"ORDER.PAYED";s:7:"compare";s:5:"EQUAL";s:5:"value";s:4:"true";s:10:"changeable";'.
750 's:1:"0";}i:1;a:5:{s:4:"type";s:5:"field";s:4:"name";s:4:"NAME";s:7:"compare";'.
751 's:8:"CONTAINS";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}i:2;a:5:{s:4:"type";'.
752 's:5:"field";s:4:"name";s:33:"PRODUCT.GoodsSection:PRODUCT.SECT";s:7:"compare";'.
753 's:5:"EQUAL";s:5:"value";a:1:{i:0;s:0:"";}s:10:"changeable";s:1:"1";}i:3;'.
754 'a:5:{s:4:"type";s:5:"field";s:4:"name";s:10:"FUSER.USER";s:7:"compare";'.
755 's:5:"EQUAL";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}i:4;a:5:{s:4:"type";'.
756 's:5:"field";s:4:"name";s:31:"FUSER.USER.UserGroup:USER.GROUP";s:7:"compare";'.
757 's:5:"EQUAL";s:5:"value";s:0:"";s:10:"changeable";s:1:"1";}s:5:"LOGIC";s:3:"AND";'.
758 '}}s:4:"sort";i:6;s:9:"sort_type";s:3:"ASC";s:5:"limit";N;s:12:"red_neg_vals";'.
759 'b:1;s:13:"grouping_mode";b:1;s:5:"chart";N;s:6:"mobile";a:1:{s:7:"enabled";b:1;}}')
760 ),
761 array(
762 'owner' => 'sale_SaleProduct',
763 'title' => GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES_MOB__12_5'),
764 'description' => '',
765 'mark_default' => 13,
766 'settings' => unserialize('a:11:{s:6:"entity";s:29:"Bitrix\Sale\Internals\Product";s:6:"period";'.
767 'a:2:{s:4:"type";s:5:"month";s:5:"value";N;}s:6:"select";a:3:{i:2;a:4:{s:4:"name";'.
768 's:56:"IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION.NAME";s:5:"alias";'.
769 's:9:"xxxxxxxxx";s:4:"aggr";s:12:"GROUP_CONCAT";s:8:"grouping";b:1;}i:8;a:2:{s:4:"name";'.
770 's:15:"NAME_WITH_IDENT";s:8:"grouping";b:1;}i:3;a:3:{s:4:"name";s:8:"QUANTITY";'.
771 's:5:"alias";s:16:"xxxxxxxx xxxxxxx";s:17:"grouping_subtotal";b:1;}}s:6:"filter";'.
772 'a:1:{i:0;a:3:{i:0;a:5:{s:4:"type";s:5:"field";s:4:"name";s:6:"ACTIVE";s:7:"compare";'.
773 's:5:"EQUAL";s:5:"value";s:4:"true";s:10:"changeable";s:1:"0";}i:1;a:5:{s:4:"type";'.
774 's:5:"field";s:4:"name";s:51:"IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION";'.
775 's:7:"compare";s:5:"EQUAL";s:5:"value";a:1:{i:0;s:0:"";}s:10:"changeable";'.
776 's:1:"1";}s:5:"LOGIC";s:3:"AND";}}s:4:"sort";i:8;s:9:"sort_type";s:3:"ASC";'.
777 's:5:"limit";N;s:12:"red_neg_vals";b:1;s:13:"grouping_mode";b:1;s:5:"chart";'.
778 'N;s:6:"mobile";a:1:{s:7:"enabled";b:1;}}')
779 ),
780 array(
781 'owner' => 'sale_SaleProduct',
782 'title' => GetMessage('SALE_REPORT_DEFAULT_PRICE_LIST_MOB__12_5'),
783 'description' => '',
784 'mark_default' => 14,
785 'settings' => unserialize('a:11:{s:6:"entity";s:29:"Bitrix\Sale\Internals\Product";s:6:"period";'.
786 'a:2:{s:4:"type";s:5:"month";s:5:"value";N;}s:6:"select";a:3:{i:4;a:4:{s:4:"name";'.
787 's:56:"IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION.NAME";s:5:"alias";'.
788 's:9:"xxxxxxxxx";s:4:"aggr";s:12:"GROUP_CONCAT";s:8:"grouping";b:1;}i:12;'.
789 'a:2:{s:4:"name";s:15:"NAME_WITH_IDENT";s:8:"grouping";b:1;}i:13;a:1:{s:4:"name";'.
790 's:22:"PRICE_IN_SITE_CURRENCY";}}s:6:"filter";a:1:{i:0;a:3:{i:0;a:5:{s:4:"type";'.
791 's:5:"field";s:4:"name";s:6:"ACTIVE";s:7:"compare";s:5:"EQUAL";s:5:"value";'.
792 's:4:"true";s:10:"changeable";s:1:"0";}i:1;a:5:{s:4:"type";s:5:"field";s:4:"name";'.
793 's:51:"IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION";s:7:"compare";'.
794 's:5:"EQUAL";s:5:"value";a:1:{i:0;s:0:"";}s:10:"changeable";s:1:"1";}s:5:"LOGIC";'.
795 's:3:"AND";}}s:4:"sort";i:12;s:9:"sort_type";s:3:"ASC";s:5:"limit";N;s:12:"red_neg_vals";'.
796 'b:1;s:13:"grouping_mode";b:1;s:5:"chart";N;s:6:"mobile";a:1:{s:7:"enabled";b:1;}}')
797 )
798 ),
799 '12.5.1' => array(
800 array(
801 'owner' => 'sale_SaleProduct',
802 'title' => GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES_BY_STORE__12_5_1'),
803 'description' => '',
804 'mark_default' => 15,
805 'settings' => unserialize('a:11:{s:6:"entity";s:29:"Bitrix\Sale\Internals\Product";s:6:"period";'.
806 'a:2:{s:4:"type";s:5:"month";s:5:"value";N;}s:6:"select";a:7:{i:16;a:2:{s:4:"name";'.
807 's:37:"StoreProduct:SALE_PRODUCT.STORE.TITLE";s:8:"grouping";b:1;}i:2;a:4:{s:4:"name";'.
808 's:56:"IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION.NAME";s:5:"alias";'.
809 's:9:"xxxxxxxxx";s:4:"aggr";s:12:"GROUP_CONCAT";s:8:"grouping";b:1;}i:8;'.
810 'a:2:{s:4:"name";s:15:"NAME_WITH_IDENT";s:8:"grouping";b:1;}i:25;a:3:{s:4:"name";'.
811 's:35:"ARRIVED_PRODUCTS_IN_PERIOD_BY_STORE";s:5:"alias";'.
812 's:6:"xxxxxx";s:17:"grouping_subtotal";b:1;}i:26;a:3:{s:4:"name";'.
813 's:35:"EXPENSE_PRODUCTS_IN_PERIOD_BY_STORE";'.
814 's:5:"alias";s:6:"xxxxxx";s:17:"grouping_subtotal";b:1;}i:23;a:3:{s:4:"name";'.
815 's:32:"StoreProduct:SALE_PRODUCT.AMOUNT";s:5:"alias";s:16:"xxxxxxxx xxxxxxx";'.
816 's:17:"grouping_subtotal";b:1;}i:11;a:1:{s:4:"name";s:22:"PRICE_IN_SITE_CURRENCY";'.
817 '}}s:6:"filter";a:1:{i:0;a:4:{i:0;a:5:{s:4:"type";s:5:"field";s:4:"name";'.
818 's:6:"ACTIVE";s:7:"compare";s:5:"EQUAL";s:5:"value";s:4:"true";s:10:"changeable";'.
819 's:1:"0";}i:1;a:5:{s:4:"type";s:5:"field";s:4:"name";s:25:"StoreProduct:SALE_PRODUCT";'.
820 's:7:"compare";s:5:"EQUAL";s:5:"value";a:1:{i:0;s:0:"";}s:10:"changeable";'.
821 's:1:"1";}i:2;a:5:{s:4:"type";s:5:"field";s:4:"name";'.
822 's:51:"IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION";'.
823 's:7:"compare";s:5:"EQUAL";s:5:"value";a:1:{i:0;s:0:"";}s:10:"changeable";'.
824 's:1:"1";}s:5:"LOGIC";s:3:"AND";}}s:4:"sort";i:8;s:9:"sort_type";s:3:"ASC";'.
825 's:5:"limit";N;s:12:"red_neg_vals";b:1;s:13:"grouping_mode";b:1;s:5:"chart";'.
826 'N;s:6:"mobile";a:1:{s:7:"enabled";b:1;}}')
827 )
828 )
829 );
830
831 foreach ($reports as $version => &$vreports)
832 {
833 foreach ($vreports as $num => &$report)
834 {
835 if ($version === '12.0.0' && $report['mark_default'] === 1)
836 {
837 $report['settings']['select'][4]['alias'] = GetMessage('SALE_REPORT_DEFAULT_LEFT_BASKETS_ALIAS_4');
838 $report['settings']['select'][5]['alias'] = GetMessage('SALE_REPORT_DEFAULT_LEFT_BASKETS_ALIAS_5');
839 $report['settings']['select'][6]['alias'] = GetMessage('SALE_REPORT_DEFAULT_LEFT_BASKETS_ALIAS_6');
840 $report['settings']['select'][7]['alias'] = GetMessage('SALE_REPORT_DEFAULT_LEFT_BASKETS_ALIAS_7');
841 }
842 if ($version === '12.0.0' && $report['mark_default'] === 2)
843 {
844 $report['settings']['select'][3]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_PROFIT_ALIAS_3');
845 $report['settings']['select'][4]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_PROFIT_ALIAS_4');
846 $report['settings']['select'][5]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_PROFIT_ALIAS_5');
847 $report['settings']['select'][6]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_PROFIT_ALIAS_6');
848 $report['settings']['select'][14]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_PROFIT_ALIAS_14');
849 }
850 if ($version === '12.0.0' && $report['mark_default'] === 3)
851 {
852 $report['settings']['select'][1]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES_ALIAS_1');
853 $report['settings']['select'][3]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES_ALIAS_3');
854 $report['settings']['select'][5]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES_ALIAS_5');
855 }
856 if ($version === '12.0.0' && $report['mark_default'] === 4)
857 {
858 $report['settings']['select'][0]['alias'] = GetMessage('SALE_REPORT_DEFAULT_BEST_CLIENTS_ALIAS_0');
859 $report['settings']['select'][2]['alias'] = GetMessage('SALE_REPORT_DEFAULT_BEST_CLIENTS_ALIAS_2');
860 $report['settings']['select'][3]['alias'] = GetMessage('SALE_REPORT_DEFAULT_BEST_CLIENTS_ALIAS_3');
861 $report['settings']['select'][5]['alias'] = GetMessage('SALE_REPORT_DEFAULT_BEST_CLIENTS_ALIAS_5');
862 $report['settings']['select'][14]['alias'] = GetMessage('SALE_REPORT_DEFAULT_BEST_CLIENTS_ALIAS_14');
863 }
864 if ($version === '12.0.0' && $report['mark_default'] === 5)
865 {
866 $report['settings']['select'][0]['alias'] = GetMessage('SALE_REPORT_DEFAULT_NEW_CLIENTS_ALIAS_0');
867 $report['settings']['select'][3]['alias'] = GetMessage('SALE_REPORT_DEFAULT_NEW_CLIENTS_ALIAS_3');
868 $report['settings']['select'][4]['alias'] = GetMessage('SALE_REPORT_DEFAULT_NEW_CLIENTS_ALIAS_4');
869 $report['settings']['select'][5]['alias'] = GetMessage('SALE_REPORT_DEFAULT_NEW_CLIENTS_ALIAS_5');
870 $report['settings']['select'][6]['alias'] = GetMessage('SALE_REPORT_DEFAULT_NEW_CLIENTS_ALIAS_6');
871 $report['settings']['select'][9]['alias'] = GetMessage('SALE_REPORT_DEFAULT_NEW_CLIENTS_ALIAS_9');
872 }
873 if ($version === '12.0.0' && $report['mark_default'] === 6)
874 {
875 $report['settings']['select'][0]['alias'] = GetMessage('SALE_REPORT_DEFAULT_SALES_ALIAS_0');
876 $report['settings']['select'][1]['alias'] = GetMessage('SALE_REPORT_DEFAULT_SALES_ALIAS_1');
877 $report['settings']['select'][2]['alias'] = GetMessage('SALE_REPORT_DEFAULT_SALES_ALIAS_2');
878 $report['settings']['select'][3]['alias'] = GetMessage('SALE_REPORT_DEFAULT_SALES_ALIAS_3');
879 $report['settings']['select'][4]['alias'] = GetMessage('SALE_REPORT_DEFAULT_SALES_ALIAS_4');
880 $report['settings']['select'][5]['alias'] = GetMessage('SALE_REPORT_DEFAULT_SALES_ALIAS_5');
881 $report['settings']['select'][6]['alias'] = GetMessage('SALE_REPORT_DEFAULT_SALES_ALIAS_6');
882 $report['settings']['select'][13]['alias'] = GetMessage('SALE_REPORT_DEFAULT_SALES_ALIAS_13');
883 }
884 if ($version === '12.0.0' && $report['mark_default'] === 7)
885 {
886 $report['settings']['select'][0]['alias'] = GetMessage('SALE_REPORT_DEFAULT_MOST_EXPECTED_GOODS_ALIAS_0');
887 $report['settings']['select'][1]['alias'] = GetMessage('SALE_REPORT_DEFAULT_MOST_EXPECTED_GOODS_ALIAS_1');
888 $report['settings']['select'][2]['alias'] = GetMessage('SALE_REPORT_DEFAULT_MOST_EXPECTED_GOODS_ALIAS_5');
889 $report['settings']['select'][3]['alias'] = GetMessage('SALE_REPORT_DEFAULT_MOST_EXPECTED_GOODS_ALIAS_8');
890 }
891 if ($version === '12.0.0' && $report['mark_default'] === 8)
892 {
893 $report['settings']['select'][5]['alias'] = GetMessage('SALE_REPORT_DEFAULT_MOST_VIEWED_GOODS_ALIAS_5');
894 $report['settings']['select'][7]['alias'] = GetMessage('SALE_REPORT_DEFAULT_MOST_VIEWED_GOODS_ALIAS_7');
895 $report['settings']['select'][8]['alias'] = GetMessage('SALE_REPORT_DEFAULT_MOST_VIEWED_GOODS_ALIAS_8');
896 $report['settings']['select'][12]['alias'] = GetMessage('SALE_REPORT_DEFAULT_MOST_VIEWED_GOODS_ALIAS_12');
897 }
898 if ($version === '12.5.0' && $report['mark_default'] === 9)
899 {
900 $report['settings']['select'][2]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES__12_5_ALIAS_2');
901 $report['settings']['select'][12]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES__12_5_ALIAS_12');
902 $report['settings']['select'][6]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES__12_5_ALIAS_6');
903 $report['settings']['select'][3]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES__12_5_ALIAS_3');
904 }
905 if ($version === '12.5.0' && $report['mark_default'] === 10)
906 {
907 $report['settings']['select'][4]['alias'] = GetMessage('SALE_REPORT_DEFAULT_PRICE_LIST__12_5_ALIAS_4');
908 }
909 if ($version === '12.5.0' && $report['mark_default'] === 11)
910 {
911 $report['settings']['select'][7]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_PROFIT__12_5_ALIAS_7');
912 $report['settings']['select'][5]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_PROFIT__12_5_ALIAS_5');
913 $report['settings']['select'][9]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_PROFIT__12_5_ALIAS_9');
914 $report['settings']['select'][10]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_PROFIT__12_5_ALIAS_10');
915 $report['settings']['select'][11]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_PROFIT__12_5_ALIAS_11');
916 }
917 if ($version === '12.5.0' && $report['mark_default'] === 12)
918 {
919 $report['settings']['select'][7]['alias'] = GetMessage('SALE_REPORT_DEFAULT_CLIENTS_PROFIT__12_5_ALIAS_7');
920 $report['settings']['select'][5]['alias'] = GetMessage('SALE_REPORT_DEFAULT_CLIENTS_PROFIT__12_5_ALIAS_5');
921 $report['settings']['select'][15]['alias'] = GetMessage('SALE_REPORT_DEFAULT_CLIENTS_PROFIT__12_5_ALIAS_15');
922 $report['settings']['select'][13]['alias'] = GetMessage('SALE_REPORT_DEFAULT_CLIENTS_PROFIT__12_5_ALIAS_13');
923 $report['settings']['select'][14]['alias'] = GetMessage('SALE_REPORT_DEFAULT_CLIENTS_PROFIT__12_5_ALIAS_14');
924 }
925 if ($version === '12.5.0' && $report['mark_default'] === 13)
926 {
927 $report['settings']['select'][2]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES_MOB__12_5_ALIAS_2');
928 $report['settings']['select'][3]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES_MOB__12_5_ALIAS_3');
929 }
930 if ($version === '12.5.0' && $report['mark_default'] === 14)
931 {
932 $report['settings']['select'][4]['alias'] = GetMessage('SALE_REPORT_DEFAULT_PRICE_LIST__12_5_ALIAS_4');
933 }
934 if ($version === '12.5.1' && $report['mark_default'] === 15)
935 {
936 $report['settings']['select'][2]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES_BY_STORE__12_5_1_ALIAS_2');
937 $report['settings']['select'][23]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES_BY_STORE__12_5_1_ALIAS_23');
938 $report['settings']['select'][25]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES_BY_STORE__12_5_1_ALIAS_25');
939 $report['settings']['select'][26]['alias'] = GetMessage('SALE_REPORT_DEFAULT_GOODS_INVENTORIES_BY_STORE__12_5_1_ALIAS_26');
940 }
941
942 // remove old reports
943 if ($version === '12.0.0' && in_array($report['mark_default'], array(2, 3)))
944 {
945 unset($vreports[$num]);
946 }
947
948 }
949 }
950
951 return $reports;
952 }
953
954 public static function getCurrentVersion()
955 {
956 $arModuleVersion = array();
957 include($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/sale/install/version.php");
958 return $arModuleVersion['VERSION'];
959 }
960
961 public static function getFirstVersion()
962 {
963 return '12.0.0';
964 }
965
966 public static function getAjaxResponse($arRequestData)
967 {
969 $arResponseData = array();
970 $arbFilterTypeFill = array();
971 foreach (array_unique($arRequestData) as $filterType)
972 {
973 if (empty($arbFilterTypeFill[$filterType]))
974 {
975 switch ($filterType)
976 {
977 case 'PersonType':
978 $arResponseData[$filterType][] = array(
979 'value' => '',
980 'text' => GetMessage('REPORT_IGNORE_FILTER_VALUE')
981 );
982 foreach(self::getPersonTypes() as $kID => $v)
983 {
984 if ($v['LID'] === $siteId)
985 {
986 $arResponseData[$filterType][] = array('value' => $kID, 'text' => $v['NAME']);
987 }
988 }
989 break;
990 case 'PaySystem':
991 $arResponseData[$filterType][] = array(
992 'value' => '',
993 'text' => GetMessage('REPORT_IGNORE_FILTER_VALUE')
994 );
995 foreach(self::getPaySystemList() as $kID => $val)
996 {
997 if ($val['site_id'] === '' || $val['site_id'] === $siteId)
998 {
999 $arResponseData[$filterType][] = array('value' => $kID, 'text' => $val['value']);
1000 }
1001 }
1002 break;
1003 case 'Delivery':
1004 $arResponseData[$filterType][] = array(
1005 'value' => '',
1006 'text' => GetMessage('REPORT_IGNORE_FILTER_VALUE')
1007 );
1008 foreach(self::getDeliveryList() as $kID => $val)
1009 {
1010 if ($val['site_id'] === '' || $val['site_id'] === $siteId)
1011 {
1012 $arResponseData[$filterType][] = array('value' => $kID, 'text' => $val['value']);
1013 }
1014 }
1015 break;
1016 case 'Section':
1017 $arResponseData[$filterType][] = array(
1018 'value' => '',
1019 'text' => GetMessage('REPORT_IGNORE_FILTER_VALUE')
1020 );
1021 $prevCatalog = -1;
1022 foreach(self::getCatalogSections() as $kSectionID => $vSection)
1023 {
1024 if (self::isCatalogCorrespondsDefSite($vSection['catalog']['ID']))
1025 {
1026 // Inserting catalogs headers in list of sections of goods.
1027 if ($vSection['catalog']['ID'] != $prevCatalog)
1028 {
1029 $arResponseData[$filterType][] = array(
1030 'value' => 'c'.$vSection['catalog']['ID'],
1031 'text' => '- '.GetMessage('SALE_REPORT_CONSTRUCT_CATALOG_NAME_LABEL').
1032 ': '.$vSection['catalog']['NAME']
1033 );
1034 }
1035 $prevCatalog = $vSection['catalog']['ID'];
1036 $arResponseData[$filterType][] = array('value' => $kSectionID, 'text' => '&nbsp;'.$vSection['name']);
1037 }
1038 }
1039 break;
1040 }
1041 }
1042 $arbFilterTypeFill[$filterType] = true;
1043 }
1044 return $arResponseData;
1045 }
1046
1047 public static function getSectionsSelectHTMLOptions()
1048 {
1049 $html = '';
1050 $prevCatalog = -1;
1051 $html .= '<option value="">'.GetMessage('REPORT_IGNORE_FILTER_VALUE').'</option>';
1052 foreach(self::getCatalogSections() as $kSectionID => $vSection)
1053 {
1054 if (self::isCatalogCorrespondsDefSite($vSection['catalog']['ID']))
1055 {
1056 // Inserting catalogs headers in list of sections of goods.
1057 if ($vSection['catalog']['ID'] != $prevCatalog)
1058 {
1059 $html .= '<option value="c'.htmlspecialcharsbx($vSection['catalog']['ID']).'">- '.GetMessage('SALE_REPORT_CONSTRUCT_CATALOG_NAME_LABEL').
1060 ': '.htmlspecialcharsbx($vSection['catalog']['NAME']).'</option>';
1061 }
1062 $prevCatalog = $vSection['catalog']['ID'];
1063 $html .= '<option value="'.htmlspecialcharsbx($kSectionID).'">&nbsp;'.htmlspecialcharsbx($vSection['name']).'</option>';
1064 }
1065 }
1066 return $html;
1067 }
1068
1069 public static function calculateInReportCurrency($value)
1070 {
1071 $res = $value;
1072 if (self::$reportCurrencyId != self::$siteCurrencyId)
1073 {
1074 $res = \CCurrencyRates::ConvertCurrency($value, self::$siteCurrencyId, self::$reportCurrencyId);
1075 }
1076
1077 return $res;
1078 }
1079}
1080
1082{
1083
1084 private static $monetaryFields = array(
1085 'TAX_VALUE',
1086 'PRICE_DELIVERY',
1087 'DISCOUNT_ALL',
1088 'PRICE',
1089 'SUM_PAID_FORREP',
1090 'PAYMENT_ORDER_SUM'
1091 );
1092
1093 private static $goodsQuantityFields = array(
1094 'PRODUCTS_QUANT'
1095 );
1096
1097 private static $withoutTotalFields = array(
1098 'PERSON_TYPE_ID'
1099 );
1100
1101 private static $userNotAuthNameFields = array();
1102
1103 public static function getEntityName()
1104 {
1105 return 'Bitrix\Sale\Internals\Order';
1106 }
1107
1108 public static function getOwnerId()
1109 {
1110 return SALE_REPORT_OWNER_ID.'_SaleOrder';
1111 }
1112
1113 public static function getColumnList()
1114 {
1115 IncludeModuleLangFile(__FILE__);
1116
1117 return array(
1118 'ID',
1119 'DATE_INSERT_SHORT',
1120 'DATE_UPDATE_SHORT',
1121 'STATUS' => array(
1122 'STATUS_ID',
1123 'NAME',
1124 'DESCRIPTION'
1125 ),
1126 'EMP_STATUS_BY' => array(
1127 'ID',
1128 'NAME',
1129 'LAST_NAME',
1130 'SHORT_NAME',
1131 'EMAIL',
1132 'PERSONAL_PHONE'
1133 ),
1134 'DATE_STATUS_SHORT',
1135 'PRICE_DELIVERY',
1136 'PAYED',
1137 'SUM_PAID_FORREP',
1138 'Payment:ORDER' => array(
1139 'ID',
1140 'DATE_BILL',
1141 'DATE_PAY_BEFORE',
1142 'DATE_PAID',
1143 'EMP_PAID_BY' => array(
1144 'ID',
1145 'NAME',
1146 'LAST_NAME',
1147 'SHORT_NAME',
1148 'EMAIL',
1149 'PERSONAL_PHONE'
1150 ),
1151 'PAY_VOUCHER_NUM',
1152 'PAY_VOUCHER_DATE',
1153 'PAY_SYSTEM_ID',
1154 'PAY_SYSTEM_NAME',
1155 'PAY_RETURN_NUM',
1156 'PAY_RETURN_DATE',
1157 'SUM',
1158 'CURRENCY',
1159 'RESPONSIBLE_BY' => array(
1160 'ID',
1161 'NAME',
1162 'LAST_NAME',
1163 'SHORT_NAME',
1164 'EMAIL',
1165 'PERSONAL_PHONE'
1166 )
1167 ),
1168 'DEDUCTED',
1169 'Shipment:REPS_ORDER' => array(
1170 'ID',
1171 'ALLOW_DELIVERY',
1172 'DELIVERY_ID',
1173 'DELIVERY_NAME',
1174 'EMP_ALLOW_DELIVERY_BY' => array(
1175 'ID',
1176 'NAME',
1177 'LAST_NAME',
1178 'SHORT_NAME',
1179 'EMAIL',
1180 'PERSONAL_PHONE'
1181 ),
1182 'DATE_ALLOW_DELIVERY_SHORT',
1183 'DELIVERY_DOC_NUM',
1184 'DELIVERY_DOC_DATE_SHORT',
1185 'DEDUCTED',
1186 'EMP_DEDUCTED_BY' => array(
1187 'ID',
1188 'NAME',
1189 'LAST_NAME',
1190 'SHORT_NAME',
1191 'EMAIL',
1192 'PERSONAL_PHONE'
1193 ),
1194 'DATE_DEDUCTED_SHORT',
1195 'RESERVED',
1196 'TRACKING_NUMBER',
1197 'PRICE_DELIVERY',
1198 'CURRENCY',
1199 'RESPONSIBLE_BY' => array(
1200 'ID',
1201 'NAME',
1202 'LAST_NAME',
1203 'SHORT_NAME',
1204 'EMAIL',
1205 'PERSONAL_PHONE'
1206 )
1207 ),
1208 'CANCELED',
1209 'EMP_CANCELED_BY' => array(
1210 'ID',
1211 'NAME',
1212 'LAST_NAME',
1213 'SHORT_NAME',
1214 'EMAIL',
1215 'PERSONAL_PHONE'
1216 ),
1217 'DATE_CANCELED_SHORT',
1218 'REASON_CANCELED',
1219 'PRODUCTS_QUANT',
1220 'TAX_VALUE',
1221 'PRICE',
1222 'DISCOUNT_ALL',
1223 /*'LID',*/
1224 'PERSON_TYPE_ID',
1225 'USER' => array(
1226 'ID',
1227 'NAME',
1228 'LAST_NAME',
1229 'SHORT_NAME',
1230 'EMAIL',
1231 'PERSONAL_PHONE',
1232 'DATE_REG_SHORT',
1233 'UserGroup:USER.GROUP' => array(
1234 'ID',
1235 'NAME'
1236 )
1237 )
1238 );
1239 }
1240
1241 public static function getDefaultColumns()
1242 {
1243 return array(
1244 array('name' => 'ID'),
1245 array('name' => 'DATE_INSERT_SHORT')
1246 );
1247 }
1248
1249 public static function getCalcVariations()
1250 {
1251 return array_merge(parent::getCalcVariations(), array(
1252 'date' => array(
1253 'MIN',
1254 'MAX',
1255 'COUNT_DISTINCT'
1256 ),
1257 'USER.UserGroup:USER.GROUP.ID' => array(
1258 'COUNT_DISTINCT',
1259 'GROUP_CONCAT'
1260 ),
1261 'USER.UserGroup:USER.GROUP.NAME' => array(
1262 'COUNT_DISTINCT',
1263 'GROUP_CONCAT'
1264 )
1265 ));
1266 }
1267
1268 public static function getCompareVariations()
1269 {
1270 return array_merge(parent::getCompareVariations(), array(
1271 'date' => array(
1272 'EQUAL',
1273 'GREATER_OR_EQUAL',
1274 'GREATER',
1275 'LESS',
1276 'LESS_OR_EQUAL',
1277 'NOT_EQUAL'
1278 ),
1279 'LID' => array(
1280 'EQUAL',
1281 'NOT_EQUAL'
1282 ),
1283 'PERSON_TYPE_ID' => array(
1284 'EQUAL',
1285 'NOT_EQUAL'
1286 ),
1287 'STATUS' => array(
1288 'EQUAL',
1289 'NOT_EQUAL'
1290 ),
1291 'USER.UserGroup:USER.GROUP' => array(
1292 'EQUAL',
1293 'NOT_EQUAL'
1294 ),
1295 '\Bitrix\Main\User' => array(
1296 'EQUAL'
1297 ),
1298 '\Bitrix\Main\Group' => array(
1299 'EQUAL'
1300 )
1301 ));
1302 }
1303
1304 public static function getPeriodFilter($date_from, $date_to)
1305 {
1306 global $DB;
1307
1308 $filter = array('LOGIC' => 'AND');
1309
1310 if(!is_null($date_to))
1311 {
1312 $filter[] = array(
1313 'LOGIC' => 'OR',
1314 '<=DATE_INSERT_SHORT' => $date_to,
1315 '=DATE_INSERT_SHORT' => null
1316 );
1317 }
1318
1319 if(!is_null($date_from))
1320 {
1321 $filter[] = array(
1322 'LOGIC' => 'OR',
1323 '>=DATE_INSERT_SHORT' => $date_from,
1324 '=DATE_INSERT_SHORT' => null
1325 );
1326 }
1327
1328 // Site filter
1329 $filter[] = array(
1330 '=LID' => $DB->ForSql(self::getDefaultSiteId())
1331 );
1332
1333 return $filter;
1334 }
1335
1336 public static function fillFilterReferenceColumn(&$filterElement, Entity\ReferenceField $field)
1337 {
1338 if ($field->getRefEntityName() == '\Bitrix\Main\User')
1339 {
1340 // USER
1341 if ($filterElement['value'])
1342 {
1343 $res = CUser::GetByID($filterElement['value']);
1344 $user = $res->fetch();
1345
1346 if ($user)
1347 {
1348 $username = CUser::FormatName(CSite::GetNameFormat(null, self::getDefaultSiteId()), $user, true, false);
1349 $filterElement['value'] = array('id' => $user['ID'], 'name' => $username);
1350 }
1351 else
1352 {
1353 $filterElement['value'] = array('id' => $filterElement['value'], 'name' => GetMessage('REPORT_USER_NOT_FOUND'));
1354 }
1355 }
1356 else
1357 {
1358 $filterElement['value'] = array('id' => '');
1359 }
1360 }
1361 else if ($field->getRefEntityName() == '\Bitrix\Main\Group')
1362 {
1363 // GROUP
1364 if ($filterElement['value'])
1365 {
1366 $res = CGroup::GetByID($filterElement['value']);
1367 $group = $res->fetch();
1368
1369 if ($group)
1370 {
1371 $filterElement['value'] = array('id' => $group['ID'], 'name' => $group['NAME']);
1372 }
1373 else
1374 {
1375 $filterElement['value'] = array('id' => $filterElement['value'], 'name' => GetMessage('SALE_REPORT_GROUP_NOT_FOUND'));
1376 }
1377 }
1378 else
1379 {
1380 $filterElement['value'] = array('id' => '');
1381 }
1382 }
1383 }
1384
1385 /* remove it when PHP 5.3 available */
1386 public static function formatResults(&$rows, &$columnInfo, $total)
1387 {
1388 foreach ($rows as &$row)
1389 {
1390 foreach ($row as $k => &$v)
1391 {
1392 if (!array_key_exists($k, $columnInfo))
1393 {
1394 continue;
1395 }
1396
1397 $cInfo = &$columnInfo[$k];
1398
1399 if (is_array($v))
1400 {
1401 foreach ($v as &$subv)
1402 {
1403 self::formatResultValue($k, $subv, $row, $cInfo, $total);
1404 }
1405 }
1406 else
1407 {
1408 self::formatResultValue($k, $v, $row, $cInfo, $total);
1409 }
1410 }
1411 }
1412
1413 unset($row, $v, $subv);
1414 }
1415 /* \remove it */
1416
1417 public static function formatResultValue($k, &$v, &$row, &$cInfo, $total, &$customChartValue = null)
1418 {
1419 $dataType = self::getFieldDataType($cInfo['field']);
1420
1422 if ($dataType !== 'float' ) // skip base rounding
1423 {
1424 parent::formatResultValue($k, $v, $row, $cInfo, $total);
1425 }
1426
1427 if ($k === 'PERSON_TYPE_ID')
1428 {
1429 $v = self::$personTypes[$v]['NAME'];
1430 }
1431 else if ($k === 'LID')
1432 {
1433 $v = self::$sitelist[$v];
1434 }
1435 // Removing the link from the email field if is empty.
1436 else if ($k === 'SALE_ORDER_USER_EMAIL')
1437 {
1438 if (is_null($v) || empty($v) || $v == '&nbsp;') unset($row['__HREF_'.$k]);
1439 }
1440
1441 // Inserting zero in numerical fields with null value.
1442 if (empty($v))
1443 {
1444 if (in_array($dataType, array('integer', 'float')))
1445 {
1446 $v = 0;
1447 }
1448 //else $v = '&nbsp;';
1449 }
1450
1451 if (empty($cInfo['aggr']))
1452 {
1453 if (($cInfo['field']->getEntity()->getName() === 'Shipment'
1454 && in_array($cInfo['field']->getName(), array('ID', 'DELIVERY_ID', 'DELIVERY_NAME'), true))
1455 || ($cInfo['field']->getEntity()->getName() === 'Payment'
1456 && in_array($cInfo['field']->getName(), array('ID', 'PAY_SYSTEM_ID', 'PAY_SYSTEM_NAME'), true)))
1457 {
1458 if (is_null($v) || empty($v) || $v == '&nbsp;')
1459 {
1460 unset($row['__HREF_'.$k]);
1461 }
1462 }
1463 }
1464
1465 // Formatting of monetary fields.
1466 foreach (self::$monetaryFields as $monField)
1467 {
1468 if (preg_match('/'.$monField.'$/', $k))
1469 {
1471 $v = number_format(doubleval($v), 2, '.', ' ');
1472 break;
1473 }
1474 }
1475
1476 // Formatting fields with goods quantity.
1477 foreach (self::$goodsQuantityFields as $qField)
1478 {
1479 if (preg_match('/'.$qField.'$/', $k))
1480 {
1481 if (!empty($v) && !is_null($v) && $v != '&nbsp;')
1482 {
1483 if (self::$fDecimalQuant) $v = sprintf('%.3f', round($v,3));
1484 else $v = sprintf('%d', round($v,0));
1485 }
1486 break;
1487 }
1488 }
1489
1490 // Formatting short name fields of buyers.
1491 foreach (self::$userNotAuthNameFields as $uField)
1492 {
1493 if (preg_match('/'.$uField.'$/', $k))
1494 {
1495 if (empty($v) || is_null($v) || $v == '&nbsp;')
1496 {
1497 $v = GetMessage('SALE_REPORT_USER_NOT_AUTH');
1498 }
1499 break;
1500 }
1501 }
1502 }
1503
1504 public static function formatResultGroupingTotal($params)
1505 {
1506 $paramTotal = array('TOTAL_'.$params['k'] => &$params['v']);
1507 $viewColumns = array($params['k'] => &$params['cInfo']);
1508 $bFormatOnly = true;
1509 static::formatResultsTotal($paramTotal, $viewColumns, $bFormatOnly);
1510 }
1511
1512 public static function formatResultsTotal(&$total, &$columnInfo, &$bFormatOnly = null)
1513 {
1514 parent::formatResultsTotal($total, $columnInfo);
1515
1516 foreach ($total as $k => &$v)
1517 {
1518 // Formatting of monetary fields.
1519 foreach (self::$monetaryFields as $monField)
1520 {
1521 if (preg_match('/'.$monField.'$/', $k))
1522 {
1523 if (!$bFormatOnly) $v = self::calculateInReportCurrency($v);
1524 $v = number_format(doubleval($v), 2, '.', ' ');
1525 break;
1526 }
1527 }
1528
1529 // Formatting fields with goods quantity.
1530 foreach (self::$goodsQuantityFields as $qField)
1531 {
1532 if (preg_match('/'.$qField.'$/', $k))
1533 {
1534 if (!empty($v) && !is_null($v) && $v != '&nbsp;')
1535 {
1536 if (self::$fDecimalQuant) $v = sprintf('%.3f', round($v,3));
1537 else $v = sprintf('%d', round($v,0));
1538 }
1539 break;
1540 }
1541 }
1542
1543 // Formatting fields without summary calculation.
1544 foreach (self::$withoutTotalFields as $wtField)
1545 {
1546 if (preg_match('/TOTAL_'.$wtField.'$/', $k))
1547 {
1548 unset($total[$k]);
1549 break;
1550 }
1551 }
1552 }
1553 }
1554
1555 public static function getDefaultElemHref($elem, $fList)
1556 {
1557 $href = '';
1558 if (empty($elem['aggr']))
1559 {
1560 $field = $fList[$elem['name']];
1561
1562 if ($field->getEntity()->getName() == 'User')
1563 {
1564 if (in_array(
1565 $elem['name'],
1566 array(
1567 'USER.EMAIL',
1568 'EMP_CANCELED_BY.EMAIL',
1569 'EMP_STATUS_BY.EMAIL',
1570 'Payment:ORDER.EMP_PAID_BY.EMAIL',
1571 'Payment:ORDER.RESPONSIBLE_BY.EMAIL',
1572 'Shipment:REPS_ORDER.EMP_ALLOW_DELIVERY_BY.EMAIL',
1573 'Shipment:REPS_ORDER.EMP_DEDUCTED_BY.EMAIL',
1574 'Shipment:REPS_ORDER.RESPONSIBLE_BY.EMAIL'
1575 ),
1576 true))
1577 {
1578 $href = array('pattern' => 'mailto:#'.$elem['name'].'#');
1579 }
1580 else if (in_array(
1581 $elem['name'],
1582 array(
1583 'USER.SHORT_NAME',
1584 'EMP_CANCELED_BY.SHORT_NAME',
1585 'EMP_STATUS_BY.SHORT_NAME',
1586 'Payment:ORDER.EMP_PAID_BY.SHORT_NAME',
1587 'Payment:ORDER.RESPONSIBLE_BY.SHORT_NAME',
1588 'Shipment:REPS_ORDER.EMP_ALLOW_DELIVERY_BY.SHORT_NAME',
1589 'Shipment:REPS_ORDER.EMP_DEDUCTED_BY.SHORT_NAME',
1590 'Shipment:REPS_ORDER.RESPONSIBLE_BY.SHORT_NAME'
1591 ),
1592 true))
1593 {
1594 $userDef = mb_substr($elem['name'], 0, -11);
1595 $href = array('pattern' => '/bitrix/admin/sale_buyers_profile.php?USER_ID=#'.$userDef.'.ID#&lang='.LANG);
1596 }
1597 }
1598 else if ($field->getEntity()->getName() == 'Order')
1599 {
1600 if ($elem['name'] === 'ID')
1601 {
1602 $href = array('pattern' => '/bitrix/admin/sale_order_view.php?ID=#ID#&lang='.LANG);
1603 }
1604 }
1605 else if ($field->getEntity()->getName() === 'Payment')
1606 {
1607 if ($elem['name'] === 'Payment:ORDER.ID')
1608 {
1609 $href = array('pattern' => '/bitrix/admin/sale_order_payment_edit.php?order_id=#Payment:ORDER.ORDER_ID#&payment_id=#Payment:ORDER.ID#&lang='.LANG);
1610 }
1611 else if ($elem['name'] === 'Payment:ORDER.PAY_SYSTEM_ID'
1612 || $elem['name'] === 'Payment:ORDER.PAY_SYSTEM_NAME')
1613 {
1614 $href = array('pattern' => '/bitrix/admin/sale_pay_system_edit.php?ID=#Payment:ORDER.PAY_SYSTEM_ID#&lang='.LANG);
1615 }
1616 }
1617 else if ($field->getEntity()->getName() === 'Shipment')
1618 {
1619 if ($elem['name'] === 'Shipment:REPS_ORDER.ID')
1620 {
1621 $href = array('pattern' => '/bitrix/admin/sale_order_shipment_edit.php?order_id=#Shipment:REPS_ORDER.ORDER_ID#&shipment_id=#Shipment:REPS_ORDER.ID#&lang='.LANG);
1622 }
1623 else if ($elem['name'] === 'Shipment:REPS_ORDER.DELIVERY_ID'
1624 || $elem['name'] === 'Shipment:REPS_ORDER.DELIVERY_NAME')
1625 {
1626 $href = array('pattern' => '/bitrix/admin/sale_delivery_service_edit.php?ID=#Shipment:REPS_ORDER.DELIVERY_ID#&lang='.LANG);
1627 }
1628 }
1629 }
1630
1631 return $href;
1632 }
1633}
1634
1636{
1637 private static $monetaryFields = array(
1638 'DISCOUNT_ALL',
1639 'PRICE',
1640 'SUM_PAID_FORREP',
1641 // Order fields
1642 'TAX_VALUE',
1643 'PRICE_DELIVERY',
1644 'DISCOUNT_ALL',
1645 'PRICE',
1646 'SUM_PAID_FORREP'
1647 );
1648
1649 private static $goodsQuantityFields = array(
1650 'SALE_ORDER_USER_PRODUCTS_QUANT',
1651 // Order fields
1652 'PRODUCTS_QUANT'
1653 );
1654
1655 private static $withoutTotalFields = array(
1656 // Order fields
1657 'PERSON_TYPE_ID'
1658 );
1659
1660 private static $userNotAuthNameFields = array();
1661
1662 public static function getEntityName()
1663 {
1664 return 'Bitrix\Main\User';
1665 }
1666
1667 public static function getOwnerId()
1668 {
1669 return SALE_REPORT_OWNER_ID.'_User';
1670 }
1671
1672 public static function getColumnList()
1673 {
1674 IncludeModuleLangFile(__FILE__);
1675
1676 return array(
1677 'ID',
1678 'DATE_REG_SHORT',
1679 'LAST_LOGIN_SHORT',
1680 'ACTIVE',
1681 'LOGIN',
1682 'NAME',
1683 'LAST_NAME',
1684 /*'LID',*/
1685 'SHORT_NAME',
1686 'PERSONAL_GENDER',
1687 'EMAIL',
1688 'PERSONAL_PHONE',
1689 'Bitrix\Sale\Internals\Order:USER' => array(
1690 'DATE_INSERT_SHORT',
1691 'DATE_UPDATE_SHORT',
1692 'STATUS' => array(
1693 'STATUS_ID',
1694 'NAME',
1695 'DESCRIPTION'
1696 ),
1697 'EMP_STATUS_BY' => array(
1698 'ID',
1699 'NAME',
1700 'LAST_NAME',
1701 'SHORT_NAME',
1702 'EMAIL',
1703 'PERSONAL_PHONE'
1704 ),
1705 'DATE_STATUS_SHORT',
1706 'PRICE_DELIVERY',
1707 'PAYED',
1708 'DEDUCTED',
1709 'PRICE',
1710 'SUM_PAID_FORREP',
1711 'CANCELED',
1712 'EMP_CANCELED_BY' => array(
1713 'ID',
1714 'NAME',
1715 'LAST_NAME',
1716 'SHORT_NAME',
1717 'EMAIL',
1718 'PERSONAL_PHONE'
1719 ),
1720 'DATE_CANCELED_SHORT',
1721 'REASON_CANCELED',
1722 'PRODUCTS_QUANT',
1723 'TAX_VALUE',
1724 'DISCOUNT_ALL',
1725 'PERSON_TYPE_ID'
1726 ),
1727 'UserGroup:USER.GROUP' => array(
1728 'ID',
1729 'NAME'
1730 )
1731 );
1732 }
1733
1734 public static function getCalcVariations()
1735 {
1736 return array_merge(parent::getCalcVariations(), array(
1737 'UserGroup:USER.GROUP.ID' => array(
1738 'COUNT_DISTINCT',
1739 'GROUP_CONCAT'
1740 ),
1741 'UserGroup:USER.GROUP.NAME' => array(
1742 'COUNT_DISTINCT',
1743 'GROUP_CONCAT'
1744 )
1745 ));
1746 }
1747
1748 public static function getCompareVariations()
1749 {
1750 return array_merge(parent::getCompareVariations(), array(
1751 // Order
1752 '\Bitrix\Sale\Internals\StatusLang' => array(
1753 'EQUAL',
1754 'NOT_EQUAL'
1755 ),
1756 'Bitrix\Sale\Internals\Order:USER.PERSON_TYPE_ID' => array(
1757 'EQUAL',
1758 'NOT_EQUAL'
1759 ),
1760 // User
1761 'PERSONAL_GENDER' => array(
1762 'EQUAL',
1763 'NOT_EQUAL'
1764 ),
1765 'UserGroup:USER.GROUP' => array(
1766 'EQUAL',
1767 'NOT_EQUAL'
1768 ),
1769 '\Bitrix\Main\User' => array(
1770 'EQUAL'
1771 ),
1772 '\Bitrix\Main\Group' => array(
1773 'EQUAL'
1774 )
1775 ));
1776 }
1777
1778 public static function getDefaultColumns()
1779 {
1780 return array(
1781 array('name' => 'ID'),
1782 array('name' => 'SHORT_NAME')
1783 );
1784 }
1785
1786 public static function getPeriodFilter($date_from, $date_to)
1787 {
1788 if(is_null($date_from) && is_null($date_to))
1789 {
1790 return array(); // Empty filter for empty time interval.
1791 }
1792
1793 $filter = array('LOGIC' => 'AND');
1794 if(!is_null($date_to))
1795 {
1796 $filter[] = array(
1797 'LOGIC' => 'OR',
1798 '<=DATE_REG_SHORT' => $date_to,
1799 '=DATE_REG_SHORT' => null
1800 );
1801 }
1802
1803 if(!is_null($date_from))
1804 {
1805 $filter[] = array(
1806 'LOGIC' => 'OR',
1807 '>=DATE_REG_SHORT' => $date_from,
1808 '=DATE_REG_SHORT' => null
1809 );
1810 }
1811
1812 return $filter;
1813 }
1814
1815 public static function fillFilterReferenceColumn(&$filterElement, Entity\ReferenceField $field)
1816 {
1817 if ($field->getRefEntityName() == '\Bitrix\Main\User')
1818 {
1819 // USER
1820 if ($filterElement['value'])
1821 {
1822 $res = CUser::GetByID($filterElement['value']);
1823 $user = $res->fetch();
1824
1825 if ($user)
1826 {
1827 $username = CUser::FormatName(CSite::GetNameFormat(null, self::getDefaultSiteId()), $user, true, false);
1828 $filterElement['value'] = array('id' => $user['ID'], 'name' => $username);
1829 }
1830 else
1831 {
1832 $filterElement['value'] = array('id' => $filterElement['value'], 'name' => GetMessage('REPORT_USER_NOT_FOUND'));
1833 }
1834 }
1835 else
1836 {
1837 $filterElement['value'] = array('id' => '');
1838 }
1839 }
1840 else if ($field->getRefEntityName() == '\Bitrix\Main\Group')
1841 {
1842 // GROUP
1843 if ($filterElement['value'])
1844 {
1845 $res = CGroup::GetByID($filterElement['value']);
1846 $group = $res->fetch();
1847
1848 if ($group)
1849 {
1850 $filterElement['value'] = array('id' => $group['ID'], 'name' => $group['NAME']);
1851 }
1852 else
1853 {
1854 $filterElement['value'] = array('id' => $filterElement['value'], 'name' => GetMessage('SALE_REPORT_GROUP_NOT_FOUND'));
1855 }
1856 }
1857 else
1858 {
1859 $filterElement['value'] = array('id' => '');
1860 }
1861 }
1862 }
1863
1864 public static function confirmFilterBackReferenceRewrite($fElem, $chain)
1865 {
1866 if (strncasecmp($fElem['name'], 'Bitrix\Sale\Internals\Order:USER', 23) === 0)
1867 {
1868 return false;
1869 }
1870
1871 return true;
1872 }
1873
1874 public static function confirmSelectBackReferenceRewrite($elem, $chain)
1875 {
1876 if (strncasecmp($elem['name'], 'Bitrix\Sale\Internals\Order:USER', 23) === 0)
1877 {
1878 return false;
1879 }
1880
1881 return true;
1882 }
1883
1884 private static function fieldInFilter(&$filter, $fieldPathStr)
1885 {
1886 foreach ($filter as $k => &$v)
1887 {
1888 if ($k === 'LOGIC') continue;
1889 if (is_array($v)) return(self::fieldInFilter($v, $fieldPathStr));
1890 else if (mb_strpos($k, $fieldPathStr) !== false) return true;
1891 }
1892 return false;
1893 }
1894
1895 private static function filterBySiteNeeded(&$select, &$filter)
1896 {
1897 // The filter by site is necessary, if the field of "Order" entity in the filter or select is used.
1898 $bResult = false;
1899 foreach (array_keys($select) as $k)
1900 {
1901 if (mb_strpos($k, '_SALE_ORDER_USER_') !== false)
1902 {
1903 $bResult = true;
1904 break;
1905 }
1906 }
1907 if (!$bResult)
1908 {
1909 if (self::fieldInFilter($filter, 'Bitrix\Sale\Internals\Order:USER.')) $bResult = true;
1910 }
1911
1912 return $bResult;
1913 }
1914
1915 public static function beforeViewDataQuery(&$select, &$filter, &$group, &$order, &$limit, &$options, &$runtime = null)
1916 {
1917 global $DB;
1918
1919 // Rewrite filter by Site.
1920 if (self::filterBySiteNeeded($select, $filter))
1921 {
1922 if ($filter['LOGIC'] === 'AND')
1923 {
1924 $filter[] = array(
1925 'LOGIC' => 'OR',
1926 array('=Bitrix\Sale\Internals\Order:USER.LID' => $DB->ForSql(self::getDefaultSiteId())),
1927 array('=Bitrix\Sale\Internals\Order:USER.LID' => null)
1928 );
1929 }
1930 else
1931 {
1932 $subFilter = $filter;
1933 foreach (array_keys($filter) as $k)
1934 {
1935 unset($filter[$k]);
1936 }
1937 $filter['LOGIC'] = 'AND';
1938 $filter[] = $subFilter;
1939 $filter[] = array(
1940 'LOGIC' => 'OR',
1941 array('=Bitrix\Sale\Internals\Order:USER.LID' => $DB->ForSql(self::getDefaultSiteId())),
1942 array('=Bitrix\Sale\Internals\Order:USER.LID' => null)
1943 );
1944 }
1945 }
1946 }
1947
1948
1949 /* remove it when PHP 5.3 available */
1950 public static function formatResults(&$rows, &$columnInfo, $total)
1951 {
1952 foreach ($rows as &$row)
1953 {
1954 foreach ($row as $k => &$v)
1955 {
1956 if (!array_key_exists($k, $columnInfo))
1957 {
1958 continue;
1959 }
1960
1961 $cInfo = &$columnInfo[$k];
1962
1963 if (is_array($v))
1964 {
1965 foreach ($v as &$subv)
1966 {
1967 self::formatResultValue($k, $subv, $row, $cInfo, $total);
1968 }
1969 }
1970 else
1971 {
1972 self::formatResultValue($k, $v, $row, $cInfo, $total);
1973 }
1974 }
1975 }
1976
1977 unset($row, $v, $subv);
1978 }
1979 /* \remove it */
1980
1981 public static function formatResultValue($k, &$v, &$row, &$cInfo, $total, &$customChartValue = null)
1982 {
1983 $dataType = self::getFieldDataType($cInfo['field']);
1984
1986 if ($dataType !== 'float' ) // skip base rounding
1987 {
1988 parent::formatResultValue($k, $v, $row, $cInfo, $total);
1989 }
1990
1991 if ($k === 'LID')
1992 {
1993 $v = self::$sitelist[$v];
1994 }
1995 else if ($k === 'PERSONAL_GENDER')
1996 {
1997 $v = self::$genders[$v];
1998 }
1999 // Removing the link from the email field if is empty.
2000 else if ($k === 'EMAIL')
2001 {
2002 if (is_null($v) || empty($v) || $v == '&nbsp;') unset($row['__HREF_'.$k]);
2003 }
2004 else if ($k === 'MAIN_USER_SALE_ORDER_USER_PERSON_TYPE_ID')
2005 {
2006 $v = self::$personTypes[$v]['NAME'];
2007 }
2008
2009 // Inserting zero in numerical fields with null value.
2010 if (empty($v))
2011 {
2012 if (in_array($dataType, array('integer', 'float')))
2013 {
2014 $v = 0;
2015 }
2016 //else $v = '&nbsp;';
2017 }
2018
2019 // Formatting of monetary fields.
2020 foreach (self::$monetaryFields as $monField)
2021 {
2022 if ($cInfo['field']->getEntity()->getDataClass() === 'Bitrix\\Sale\\Internals\\OrderTable'
2023 && preg_match('/'.$monField.'$/', $cInfo['field']->getName()))
2024 {
2026 $v = number_format(doubleval($v), 2, '.', ' ');
2027 break;
2028 }
2029 }
2030
2031 // Formatting fields with goods quantity.
2032 foreach (self::$goodsQuantityFields as $qField)
2033 {
2034 if (preg_match('/'.$qField.'$/', $k))
2035 {
2036 if (!empty($v) && !is_null($v) && $v != '&nbsp;')
2037 {
2038 if (self::$fDecimalQuant) $v = sprintf('%.3f', round($v,3));
2039 else $v = sprintf('%d', round($v,0));
2040 }
2041 break;
2042 }
2043 }
2044
2045 // Formatting short name fields of buyers.
2046 foreach (self::$userNotAuthNameFields as $uField)
2047 {
2048 if (preg_match('/'.$uField.'$/', $k))
2049 {
2050 if (empty($v) || is_null($v) || $v == '&nbsp;')
2051 {
2052 $v = GetMessage('SALE_REPORT_USER_NOT_AUTH');
2053 }
2054 break;
2055 }
2056 }
2057 }
2058
2059 public static function formatResultGroupingTotal($params)
2060 {
2061 $paramTotal = array('TOTAL_'.$params['k'] => &$params['v']);
2062 $viewColumns = array($params['k'] => &$params['cInfo']);
2063 $bFormatOnly = true;
2064 static::formatResultsTotal($paramTotal, $viewColumns, $bFormatOnly);
2065 }
2066
2067 public static function formatResultsTotal(&$total, &$columnInfo, &$bFormatOnly = null)
2068 {
2069 parent::formatResultsTotal($total, $columnInfo);
2070
2071 foreach ($total as $k => &$v)
2072 {
2073 // Formatting of monetary fields.
2074 foreach (self::$monetaryFields as $monField)
2075 {
2076 if (preg_match('/'.$monField.'$/', $k))
2077 {
2078 if (!$bFormatOnly) $v = self::calculateInReportCurrency($v);
2079 $v = number_format(doubleval($v), 2, '.', ' ');
2080 break;
2081 }
2082 }
2083
2084 // Formatting fields with goods quantity.
2085 foreach (self::$goodsQuantityFields as $qField)
2086 {
2087 if (preg_match('/'.$qField.'$/', $k))
2088 {
2089 if (!empty($v) && !is_null($v) && $v != '&nbsp;')
2090 {
2091 if (self::$fDecimalQuant) $v = sprintf('%.3f', round($v,3));
2092 else $v = sprintf('%d', round($v,0));
2093 }
2094 break;
2095 }
2096 }
2097
2098 // Formatting fields without summary calculation.
2099 foreach (self::$withoutTotalFields as $wtField)
2100 {
2101 if (preg_match('/TOTAL_'.$wtField.'$/', $k))
2102 {
2103 unset($total[$k]);
2104 break;
2105 }
2106 }
2107 }
2108 }
2109
2110 public static function getDefaultElemHref($elem, $fList)
2111 {
2112 $href = '';
2113 if (empty($elem['aggr']))
2114 {
2115 $field = $fList[$elem['name']];
2116
2117 if ($field->getEntity()->getName() == 'User')
2118 {
2119 if ($elem['name'] == 'SHORT_NAME')
2120 {
2121 $href = array('pattern' => '/bitrix/admin/sale_buyers_profile.php?USER_ID=#ID#&lang='.LANG);
2122 }
2123 else if ($elem['name'] == 'EMAIL')
2124 {
2125 $href = array('pattern' => 'mailto:#EMAIL#');
2126 }
2127 else if ($elem['name'] == 'Bitrix\Sale\Internals\Order:USER.EMP_STATUS_BY.SHORT_NAME')
2128 {
2129 $href = array('pattern' => '/bitrix/admin/sale_buyers_profile.php?USER_ID=#Bitrix\Sale\Internals\Order:USER.EMP_STATUS_BY.ID#&lang='.LANG);
2130 }
2131 else if ($elem['name'] == 'Bitrix\Sale\Internals\Order:USER.EMP_STATUS_BY.EMAIL')
2132 {
2133 $href = array('pattern' => 'mailto:#Bitrix\Sale\Internals\Order:USER.EMP_STATUS_BY.EMAIL#');
2134 }
2135 else if ($elem['name'] == 'Bitrix\Sale\Internals\Order:USER.EMP_CANCELED_BY.SHORT_NAME')
2136 {
2137 $href = array('pattern' => '/bitrix/admin/sale_buyers_profile.php?USER_ID=#Bitrix\Sale\Internals\Order:USER.EMP_CANCELED_BY.ID#&lang='.LANG);
2138 }
2139 else if ($elem['name'] == 'Bitrix\Sale\Internals\Order:USER.EMP_CANCELED_BY.EMAIL')
2140 {
2141 $href = array('pattern' => 'mailto:#Bitrix\Sale\Internals\Order:USER.EMP_CANCELED_BY.EMAIL#');
2142 }
2143 }
2144 elseif ($field->getEntity()->getName() == 'Order')
2145 {
2146 if ($elem['name'] == 'Bitrix\Sale\Internals\Order:USER.ID')
2147 {
2148 $href = array('pattern' => '/bitrix/admin/sale_order_view.php?ID=#Bitrix\Sale\Internals\Order:USER.ID#&lang='.LANG);
2149 }
2150 }
2151 }
2152
2153 return $href;
2154 }
2155}
2156
2158{
2159 private static $monetaryFields = array(
2160 'PRICE',
2161 'DISCOUNT_PRICE',
2162 'SUMMARY_PRICE',
2163 'VAT_RATE_PRC',
2164 // Order fields
2165 'TAX_VALUE',
2166 'PRICE_DELIVERY',
2167 'DISCOUNT_ALL',
2168 'PRICE',
2169 'SUM_PAID_FORREP',
2170 'PAYMENT_ORDER_SUM',
2171 'PRODUCT_PURCHASING_PRICE_IN_SITE_CURRENCY',
2172 'GROSS_PROFIT',
2173 'PROFITABILITY'
2174 );
2175
2176 private static $goodsQuantityFields = array(
2177 'QUANTITY',
2178 'PRODUCT_QUANTITY',
2179 // Order fields
2180 'PRODUCTS_QUANT'
2181 );
2182
2183 private static $withoutTotalFields = array(
2184 'PRODUCT_ID',
2185 'FUSER_ID',
2186 'ORDER_ID',
2187 'PRODUCT_SALE_GOODS_SECTION_PROD_SECT_ID',
2188 'PRODUCT_SALE_GOODS_SECTION_PROD_SECT_NAME',
2189 'VAT_RATE_PRC',
2190 // Order fields
2191 'PERSON_TYPE_ID'
2192 );
2193
2194 private static $avgGroupingAggregationFields = array(
2195 'PROFITABILITY'
2196 );
2197
2198 private static $userNotAuthNameFields = array(
2199 'FUSER_USER_SHORT_NAME'
2200 );
2201
2202 private static $currentIblockFilter = array('value' => null, 'compare' => null);
2203
2204 public static function getEntityName()
2205 {
2206 return 'Bitrix\Sale\Internals\Basket';
2207 }
2208
2209 public static function getOwnerId()
2210 {
2211 return SALE_REPORT_OWNER_ID.'_SaleBasket';
2212 }
2213
2214 public static function getColumnList()
2215 {
2216 IncludeModuleLangFile(__FILE__);
2217 return array(
2218 'ID',
2219 'FUSER_ID',
2220 'FUSER.USER' => array(
2221 'ID',
2222 'SHORT_NAME',
2223 'EMAIL',
2224 'PERSONAL_PHONE',
2225 'UserGroup:USER.GROUP' => array(
2226 'ID',
2227 'NAME'
2228 )
2229 ),
2230 'DATE_INS',
2231 'DATE_UPD',
2232 'PRODUCT_ID',
2233 'NAME',
2234 'NAME_WITH_IDENT',
2235 'DELAY',
2236 'ORDER_ID',
2237 'ORDER' => array(
2238 'DATE_INSERT_SHORT',
2239 'DATE_UPDATE_SHORT',
2240 'STATUS' => array(
2241 'STATUS_ID',
2242 'NAME',
2243 'DESCRIPTION'
2244 ),
2245 'EMP_STATUS_BY' => array(
2246 'ID',
2247 'NAME',
2248 'LAST_NAME',
2249 'SHORT_NAME',
2250 'EMAIL',
2251 'PERSONAL_PHONE'
2252 ),
2253 'DATE_STATUS_SHORT',
2254 'PRICE_DELIVERY',
2255 'PAYED',
2256 'Payment:ORDER' => array(
2257 'ID',
2258 'DATE_BILL',
2259 'DATE_PAY_BEFORE',
2260 'DATE_PAID',
2261 'EMP_PAID_BY' => array(
2262 'ID',
2263 'NAME',
2264 'LAST_NAME',
2265 'SHORT_NAME',
2266 'EMAIL',
2267 'PERSONAL_PHONE'
2268 ),
2269 'PAY_VOUCHER_NUM',
2270 'PAY_VOUCHER_DATE',
2271 'PAY_SYSTEM_ID',
2272 'PAY_SYSTEM_NAME',
2273 'PAY_RETURN_NUM',
2274 'PAY_RETURN_DATE',
2275 'SUM',
2276 'CURRENCY',
2277 'RESPONSIBLE_BY' => array(
2278 'ID',
2279 'NAME',
2280 'LAST_NAME',
2281 'SHORT_NAME',
2282 'EMAIL',
2283 'PERSONAL_PHONE'
2284 )
2285 ),
2286 'DEDUCTED',
2287 'Shipment:REPS_ORDER' => array(
2288 'ID',
2289 'ALLOW_DELIVERY',
2290 'DELIVERY_ID',
2291 'DELIVERY_NAME',
2292 'EMP_ALLOW_DELIVERY_BY' => array(
2293 'ID',
2294 'NAME',
2295 'LAST_NAME',
2296 'SHORT_NAME',
2297 'EMAIL',
2298 'PERSONAL_PHONE'
2299 ),
2300 'DATE_ALLOW_DELIVERY_SHORT',
2301 'DELIVERY_DOC_NUM',
2302 'DELIVERY_DOC_DATE_SHORT',
2303 'DEDUCTED',
2304 'EMP_DEDUCTED_BY' => array(
2305 'ID',
2306 'NAME',
2307 'LAST_NAME',
2308 'SHORT_NAME',
2309 'EMAIL',
2310 'PERSONAL_PHONE'
2311 ),
2312 'DATE_DEDUCTED_SHORT',
2313 'RESERVED',
2314 'TRACKING_NUMBER',
2315 'PRICE_DELIVERY',
2316 'CURRENCY',
2317 'RESPONSIBLE_BY' => array(
2318 'ID',
2319 'NAME',
2320 'LAST_NAME',
2321 'SHORT_NAME',
2322 'EMAIL',
2323 'PERSONAL_PHONE'
2324 )
2325 ),
2326 'PRICE',
2327 'SUM_PAID_FORREP',
2328 'CANCELED',
2329 'EMP_CANCELED_BY' => array(
2330 'ID',
2331 'NAME',
2332 'LAST_NAME',
2333 'SHORT_NAME',
2334 'EMAIL',
2335 'PERSONAL_PHONE'
2336 ),
2337 'DATE_CANCELED_SHORT',
2338 'REASON_CANCELED',
2339 'PRODUCTS_QUANT',
2340 'TAX_VALUE',
2341 'DISCOUNT_ALL',
2342 'PERSON_TYPE_ID'
2343 ),
2344 'PRICE',
2345 'DISCOUNT_PRICE',
2346 'DISCOUNT_NAME',
2347 'DISCOUNT_VALUE',
2348 'NOTES',
2349 'QUANTITY',
2350 'SUMMARY_PRICE',
2351 'VAT_RATE_PRC',
2352 'PRODUCT.ACTIVE',
2353 'SUBSCRIBE',
2354 'N_SUBSCRIBE',
2355 'PRODUCT.QUANTITY',
2356 'SUMMARY_PURCHASING_PRICE',
2357 'GROSS_PROFIT',
2358 'PROFITABILITY',
2359 'PRODUCT.GoodsSection:PRODUCT.SECT' => array(
2360 'ID',
2361 'NAME'
2362 )
2363 );
2364 }
2365
2366 public static function getDefaultColumns()
2367 {
2368 return array(
2369 array('name' => 'ID'),
2370 array('name' => 'DATE_UPD'),
2371 array('name' => 'ORDER_ID'),
2372 array('name' => 'PRODUCT_ID'),
2373 array('name' => 'NAME')
2374 );
2375 }
2376
2377 public static function getCalcVariations()
2378 {
2379 return array_merge(parent::getCalcVariations(), array(
2380 'date' => array(
2381 'MIN',
2382 'MAX',
2383 'COUNT_DISTINCT'
2384 ),
2385 'FUSER.USER.UserGroup:USER.GROUP.ID' => array(
2386 'COUNT_DISTINCT',
2387 'GROUP_CONCAT'
2388 ),
2389 'FUSER.USER.UserGroup:USER.GROUP.NAME' => array(
2390 'COUNT_DISTINCT',
2391 'GROUP_CONCAT'
2392 ),
2393 'PRODUCT.GoodsSection:PRODUCT.SECT.ID' => array(
2394 'COUNT_DISTINCT',
2395 'GROUP_CONCAT'
2396 ),
2397 'PRODUCT.GoodsSection:PRODUCT.SECT.NAME' => array(
2398 'COUNT_DISTINCT',
2399 'GROUP_CONCAT'
2400 )
2401 ));
2402 }
2403
2404 public static function getCompareVariations()
2405 {
2406 return array_merge(parent::getCompareVariations(), array(
2407 'date' => array(
2408 'EQUAL',
2409 'GREATER_OR_EQUAL',
2410 'GREATER',
2411 'LESS',
2412 'LESS_OR_EQUAL',
2413 'NOT_EQUAL'
2414 ),
2415 // Order
2416 'ORDER.LID' => array(
2417 'EQUAL',
2418 'NOT_EQUAL'
2419 ),
2420 'ORDER.PERSON_TYPE_ID' => array(
2421 'EQUAL',
2422 'NOT_EQUAL'
2423 ),
2424 'ORDER.STATUS' => array(
2425 'EQUAL',
2426 'NOT_EQUAL'
2427 ),
2428 // Basket
2429 'PRODUCT.GoodsSection:PRODUCT.SECT' => array(
2430 'EQUAL'/*,
2431 'NOT_EQUAL'*/
2432 ),
2433 'FUSER.USER.UserGroup:USER.GROUP' => array(
2434 'EQUAL',
2435 'NOT_EQUAL'
2436 ),
2437 '\Bitrix\Main\User' => array(
2438 'EQUAL'
2439 ),
2440 '\Bitrix\Main\Group' => array(
2441 'EQUAL'
2442 )
2443 ));
2444 }
2445
2446 public static function getPeriodFilter($date_from, $date_to)
2447 {
2448 global $DB;
2449
2450 $filter = array('LOGIC' => 'AND');
2451
2452 if(!is_null($date_to))
2453 {
2454 $filter[] = array(
2455 'LOGIC' => 'OR',
2456 '<=DATE_UPD' => $date_to,
2457 '=DATE_UPD' => null
2458 );
2459 }
2460
2461 if(!is_null($date_from))
2462 {
2463 $filter[] = array(
2464 'LOGIC' => 'OR',
2465 '>=DATE_UPD' => $date_from,
2466 '=DATE_UPD' => null
2467 );
2468 }
2469
2470 // Site filter
2471 $filter[] = array(
2472 '=LID' => $DB->ForSql(self::getDefaultSiteId())
2473 );
2474
2475 return $filter;
2476 }
2477
2478 public static function beforeFilterBackReferenceRewrite(&$filter, $viewColumns)
2479 {
2480 // Field for filtering category of the goods
2481 $fieldName = 'PRODUCT.GoodsSection:PRODUCT.SECT.ID';
2482
2483 // <editor-fold defaultstate="collapsed" desc="Preparation of multiple filters">
2484 foreach ($filter as $fId => &$fInfo)
2485 {
2486 foreach ($fInfo as $k => &$fElem)
2487 {
2488 if (is_array($fElem) && $fElem['type'] == 'field')
2489 {
2490 $columnName = '';
2491
2492 if (preg_match('/__COLUMN__(\d+)/', $fElem['name'], $match))
2493 {
2494 $num = $match[1];
2495 $columnName = $viewColumns[$num]['fieldName'];
2496 }
2497
2498 if ($fElem['name'] == $fieldName || $columnName == $fieldName)
2499 {
2500 $iblockFilterCompare = $fElem['compare'];
2501 if ($iblockFilterCompare === 'EQUAL'/* || $iblockFilterCompare === 'NOT_EQUAL'*/)
2502 {
2503 $iblockFilterValue = array();
2504 $arFilterValues = array();
2505 if (is_array($fElem['value'])) $arFilterValues = $fElem['value'];
2506 else $arFilterValues[] = $fElem['value'];
2507 foreach ($arFilterValues as $l => $filterValue)
2508 {
2509 if (is_string($filterValue) && $filterValue[0] == 'c')
2510 {
2511 $iblockFilterValue[] = intval(mb_substr($filterValue, 1));
2512 // The filter on a section is deleted if the filter only according
2513 // to the catalog is necessary
2514 unset($arFilterValues[$l]);
2515 }
2516 else
2517 {
2518 $sections = array();
2519 foreach (parent::$catalogSections as $sectKey => $sect)
2520 {
2521 if ($sectKey == $filterValue) $iblockFilterValue[] = intval($sect['catalog']['ID']);
2522 if (in_array($filterValue, $sect['path'])) $sections[] = $sectKey;
2523 }
2524 $arFilterValues[$l] = $sections;
2525 }
2526 }
2527 $l = count($arFilterValues);
2528 if ($l === 0) unset($fInfo[$k]);
2529 else if ($l === 1) $fInfo[$k]['value'] = reset($arFilterValues);
2530 else
2531 {
2532 $newFilterValue = array();
2533 foreach ($arFilterValues as $filterValue)
2534 {
2535 $newFilterValue = array_merge($newFilterValue, $filterValue);
2536 }
2537 $newFilterValue = array_unique($newFilterValue);
2538 $fInfo[$k]['value'] = $newFilterValue;
2539 }
2540 $l = count($iblockFilterValue);
2541 if ($l === 0) $iblockFilterValue = null;
2542 else if ($l === 1) $iblockFilterValue = reset($iblockFilterValue);
2543 else $iblockFilterValue = array_unique($iblockFilterValue);
2544 self::$currentIblockFilter['value'] = $iblockFilterValue;
2545 self::$currentIblockFilter['compare'] = $iblockFilterCompare;
2546 }
2547 }
2548 }
2549 }
2550 }
2551 // </editor-fold>
2552 }
2553
2554 public static function beforeViewDataQuery(&$select, &$filter, &$group, &$order, &$limit, &$options, &$runtime = null)
2555 {
2556 if (self::$currentIblockFilter['value'])
2557 {
2558 $filter[] = array(
2559 'LOGIC' => 'AND',
2560 ((self::$currentIblockFilter['compare'] === 'EQUAL') ? '=' : '!=').'PRODUCT.IBLOCK.IBLOCK_ID' => self::$currentIblockFilter['value']
2561 );
2562 }
2563 self::$currentIblockFilter['value'] = null;
2564 self::$currentIblockFilter['compare'] = null;
2565 }
2566
2567 public static function fillFilterReferenceColumn(&$filterElement, Entity\ReferenceField $field)
2568 {
2569 if ($field->getRefEntityName() == '\Bitrix\Main\User')
2570 {
2571 // USER
2572 if ($filterElement['value'])
2573 {
2574 $res = CUser::GetByID($filterElement['value']);
2575 $user = $res->fetch();
2576
2577 if ($user)
2578 {
2579 $username = CUser::FormatName(CSite::GetNameFormat(null, self::getDefaultSiteId()), $user, true, false);
2580 $filterElement['value'] = array('id' => $user['ID'], 'name' => $username);
2581 }
2582 else
2583 {
2584 $filterElement['value'] = array('id' => $filterElement['value'], 'name' => GetMessage('REPORT_USER_NOT_FOUND'));
2585 }
2586 }
2587 else
2588 {
2589 $filterElement['value'] = array('id' => '');
2590 }
2591 }
2592 else if ($field->getRefEntityName() == '\Bitrix\Main\Group')
2593 {
2594 // GROUP
2595 if ($filterElement['value'])
2596 {
2597 $res = CGroup::GetByID($filterElement['value']);
2598 $group = $res->fetch();
2599
2600 if ($group)
2601 {
2602 $filterElement['value'] = array('id' => $group['ID'], 'name' => $group['NAME']);
2603 }
2604 else
2605 {
2606 $filterElement['value'] = array('id' => $filterElement['value'], 'name' => GetMessage('SALE_REPORT_GROUP_NOT_FOUND'));
2607 }
2608 }
2609 else
2610 {
2611 $filterElement['value'] = array('id' => '');
2612 }
2613 }
2614 }
2615
2616 /* remove it when PHP 5.3 available */
2617 public static function formatResults(&$rows, &$columnInfo, $total)
2618 {
2619 foreach ($rows as &$row)
2620 {
2621 foreach ($row as $k => &$v)
2622 {
2623 if (!array_key_exists($k, $columnInfo))
2624 {
2625 continue;
2626 }
2627
2628 $cInfo = &$columnInfo[$k];
2629
2630 if (is_array($v))
2631 {
2632 foreach ($v as &$subv)
2633 {
2634 self::formatResultValue($k, $subv, $row, $cInfo, $total);
2635 }
2636 }
2637 else
2638 {
2639 self::formatResultValue($k, $v, $row, $cInfo, $total);
2640 }
2641 }
2642 }
2643
2644 unset($row, $v, $subv);
2645 }
2646 /* \remove it */
2647
2648 public static function formatResultValue($k, &$v, &$row, &$cInfo, $total, &$customChartValue = null)
2649 {
2650 $dataType = self::getFieldDataType($cInfo['field']);
2651
2653 if ($dataType !== 'float' ) // skip base rounding
2654 {
2655 parent::formatResultValue($k, $v, $row, $cInfo, $total);
2656 }
2657
2658 if ($k === 'SALE_BASKET_ORDER_PERSON_TYPE_ID')
2659 {
2660 $v = self::$personTypes[$v]['NAME'];
2661 }
2662 // Removing the link from the email field if is empty.
2663 else if ($k === 'SALE_BASKET_FUSER_USER_EMAIL')
2664 {
2665 if (is_null($v) || empty($v) || $v == '&nbsp;') unset($row['__HREF_'.$k]);
2666 }
2667
2668
2669 // Inserting zero in numerical fields with null value.
2670 if (empty($v))
2671 {
2672 if (in_array($dataType, array('integer', 'float')))
2673 {
2674 $v = 0;
2675 }
2676 //else $v = '&nbsp;';
2677 }
2678
2679 if (empty($cInfo['aggr']))
2680 {
2681 if (($cInfo['field']->getEntity()->getName() === 'Shipment'
2682 && in_array($cInfo['field']->getName(), array('ID', 'DELIVERY_ID', 'DELIVERY_NAME'), true))
2683 || ($cInfo['field']->getEntity()->getName() === 'Payment'
2684 && in_array($cInfo['field']->getName(), array('ID', 'PAY_SYSTEM_ID', 'PAY_SYSTEM_NAME'), true)))
2685 {
2686 if (is_null($v) || empty($v) || $v == '&nbsp;')
2687 {
2688 unset($row['__HREF_'.$k]);
2689 }
2690 }
2691 }
2692
2693 // Formatting of monetary fields.
2694 foreach (self::$monetaryFields as $monField)
2695 {
2696 if (preg_match('/'.$monField.'$/', $k))
2697 {
2699 $v = number_format(doubleval($v), 2, '.', ' ');
2700 break;
2701 }
2702 }
2703
2704 // Formatting fields with goods quantity.
2705 foreach (self::$goodsQuantityFields as $qField)
2706 {
2707 if (preg_match('/'.$qField.'$/', $k))
2708 {
2709 if (!empty($v) && !is_null($v) && $v != '&nbsp;')
2710 {
2711 if (self::$fDecimalQuant) $v = sprintf('%.3f', round($v,3));
2712 else $v = sprintf('%d', round($v,0));
2713 }
2714 break;
2715 }
2716 }
2717
2718 // Formatting short name fields of buyers.
2719 foreach (self::$userNotAuthNameFields as $uField)
2720 {
2721 if (preg_match('/'.$uField.'$/', $k))
2722 {
2723 if (empty($v) || is_null($v) || $v == '&nbsp;')
2724 {
2725 $v = GetMessage('SALE_REPORT_USER_NOT_AUTH');
2726 unset($row['__HREF_'.$k]);
2727 }
2728 break;
2729 }
2730 }
2731
2732 // fields has average grouping aggregation (default grouping aggregation is sum)
2733 if (!isset($cInfo['grouping_aggr']))
2734 {
2735 foreach (self::$avgGroupingAggregationFields as $aggrField)
2736 {
2737 if (preg_match('/'.$aggrField.'$/', $k))
2738 {
2739 $cInfo['grouping_aggr'] = 'AVG';
2740 }
2741 }
2742 }
2743 }
2744
2745 public static function formatResultGroupingTotal($params)
2746 {
2747 $paramTotal = array('TOTAL_'.$params['k'] => &$params['v']);
2748 $viewColumns = array($params['k'] => &$params['cInfo']);
2749 $bFormatOnly = true;
2750 static::formatResultsTotal($paramTotal, $viewColumns, $bFormatOnly);
2751 }
2752
2753 public static function formatResultsTotal(&$total, &$columnInfo, &$bFormatOnly = null)
2754 {
2755 parent::formatResultsTotal($total, $columnInfo);
2756
2757 foreach ($total as $k => &$v)
2758 {
2759 // Formatting of monetary fields.
2760 foreach (self::$monetaryFields as $monField)
2761 {
2762 if (preg_match('/'.$monField.'$/', $k))
2763 {
2764 if (!$bFormatOnly) $v = self::calculateInReportCurrency($v);
2765 $v = number_format(doubleval($v), 2, '.', ' ');
2766 break;
2767 }
2768 }
2769
2770 // Formatting fields with goods quantity.
2771 foreach (self::$goodsQuantityFields as $qField)
2772 {
2773 if (preg_match('/'.$qField.'$/', $k))
2774 {
2775 if (!empty($v) && !is_null($v) && $v != '&nbsp;')
2776 {
2777 if (self::$fDecimalQuant) $v = sprintf('%.3f', round($v,3));
2778 else $v = sprintf('%d', round($v,0));
2779 }
2780 break;
2781 }
2782 }
2783
2784 // Formatting fields without summary calculation.
2785 foreach (self::$withoutTotalFields as $wtField)
2786 {
2787 if (preg_match('/TOTAL_'.$wtField.'$/', $k))
2788 {
2789 unset($total[$k]);
2790 break;
2791 }
2792 }
2793 }
2794 }
2795
2796 public static function getDefaultElemHref($elem, $fList)
2797 {
2798 $href = '';
2799 if (empty($elem['aggr']))
2800 {
2801 $field = $fList[$elem['name']];
2802
2803 if ($field->getEntity()->getName() == 'User')
2804 {
2805 if (in_array(
2806 $elem['name'],
2807 array(
2808 'FUSER.USER.EMAIL',
2809 'ORDER.EMP_CANCELED_BY.EMAIL',
2810 'ORDER.EMP_STATUS_BY.EMAIL',
2811 'ORDER.Payment:ORDER.EMP_PAID_BY.EMAIL',
2812 'ORDER.Payment:ORDER.RESPONSIBLE_BY.EMAIL',
2813 'ORDER.Shipment:REPS_ORDER.EMP_ALLOW_DELIVERY_BY.EMAIL',
2814 'ORDER.Shipment:REPS_ORDER.EMP_DEDUCTED_BY.EMAIL',
2815 'ORDER.Shipment:REPS_ORDER.RESPONSIBLE_BY.EMAIL'
2816 ),
2817 true))
2818 {
2819 $href = array('pattern' => 'mailto:#'.$elem['name'].'#');
2820 }
2821 else if (in_array(
2822 $elem['name'],
2823 array(
2824 'FUSER.USER.SHORT_NAME',
2825 'ORDER.EMP_CANCELED_BY.SHORT_NAME',
2826 'ORDER.EMP_STATUS_BY.SHORT_NAME',
2827 'ORDER.Payment:ORDER.EMP_PAID_BY.SHORT_NAME',
2828 'ORDER.Payment:ORDER.RESPONSIBLE_BY.SHORT_NAME',
2829 'ORDER.Shipment:REPS_ORDER.EMP_ALLOW_DELIVERY_BY.SHORT_NAME',
2830 'ORDER.Shipment:REPS_ORDER.EMP_DEDUCTED_BY.SHORT_NAME',
2831 'ORDER.Shipment:REPS_ORDER.RESPONSIBLE_BY.SHORT_NAME'
2832 ),
2833 true))
2834 {
2835 $userDef = mb_substr($elem['name'], 0, -11);
2836 $href = array('pattern' => '/bitrix/admin/sale_buyers_profile.php?USER_ID=#'.$userDef.'.ID#&lang='.LANG);
2837 }
2838 }
2839 elseif ($field->getEntity()->getName() == 'Basket')
2840 {
2841 if ($elem['name'] == 'NAME' || $elem['name'] == 'NAME_WITH_IDENT')
2842 {
2843 $href = array('pattern' => '/bitrix/admin/cat_product_edit.php?IBLOCK_ID='.
2844 '#PRODUCT.IBLOCK.IBLOCK.ID#&type=#PRODUCT.IBLOCK.IBLOCK.IBLOCK_TYPE_ID#&ID='.
2845 '#PRODUCT_ID#&lang='.LANG.'&WF=Y');
2846 }
2847 elseif ($elem['name'] == 'ORDER_ID')
2848 {
2849 $href = array('pattern' => '/bitrix/admin/sale_order_view.php?ID=#ORDER_ID#&lang='.LANG);
2850 }
2851 }
2852 else if ($field->getEntity()->getName() == 'Order')
2853 {
2854 if ($elem['name'] === 'ORDER.ID')
2855 {
2856 $href = array('pattern' => '/bitrix/admin/sale_order_view.php?ID=#ORDER.ID#&lang='.LANG);
2857 }
2858 }
2859 else if ($field->getEntity()->getName() === 'Payment')
2860 {
2861 if ($elem['name'] === 'ORDER.Payment:ORDER.ID')
2862 {
2863 $href = array('pattern' => '/bitrix/admin/sale_order_payment_edit.php?order_id=#ORDER.Payment:ORDER.ORDER_ID#&payment_id=#ORDER.Payment:ORDER.ID#&lang='.LANG);
2864 }
2865 else if ($elem['name'] === 'ORDER.Payment:ORDER.PAY_SYSTEM_ID'
2866 || $elem['name'] === 'ORDER.Payment:ORDER.PAY_SYSTEM_NAME')
2867 {
2868 $href = array('pattern' => '/bitrix/admin/sale_pay_system_edit.php?ID=#ORDER.Payment:ORDER.PAY_SYSTEM_ID#&lang='.LANG);
2869 }
2870 }
2871 else if ($field->getEntity()->getName() === 'Shipment')
2872 {
2873 if ($elem['name'] === 'ORDER.Shipment:REPS_ORDER.ID')
2874 {
2875 $href = array('pattern' => '/bitrix/admin/sale_order_shipment_edit.php?order_id=#ORDER.Shipment:REPS_ORDER.ORDER_ID#&shipment_id=#ORDER.Shipment:REPS_ORDER.ID#&lang='.LANG);
2876 }
2877 else if ($elem['name'] === 'ORDER.Shipment:REPS_ORDER.DELIVERY_ID'
2878 || $elem['name'] === 'ORDER.Shipment:REPS_ORDER.DELIVERY_NAME')
2879 {
2880 $href = array('pattern' => '/bitrix/admin/sale_delivery_service_edit.php?ID=#ORDER.Shipment:REPS_ORDER.DELIVERY_ID#&lang='.LANG);
2881 }
2882 }
2883 }
2884
2885 return $href;
2886 }
2887}
2888
2890{
2891 private static $customProductFilter = 'all';
2892
2893 private static $monetaryFields = array(
2894 'PRICE_IN_SITE_CURRENCY',
2895 'SUMMARY_PRICE_IN_SITE_CURRENCY',
2896 'PURCHASING_PRICE_IN_SITE_CURRENCY'
2897 );
2898
2899 private static $goodsQuantityFields = array(
2900 'QUANTITY',
2901 'SALED_PRODUCTS_IN_PERIOD_BY_SHOP',
2902 'CONSUMED_PRODUCTS_IN_PERIOD_BY_SHOP',
2903 'ARRIVED_PRODUCTS_IN_PERIOD_BY_SHOP',
2904 'ARRIVED_PRODUCTS_IN_PERIOD_BY_STORE',
2905 'EXPENSE_PRODUCTS_IN_PERIOD_BY_STORE',
2906 'STORE_PRODUCT_SALE_PRODUCT_AMOUNT'
2907 );
2908
2909 private static $withoutTotalFields = array(
2910 'CONVERSION',
2911 'PRODUCT_STORE_ID'
2912 );
2913
2914 private static $userNotAuthNameFields = array();
2915
2916 private static $currentIblockFilter = array('value' => null, 'compare' => null);
2917
2918 public static function setCustomProductFilter($strFilterValue)
2919 {
2920 self::$customProductFilter = $strFilterValue;
2921 }
2922
2924 {
2925 self::$bUsePriceTypesColumns = $bUsePriceTypesColumns;
2926 }
2927
2928
2929 public static function getCustomProductFilter()
2930 {
2931 return self::$customProductFilter;
2932 }
2933
2934 public static function getEntityName()
2935 {
2936 return 'Bitrix\Sale\Internals\Product';
2937 }
2938
2939 public static function getOwnerId()
2940 {
2941 return SALE_REPORT_OWNER_ID.'_SaleProduct';
2942 }
2943
2944 public static function getColumnList()
2945 {
2946 IncludeModuleLangFile(__FILE__);
2947
2948 return array(
2949 'ID',
2950 'QUANTITY',
2951 'NAME',
2952 'NAME_WITH_IDENT',
2953 'ACTIVE',
2954 'WEIGHT_IN_SITE_UNITS',
2955 'PRICE_IN_SITE_CURRENCY',
2956 'PURCHASING_PRICE_IN_SITE_CURRENCY',
2957 'SUMMARY_PRICE_IN_SITE_CURRENCY',
2958 'VIEWS_IN_PERIOD_BY_SHOP',
2959 'SUBSCRIPTIONS_IN_PERIOD_BY_SHOP',
2960 'ORDERS_IN_PERIOD_BY_SHOP',
2961 'CONVERSION',
2962 'SALED_PRODUCTS_IN_PERIOD_BY_SHOP',
2963 'CONSUMED_PRODUCTS_IN_PERIOD_BY_SHOP',
2964 'ARRIVED_PRODUCTS_IN_PERIOD_BY_SHOP',
2965 'ARRIVED_PRODUCTS_IN_PERIOD_BY_STORE',
2966 'EXPENSE_PRODUCTS_IN_PERIOD_BY_STORE',
2967 'IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION' => array(
2968 'ID',
2969 'NAME'
2970 ),
2971 'StoreProduct:SALE_PRODUCT' => array(
2972 'STORE.ID',
2973 'STORE.TITLE',
2974 'STORE.ADDRESS',
2975 'STORE.DESCRIPTION',
2976 'STORE.PHONE',
2977 'STORE.SCHEDULE',
2978 'AMOUNT'
2979 )
2980 );
2981 }
2982
2983 public static function setRuntimeFields(\Bitrix\Main\Entity\Base $entity, $sqlTimeInterval)
2984 {
2985 global $DB;
2986
2987 $entity->addField(array(
2988 'data_type' => 'integer',
2989 'expression' => array(
2990 '(SELECT SUM(b_catalog_viewed_product.VIEW_COUNT) FROM b_catalog_product, b_catalog_viewed_product WHERE %s = b_catalog_viewed_product.ELEMENT_ID
2991 AND b_catalog_product.ID = b_catalog_viewed_product.ELEMENT_ID
2992 AND b_catalog_viewed_product.DATE_VISIT '.$sqlTimeInterval.' AND b_catalog_viewed_product.SITE_ID = \''.$DB->ForSql(self::getDefaultSiteId()).'\')', 'ID'
2993 )
2994 ), 'VIEWS_IN_PERIOD_BY_SHOP');
2995
2996 $entity->addField(array(
2997 'data_type' => 'integer',
2998 'expression' => array(
2999 '(SELECT SUM(1) FROM b_catalog_subscribe WHERE b_catalog_subscribe.ITEM_ID = %s
3000 AND b_catalog_subscribe.DATE_FROM '.$sqlTimeInterval.'
3001 AND b_catalog_subscribe.SITE_ID = \''.$DB->ForSql(self::getDefaultSiteId()).'\')', 'ID'
3002 )
3003 ), 'SUBSCRIPTIONS_IN_PERIOD_BY_SHOP');
3004
3005 $entity->addField(array(
3006 'data_type' => 'integer',
3007 'expression' => array(
3008 '(SELECT COUNT(DISTINCT b_sale_order.ID)
3009 FROM b_catalog_product
3010 INNER JOIN b_sale_basket ON b_catalog_product.ID = b_sale_basket.PRODUCT_ID
3011 INNER JOIN b_sale_order ON b_sale_basket.ORDER_ID = b_sale_order.ID
3012 WHERE
3013 b_catalog_product.ID = %s
3014 AND b_sale_order.PAYED = \'Y\'
3015 AND b_sale_order.DATE_INSERT '.$sqlTimeInterval.'
3016 AND b_sale_basket.LID = \''.$DB->ForSql(self::getDefaultSiteId()).'\')', 'ID'
3017 )
3018 ), 'ORDERS_IN_PERIOD_BY_SHOP');
3019
3020 $entity->addField(array(
3021 'data_type' => 'integer',
3022 'expression' => array(
3023 $DB->isNull('(SELECT SUM(b_sale_basket.QUANTITY)
3024 FROM b_sale_basket
3025 INNER JOIN b_sale_order ON b_sale_basket.ORDER_ID = b_sale_order.ID
3026 WHERE b_sale_basket.PRODUCT_ID = %s
3027 AND b_sale_order.PAYED = \'Y\'
3028 AND b_sale_order.DEDUCTED = \'Y\'
3029 AND b_sale_order.DATE_INSERT '.$sqlTimeInterval.'
3030 AND b_sale_basket.LID = \''.$DB->ForSql(self::getDefaultSiteId()).'\')', 0),
3031 'ID'
3032 )
3033 ), 'SALED_PRODUCTS_IN_PERIOD_BY_SHOP');
3034
3035 $entity->addField(array(
3036 'data_type' => 'integer',
3037 'expression' => array(
3038 $DB->isNull('(SELECT SUM(b_sale_basket.QUANTITY)
3039 FROM b_sale_basket
3040 INNER JOIN b_sale_order ON b_sale_basket.ORDER_ID = b_sale_order.ID
3041 WHERE b_sale_basket.PRODUCT_ID = %s
3042 AND b_sale_order.PAYED = \'Y\'
3043 AND b_sale_order.DEDUCTED = \'Y\'
3044 AND b_sale_order.DATE_INSERT '.$sqlTimeInterval.'
3045 AND b_sale_basket.LID = \''.$DB->ForSql(self::getDefaultSiteId()).'\')', 0).'+'.
3046 $DB->isNull('(SELECT SUM(b_catalog_docs_element.AMOUNT)
3047 FROM b_catalog_store_docs
3048 INNER JOIN b_catalog_docs_element on b_catalog_store_docs.ID = b_catalog_docs_element.DOC_ID
3049 WHERE b_catalog_store_docs.DOC_TYPE = \'D\'
3050 AND b_catalog_store_docs.STATUS = \'Y\'
3051 AND b_catalog_store_docs.DATE_DOCUMENT '.$sqlTimeInterval.'
3052 AND b_catalog_docs_element.ELEMENT_ID = %s)', 0),
3053 'ID', 'ID'
3054 )
3055 ), 'CONSUMED_PRODUCTS_IN_PERIOD_BY_SHOP');
3056
3057 $entity->addField(array(
3058 'data_type' => 'float',
3059 'expression' => array(
3060 '(SELECT SUM(b_catalog_docs_element.AMOUNT)
3061 FROM b_catalog_store_docs
3062 INNER JOIN b_catalog_docs_element on b_catalog_store_docs.ID = b_catalog_docs_element.DOC_ID
3063 WHERE b_catalog_store_docs.DOC_TYPE in (\'A\', \'R\')
3064 AND b_catalog_store_docs.STATUS = \'Y\'
3065 AND b_catalog_store_docs.DATE_DOCUMENT '.$sqlTimeInterval.'
3066 AND b_catalog_docs_element.ELEMENT_ID = %s)', 'ID'
3067 )
3068 ), 'ARRIVED_PRODUCTS_IN_PERIOD_BY_SHOP');
3069
3070 $entity->addField(array(
3071 'data_type' => 'float',
3072 'expression' => array(
3073 '(SELECT SUM(b_catalog_docs_element.AMOUNT)
3074 FROM b_catalog_store_docs
3075 INNER JOIN b_catalog_docs_element on b_catalog_store_docs.ID = b_catalog_docs_element.DOC_ID
3076 WHERE b_catalog_store_docs.DOC_TYPE in (\'A\', \'M\', \'R\')
3077 AND b_catalog_store_docs.STATUS = \'Y\'
3078 AND b_catalog_store_docs.DATE_DOCUMENT '.$sqlTimeInterval.'
3079 AND b_catalog_docs_element.STORE_TO = %s
3080 AND b_catalog_docs_element.ELEMENT_ID = %s)', 'StoreProduct:SALE_PRODUCT.STORE_ID', 'ID'
3081 )
3082 ), 'ARRIVED_PRODUCTS_IN_PERIOD_BY_STORE');
3083
3084 $entity->addField(array(
3085 'data_type' => 'integer',
3086 'expression' => array(
3087 $DB->isNull('(SELECT SUM(b_sale_store_barcode.QUANTITY)
3088 FROM b_sale_store_barcode
3089 INNER JOIN b_sale_basket ON b_sale_store_barcode.BASKET_ID = b_sale_basket.ID
3090 INNER JOIN b_sale_order ON b_sale_basket.ORDER_ID = b_sale_order.ID
3091 WHERE b_sale_store_barcode.STORE_ID = %s
3092 AND b_sale_basket.PRODUCT_ID = %s
3093 AND b_sale_order.PAYED = \'Y\'
3094 AND b_sale_order.DEDUCTED = \'Y\'
3095 AND b_sale_order.DATE_INSERT '.$sqlTimeInterval.'
3096 AND b_sale_basket.LID = \''.$DB->ForSql(self::getDefaultSiteId()).'\')', 0).'+'.
3097 $DB->isNull('(SELECT SUM(b_catalog_docs_element.AMOUNT)
3098 FROM b_catalog_store_docs
3099 INNER JOIN b_catalog_docs_element on b_catalog_store_docs.ID = b_catalog_docs_element.DOC_ID
3100 WHERE b_catalog_store_docs.DOC_TYPE in (\'M\', \'D\')
3101 AND b_catalog_store_docs.STATUS = \'Y\'
3102 AND b_catalog_store_docs.DATE_DOCUMENT '.$sqlTimeInterval.'
3103 AND b_catalog_docs_element.STORE_FROM = %s
3104 AND b_catalog_docs_element.ELEMENT_ID = %s)', 0),
3105 'StoreProduct:SALE_PRODUCT.STORE_ID', 'ID', 'StoreProduct:SALE_PRODUCT.STORE_ID', 'ID'
3106 )
3107 ), 'EXPENSE_PRODUCTS_IN_PERIOD_BY_STORE');
3108
3109 $entity->addField(array(
3110 'data_type' => 'float',
3111 'expression' => array(
3112 '100 * CASE WHEN %s IS NULL OR %s = 0 THEN NULL ELSE %s / %s END',
3113 'VIEWS_IN_PERIOD_BY_SHOP', 'VIEWS_IN_PERIOD_BY_SHOP', 'ORDERS_IN_PERIOD_BY_SHOP', 'VIEWS_IN_PERIOD_BY_SHOP'
3114 )
3115 ), 'CONVERSION');
3116 }
3117
3118 public static function getDefaultColumns()
3119 {
3120 return array(
3121 array('name' => 'ID'),
3122 array('name' => 'NAME')
3123 );
3124 }
3125
3126 public static function getCompareVariations()
3127 {
3128 return array_merge(parent::getCompareVariations(), array(
3129 'IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION' => array(
3130 'EQUAL'/*,
3131 'NOT_EQUAL'*/
3132 ),
3133 'StoreProduct:SALE_PRODUCT' => array(
3134 'EQUAL'
3135 )
3136 ));
3137 }
3138
3139 public static function getCalcVariations()
3140 {
3141 return array_merge(parent::getCalcVariations(), array(
3142 'IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION.ID' => array(
3143 'COUNT_DISTINCT',
3144 'GROUP_CONCAT'
3145 ),
3146 'IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION.NAME' => array(
3147 'COUNT_DISTINCT',
3148 'GROUP_CONCAT'
3149 ),
3150 'StoreProduct:SALE_PRODUCT.STORE.ID' => array(
3151 'COUNT_DISTINCT',
3152 'GROUP_CONCAT'
3153 ),
3154 'StoreProduct:SALE_PRODUCT.STORE.TITLE' => array(
3155 'COUNT_DISTINCT',
3156 'GROUP_CONCAT'
3157 )
3158 ));
3159 }
3160
3161 public static function getPeriodFilter($date_from, $date_to)
3162 {
3163 global $DB;
3164
3165 $filter = array('LOGIC' => 'AND');
3166
3167 // Site filter
3168 $filter[] = array(
3169 '=IBLOCK.IBLOCK.Site:IBLOCK.SITE_ID' => $DB->ForSql(self::getDefaultSiteId())
3170 );
3171
3172 // Custom Product filter
3173 $customProductFilter = self::getCustomProductFilter();
3174 if (!empty($customProductFilter))
3175 {
3176 if ($customProductFilter === 'avail') $strOperation = '>';
3177 else if ($customProductFilter === 'not_avail') $strOperation = '<=';
3178 else $strOperation = '';
3179 if (!empty($strOperation)) $filter[] = array($strOperation.'QUANTITY' => '0');
3180 }
3181
3182 return $filter;
3183 }
3184
3185 public static function getEntityFilterPrimaryFieldName($fElem)
3186 {
3187 $res = 'ID';
3188 if ($fElem['name'] === 'StoreProduct:SALE_PRODUCT')
3189 {
3190 $res = 'STORE_ID';
3191 }
3192 else
3193 {
3194 $res = parent::getEntityFilterPrimaryFieldName($fElem);
3195 }
3196 return $res;
3197 }
3198
3199 public static function confirmFilterBackReferenceRewrite($fElem, $chain)
3200 {
3201 if ($fElem['name'] === 'StoreProduct:SALE_PRODUCT.STORE_ID')
3202 {
3203 return false;
3204 }
3205
3206 return true;
3207 }
3208
3209 public static function confirmSelectBackReferenceRewrite($elem, $chain)
3210 {
3211 if ($elem['name'] === 'StoreProduct:SALE_PRODUCT.STORE_ID')
3212 {
3213 return false;
3214 }
3215
3216 return true;
3217 }
3218
3219 public static function beforeFilterBackReferenceRewrite(&$filter, $viewColumns)
3220 {
3221 // Field for filtering category of the goods
3222 $fieldName = 'IBLOCK.SectionElement:IBLOCK_ELEMENT.IBLOCK_SECTION.ID';
3223
3224 // <editor-fold defaultstate="collapsed" desc="Preparation of multiple filters">
3225 foreach ($filter as $fId => &$fInfo)
3226 {
3227 foreach ($fInfo as $k => &$fElem)
3228 {
3229 if (is_array($fElem) && $fElem['type'] == 'field')
3230 {
3231 $columnName = '';
3232
3233 if (preg_match('/__COLUMN__(\d+)/', $fElem['name'], $match))
3234 {
3235 $num = $match[1];
3236 $columnName = $viewColumns[$num]['fieldName'];
3237 }
3238
3239 if ($fElem['name'] == $fieldName || $columnName == $fieldName)
3240 {
3241 $iblockFilterCompare = $fElem['compare'];
3242 if ($iblockFilterCompare === 'EQUAL'/* || $iblockFilterCompare === 'NOT_EQUAL'*/)
3243 {
3244 $iblockFilterValue = array();
3245 $arFilterValues = array();
3246 if (is_array($fElem['value'])) $arFilterValues = $fElem['value'];
3247 else $arFilterValues[] = $fElem['value'];
3248 foreach ($arFilterValues as $l => $filterValue)
3249 {
3250 if (is_string($filterValue) && $filterValue[0] == 'c')
3251 {
3252 $iblockFilterValue[] = intval(mb_substr($filterValue, 1));
3253 // The filter on a section is deleted if the filter only according
3254 // to the catalog is necessary
3255 unset($arFilterValues[$l]);
3256 }
3257 else
3258 {
3259 $sections = array();
3260 foreach (parent::$catalogSections as $sectKey => $sect)
3261 {
3262 if ($sectKey == $filterValue) $iblockFilterValue[] = intval($sect['catalog']['ID']);
3263 if (in_array($filterValue, $sect['path'])) $sections[] = $sectKey;
3264 }
3265 $arFilterValues[$l] = $sections;
3266 }
3267 }
3268 $l = count($arFilterValues);
3269 if ($l === 0) unset($fInfo[$k]);
3270 else if ($l === 1) $fInfo[$k]['value'] = reset($arFilterValues);
3271 else
3272 {
3273 $newFilterValue = array();
3274 foreach ($arFilterValues as $filterValue)
3275 {
3276 $newFilterValue = array_merge($newFilterValue, $filterValue);
3277 }
3278 $newFilterValue = array_unique($newFilterValue);
3279 $fInfo[$k]['value'] = $newFilterValue;
3280 }
3281 $l = count($iblockFilterValue);
3282 if ($l === 0) $iblockFilterValue = null;
3283 else if ($l === 1) $iblockFilterValue = reset($iblockFilterValue);
3284 else $iblockFilterValue = array_unique($iblockFilterValue);
3285 self::$currentIblockFilter['value'] = $iblockFilterValue;
3286 self::$currentIblockFilter['compare'] = $iblockFilterCompare;
3287 }
3288 }
3289
3290 // rewrite StoreProduct.STORE_ID
3291 if ($fElem['name'] == 'StoreProduct:SALE_PRODUCT.STORE_ID')
3292 {
3293 $fElem['name'] = 'StoreProduct:SALE_PRODUCT.STORE_ID';
3294 }
3295 }
3296 }
3297 }
3298 // </editor-fold>
3299 }
3300
3301 public static function beforeViewDataQuery(&$select, &$filter, &$group, &$order, &$limit, &$options, &$runtime = null)
3302 {
3303 // Runtime fields
3304 if (self::$bUsePriceTypesColumns)
3305 {
3307 $helper = $connection->getSqlHelper();
3308 if ($connection instanceof PgsqlConnection)
3309 {
3310 $priceField = 'cast(b_catalog_price.PRICE as text)';
3311 }
3312 else
3313 {
3314 $priceField = 'b_catalog_price.PRICE';
3315 }
3316 $price = $helper->getConcatFunction(
3317 $priceField,
3318 "' '",
3319 'b_catalog_price.CURRENCY'
3320 );
3321 unset($helper, $connection);
3322
3323 foreach (self::$priceTypes as $id => $info)
3324 {
3325 if ($info['selected'] === true)
3326 {
3327 $fieldName = 'PRICE_TYPE_'.$id;
3328 $runtime[$fieldName] = array(
3329 'data_type' => 'string',
3330 'expression' => array('
3331 (SELECT ' . $price .'
3332 FROM b_catalog_price
3333 LEFT JOIN b_catalog_group ON b_catalog_group.ID = b_catalog_price.CATALOG_GROUP_ID
3334 WHERE b_catalog_price.PRODUCT_ID = %s
3335 AND b_catalog_group.ID = '.$id.'
3336 AND ( b_catalog_price.quantity_from <= 1 OR b_catalog_price.quantity_from IS NULL )
3337 AND ( b_catalog_price.quantity_to >= 1 OR b_catalog_price.quantity_to IS NULL ) LIMIT 1)',
3338 'ID'
3339 ),
3340 'view_column' => array(
3341 'humanTitle' => $info['name']
3342 )
3343 );
3344 $select[$fieldName] = $fieldName;
3345 }
3346 }
3347 }
3348
3349 if (self::$currentIblockFilter['value'])
3350 {
3351 $filter[] = array(
3352 'LOGIC' => 'AND',
3353 ((self::$currentIblockFilter['compare'] === 'EQUAL') ? '=' : '!=').'IBLOCK.IBLOCK_ID' => self::$currentIblockFilter['value']
3354 );
3355 }
3356 self::$currentIblockFilter['value'] = null;
3357 self::$currentIblockFilter['compare'] = null;
3358 }
3359
3360 /* remove it when PHP 5.3 available */
3361 public static function formatResults(&$rows, &$columnInfo, $total)
3362 {
3363 foreach ($rows as &$row)
3364 {
3365
3366 foreach ($row as $k => &$v)
3367 {
3368 if (!array_key_exists($k, $columnInfo))
3369 {
3370 continue;
3371 }
3372
3373 $cInfo = &$columnInfo[$k];
3374
3375 if (is_array($v))
3376 {
3377 foreach ($v as &$subv)
3378 {
3379 self::formatResultValue($k, $subv, $row, $cInfo, $total);
3380 }
3381 }
3382 else
3383 {
3384 self::formatResultValue($k, $v, $row, $cInfo, $total);
3385 }
3386 }
3387 }
3388
3389 unset($row, $v, $subv);
3390 }
3391 /* \remove it */
3392
3393 // format result value in grouping mode
3394 /*public static function formatResultGroupingValue($params)
3395 {
3396 $k = $params['k'];
3397 $v = $params['v'];
3398 $row = $params['row'];
3399 $cInfo = $params['cInfo'];
3400 static::formatResultValue($k, $v, $row, $cInfo, array());
3401 }*/
3402
3403 public static function formatResultValue($k, &$v, &$row, &$cInfo, $total, &$customChartValue = null)
3404 {
3405 $dataType = self::getFieldDataType($cInfo['field']);
3406
3408 if ($dataType !== 'float' ) // skip base rounding
3409 {
3410 parent::formatResultValue($k, $v, $row, $cInfo, $total);
3411 }
3412
3413 // Inserting zero in numerical fields with null value.
3414 if (empty($v))
3415 {
3416 if (in_array($dataType, array('integer', 'float')))
3417 {
3418 $v = 0;
3419 }
3420 //else $v = '&nbsp;';
3421 }
3422
3423 // Formatting of monetary fields.
3424 foreach (self::$monetaryFields as $monField)
3425 {
3426 if (preg_match('/'.$monField.'$/', $k))
3427 {
3429 $v = number_format(doubleval($v), 2, '.', ' ');
3430 break;
3431 }
3432 }
3433
3434 // Formatting fields with goods quantity.
3435 foreach (self::$goodsQuantityFields as $qField)
3436 {
3437 if (preg_match('/'.$qField.'$/', $k))
3438 {
3439 if (!empty($v) && !is_null($v) && $v != '&nbsp;')
3440 {
3441 if (self::$fDecimalQuant) $v = sprintf('%.3f', round($v,3));
3442 else $v = sprintf('%d', round($v,0));
3443 }
3444 break;
3445 }
3446 }
3447
3448 // Formatting short name fields of buyers.
3449 foreach (self::$userNotAuthNameFields as $uField)
3450 {
3451 if (preg_match('/'.$uField.'$/', $k))
3452 {
3453 if (empty($v) || is_null($v) || $v == '&nbsp;')
3454 {
3455 $v = GetMessage('SALE_REPORT_USER_NOT_AUTH');
3456 }
3457 break;
3458 }
3459 }
3460
3461 // runtime fields which align right
3462 if (self::$bUsePriceTypesColumns)
3463 {
3464 if (mb_strpos($k, 'PRICE_TYPE_') === 0 && is_numeric(mb_substr($k, 11))) $cInfo['align'] = 'right';
3465 }
3466
3467 // Formatting fields of price types
3468 if (preg_match('/[A-Za-z_]*PRICE_TYPE_[0-9]+$/', $k) && !empty($v) && $v !== '&nbsp;')
3469 {
3470 $v = trim($v);
3471 $spacePos = mb_strpos(trim($v), ' ');
3472 $v = number_format(doubleval(mb_substr($v, 0, $spacePos)), 2, '.', ' ').mb_substr($v, $spacePos);
3473 }
3474 }
3475
3476 public static function formatResultGroupingTotal($params)
3477 {
3478 $paramTotal = array('TOTAL_'.$params['k'] => &$params['v']);
3479 $viewColumns = array($params['k'] => &$params['cInfo']);
3480 $bFormatOnly = true;
3481 static::formatResultsTotal($paramTotal, $viewColumns, $bFormatOnly);
3482 }
3483
3484 public static function formatResultsTotal(&$total, &$columnInfo, &$bFormatOnly = null)
3485 {
3486 parent::formatResultsTotal($total, $columnInfo);
3487
3488 foreach ($total as $k => &$v)
3489 {
3490 // Formatting of monetary fields.
3491 foreach (self::$monetaryFields as $monField)
3492 {
3493 if (preg_match('/'.$monField.'$/', $k))
3494 {
3495 if (!$bFormatOnly) $v = self::calculateInReportCurrency($v);
3496 $v = number_format(doubleval($v), 2, '.', ' ');
3497 break;
3498 }
3499 }
3500
3501 // Formatting fields with goods quantity.
3502 foreach (self::$goodsQuantityFields as $qField)
3503 {
3504 if (preg_match('/'.$qField.'$/', $k))
3505 {
3506 if (!empty($v) && !is_null($v) && $v != '&nbsp;')
3507 {
3508 if (self::$fDecimalQuant) $v = sprintf('%.3f', round($v,3));
3509 else $v = sprintf('%d', round($v,0));
3510 }
3511 break;
3512 }
3513 }
3514
3515 // Formatting fields without summary calculation.
3516 foreach (self::$withoutTotalFields as $wtField)
3517 {
3518 if (preg_match('/TOTAL_'.$wtField.'$/', $k))
3519 {
3520 unset($total[$k]);
3521 break;
3522 }
3523 }
3524
3525 // Formatting fields of price types
3526 if (!$bFormatOnly)
3527 {
3528 if (preg_match('/[A-Za-z_]*PRICE_TYPE_[0-9]+$/', $k) && !empty($v) && $v !== '&nbsp;')
3529 {
3530 $v = trim($v);
3531 $spacePos = mb_strpos($v, ' ');
3532 $v = number_format(doubleval(mb_substr($v, 0, $spacePos)), 2, '.', ' ').mb_substr($v, $spacePos);
3533 }
3534 }
3535 }
3536 }
3537
3538 public static function getDefaultElemHref($elem, $fList)
3539 {
3540 $href = '';
3541 if (empty($elem['aggr']))
3542 {
3543 $field = $fList[$elem['name']];
3544
3545 if ($field->getEntity()->getName() == 'Product')
3546 {
3547 if ($elem['name'] == 'NAME')
3548 {
3549 $href = array('pattern' => '/bitrix/admin/cat_product_edit.php?IBLOCK_ID='.
3550 '#IBLOCK.IBLOCK.ID#&type=#IBLOCK.IBLOCK.IBLOCK_TYPE_ID#&ID='.
3551 '#ID#&lang='.LANG.'&WF=Y');
3552 }
3553 }
3554 }
3555
3556 return $href;
3557 }
3558}
$path
Определения access_edit.php:21
$connection
Определения actionsdefinitions.php:38
static getConnection($name="")
Определения application.php:638
static getList(array $parameters=array())
Определения datamanager.php:431
static getList(array $params=array())
Определения manager.php:84
static ConvertCurrency($valSum, $curFrom, $curTo, $valDate="")
Определения currency_rate.php:393
static GetByID($ID, $SHOW_USERS_AMOUNT="N")
Определения group.php:853
static getPersonTypes()
Определения sale_report_helper.php:398
static getPriceTypes()
Определения sale_report_helper.php:326
static $productStores
Определения sale_report_helper.php:31
static $priceTypes
Определения sale_report_helper.php:35
static getPaySystemList()
Определения sale_report_helper.php:431
static getDefaultReports()
Определения sale_report_helper.php:468
static getReportCurrencyId()
Определения sale_report_helper.php:378
static calculateInReportCurrency($value)
Определения sale_report_helper.php:1069
static getStatusList()
Определения sale_report_helper.php:388
static getSectionsSelectHTMLOptions()
Определения sale_report_helper.php:1047
static $sitelist
Определения sale_report_helper.php:22
static getCatalogSections()
Определения sale_report_helper.php:453
static $deliveryList
Определения sale_report_helper.php:28
static getAjaxResponse($arRequestData)
Определения sale_report_helper.php:966
static $defaultSiteId
Определения sale_report_helper.php:23
static getProductStores()
Определения sale_report_helper.php:458
static getCurrentVersion()
Определения sale_report_helper.php:954
static getSiteCookieId()
Определения sale_report_helper.php:383
static getWeightOptions()
Определения sale_report_helper.php:321
static getSiteList()
Определения sale_report_helper.php:316
static initOwners()
Определения sale_report_helper.php:303
static $genders
Определения sale_report_helper.php:32
static setSelectedPriceTypes($arSelected)
Определения sale_report_helper.php:331
static getOwners()
Определения sale_report_helper.php:446
static $catalogs
Определения sale_report_helper.php:30
static $paySystemList
Определения sale_report_helper.php:27
static getSiteCurrencyId()
Определения sale_report_helper.php:373
static $personTypes
Определения sale_report_helper.php:33
static $currencies
Определения sale_report_helper.php:37
static isCatalogCorrespondsDefSite($catalogId)
Определения sale_report_helper.php:408
static $bUsePriceTypesColumns
Определения sale_report_helper.php:36
static addOwner($ownerName)
Определения sale_report_helper.php:441
static setSiteCurrencyId($currencyId)
Определения sale_report_helper.php:368
static $statuslist
Определения sale_report_helper.php:26
static init()
Определения sale_report_helper.php:119
static getHelperByOwner($ownerId)
Определения sale_report_helper.php:463
static getDefaultSiteWeightUnits()
Определения sale_report_helper.php:416
static isInitialized()
Определения sale_report_helper.php:298
static $reportCurrencyId
Определения sale_report_helper.php:38
static $iblockSite
Определения sale_report_helper.php:21
static $siteCookieId
Определения sale_report_helper.php:24
static $weightOptions
Определения sale_report_helper.php:34
static setSelectedCurrency($currencyId)
Определения sale_report_helper.php:353
static $catalogSections
Определения sale_report_helper.php:29
static setDefaultSiteId($siteId)
Определения sale_report_helper.php:426
static getGenders()
Определения sale_report_helper.php:393
static getDeliveryList()
Определения sale_report_helper.php:436
static getCurrencies()
Определения sale_report_helper.php:348
static $siteCurrencyId
Определения sale_report_helper.php:39
static getFirstVersion()
Определения sale_report_helper.php:961
static getDefaultSiteId()
Определения sale_report_helper.php:403
static $fDecimalQuant
Определения sale_report_helper.php:19
static getDefaultSiteWeightDivider()
Определения sale_report_helper.php:421
Определения cataloggroup.php:8
Определения catalog.php:6
Определения currency.php:810
Определения report_helper.php:10
static formatResultGroupingTotal($params)
Определения sale_report_helper.php:2745
static beforeFilterBackReferenceRewrite(&$filter, $viewColumns)
Определения sale_report_helper.php:2478
static getCompareVariations()
Определения sale_report_helper.php:2404
static beforeViewDataQuery(&$select, &$filter, &$group, &$order, &$limit, &$options, &$runtime=null)
Определения sale_report_helper.php:2554
static fillFilterReferenceColumn(&$filterElement, Entity\ReferenceField $field)
Определения sale_report_helper.php:2567
static getDefaultElemHref($elem, $fList)
Определения sale_report_helper.php:2796
static formatResults(&$rows, &$columnInfo, $total)
Определения sale_report_helper.php:2617
static formatResultsTotal(&$total, &$columnInfo, &$bFormatOnly=null)
Определения sale_report_helper.php:2753
static getPeriodFilter($date_from, $date_to)
Определения sale_report_helper.php:2446
static getDefaultColumns()
Определения sale_report_helper.php:2366
static getCalcVariations()
Определения sale_report_helper.php:2377
static formatResultGroupingTotal($params)
Определения sale_report_helper.php:1504
static getColumnList()
Определения sale_report_helper.php:1113
static getCompareVariations()
Определения sale_report_helper.php:1268
static fillFilterReferenceColumn(&$filterElement, Entity\ReferenceField $field)
Определения sale_report_helper.php:1336
static getDefaultElemHref($elem, $fList)
Определения sale_report_helper.php:1555
static formatResults(&$rows, &$columnInfo, $total)
Определения sale_report_helper.php:1386
static formatResultsTotal(&$total, &$columnInfo, &$bFormatOnly=null)
Определения sale_report_helper.php:1512
static getPeriodFilter($date_from, $date_to)
Определения sale_report_helper.php:1304
static getDefaultColumns()
Определения sale_report_helper.php:1241
static getEntityName()
Определения sale_report_helper.php:1103
static getCalcVariations()
Определения sale_report_helper.php:1249
static enablePriceTypesColumns($bUsePriceTypesColumns)
Определения sale_report_helper.php:2923
static confirmFilterBackReferenceRewrite($fElem, $chain)
Определения sale_report_helper.php:3199
static getCustomProductFilter()
Определения sale_report_helper.php:2929
static formatResultGroupingTotal($params)
Определения sale_report_helper.php:3476
static beforeFilterBackReferenceRewrite(&$filter, $viewColumns)
Определения sale_report_helper.php:3219
static getCompareVariations()
Определения sale_report_helper.php:3126
static confirmSelectBackReferenceRewrite($elem, $chain)
Определения sale_report_helper.php:3209
static beforeViewDataQuery(&$select, &$filter, &$group, &$order, &$limit, &$options, &$runtime=null)
Определения sale_report_helper.php:3301
static setRuntimeFields(\Bitrix\Main\Entity\Base $entity, $sqlTimeInterval)
Определения sale_report_helper.php:2983
static getDefaultElemHref($elem, $fList)
Определения sale_report_helper.php:3538
static formatResults(&$rows, &$columnInfo, $total)
Определения sale_report_helper.php:3361
static formatResultsTotal(&$total, &$columnInfo, &$bFormatOnly=null)
Определения sale_report_helper.php:3484
static getPeriodFilter($date_from, $date_to)
Определения sale_report_helper.php:3161
static setCustomProductFilter($strFilterValue)
Определения sale_report_helper.php:2918
static getDefaultColumns()
Определения sale_report_helper.php:3118
static getEntityFilterPrimaryFieldName($fElem)
Определения sale_report_helper.php:3185
static getCalcVariations()
Определения sale_report_helper.php:3139
static confirmFilterBackReferenceRewrite($fElem, $chain)
Определения sale_report_helper.php:1864
static formatResultGroupingTotal($params)
Определения sale_report_helper.php:2059
static getColumnList()
Определения sale_report_helper.php:1672
static getCompareVariations()
Определения sale_report_helper.php:1748
static confirmSelectBackReferenceRewrite($elem, $chain)
Определения sale_report_helper.php:1874
static beforeViewDataQuery(&$select, &$filter, &$group, &$order, &$limit, &$options, &$runtime=null)
Определения sale_report_helper.php:1915
static fillFilterReferenceColumn(&$filterElement, Entity\ReferenceField $field)
Определения sale_report_helper.php:1815
static getDefaultElemHref($elem, $fList)
Определения sale_report_helper.php:2110
static getOwnerId()
Определения sale_report_helper.php:1667
static formatResults(&$rows, &$columnInfo, $total)
Определения sale_report_helper.php:1950
static formatResultsTotal(&$total, &$columnInfo, &$bFormatOnly=null)
Определения sale_report_helper.php:2067
static getPeriodFilter($date_from, $date_to)
Определения sale_report_helper.php:1786
static getDefaultColumns()
Определения sale_report_helper.php:1778
static getEntityName()
Определения sale_report_helper.php:1662
static getCalcVariations()
Определения sale_report_helper.php:1734
$options
Определения commerceml2.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
$entity
$select
Определения iblock_catalog_list.php:194
$filter
Определения iblock_catalog_list.php:54
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $DB
Определения cron_frame.php:29
$l
Определения options.php:783
$siteId
Определения ajax.php:8
if($NS['step']==6) if( $NS[ 'step']==7) if(COption::GetOptionInt('main', 'disk_space', 0) > 0) $info
Определения backup.php:924
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
getName()
Определения Param.php:99
Определения ufield.php:9
$user
Определения mysql_to_pgsql.php:33
$order
Определения payment.php:8
$settings
Определения product_settings.php:43
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$i
Определения factura.php:643
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
const SALE_REPORT_OWNER_ID
Определения include.php:31
$title
Определения pdf.php:123
$val
Определения options.php:1793
$rows
Определения options.php:264
$k
Определения template_pdf.php:567
$GLOBALS['_____370096793']
Определения update_client.php:1