52 if (class_exists(
'\CBaseSaleReportHelper'))
54 if (\CBaseSaleReportHelper::isInitialized())
56 $siteId = \CBaseSaleReportHelper::getDefaultSiteId();
59 $weight_koef = intval(\CBaseSaleReportHelper::getDefaultSiteWeightDivider());
63 $site_currency = \CBaseSaleReportHelper::getSiteCurrencyId();
66 if ($weight_koef <= 0) $weight_koef = 1;
70 if (function_exists(
'___dbCastIntToChar') !==
true)
73 'function ___dbCastIntToChar($dbtype, $param)'.
76 ' if (ToLower($dbtype) === "mssql")'.
78 ' $result = "CAST(".$param." AS VARCHAR)";'.
87 'data_type' =>
'integer',
93 'TIMESTAMP_X' => array(
94 'data_type' =>
'integer'
96 'DATE_UPDATED' => array(
97 'data_type' =>
'datetime',
98 'expression' => array(
99 $DB->datetimeToDateFunction(
'%s'),
'TIMESTAMP_X',
103 'data_type' =>
'float'
106 'data_type' =>
'integer'
108 'PURCHASING_PRICE' => array(
109 'data_type' =>
'float'
111 'PURCHASING_CURRENCY' => array(
112 'data_type' =>
'string'
115 'data_type' =>
'Bitrix\Iblock\Element',
116 'reference' => array(
'=this.ID' =>
'ref.ID')
119 'data_type' =>
'string',
120 'expression' => array(
124 'NAME_WITH_IDENT' => array(
125 'data_type' =>
'string',
126 'expression' => array(
127 $DB->concat(
'%s',
'\' [\
'', ___dbCastIntToChar(
'mysql',
'%s'),
'\']\
''),
'NAME',
'ID'
131 'data_type' =>
'boolean',
132 'expression' => array(
133 '%s',
'IBLOCK.ACTIVE'
135 'values' => array(
'N',
'Y')
138 'data_type' =>
'float'
140 'WEIGHT_IN_SITE_UNITS' => array(
141 'data_type' =>
'float',
142 'expression' => array(
143 '%s / '.$DB->forSql($weight_koef),
'WEIGHT'
147 'data_type' =>
'float',
148 'expression' => array(
149 '(SELECT b_catalog_price.PRICE FROM b_catalog_price
150 LEFT JOIN b_catalog_group ON b_catalog_group.ID = b_catalog_price.CATALOG_GROUP_ID
152 b_catalog_price.PRODUCT_ID = %s
154 b_catalog_group.base = \'Y\'
156 ( b_catalog_price.quantity_from <= 1 OR b_catalog_price.quantity_from IS NULL )
158 ( b_catalog_price.quantity_to >= 1 OR b_catalog_price.quantity_to IS NULL)
163 'data_type' =>
'string',
164 'expression' => array(
165 '(SELECT b_catalog_price.CURRENCY FROM b_catalog_price
166 LEFT JOIN b_catalog_group ON b_catalog_group.ID = b_catalog_price.CATALOG_GROUP_ID
168 b_catalog_price.PRODUCT_ID = %s
170 b_catalog_group.base = \'Y\'
172 ( b_catalog_price.quantity_from <= 1 OR b_catalog_price.quantity_from IS NULL )
174 ( b_catalog_price.quantity_to >= 1 OR b_catalog_price.quantity_to IS NULL)
178 'SUMMARY_PRICE' => array(
179 'data_type' =>
'float',
180 'expression' => array(
181 '%s * %s',
'QUANTITY',
'PRICE'
187 'CURRENT_CURRENCY_RATE' => array(
188 'data_type' =>
'float',
189 'expression' => array(
190 '('.$DB->topSql(
'SELECT (CASE WHEN b_catalog_currency_rate.RATE IS NOT NULL THEN b_catalog_currency_rate.RATE ELSE b_catalog_currency.AMOUNT END)
191 FROM b_catalog_product INNER JOIN b_catalog_currency ON 1=1
192 LEFT JOIN b_catalog_currency_rate ON (b_catalog_currency.CURRENCY = b_catalog_currency_rate.CURRENCY AND b_catalog_currency_rate.DATE_RATE <= '.$DB->datetimeToDateFunction(
'b_catalog_product.TIMESTAMP_X').
')
193 WHERE b_catalog_product.ID = %s AND b_catalog_currency.CURRENCY = %s
194 ORDER BY DATE_RATE DESC', 1).
')',
'ID',
'CURRENCY'
197 'CURRENT_CURRENCY_RATE_CNT' => array(
198 'data_type' =>
'float',
199 'expression' => array(
200 '('.$DB->topSql(
'SELECT (CASE WHEN b_catalog_currency_rate.RATE_CNT IS NOT NULL THEN b_catalog_currency_rate.RATE_CNT ELSE b_catalog_currency.AMOUNT_CNT END)
201 FROM b_catalog_product INNER JOIN b_catalog_currency ON 1=1
202 LEFT JOIN b_catalog_currency_rate ON (b_catalog_currency.CURRENCY = b_catalog_currency_rate.CURRENCY AND b_catalog_currency_rate.DATE_RATE <= '.$DB->datetimeToDateFunction(
'b_catalog_product.TIMESTAMP_X').
')
203 WHERE b_catalog_product.ID = %s AND b_catalog_currency.CURRENCY = %s
204 ORDER BY DATE_RATE DESC', 1).
')',
'ID',
'CURRENCY'
208 'CURRENT_SITE_CURRENCY_RATE' => array(
209 'data_type' =>
'float',
210 'expression' => array(
211 '('.$DB->topSql(
'SELECT (CASE WHEN b_catalog_currency_rate.RATE IS NOT NULL THEN b_catalog_currency_rate.RATE ELSE b_catalog_currency.AMOUNT END)
212 FROM b_catalog_product INNER JOIN b_catalog_currency ON 1=1
213 LEFT JOIN b_catalog_currency_rate ON (b_catalog_currency.CURRENCY = b_catalog_currency_rate.CURRENCY AND b_catalog_currency_rate.DATE_RATE <= '.$DB->datetimeToDateFunction(
'b_catalog_product.TIMESTAMP_X').
')
214 WHERE b_catalog_product.ID = %s AND b_catalog_currency.CURRENCY = \''.$DB->forSql($site_currency).
'\'
215 ORDER BY DATE_RATE DESC
', 1).')
', 'ID
'
219 'CURRENT_SITE_CURRENCY_RATE_CNT
' => array(
220 'data_type
' => 'float',
221 'expression
' => array(
222 '(
'.$DB->topSql('SELECT (CASE WHEN b_catalog_currency_rate.RATE_CNT IS NOT NULL THEN b_catalog_currency_rate.RATE_CNT ELSE b_catalog_currency.AMOUNT_CNT END)
223 FROM b_catalog_product INNER JOIN b_catalog_currency ON 1=1
224 LEFT JOIN b_catalog_currency_rate ON (b_catalog_currency.CURRENCY = b_catalog_currency_rate.CURRENCY AND b_catalog_currency_rate.DATE_RATE <=
'.$DB->datetimeToDateFunction('b_catalog_product.TIMESTAMP_X
').')
225 WHERE b_catalog_product.ID = %s AND b_catalog_currency.CURRENCY = \
''.$DB->forSql($site_currency).
'\'
226 ORDER BY DATE_RATE DESC
', 1).')
', 'ID
'
232 'PURCHASING_CURRENCY_RATE
' => array(
233 'data_type
' => 'float',
234 'expression
' => array(
235 '(
'.$DB->topSql('SELECT (CASE WHEN b_catalog_currency_rate.RATE IS NOT NULL THEN b_catalog_currency_rate.RATE ELSE b_catalog_currency.AMOUNT END)
236 FROM b_catalog_product INNER JOIN b_catalog_currency ON 1=1
237 LEFT JOIN b_catalog_currency_rate ON (b_catalog_currency.CURRENCY = b_catalog_currency_rate.CURRENCY AND b_catalog_currency_rate.DATE_RATE <=
'.$DB->datetimeToDateFunction('b_catalog_product.TIMESTAMP_X
').')
238 WHERE b_catalog_product.ID = %s AND b_catalog_currency.CURRENCY = %s
239 ORDER BY DATE_RATE DESC
', 1).')
', 'ID
', 'PURCHASING_CURRENCY
'
242 'PURCHASING_CURRENCY_RATE_CNT
' => array(
243 'data_type
' => 'float',
244 'expression
' => array(
245 '(
'.$DB->topSql('SELECT (CASE WHEN b_catalog_currency_rate.RATE_CNT IS NOT NULL THEN b_catalog_currency_rate.RATE_CNT ELSE b_catalog_currency.AMOUNT_CNT END)
246 FROM b_catalog_product INNER JOIN b_catalog_currency ON 1=1
247 LEFT JOIN b_catalog_currency_rate ON (b_catalog_currency.CURRENCY = b_catalog_currency_rate.CURRENCY AND b_catalog_currency_rate.DATE_RATE <=
'.$DB->datetimeToDateFunction('b_catalog_product.TIMESTAMP_X
').')
248 WHERE b_catalog_product.ID = %s AND b_catalog_currency.CURRENCY = %s
249 ORDER BY DATE_RATE DESC
', 1).')
', 'ID
', 'PURCHASING_CURRENCY
'
255 'PRICE_IN_SITE_CURRENCY
' => array(
256 'data_type
' => 'float',
257 'expression
' => array(
258 '%s * (%s * %s / %s / %s)
',
259 'PRICE
', 'CURRENT_CURRENCY_RATE
', 'CURRENT_SITE_CURRENCY_RATE_CNT
', 'CURRENT_SITE_CURRENCY_RATE
', 'CURRENT_CURRENCY_RATE_CNT
'
263 'PURCHASING_PRICE_IN_SITE_CURRENCY
' => array(
264 'data_type
' => 'float',
265 'expression
' => array(
266 '%s * (%s * %s / %s / %s)
',
267 'PURCHASING_PRICE
', 'PURCHASING_CURRENCY_RATE
', 'CURRENT_SITE_CURRENCY_RATE_CNT
', 'CURRENT_SITE_CURRENCY_RATE
', 'PURCHASING_CURRENCY_RATE_CNT
'
271 'SUMMARY_PRICE_IN_SITE_CURRENCY
' => array(
272 'data_type
' => 'float',
273 'expression
' => array(
274 '%s * (%s * %s / %s / %s)
',
275 'SUMMARY_PRICE
', 'CURRENT_CURRENCY_RATE
', 'CURRENT_SITE_CURRENCY_RATE_CNT
', 'CURRENT_SITE_CURRENCY_RATE
', 'CURRENT_CURRENCY_RATE_CNT
'