unset($attributeTypes['conversion_site']); $attributeName = $_GET['split']; // different split in $userOptions from summary page! if (!($attributeType = $attributeTypes[$attributeName])) { list($attributeName, $attributeType) = each($attributeTypes); } $attributeGroupTypes = AttributeGroupManager::getTypes(); // FILTER $filter = array('from' => $from->toString(), 'to' => $to->toString(), 'site' => $site); CUserOptions::SetOption('conversion', 'filter', array_merge($userOptions, $filter)); $filter['rate'] = $rateName; $filter['split'] = $attributeName; $filter['lang'] = LANGUAGE_ID; // CONTEXT $context = new ReportContext(); $context->setAttribute('conversion_site', $site); $filterInfo = array(); foreach ($attributeTypes as $name => $type) { if (($value = $_GET[$name]) !== null && $name != $attributeName) { $context->setAttribute($name, $value); if ($value) { $filterInfo[$type['NAME'] ?: $name] = ($gv = $type['GET_VALUES']) && ($vs = $gv(array($value))) && isset($vs[$value]['NAME']) ? $vs[$value]['NAME'] : htmlspecialcharsbx($value); } elseif ($g = $type['GROUP']) { $filterInfo[isset($attributeGroupTypes[$g]['NAME']) ? $attributeGroupTypes[$g]['NAME'] : $g] = $type['NAME'] ?: $name; } else { $filterInfo[$type['NAME'] ?: $name] = htmlspecialcharsbx($value); } } } //echo '<pre>'.print_r($context->getCounters(array( // 'filter' => array(
list($topRateName, $topRateType) = each($rateTypes); } $scale = $topRateType['SCALE']; } else { $topRateName = null; $topRateType = null; $scale = array(0.5, 1, 1.5, 2, 5); } // FILTER $filter = array('from' => $from->toString(), 'to' => $to->toString(), 'site' => $site, 'split' => $attributeGroupName, 'rate' => $topRateName); CUserOptions::SetOption('conversion', 'filter', array_merge($userOptions, $filter)); $filter['lang'] = LANGUAGE_ID; // CONTEXT GeneratorContext::generateInitialData($from); $context = new ReportContext(); $context->setAttribute('conversion_site', $site); $splitRates = $context->getSplitRatesDeprecated($splits, $rateTypes, array('>=DAY' => $from, '<=DAY' => $to), array('FORMAT' => 'Y-m-d', 'SELECT' => 'RATE')); $totalRates = $splitRates['total']; unset($splitRates['total']); if ($totalTopRate = reset($totalRates)) { $totalTopDenominator = $totalTopRate['DENOMINATOR']; $totalTopConversion = $totalTopRate['RATE'] * 100; } else { $totalTopDenominator = 0; $totalTopConversion = 0; } // VIEW require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_admin_after.php'; require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/conversion/admin/helpers/scale.php'; $APPLICATION->SetTitle(Loc::getMessage('CONVERSION_SUMMARY_TITLE')); CJSCore::Init(array('amcharts', 'amcharts_serial'));
/** * Returns A/B-test traffic amounts * * @param int $id A/B-test ID. * @return array */ public static function getTestCapacity($id) { $cache = new \CPHPCache(); if ($cache->initCache(time() - strtotime('today'), 'abtest_capacity_' . intval($id), '/abtest')) { $capacity = $cache->getVars(); } else { if (Loader::includeModule('conversion')) { if ($conversionRates = Conversion\RateManager::getTypes(array('ACTIVE' => true))) { if ($abtest = ABTestTable::getById($id)->fetch()) { $lid = $abtest['SITE_ID']; $baseRate = array_slice($conversionRates, 0, 1, true); $reportContext = new Conversion\ReportContext(); $reportContext->setAttribute('conversion_site', $lid); $reportContext->setAttribute('abtest', $id); $reportContext->setAttribute('abtest_section', 'A'); $groupAData = reset($reportContext->getRatesDeprecated($baseRate, array(), null)); $reportContext->unsetAttribute('abtest_section', 'A'); $reportContext->setAttribute('abtest_section', 'B'); $groupBData = reset($reportContext->getRatesDeprecated($baseRate, array(), null)); $capacity = array('A' => $groupAData['DENOMINATOR'], 'B' => $groupBData['DENOMINATOR']); $cache->startDataCache(strtotime('tomorrow') - time()); $cache->endDataCache($capacity); } } } } return !empty($capacity) ? $capacity : array('A' => 0, 'B' => 0); }
if (!$filter[$name]) { $splitByAttribute = $name; } } } }); // SPLITS $splits = array(); foreach ($attributeTypes[$splitByAttribute]['VALUES'] as $name => $type) { $splits[$name] = array('NAME' => $splitByAttribute, 'VALUE' => $name, 'TITLE' => $type['NAME']); } // CONTEXT $context = new ReportContext(); foreach ($attributeTypes as $name => $type) { if ($value = $filter[$name]) { $context->setAttribute($name, $value); } } $splitRates = $context->getSplitRatesDeprecated($splits, array($rateName => $rateType), array('>=DAY' => $filter['from'], '<=DAY' => $filter['to'])); unset($splitRates['total'], $splitRates['other']); // TODO loop through getRates // LIST $adminList = new CAdminList($sTableID, $oSort); $adminList->AddHeaders(array(array('id' => 'TITLE', 'default' => true, 'content' => Loc::getMessage('CONVERSION_DETAILED_HEAD_TITLE')), array('id' => 'CONVERSION', 'default' => true, 'content' => Loc::getMessage('CONVERSION_DETAILED_HEAD_CONVERSION')), array('id' => 'SUM', 'default' => true, 'content' => Loc::getMessage('CONVERSION_DETAILED_HEAD_SUM')), array('id' => 'ACHIEVEMENTS', 'default' => true, 'content' => Loc::getMessage('CONVERSION_DETAILED_HEAD_ACHIEVEMENTS')), array('id' => 'TRAFFIC', 'default' => true, 'content' => Loc::getMessage('CONVERSION_DETAILED_HEAD_TRAFFIC')))); foreach ($splitRates as $name => $rates) { $split = $splits[$name]; $rate = current($rates); $row =& $adminList->AddRow(); $row->AddField('TITLE', $split['TITLE']); $row->AddField('CONVERSION', number_format($rate['RATE'] * 100, 2) . ' %'); $row->AddField('SUM', isset($rate['SUM']) ? isset($rateType['FORMAT']['SUM']) ? $rateType['FORMAT']['SUM']($rate['SUM']) : $rate['SUM'] : '');