GetGroupRight($module_id); if ($SALE_RIGHT>="R") : IncludeModuleLangFile($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/options.php'); IncludeModuleLangFile(__FILE__); Main\Page\Asset::getInstance()->addJs('/bitrix/js/sale/options.js'); $APPLICATION->SetAdditionalCSS("/bitrix/themes/.default/sale.css"); Loader::includeModule('sale'); Loader::includeModule('currency'); $lpEnabled = CSaleLocation::isLocationProEnabled(); $lMigrated = CSaleLocation::isLocationProMigrated(); function checkAccountNumberValue($templateType, $number_data, $number_prefix) { $res = true; switch ($templateType) { case 'NUMBER': if (strlen($number_data) <= 0 || strlen($number_data) > 7 || !preg_match('/^[0-9]+$/', $number_data) || intval($number_data) < intval(COption::GetOptionString("sale", "account_number_data", "")) ) $res = false; break; case 'PREFIX': if (strlen($number_prefix) <= 0 || strlen($number_prefix) > 7 || preg_match('/[^a-zA-Z0-9_-]/', $number_prefix) ) $res = false; break; } return $res; } $siteList = array(); $siteIterator = SiteTable::getList(array( 'select' => array('LID', 'NAME'), 'order' => array('SORT' => 'ASC') )); while ($oneSite = $siteIterator->fetch()) { $siteList[] = array('ID' => $oneSite['LID'], 'NAME' => $oneSite['NAME']); } unset($oneSite, $siteIterator); $siteCount = count($siteList); $bWasUpdated = false; if ($_SERVER['REQUEST_METHOD'] == "GET" && strlen($RestoreDefaults)>0 && $SALE_RIGHT=="W" && check_bitrix_sessid()) { $bWasUpdated = true; COption::RemoveOption("sale"); $z = CGroup::GetList($v1="id",$v2="asc", array("ACTIVE" => "Y", "ADMIN" => "N")); while($zr = $z->Fetch()) $APPLICATION->DelGroupRight($module_id, array($zr["ID"])); } $arAllOptions = array( Array("order_email", GetMessage("SALE_EMAIL_ORDER"), "order@".$SERVER_NAME, Array("text", 30)), //Array("default_email", GetMessage("SALE_EMAIL_REGISTER"), "admin@".$SERVER_NAME, Array("text", 30)), Array("delete_after", GetMessage("SALE_DELETE_AFTER"), "", Array("text", 10)), Array("order_list_date", GetMessage("SALE_ORDER_LIST_DATE"), 30, Array("text", 10)), Array("MAX_LOCK_TIME", GetMessage("SALE_MAX_LOCK_TIME"), 30, Array("text", 10)), Array("GRAPH_WEIGHT", GetMessage("SALE_GRAPH_WEIGHT"), 800, Array("text", 10)), Array("GRAPH_HEIGHT", GetMessage("SALE_GRAPH_HEIGHT"), 600, Array("text", 10)), Array("path2user_ps_files", GetMessage("SALE_PATH2UPSF"), BX_PERSONAL_ROOT."/php_interface/include/sale_payment/", Array("text", 40)), Array("path2custom_view_order", GetMessage("SMO_SALE_PATH2ORDER"), "", Array("text", 40)), Array("lock_catalog", GetMessage("SMO_LOCK_CATALOG"), "Y", Array("checkbox", 40)), (CBXFeatures::IsFeatureEnabled('SaleAffiliate')) ? Array("affiliate_param_name", GetMessage("SMOS_AFFILIATE_PARAM"), "partner", Array("text", 40)) : array(), (CBXFeatures::IsFeatureEnabled('SaleAffiliate')) ? Array("affiliate_life_time", GetMessage("SMO_AFFILIATE_LIFE_TIME"), "30", Array("text", 10)): array(), Array("show_order_sum", GetMessage("SMO_SHOW_ORDER_SUM"), "N", Array("checkbox", 40)), Array("show_order_product_xml_id", GetMessage("SMO_SHOW_ORDER_PRODUCT_XML_ID"), "N", Array("checkbox", 40)), Array("show_paysystem_action_id", GetMessage("SMO_SHOW_PAYSYSTEM_ACTION_ID"), "N", Array("checkbox", 40)), Array("measurement_path", GetMessage("SMO_MEASUREMENT_PATH"), "/bitrix/modules/sale/measurements.php", Array("text", 40)), //Array("use_delivery_handlers", GetMessage("SMO_USE_DELIVERY_HANDLERS"), "N", Array("checkbox", 40)), Array("delivery_handles_custom_path", GetMessage("SMO_DELIVERY_HANDLERS_CUSTOM_PATH"), BX_PERSONAL_ROOT."/php_interface/include/sale_delivery/", Array("text", 40)), Array("use_secure_cookies", GetMessage("SMO_USE_SECURE_COOKIES"), "N", Array("checkbox", 40)), Array("encode_fuser_id", GetMessage("SMO_ENCODE_FUSER_ID"), "N", Array("checkbox", 40)), //Array("recalc_product_list", GetMessage("SALE_RECALC_PRODUCT_LIST"), "N", Array("checkbox", 40)), //Array("recalc_product_list_period", GetMessage("SALE_RECALC_PRODUCT_LIST_PERIOD"), 7, Array("text", 10)), Array("COUNT_DISCOUNT_4_ALL_QUANTITY", GetMessage("SALE_OPT_COUNT_DISCOUNT_4_ALL_QUANTITY"), "N", Array("checkbox", 40)), Array("COUNT_DELIVERY_TAX", GetMessage("SALE_OPT_COUNT_DELIVERY_TAX"), "N", Array("checkbox", 40)), Array("QUANTITY_FACTORIAL", GetMessage("SALE_OPT_QUANTITY_FACTORIAL"), "N", Array("checkbox", 40)), Array("viewed_capability", GetMessage("SALE_VIEWED_CAPABILITY"), "Y", Array("checkbox", 40)), Array("viewed_time", GetMessage("SALE_VIEWED_TIME"), 90, Array("text", 10)), Array("viewed_count", GetMessage("SALE_VIEWED_COUNT"), 100, Array("text", 10)), Array("SALE_ADMIN_NEW_PRODUCT", GetMessage("SALE_ADMIN_NEW_PRODUCT"), "N", Array("checkbox", 40)), Array("use_ccards", GetMessage("SALE_ADMIN_USE_CARDS"), "N", Array("checkbox", 40)), Array("show_basket_props_in_order_list", GetMessage("SALE_SHOW_BASKET_PROPS_IN_ORDER_LIST"), "Y", Array("checkbox", 40)), ); $arOrderFlags = array("P" => GetMessage("SMO_PAYMENT_FLAG"), "C" => GetMessage("SMO_CANCEL_FLAG"), "D" => GetMessage("SMO_DELIVERY_FLAG")); $arAccountNumberDefaultTemplates = array( "" => GetMessage("SALE_ACCOUNT_NUMBER_TEMPLATE_0"), "NUMBER" => GetMessage("SALE_ACCOUNT_NUMBER_TEMPLATE_1"), "PREFIX" => GetMessage("SALE_ACCOUNT_NUMBER_TEMPLATE_2"), "RANDOM" => GetMessage("SALE_ACCOUNT_NUMBER_TEMPLATE_3"), "USER" => GetMessage("SALE_ACCOUNT_NUMBER_TEMPLATE_4"), "DATE" => GetMessage("SALE_ACCOUNT_NUMBER_TEMPLATE_5"), ); $arAccountNumberCustomHandlers = array(); foreach(GetModuleEvents("sale", "OnBuildAccountNumberTemplateList", true) as $arEvent) { $arRes = ExecuteModuleEventEx($arEvent, array()); if (isset($arRes["CODE"]) && isset($arRes["NAME"])) $arAccountNumberCustomHandlers[$arRes["CODE"]] = $arRes["NAME"]; } $arAccountNumberTemplates = array_merge($arAccountNumberDefaultTemplates, $arAccountNumberCustomHandlers); $aTabs = array( array("DIV" => "edit1", "TAB" => GetMessage("MAIN_TAB_SET"), "ICON" => "sale_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_SET")), array("DIV" => "edit7", "TAB" => GetMessage("SALE_TAB_WEIGHT"), "ICON" => "sale_settings", "TITLE" => GetMessage("SALE_TAB_WEIGHT_TITLE")), array("DIV" => "edit5", "TAB" => GetMessage("SALE_TAB_ADDRESS"), "ICON" => "sale_settings", "TITLE" => GetMessage("SALE_TAB_ADDRESS_TITLE")) ); if (CBXFeatures::IsFeatureEnabled('SaleCCards') && COption::GetOptionString($module_id, "use_ccards", "N") == "Y") $aTabs[] = array("DIV" => "edit2", "TAB" => GetMessage("SALE_TAB_2"), "ICON" => "sale_settings", "TITLE" => GetMessage("SMO_CRYPT_TITLE")); $aTabs[] = array("DIV" => "edit3", "TAB" => GetMessage("SALE_TAB_3"), "ICON" => "sale_settings", "TITLE" => GetMessage("SALE_TAB_3_TITLE")); $aTabs[] = array("DIV" => "edit4", "TAB" => GetMessage("MAIN_TAB_RIGHTS"), "ICON" => "sale_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_RIGHTS")); $tabControl = new CAdminTabControl("tabControl", $aTabs); $strWarning = ""; if ($_SERVER['REQUEST_METHOD'] == "POST" && strlen($Update) > 0 && $SALE_RIGHT == "W" && check_bitrix_sessid()) { if (!checkAccountNumberValue($_POST["account_number_template"], $_POST["account_number_number"], $_POST["account_number_prefix"])) { if ($_POST["account_number_template"] == "PREFIX") $strWarning = GetMessage("SALE_ACCOUNT_NUMBER_PREFIX_WARNING", array("#PREFIX#" => $_POST["account_number_prefix"])); elseif ($_POST["account_number_template"] == "NUMBER") $strWarning = GetMessage("SALE_ACCOUNT_NUMBER_NUMBER_WARNING", array("#NUMBER#" => $_POST["account_number_number"])); } else { $bWasUpdated = true; COption::RemoveOption($module_id, "weight_unit"); COption::RemoveOption($module_id, "weight_koef"); if (!empty($_REQUEST["WEIGHT_dif_settings"])) { for ($i = 0; $i < $siteCount; $i++) { COption::SetOptionString($module_id, "weight_unit", trim($_REQUEST["weight_unit"][$siteList[$i]["ID"]]), false, $siteList[$i]["ID"]); COption::SetOptionString($module_id, "weight_koef", floatval($_REQUEST["weight_koef"][$siteList[$i]["ID"]]), false, $siteList[$i]["ID"]); } COption::SetOptionString($module_id, "WEIGHT_different_set", "Y"); } else { $site_id = trim($_REQUEST["WEIGHT_current_site"]); COption::SetOptionString($module_id, "weight_unit", trim($_REQUEST["weight_unit"][$site_id])); COption::SetOptionString($module_id, "weight_koef", floatval($_REQUEST["weight_koef"][$site_id])); COption::SetOptionString($module_id, "WEIGHT_different_set", "N"); } COption::RemoveOption($module_id, "location_zip"); COption::RemoveOption($module_id, "location"); if (!empty($_REQUEST["ADDRESS_dif_settings"])) { for ($i = 0; $i < $siteCount; $i++) { COption::SetOptionString($module_id, "location_zip", $_REQUEST["location_zip"][$siteList[$i]["ID"]], false, $siteList[$i]["ID"]); COption::SetOptionString($module_id, "location", $_REQUEST["location"][$siteList[$i]["ID"]], false, $siteList[$i]["ID"]); } COption::SetOptionString($module_id, "ADDRESS_different_set", "Y"); } else { $site_id = trim($_REQUEST["ADDRESS_current_site"]); COption::SetOptionString($module_id, "location_zip", $_REQUEST["location_zip"][$site_id]); COption::SetOptionString($module_id, "location", $_REQUEST["location"][$site_id]); COption::SetOptionString($module_id, "ADDRESS_different_set", "N"); } if(!$lMigrated ) { COption::RemoveOption($module_id, "sales_zone_countries"); COption::RemoveOption($module_id, "sales_zone_regions"); COption::RemoveOption($module_id, "sales_zone_cities"); } if(!$lpEnabled) { if (!empty($_REQUEST["ADDRESS_dif_settings"])) { for ($i = 0; $i < $siteCount; $i++) { if($lMigrated) { try { \Bitrix\Sale\SalesZone::saveSelectedTypes(array( 'COUNTRY' => $_REQUEST["sales_zone_countries"][$siteList[$i]["ID"]], 'REGION' => $_REQUEST["sales_zone_regions"][$siteList[$i]["ID"]], 'CITY' => $_REQUEST["sales_zone_cities"][$siteList[$i]["ID"]] ), $siteList[$i]["ID"]); } catch(Exception $e) { } } else { COption::SetOptionString($module_id, "sales_zone_countries", implode(":", $_REQUEST["sales_zone_countries"][$siteList[$i]["ID"]]), false, $siteList[$i]["ID"]); COption::SetOptionString($module_id, "sales_zone_regions", implode(":",$_REQUEST["sales_zone_regions"][$siteList[$i]["ID"]]), false, $siteList[$i]["ID"]); COption::SetOptionString($module_id, "sales_zone_cities", implode(":",$_REQUEST["sales_zone_cities"][$siteList[$i]["ID"]]), false, $siteList[$i]["ID"]); } } } else { $site_id = trim($_REQUEST["ADDRESS_current_site"]); if($lMigrated) { try { \Bitrix\Sale\SalesZone::saveSelectedTypes(array( 'COUNTRY' => $_REQUEST["sales_zone_countries"][$site_id], 'REGION' => $_REQUEST["sales_zone_regions"][$site_id], 'CITY' => $_REQUEST["sales_zone_cities"][$site_id] ), $site_id); } catch(Exception $e) { } } else { COption::SetOptionString($module_id, "sales_zone_countries", implode(":",$_REQUEST["sales_zone_countries"][$site_id])); COption::SetOptionString($module_id, "sales_zone_regions", implode(":",$_REQUEST["sales_zone_regions"][$site_id])); COption::SetOptionString($module_id, "sales_zone_cities", implode(":",$_REQUEST["sales_zone_cities"][$site_id])); } } } for ($i = 0, $intCount = count($arAllOptions); $i < $intCount; $i++) { if(!empty($arAllOptions[$i])) { $name = $arAllOptions[$i][0]; $val = ${$name}; if ($arAllOptions[$i][3][0]=="checkbox" && $val!="Y") $val = "N"; if ($name == "path2user_ps_files" && substr($val, strlen($val)-1, 1) != "/") { $val .= "/"; } COption::SetOptionString("sale", $name, $val, $arAllOptions[$i][1]); } } $rsAgents = CAgent::GetList(array("ID"=>"DESC"), array( "MODULE_ID" => "sale", "NAME" => "CSaleUser::DeleteOldAgent(%", )); while($arAgent = $rsAgents->Fetch()) { CAgent::Delete($arAgent["ID"]); } $delete_after = (int)COption::GetOptionInt("sale", "delete_after"); if ($delete_after > 0) CAgent::AddAgent("CSaleUser::DeleteOldAgent(".$delete_after.");", "sale", "N", 8*60*60, "", "Y"); /*$recalc_product_list_period = intval(COption::GetOptionInt("sale", "recalc_product_list_period", 7)); CAgent::RemoveAgent("CSaleProduct::RefreshProductList();", "sale"); if( COption::GetOptionString("sale", "recalc_product_list", "N") == "Y" && $recalc_product_list_period > 0 ) { CAgent::AddAgent("CSaleProduct::RefreshProductList();", "sale", "N", 60*60*24*$recalc_product_list_period, "", "Y"); }*/ if(CBXFeatures::IsFeatureEnabled('SaleAffiliate')) { COption::SetOptionString("sale", "affiliate_plan_type", $affiliate_plan_type); } $arAmountSer = Array(); foreach($amount_val as $key =>$val) { if(DoubleVal($val) > 0) $arAmountSer[$key] = Array("AMOUNT" => DoubleVal($val), "CURRENCY" => $amount_currency[$key]); } if(!empty($arAmountSer)) COption::SetOptionString("sale", "pay_amount", serialize($arAmountSer)); CAgent::RemoveAgent("CSaleOrder::RemindPayment();", "sale"); COption::RemoveOption("sale", "pay_reminder"); if (isset($_POST["reminder"]) && is_array($_POST["reminder"]) && !empty($_POST["reminder"])) { COption::SetOptionString("sale", "pay_reminder", serialize($_POST["reminder"])); CAgent::AddAgent("CSaleOrder::RemindPayment();", "sale", "N", 86400, "", "Y"); } //subscribe product $rsAgents = CAgent::GetList( array("ID"=>"DESC"), array( "MODULE_ID" => "sale", "NAME" => "CSaleBasket::ClearProductSubscribe(%", ) ); while($arAgent = $rsAgents->Fetch()) CAgent::Delete($arAgent["ID"]); if(!empty($subscribProd)) { foreach($siteList as $vv) { $lid = $vv["ID"]; $val = $subscribProd[$lid]; if ($val["use"] == "Y") { if (IntVal($val["del_after"]) <= 0) $subscribProd[$lid]["del_after"] = 30; CAgent::AddAgent("CSaleBasket::ClearProductSubscribe('".EscapePHPString($lid)."');", "sale", "N", IntVal($subscribProd[$lid]["del_after"])*24*60*60, "", "Y"); } } COption::SetOptionString("sale", "subscribe_prod", serialize($subscribProd)); } //viewed product if(!empty($viewed)) { foreach ($viewed as $lid => $val) { if (IntVal($val["time"]) <= 0) $viewed[$lid]["time"] = 90; if (IntVal($val["count"]) <= 0) $viewed[$lid]["count"] = 1000; } COption::SetOptionString("sale", "viewed_product", serialize($viewed)); } if(isset($_POST['viewed_capability']) && $_POST['viewed_capability'] == "Y") { COption::SetOptionString("sale", "viewed_capability", "Y"); } else { COption::SetOptionString("sale", "viewed_capability", "N"); } COption::SetOptionString("sale", "default_currency", $CURRENCY_DEFAULT); COption::SetOptionString("sale", "crypt_algorithm", $crypt_algorithm); COption::SetOptionString("sale", "sale_data_file", $sale_data_file); COption::SetOptionString("sale", "sale_data_file", $sale_data_file); if ($sale_ps_success_path == "") $sale_ps_success_path = "/"; COption::SetOptionString("sale", "sale_ps_success_path", $sale_ps_success_path); if ($sale_ps_fail_path == "") $sale_ps_fail_path = "/"; COption::SetOptionString("sale", "sale_ps_fail_path", $sale_ps_fail_path); if ($sale_location_selector_appearance == "") $sale_location_selector_appearance = "steps"; COption::SetOptionString("sale", "sale_location_selector_appearance", $sale_location_selector_appearance); COption::SetOptionString("sale", "status_on_paid", $PAID_STATUS); COption::SetOptionString("sale", "status_on_allow_delivery", $ALLOW_DELIVERY_STATUS); COption::SetOptionString("sale", "status_on_payed_2_allow_delivery", $PAYED_2_ALLOW_DELIVERY); COption::SetOptionString("sale", "allow_deduction_on_delivery", $ALLOW_DEDUCTION_ON_DELIVERY); COption::SetOptionString("sale", "format_quantity", ($FORMAT_QUANTITY == 'AUTO' ? $FORMAT_QUANTITY: intval($FORMAT_QUANTITY))); $oldExpirationProcessingEvents = Option::get('sale', 'expiration_processing_events'); COption::SetOptionString("sale", "expiration_processing_events", $EXPIRATION_PROCESSING_EVENTS); if ($oldExpirationProcessingEvents != $EXPIRATION_PROCESSING_EVENTS) { if ($EXPIRATION_PROCESSING_EVENTS == "Y") { Sale\Compatible\EventCompatibility::registerEvents(); } else { Sale\Compatible\EventCompatibility::unRegisterEvents(); } } if (!empty($SELECTED_FIELDS) && is_array($SELECTED_FIELDS)) { for ($i = 0, $intCount = count($SELECTED_FIELDS); $i < $intCount; $i++) { if (strlen($saveValue) > 0) $saveValue .= ","; $saveValue .= $SELECTED_FIELDS[$i]; } } else { $saveValue = "ID,USER,PAY_SYSTEM,PRICE,STATUS,PAYED,PS_STATUS,CANCELED,BASKET"; } COption::SetOptionString("sale", "order_list_fields", $saveValue); // account number generation algorithm if (isset($_POST["account_number_template"])) { if (array_key_exists($_POST["account_number_template"], $arAccountNumberDefaultTemplates)) { switch ($_POST["account_number_template"]) { case 'NUMBER': COption::SetOptionString("sale", "account_number_template", "NUMBER"); COption::SetOptionString("sale", "account_number_data", intval($_POST["account_number_number"])); break; case 'PREFIX': COption::SetOptionString("sale", "account_number_template", "PREFIX"); COption::SetOptionString("sale", "account_number_data", $_POST["account_number_prefix"]); break; case 'RANDOM': COption::SetOptionString("sale", "account_number_template", "RANDOM"); COption::SetOptionString("sale", "account_number_data", intval($_POST["account_number_random_length"])); break; case 'USER': COption::SetOptionString("sale", "account_number_template", "USER"); COption::SetOptionString("sale", "account_number_data", ""); break; case 'DATE': COption::SetOptionString("sale", "account_number_template", "DATE"); COption::SetOptionString("sale", "account_number_data", $_POST["account_number_date_period"]); break; default: COption::SetOptionString("sale", "account_number_template", ""); COption::SetOptionString("sale", "account_number_data", ""); break; } } else // custom account number generation template { COption::SetOptionString("sale", "account_number_template", $_POST["account_number_template"]); } } //subscribe product if (!empty($defaultDeductStore)) { COption::RemoveOption("sale", "deduct_store_id"); foreach ($defaultDeductStore as $lid => $val) { if (isset($val["save"]) && $val["save"] == "Y") COption::SetOptionString("sale", "deduct_store_id", intval($val["id"]), "", $lid); } } //SAVE SHOP LIST SITE foreach($siteList as $val) { COption::RemoveOption("sale", "SHOP_SITE_".$val["ID"]); } if (isset(${"SHOP_SITE"}) AND is_array(${"SHOP_SITE"})) { foreach (${"SHOP_SITE"} as $key => $val) { COption::SetOptionString("sale", "SHOP_SITE_".$val, $val); } } $p2p_del_exp_old = COption::GetOptionString("sale", "p2p_del_exp", 10); CAgent::RemoveAgent("Bitrix\\Sale\\Product2ProductTable::deleteOldProducts({$p2p_del_exp_old});", "sale"); COption::SetOptionString("sale", "p2p_status_list", serialize($SALE_P2P_STATUS_LIST)); if(intval($p2p_del_period) <= 0) $p2p_del_period = 10; COption::SetOptionString("sale", "p2p_del_period", $p2p_del_period); if(intval($p2p_del_exp) <= 0) $p2p_del_exp = 10; COption::SetOptionString("sale", "p2p_del_exp", $p2p_del_exp); CAgent::AddAgent("Bitrix\\Sale\\Product2ProductTable::deleteOldProducts({$p2p_del_exp});", "sale", "N", 24 * 3600 * $p2p_del_period, "", "Y"); foreach ($siteList as &$oneSite) { $valCurrency = trim(${"CURRENCY_".$oneSite['ID']}); if ($valCurrency == '') $valCurrency = false; $arFields = array( 'LID' => $oneSite['ID'], 'CURRENCY' => $valCurrency ); if ($arRes = CSaleLang::GetByID($oneSite['ID'])) { if ($valCurrency!==false) { CSaleLang::Update($oneSite['ID'], $arFields); } else { CSaleLang::Delete($oneSite['ID']); } } else { if ($valCurrency!==false) { CSaleLang::Add($arFields); } } CSaleGroupAccessToSite::DeleteBySite($oneSite['ID']); if (isset(${"SITE_USER_GROUPS_".$oneSite['ID']}) && is_array(${"SITE_USER_GROUPS_".$oneSite['ID']})) { for ($i = 0, $intCount = count(${"SITE_USER_GROUPS_".$oneSite['ID']}); $i < $intCount; $i++) { $groupID = intval(${"SITE_USER_GROUPS_".$oneSite['ID']}[$i]); if ($groupID > 0) { CSaleGroupAccessToSite::Add( array( "SITE_ID" => $oneSite['ID'], "GROUP_ID" => $groupID ) ); } } } } if (isset($_POST['product_reserve_condition'])) { $productReserveCondition = (string)$_POST['product_reserve_condition']; if (in_array($productReserveCondition, Sale\Configuration::getReservationConditionList(false))) Option::set('sale', 'product_reserve_condition', $productReserveCondition, ''); unset($productReserveCondition); } if (isset($_POST['product_reserve_clear_period'])) { $clearPeriod = (int)$_POST['product_reserve_clear_period']; if ($clearPeriod >= 0) Option::set('sale', 'product_reserve_clear_period', $clearPeriod, ''); unset($clearPeriod); } if (isset($_POST['use_sale_discount_only'])) { $useSaleDiscountOnly = (string)$_POST['use_sale_discount_only']; if ($useSaleDiscountOnly == 'Y' || $useSaleDiscountOnly == 'N') Option::set('sale', 'use_sale_discount_only', $useSaleDiscountOnly, ''); unset($useSaleDiscountOnly); } if (isset($_POST['get_discount_percent_from_base_price'])) { $discountPercent = (string)$_REQUEST['get_discount_percent_from_base_price']; if ($discountPercent == 'Y' || $discountPercent == 'N') Option::set('sale', 'get_discount_percent_from_base_price', $discountPercent, ''); unset($discountPercent); } $useSaleDiscountOnly = (string)Option::get('sale', 'use_sale_discount_only'); if ($useSaleDiscountOnly == 'N') { if (isset($_POST['discount_apply_mode'])) { $discountModeApply = (int)$_POST['discount_apply_mode']; $modeList = Sale\Discount::getApplyModeList(false); if (in_array($discountModeApply, $modeList)) Option::set('sale', 'discount_apply_mode', $discountModeApply, ''); unset($modeList, $discountModeApply); } } unset($useSaleDiscountOnly); ob_start(); require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/admin/group_rights.php"); ob_end_clean(); } } $arStatuses = array("" => GetMessage("SMO_STATUS")); $dbStatus = CSaleStatus::GetList(Array("SORT" => "ASC"), Array("LID" => LANGUAGE_ID), false, false, Array("ID", "NAME", "SORT")); while ($arStatus = $dbStatus->GetNext()) { $arStatuses[$arStatus["ID"]] = "[".$arStatus["ID"]."] ".$arStatus["NAME"]; } if($strWarning != '') CAdminMessage::ShowMessage($strWarning); elseif ($bWasUpdated) { if(strlen($Update)>0 && strlen($_REQUEST["back_url_settings"])>0) LocalRedirect($_REQUEST["back_url_settings"]); else LocalRedirect($APPLICATION->GetCurPage()."?mid=".$module_id."&lang=".LANGUAGE_ID."&back_url_settings=".urlencode($_REQUEST["back_url_settings"])."&".$tabControl->ActiveTabParam()); } $currentSettings = array(); $currentSettings['use_sale_discount_only'] = Option::get('sale', 'use_sale_discount_only'); $currentSettings['get_discount_percent_from_base_price'] = Option::get('sale', 'get_discount_percent_from_base_price'); $currentSettings['discount_apply_mode'] = (int)Option::get('sale', 'discount_apply_mode'); $currentSettings['product_reserve_condition'] = (string)Option::get('sale', 'product_reserve_condition'); $currentSettings['product_reserve_clear_period'] = (int)Option::get('sale', 'product_reserve_clear_period'); $tabControl->Begin(); ?>