public static function init() { IncludeModuleLangFile(__FILE__); if (!self::$fInit) { self::$fInit = true; self::$siteCookieId = md5('SALE_REPORT_SITE_ID'); // Initializing list of sites. $result = Bitrix\Main\SiteTable::getList(array('select' => array('LID', 'DEF', 'NAME'))); $i = 0; while ($row = $result->fetch()) { self::$sitelist[$row['LID']] = $row['NAME']; if (++$i === 1) { self::$defaultSiteId = $row['LID']; } else { if ($row['DEF'] === 'Y') { self::$defaultSiteId = $row['LID']; } } self::$weightOptions[$row['LID']] = array('unit' => COption::GetOptionString('sale', 'weight_unit', null, $row['LID']), 'koef' => COption::GetOptionInt('sale', 'weight_koef', null, $row['LID'])); } unset($i, $row, $result); // hack, add virtual ID field into StatusLang entity for filtering $statusEntity = Entity\Base::getInstance('\\Bitrix\\Sale\\Internals\\StatusLang'); if ($statusEntity instanceof \Bitrix\Main\Entity\Base) { $statusEntity->addField(array('data_type' => 'string', 'expression' => array('%s', 'STATUS_ID')), 'ID'); } unset($statusEntity); // hack, add virtual REPS_ORDER field into Shipment entity for filtering system records $shipmentEntity = Entity\Base::getInstance('\\Bitrix\\Sale\\Internals\\Shipment'); if ($shipmentEntity instanceof \Bitrix\Main\Entity\Base) { $shipmentEntity->addField(array('data_type' => 'Order', 'reference' => array('=ref.ID' => 'this.ORDER_ID', '!=this.SYSTEM' => array('?', 'Y'))), 'REPS_ORDER'); } unset($shipmentEntity); // Initializing list of statuses of orders. $result = Bitrix\Sale\Internals\StatusLangTable::getList(array('select' => array('STATUS_ID', 'NAME'), 'filter' => array('=LID' => LANGUAGE_ID))); while ($row = $result->fetch()) { self::$statuslist[$row['STATUS_ID']] = $row['NAME']; } unset($row, $result); self::$genders = array('M' => GetMessage('USER_MALE'), 'F' => GetMessage('USER_FEMALE')); // Initializing list of person types. $result = Bitrix\Sale\Internals\PersonTypeTable::getList(array('select' => array('ID', 'LID', 'NAME'))); while ($row = $result->fetch()) { self::$personTypes[$row['ID']] = array('LID' => $row['LID'], 'NAME' => $row['NAME']); } unset($row, $result); // Initializing list of pay systems of orders. $result = Bitrix\Sale\PaySystemTable::getList(array('select' => array('ID', 'LID', 'NAME'))); while ($row = $result->fetch()) { self::$paySystemList[$row['ID']] = array('value' => $row['NAME'], 'site_id' => $row['LID']); } unset($row, $result); // Initializing list of services and methods of delivery. $result = \Bitrix\Sale\Delivery\Services\Table::getList(array('select' => array('ID', 'NAME'))); while ($row = $result->fetch()) { self::$deliveryList[$row['ID']] = array('value' => $row['NAME'], 'site_id' => ''); } unset($row, $result); // Obtaining table of correspondences of iblocks to sites. $result = Bitrix\Iblock\IblockSiteTable::getList(); while ($row = $result->fetch()) { self::$iblockSite[$row['SITE_ID']][] = $row['IBLOCK_ID']; } unset($row, $result); // Obtaining the list of iblocks which are directories and filling // a property $catalogSections with sections of these units. $ent = new CCatalog(); $result = $ent->GetList(); while ($ibRow = $result->Fetch()) { // Obtaining list of sections of the catalog. self::$catalogs[] = $ibRow; $path = array(); $curLevel = $prevLevel = 0; $sections = CIBlockSection::GetTreeList(array('=IBLOCK_ID' => $ibRow['IBLOCK_ID'])); $row = null; while ($row = $sections->GetNext()) { // Formation of an array of identifiers of current and parent sections. $curLevel = $row['DEPTH_LEVEL']; for ($i = 0; $i <= $prevLevel - $curLevel; $i++) { array_pop($path); } array_push($path, $row['ID']); $prevLevel = $curLevel; self::$catalogSections[$row['ID']] = array('name' => ltrim(str_repeat(' . ', $curLevel) . $row['NAME']), 'path' => $path, 'catalog' => array('ID' => $ibRow['ID'], 'NAME' => $ibRow['NAME'])); } } unset($ent, $ibRow, $row, $sections, $result); // Initialization of the list of warehouses. $result = Bitrix\Catalog\StoreTable::getList(array('select' => array('ID', 'TITLE'))); while ($row = $result->fetch()) { self::$productStores[$row['ID']] = $row['TITLE']; } unset($row, $result); // Getting currencies $obj = new CCurrency(); $by = ''; $order = ''; $result = $obj->GetList($by, $order, LANGUAGE_ID); while ($row = $result->Fetch()) { self::$currencies[$row['CURRENCY']] = array('name' => $row['FULL_NAME']); } unset($row, $result, $obj, $by, $order); // Getting types of prices $obj = new CCatalogGroup(); $result = $obj->GetListEx(array('SORT'), array(), false, false, array('ID', 'NAME', 'BASE', 'NAME_LANG')); while ($row = $result->Fetch()) { self::$priceTypes[$row['ID']] = array('name' => empty($row['NAME_LANG']) ? $row['NAME'] : $row['NAME_LANG'], 'base' => $row['BASE'] === 'Y' ? true : false); } unset($row, $result, $obj); // Getting option, which means, it is necessary to display a fractional quantity of goods of no. self::$fDecimalQuant = COption::GetOptionString('sale', 'QUANTITY_FACTORIAL') == 'Y'; self::initOwners(); } }