use Bitrix\Main\Localization\Loc; Loc::loadMessages(__FILE__); class CStoreAssist { static $arAllPageId = array( "currencies", "cat_group_admin", "cat_measure_list", "sale_report_edit", "sale_person_type", "locations", "sale_buyers", "sale_status", "cat_store_list", "storeassist_social", "cat_product_list", "quantity", "cat_store_document_list", "order_setting", "reserve_setting", "storeassist_1c_catalog_fill", "1c_integration", "storeassist_1c_unloading", "1c_exchange", "storeassist_1c_exchange_realtime", "storeassist_1c_small_firm", "sale_pay_system", "sale_delivery", "sale_delivery_service_list", "storeassist_seo_settings", "seo_robots", "seo_sitemap", "seo_search_yandex", "seo_search_google", "search_reindex", "storeassist_adaptive", "opening", "checklist", "storeassist_context_adv", "cat_discount_admin", "storeassist_marketing", "posting_admin", "cat_export_setup", "sale_ymarket", "ebay", "sale_order", "sale_report", "storeassist_print", "client", "sale_account_admin", "sale_basket", "sale_personalization", "sale_crm", "storeassist_crm_client", "storeassist_crm_calls", "site_speed", "composite", "bitrixcloud_cdn", "perfmon_panel", "security_filter", "dump_auto", "bitrixcloud_monitoring_admin", "security_scanner", "security_otp", "scale_graph", "cluster_index", "storeassist_virtual", "blog_comment", "ticket_desktop", "site_checker", "info_vk", "info_blog", "info_forum_guest", "info_forum_client", "info_idea", "info_user_doc", "info_api_doc", "info_courses", "support_developer", "support_bitrix" ); public static function setSettingOption($pageId, $isDone) { if (!in_array($pageId, self::$arAllPageId)) return false; if (!in_array($isDone, array("Y", "N"))) return false; $option = Bitrix\Main\Config\Option::get('storeassist', 'storeassist_settings', ''); if (!$option) $option = array(); else $option = explode(",", $option); if ($isDone == "Y" && !in_array($pageId, $option)) { $option[] = $pageId; } elseif($isDone == "N" && in_array($pageId, $option)) { $key = array_search($pageId, $option); unset($option[$key]); } $option = implode(",", $option); Bitrix\Main\Config\Option::set('storeassist', 'storeassist_settings', $option, ''); return $option; } public static function getSettingOption() { $option = Bitrix\Main\Config\Option::get('storeassist', 'storeassist_settings', ''); if (!$option) $option = array(); else $option = explode(",", $option); return $option; } public static function getDocumentationLink($pageId) { if (!$pageId) return false; if (!in_array($pageId, self::$arAllPageId)) return false; return Loc::getMessage("STOREAS_DOCURL_".$pageId); } public static function onPrologAdminTitle($pageUrl, $pageId = "") { if (!in_array(LANGUAGE_ID, array("ru", "ua"))) return; global $APPLICATION, $bxProductConfig; $ST_RIGHT = $APPLICATION->GetGroupRight("storeassist"); if (!($ST_RIGHT >= "R")) { return false; } $partnerUrl = Bitrix\Main\Config\Option::get("storeassist", "partner_url", ''); if ($partnerUrl) $bxProductConfig["admin"]["links"] = 'www.1c-bitrix.ru | '.Loc::getMessage("STOREAS_SUPPORT").''; if (!$pageId) { preg_match("/([^\/]*?)\.php/i", $pageUrl, $matches); if (isset($matches[1])) $pageId = $matches[1]; else return false; } if (!in_array($pageId, self::$arAllPageId)) return false; $arSettingOption = self::getSettingOption(); $isItemDone = (in_array($pageId, $arSettingOption)) ? true : false; CJSCore::Init(array('storeassist', 'fx')); $APPLICATION->SetAdditionalCSS('/bitrix/panel/storeassist/storeassist.css'); //Bitrix\Main\Page\Asset::getInstance()->addCss('/bitrix/panel/storeassist/storeassist.css'); $hash = (isset($_GET["back"])) ? "#".htmlspecialcharsbx($_GET["back"]) : ""; echo '
'; if (!$isItemDone) { echo ''; } } public static function onBuildGlobalMenu(&$arGlobalMenu, &$arModuleMenu) { if (!in_array(LANGUAGE_ID, array("ru", "ua"))) return; global $APPLICATION; if ($APPLICATION->GetGroupRight("storeassist") >= "R") { $storeAssistItem = array( "text" => Loc::getMessage("STOREAS_MENU_TEXT"), "url" => "storeassist.php?lang=".LANGUAGE_ID, "title" => Loc::getMessage("STOREAS_MENU_TITLE"), ); foreach ($arModuleMenu as &$arMenuItem) { if (!isset($arMenuItem["items_id"]) || $arMenuItem["items_id"] !== "menu_sale_settings") { continue; } if (isset($arMenuItem["items"]) && is_array($arMenuItem["items"])) { array_unshift($arMenuItem["items"], $storeAssistItem); } else { $arMenuItem["items"] = array($storeAssistItem); } break; } } } public static function getProgressPercent() { $progress = Bitrix\Main\Config\Option::get("storeassist", "progress_percent", 0); if ($progress < 0) $progress = 0; elseif ($progress > 10) $progress = 10; return $progress; } public static function AgentCountDayOrders() { global $DB; if (Bitrix\Main\Loader::includeModule("sale")) { //count orders $arFilter = array( "STATUS_ID" => array("F", "P"), "PAYED" => "Y", ); $dateFromTs = MakeTimeStamp(date("d", time()-3600*24*2).".".date("m", time()-3600*24*2).".".date("Y", time()-3600*24*2)." 23:59:59", "DD.MM.YYYY HH:MI:SS"); $dateToTs = MakeTimeStamp(date("d").".".date("m").".".date("Y")." 00:00:00", "DD.MM.YYYY HH:MI:SS"); $arFilter[">DATE_STATUS"] = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID)), $dateFromTs); $arFilter["