require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/sale/prolog.php");
\Bitrix\Main\Loader::includeModule('sale');
$saleModulePermissions = $APPLICATION->GetGroupRight("sale");
if ($saleModulePermissions <= "D")
$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
IncludeModuleLangFile(__FILE__);
if(!CBXFeatures::IsFeatureEnabled('SaleReports'))
{
require($_SERVER['DOCUMENT_ROOT']."/bitrix/modules/main/include/prolog_admin_after.php");
ShowError(GetMessage("SALE_FEATURE_NOT_ALLOW"));
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php");
die();
}
//
ClearVars();
$errorMessage = '';
$errAdmMessage = null;
$fCriticalError = false;
// Using report module
if (!CModule::IncludeModule('report'))
{
$errorMessage .= GetMessage("REPORT_MODULE_NOT_INSTALLED").'
';
$fCriticalError = true;
}
// Using catalog module
if (!CModule::IncludeModule('catalog'))
{
$errorMessage .= GetMessage("CATALOG_MODULE_NOT_INSTALLED").'
';
$fCriticalError = true;
}
// Using iblock module
if (!CModule::IncludeModule('iblock'))
{
$errorMessage .= GetMessage("IBLOCK_MODULE_NOT_INSTALLED").'
';
$fCriticalError = true;
}
// If exists $copyID parameter and it more than 0, then will creating a copy of existing report.
$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'] ?? 0);
$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)->fetch()))
{
$errorMessage .= GetMessage("SALE_REPORT_CONSTRUCT_ERROR_EDIT_REPORT_ON_GET_PARAMS").'
';
$fCriticalError = true;
}
}
if ($fEditMode && isset($arRepParams['MARK_DEFAULT']) && intval($arRepParams['MARK_DEFAULT']) > 0)
{
$errorMessage .= GetMessage("SALE_REPORT_DEFAULT_CAN_NOT_BE_EDITED").'
';
$fCriticalError = true;
}
CBaseSaleReportHelper::init();
//
$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=' . LANGUAGE_ID . '&ID=#report_id#',
'USE_CHART' => true
);
// check helper selection
$fSelectHelperMode = false;
$rep_owner = '';
if ($rep_owner = ($_REQUEST['rep_owner'] ?? ''))
{
try
{
// filter rep_owner value
$matches = array();
$rep_owner = mb_substr($rep_owner, 0, 50);
if (preg_match('/^[A-Z_][A-Z0-9_-]*[A-Z0-9_]$/i', $rep_owner, $matches)) $rep_owner = $matches[0];
else $rep_owner = '';
if (!$rep_owner || !in_array($rep_owner, CBaseSaleReportHelper::getOwners()))
throw new Exception(GetMessage('REPORT_UNKNOWN_ERROR'));
if (!$fCriticalError)
{
// set owner id
$arParams['OWNER_ID'] = $rep_owner;
// get helper name
$arParams['REPORT_HELPER_CLASS'] = CBaseSaleReportHelper::getHelperByOwner($rep_owner);
}
}
catch (Exception $e)
{
$errorMessage .= $e->getMessage().'
';
$fCriticalError = true;
}
}
if ($fEditMode)
{
$arParams['report'] = $arRepParams;
$arParams['ACTION'] = 'edit';
$arParams['TITLE'] = $arRepParams['TITLE'];
$arParams['REPORT_ID'] = $ID;
$arParams['REPORT_HELPER_CLASS'] = CBaseSaleReportHelper::getHelperByOwner($arRepParams['OWNER_ID']);
$rep_owner = $arRepParams['OWNER_ID'];
}
elseif ($fCopyMode)
{
$arParams['report'] = $arRepParams;
$arParams['ACTION'] = 'copy';
$arParams['TITLE'] = $arRepParams['TITLE'];
$arParams['REPORT_ID'] = $copyID;
$arParams['REPORT_HELPER_CLASS'] = CBaseSaleReportHelper::getHelperByOwner($arRepParams['OWNER_ID']);
$rep_owner = $arRepParams['OWNER_ID'];
}
if ($arParams['ACTION'] == 'create' && !$arParams['REPORT_HELPER_CLASS']) $fSelectHelperMode = true;
//
//
if ($_REQUEST['cancel'] ?? false)
{
if (!empty($_POST['rep_referer']))
{
$url = $_POST['rep_referer'];
}
else
{
$url = $_SERVER['HTTP_REFERER'];
}
/*else
{
$url = $fEditMode ? str_replace('#report_id#', $ID, $arParams['PATH_TO_REPORT_VIEW']) : $arParams['PATH_TO_REPORT_LIST'];
}*/
LocalRedirect($url);
}
$siteList = CBaseSaleReportHelper::getSiteList();
if (isset($_REQUEST['F_SALE_SITE']))
{
$siteId = mb_substr($_REQUEST['F_SALE_SITE'], 0, 2);
if (array_key_exists($siteId, $siteList))
{
$siteCookieId = CBaseSaleReportHelper::getSiteCookieId();
setcookie($siteCookieId, $siteId, time()+365*24*3600);
}
$arParams['F_SALE_SITE'] = $siteId;
CBaseSaleReportHelper::setDefaultSiteId($siteId);
unset($siteId);
}
else
{
$siteCookieId = CBaseSaleReportHelper::getSiteCookieId();
if (isset($_COOKIE[$siteCookieId]))
{
$siteId = mb_substr($_COOKIE[$siteCookieId], 0, 2);
if (array_key_exists($siteId, $siteList))
{
$arParams['F_SALE_SITE'] = $siteId;
CBaseSaleReportHelper::setDefaultSiteId($siteId);
}
unset($siteId);
}
}
if (($_REQUEST['REPORT_AJAX'] ?? '') === 'Y')
{
$arResponse = array();
if (is_array($_REQUEST['filterTypes']))
{
$result = CBaseSaleReportHelper::getAjaxResponse($_REQUEST['filterTypes']);
if (is_array($result)) $arResponse = $result;
}
header("Content-Type: application/x-javascript; charset=".LANG_CHARSET);
echo CUtil::PhpToJSObject($arResponse);
exit;
}
//
if (!isset($arParams['F_SALE_SITE']))
{
$arParams['F_SALE_SITE'] = CBaseSaleReportHelper::getDefaultSiteId();
}
//
// Page header
$rep_title = ($fEditMode) ? GetMessage("SALE_REPORT_EDIT_TITLE") : GetMessage("SALE_REPORT_CONSTRUCT_TITLE");
if (isset($arParams['TITLE']) && !empty($arParams['TITLE'])) $rep_title .= ' "'.$arParams['TITLE'].'"';
$APPLICATION->SetTitle($rep_title);
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php");
//
if( $errorMessage )
{
$errAdmMessage = new CAdminMessage(
array(
"DETAILS"=>$errorMessage,
"TYPE"=>"ERROR",
"MESSAGE"=>(
($fEditMode) ? GetMessage('SALE_REPORT_CONSTRUCT_ERROR_EDIT_REPORT')
: GetMessage('SALE_REPORT_CONSTRUCT_ERROR_ADD_REPORT')
),
"HTML"=>true
)
);
echo $errAdmMessage->Show();
}
if (!$fCriticalError)
{
//
?>
Fatal error: Uncaught Error: Call to undefined function GetMessage() in D:\ktt\ttepla.com\public_html\bitrix\modules\sale\admin\report_construct.php:248
Stack trace:
#0 {main}
thrown in D:\ktt\ttepla.com\public_html\bitrix\modules\sale\admin\report_construct.php on line 248