function getMobileReports() { define('COLUMNS_COUNT_FOR_SIMPLE_TEMPLATE', 3); define('PATH_TO_MOBILE_REPORTS', '/bitrix/admin/mobile/sale_reports_view.php'); // Using report module if (!CModule::IncludeModule('report')) { return false; } // Using catalog module if (!CModule::IncludeModule('catalog')) { return false; } CBaseSaleReportHelper::initOwners(); $dbRepList = Bitrix\Report\ReportTable::getList(array('select' => array('ID', 'TITLE', 'SETTINGS'), 'filter' => array('=CREATED_BY' => $GLOBALS["USER"]->GetID(), '=OWNER_ID' => CBaseSaleReportHelper::getOwners()))); $arMenuItems = array(); while ($arReport = $dbRepList->fetch()) { $settings = unserialize($arReport['SETTINGS']); if (isset($settings['mobile']) && is_array($settings['mobile']) && isset($settings['mobile']['enabled']) && $settings['mobile']['enabled'] == true) { if (count($settings['select']) <= COLUMNS_COUNT_FOR_SIMPLE_TEMPLATE) { $template = "admin_mobile"; } else { $template = "admin_mobile_encl"; } $arMenuItems[] = array("text" => htmlspecialcharsbx($arReport['TITLE']), "data-url" => PATH_TO_MOBILE_REPORTS . '?ID=' . $arReport['ID'] . '&rep_templ=' . $template); } } if (empty($arMenuItems)) { return false; } else { return array("text" => GetMessage("SMOB_REPORTS"), "type" => "section", "items" => $arMenuItems); } }
"page_icon" => "sale_page_icon_statistic", "items_id" => "menu_sale_stat", "items" => array(), ); if(IsModuleInstalled('report')) { $arSaleReports = array(); if(method_exists($adminMenu, "IsSectionActive")) { if($adminMenu->IsSectionActive("menu_sale_report") && CModule::IncludeModule("report")) { CModule::IncludeModule("sale"); CBaseSaleReportHelper::initOwners(); $dbRepList = Bitrix\Report\ReportTable::getList(array( 'select' => array('ID', 'TITLE', 'DESCRIPTION'), 'filter' => array('=CREATED_BY' => $USER->GetID(), '=OWNER_ID' => CBaseSaleReportHelper::getOwners()) )); while($arReport = $dbRepList->fetch()) { $arSaleReports[] = array( "text" => htmlspecialcharsbx($arReport["TITLE"]), "title" => htmlspecialcharsbx($arReport["DESCRIPTION"]), "url" => "sale_report_view.php?lang=".LANGUAGE_ID."&ID=".$arReport["ID"], "more_url" => array("sale_report_construct.php?lang=".LANGUAGE_ID."&ID=".$arReport["ID"]), ); } } } $arMenu["items"][] = array( "text" => GetMessage("SALE_REPORTS_DESCR"),
// add fresh vReports CReport::addFreshDefaultReports($vReports, $ownerId); } } } } // create default reports by user request if ($isPost && !empty($_POST['CREATE_DEFAULT'])) { $dReports = call_user_func(array($helperClassName, 'getDefaultReports')); foreach ($dReports as $moduleVer => $vReports) { CReport::addFreshDefaultReports($vReports, $ownerId); } LocalRedirect($arParams['PATH_TO_REPORT_LIST']); } // main action $arResult['list'] = array(); $result = Bitrix\Report\ReportTable::getList(array('order' => array('ID' => 'ASC'), 'select' => array('ID', 'TITLE', 'DESCRIPTION', 'CREATED_DATE'), 'filter' => array('=CREATED_BY' => $USER->GetID(), '=OWNER_ID' => $ownerId))); while ($row = $result->fetch()) { $arResult['list'][] = $row; } // add default reports always if them isn't present if (empty($arResult['list'])) { $dReports = call_user_func(array($helperClassName, 'getDefaultReports')); foreach ($dReports as $moduleVer => $vReports) { CReport::addFreshDefaultReports($vReports, $ownerId); } LocalRedirect($arParams['PATH_TO_REPORT_LIST']); } global $DB; $arResult['dateFormat'] = $DB->DateFormatToPHP(CSite::GetDateFormat("SHORT")); $this->IncludeComponentTemplate();
CBaseSaleReportHelper::setSiteCurrencyId($siteCurrencyId); $reportCurrencyId = $siteCurrencyId; if (isset($_REQUEST['F_SALE_CURRENCY'])) { $currenciesIds = array_keys(CBaseSaleReportHelper::getCurrencies()); if (in_array($_REQUEST['F_SALE_CURRENCY'], $currenciesIds, true)) { $reportCurrencyId = $_REQUEST['F_SALE_CURRENCY']; } } CBaseSaleReportHelper::setSelectedCurrency($reportCurrencyId); $reportCurrency = CCurrencyLang::GetById($reportCurrencyId, LANGUAGE_ID); $reportWeightUnits = CBaseSaleReportHelper::getDefaultSiteWeightUnits(); $arParams['REPORT_CURRENCY_LABEL_TEXT'] = GetMessage('SALE_REPORT_VIEW_CURRENCY_LABEL_TITLE') . ': ' . $reportCurrency['FULL_NAME']; $arParams['REPORT_WEIGHT_UNITS_LABEL_TEXT'] = GetMessage('SALE_REPORT_VIEW_WEIGHT_UNITS_LABEL_TITLE') . ': ' . $reportWeightUnits; // Beforehand we get report parameters. $arRepParams = array(); if (!($arRepParams = Bitrix\Report\ReportTable::getById($ID)->fetch())) { $errorMessage .= GetMessage("SALE_REPORT_VIEW_ERROR_GET_REP_PARAMS") . '<br>'; $fCriticalError = true; } } if (!$fCriticalError) { // get helper name $arParams['OWNER_ID'] = $arRepParams['OWNER_ID']; $arParams['REPORT_HELPER_CLASS'] = CBaseSaleReportHelper::getHelperByOwner($arRepParams['OWNER_ID']); // fill report title $arParams['TITLE'] = $arRepParams['TITLE']; } if (!$fCriticalError) { // helper specific filters if ($arParams['OWNER_ID'] === 'sale_SaleProduct') { // Product custom filter (set value to helper)
// </editor-fold> try { // <editor-fold defaultstate="collapsed" desc="common initiazlize"> $ownerId = call_user_func(array($arParams['REPORT_HELPER_CLASS'], 'getOwnerId')); $entityName = call_user_func(array($arParams['REPORT_HELPER_CLASS'], 'getEntityName')); $entityFields = call_user_func(array($arParams['REPORT_HELPER_CLASS'], 'getColumnList')); $initEntity = Entity\Base::getInstance($entityName); $strChains = $entityFields; $chains = CReport::generateChains($strChains, $initEntity, ''); $arResult['chains'] = $chains; $arResult['fieldsTree'] = CReport::generateColumnTree($chains, $initEntity, $arParams['REPORT_HELPER_CLASS']); $fieldList = CReport::getUniqueFieldsByTree($arResult['fieldsTree']); // </editor-fold> // <editor-fold defaultstate="collapsed" desc="validation"> if ($arParams['ACTION'] == 'edit' || $arParams['ACTION'] == 'copy' || $arParams['ACTION'] == 'delete') { $result = Bitrix\Report\ReportTable::getById($arParams['REPORT_ID']); $report = $result->fetch(); if (empty($report)) { throw new BXUserException(sprintf(GetMessage('REPORT_NOT_FOUND'), $arParams['REPORT_ID'])); } if ($report['CREATED_BY'] != $USER->GetID()) { throw new BXUserException(GetMessage('REPORT_VIEW_PERMISSION_DENIED')); } $arResult['report'] = $report; } // </editor-fold> if (!empty($_POST) && (!empty($_POST['report_select_columns']) || $arParams['ACTION'] == 'delete_confirmed')) { // <editor-fold defaultstate="collapsed" desc="POST action"> $formErr = ''; // check csrf if (!check_bitrix_sessid('csrf_token')) {
public static function getReportData($reportID) { $reportID = intval($reportID); return $reportID > 0 ? Bitrix\Report\ReportTable::getById($reportID)->fetch() : null; }
$copyID = (int) $_REQUEST['copyID']; $fCopyMode = $copyID > 0 ? true : false; // If exists $ID parameter and it more than 0, then will creating a new report. $ID = (int) $_REQUEST['ID']; $fEditMode = $ID > 0 ? true : false; // If editing report that exists, then beforehand we gets its parameters. $arRepParams = array(); if ($fEditMode || $fCopyMode) { if ($fEditMode) { $repID = $ID; } else { if ($fCopyMode) { $repID = $copyID; } } if (!($arRepParams = Bitrix\Report\ReportTable::getById($repID)->NavNext(false))) { $errorMessage .= GetMessage("SALE_REPORT_CONSTRUCT_ERROR_EDIT_REPORT_ON_GET_PARAMS") . '<br>'; $fCriticalError = true; } } CBaseSaleReportHelper::init(); //<editor-fold defaultstate='collapsed' desc="Forming parameters of component report.construct"> $arParams = array('ACTION' => 'create', 'TITLE' => GetMessage('SALE_REPORT_CONSTRUCT_NEW_REPORT_TAB'), 'PATH_TO_REPORT_LIST' => '/bitrix/admin/sale_report.php?lang=' . LANG, 'PATH_TO_REPORT_CONSTRUCT' => '/bitrix/admin/sale_report_construct.php', 'PATH_TO_REPORT_VIEW' => '/bitrix/admin/sale_report_view.php?lang=' . LANG . '&ID=#report_id#'); // check helper selection $fSelectHelperMode = false; $rep_owner = ''; if ($rep_owner = $_REQUEST['rep_owner']) { try { // filter rep_owner value $matches = array(); $rep_owner = substr($rep_owner, 0, 50);
public static function GetList($owner = '') { global $USER; return Bitrix\Report\ReportTable::getList(array('select' => array('ID', 'TITLE', 'DESCRIPTION', 'CREATED_DATE'), 'filter' => array('=CREATED_BY' => $USER->GetID(), '=OWNER_ID' => $owner))); }