Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
eventhandler.php
1<?php
2
4
9
11{
12 const BATCH_GROUP_SALES_GENERAL = 'sales_general';
13
14 const BATCH_INTERNET_SHOP = 'sale_internet_shop';
15 const REPORT_KEY = 'sale_report_board_';
16 const REPORT_VIEW_URL = '/shop/settings/sale_report_view.php';
17
21 public static function onAnalyticPageBatchCollect()
22 {
23 $batchList = [];
24 if(!\CBXFeatures::IsFeatureEnabled('SaleReports'))
25 {
26 return $batchList;
27 }
28
29 $batch = new AnalyticBoardBatch();
30 $batch->setKey(static::BATCH_INTERNET_SHOP);
31 $batch->setTitle(Loc::getMessage("SALE_REPORT_INTERNET_SHOP_BATCH_TITLE"));
32 $batch->setOrder(300);
33
34 if (method_exists($batch, 'setGroup'))
35 {
36 $batch->setGroup(self::BATCH_GROUP_SALES_GENERAL);
37 }
38
39 $batchList[] = $batch;
40
41 return $batchList;
42 }
43
47 public static function onAnalyticPageCollect()
48 {
49 $analyticPageList = [];
50 if(!\CBXFeatures::IsFeatureEnabled('SaleReports'))
51 {
52 return $analyticPageList;
53 }
54
55 \CBaseSaleReportHelper::initOwners();
56
57 $cursor = ReportTable::getList([
58 'select' => ['ID', 'TITLE'],
59 'filter' => [
60 '=CREATED_BY' => static::getCurrentUserId(),
61 '=OWNER_ID' => \CBaseSaleReportHelper::getOwners()
62 ]
63 ]);
64
65 while ($row = $cursor->fetch())
66 {
67 $reportPage = new AnalyticBoard();
68 $reportPage->setTitle($row['TITLE']);
69 $reportPage->setBoardKey(static::REPORT_KEY . $row['ID']);
70 $reportPage->setBatchKey(static::BATCH_INTERNET_SHOP);
71
72 if (method_exists($reportPage, 'setGroup'))
73 {
74 $reportPage->setGroup(self::BATCH_GROUP_SALES_GENERAL);
75 }
76
77 $reportPage->setExternal(true);
78
79 $reportViewUrl = static::REPORT_VIEW_URL;
80 $reportViewUrl = \CHTTP::urlAddParams($reportViewUrl, [
81 'ID' => $row['ID'],
82 'publicSidePanel' => 'Y'
83 ]);
84 $reportPage->setExternalUrl($reportViewUrl);
85
86 $analyticPageList[] = $reportPage;
87 }
88
89 return $analyticPageList;
90 }
91
92 public static function getCurrentUserId()
93 {
94 global $USER;
95 return $USER->getId();
96 }
97}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29