GetGroupRight("sale"); if ($saleModulePermissions < "W") $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED")); \Bitrix\Main\Loader::includeModule('sale'); IncludeModuleLangFile(__FILE__); require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/sale/prolog.php"); if ('POST' == $_SERVER['REQUEST_METHOD'] && (isset($_REQUEST["Convert"]) && 'Y' == $_REQUEST["Convert"]) && check_bitrix_sessid()) { CUtil::JSPostUnescape(); require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_js.php"); $max_execution_time = 10; if (isset($_REQUEST['max_execution_time']) && 0 < intval($_REQUEST['max_execution_time'])) { $max_execution_time = intval($_REQUEST['max_execution_time']); } COption::SetOptionString("sale", "max_execution_time", $max_execution_time); $converted = isset($_REQUEST['converted'])? intval($_REQUEST['converted']): 0; $maxMessage = isset($_REQUEST['maxMessage'])? intval($_REQUEST['maxMessage']): 0; $maxMessagePerStep = isset($_REQUEST['maxMessagePerStep'])? intval($_REQUEST['maxMessagePerStep']): 100; if ($converted == 0 && $maxMessage == 0) $maxMessage = CSaleDiscountConvert::GetCountOld(); $strSessID = isset($_REQUEST['DC']) ? $_REQUEST['DC'] : ''; CSaleDiscountConvert::$intConvertPerStep = 0; CSaleDiscountConvert::$intConverted = $converted; CSaleDiscountConvert::$strSessID = $strSessID; CSaleDiscountConvert::ConvertDiscount($maxMessagePerStep, $max_execution_time); if (CSaleDiscountConvert::$intConvertPerStep > 0) { $aboutMinute = ($maxMessage-CSaleDiscountConvert::$intConverted)/CSaleDiscountConvert::$intConvertPerStep*$max_execution_time/60; $strAbout = ($aboutMinute >= 1 ? str_replace('#MIN#', ceil($aboutMinute), GetMessage('SALE_DISC_CONVERT_TOTAL_MIN')) : str_replace('#SEC#', ceil($aboutMinute*60), GetMessage('SALE_DISC_CONVERT_TOTAL_SEC'))); CAdminMessage::ShowMessage(array( "MESSAGE"=>GetMessage("SALE_DISC_CONVERT_IN_PROGRESS"), "DETAILS" => str_replace(array('#COUNT#', '#PERCENT#', '#TIME#'), array($converted, ceil(CSaleDiscountConvert::$intConverted/$maxMessage*100), $strAbout), GetMessage('SALE_DISC_CONVERT_TOTAL')), "HTML"=>true, "TYPE"=>"OK", )); ?>