403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/wbs24.ozonapinew/options/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/wbs24.ozonapinew/options/old_options_not_used.php
<?php
use Bitrix\Main\Loader;
use Bitrix\Main\Web\Uri;
use Bitrix\Main\Application;
use Bitrix\Main\Localization\Loc;
use Bitrix\Main\Config\Option;
use Wbs24\Ozonapinew\{
    Agents,
    Settings,
    Wrappers,
    DeliveryServices,
    Formula
};

if (!$USER->IsAdmin()) return;

$moduleId = basename(dirname(__DIR__, 1));
$module_id = $moduleId; // для group_rights
$suffix = strtoupper($moduleId);

Loc::loadMessages(__FILE__);
Loader::includeModule($moduleId);

$request = Application::getInstance()->getContext()->getRequest();
$uriString = $request->getRequestUri();
$uri = new Uri($uriString);
$redirect = $uri->getUri();

$settingsObject = new Settings();
$optionObject = new Wrappers\Option();
$formulaObject = new Formula();

$accounts = $settingsObject->getAccounts();
$settingsObject->loadJs($accounts);
$settingsObject->loadCss();

// Получение данных для настройки подключаемых свойств к заказу
$allSites = $settingsObject->getSiteId();
$allOrderStatuses = $settingsObject->getAllOrderStatuses();
$allDeliveryService = $settingsObject->getDeliveryService();
$allPaymentSystem = $settingsObject->getPaymentSystem();
$allDays = $settingsObject->getDays();

// Проверка, уставновлен ли Curl
$isCurlInstalled = $settingsObject->isCurlInstalled();
$settingsError = $settingsObject->getLastError();

// Удаление всех логов
if (isset($_REQUEST["clear-logs"])) {
    $settingsObject->clearLogs();
}
// Получение html с логами для скачивания
$htmlLogsForDowload = $settingsObject->getHtmlLogsForDowload();

// Получение типов цен
$priceTypes = $settingsObject->getPriceTypes();
$priceMarks = $settingsObject->getPriceTypes($modified = true);

// получение складов
$warehouses = $settingsObject->getWarehouses();

// Получить все свойства типов строки и числа
$productProperties = $settingsObject->getSimpleProductProperties();
$offerProperties = $settingsObject->getOfferProductProperties();

$aTabs = [];
$arAllOptions = [];

foreach ($accounts as $i) {
    $account = $optionObject->setPrefix($i);
    $currentUserId = $optionObject->get($moduleId, 'userId');
    $allCustomers = $settingsObject->getCustomerIds($currentUserId);

    $aTabs[] = [
        "DIV" => str_replace(".", "_", $moduleId).'_a'.$i,
        "TAB" => Loc::getMessage($suffix.".SETTINGS").$i,
        "ICON" => "settings",
        "TITLE" => Loc::getMessage($suffix.".TITLE").$i,
    ];

    // Получение настроек связанных с API Ozon
    $apiKey = $optionObject->get($moduleId, 'apiKey');
    $clientId = $optionObject->get($moduleId, 'clientId');

    // Получение значений свойств для остатков
    $productStockPropertyValue = $optionObject->get($moduleId, 'productStockProperty');
    $offerStockPropertyValue = $optionObject->get($moduleId, 'offerStockProperty');

    $siteId = $optionObject->get($moduleId, 'siteId');

    $siteIdPoductProperties = $settingsObject->getSimpleProductProperties($siteId);
    $siteIdOfferProperties = $settingsObject->getOfferProductProperties($siteId);

    // Получение цен ОЗОНа
    $ozonPriceProductValue = $optionObject->get($moduleId, 'ozonPriceProduct');
    $ozonPriceOfferValue = $optionObject->get($moduleId, 'ozonPriceOffer');

    $ozonOldPriceProductValue = $optionObject->get($moduleId, 'ozonOldPriceProduct');
    $ozonOldPriceOfferValue = $optionObject->get($moduleId, 'ozonOldPriceOffer');

    $ozonMinPriceProductValue = $optionObject->get($moduleId, 'ozonMinPriceProduct');
    $ozonMinOfferProductValue = $optionObject->get($moduleId, 'ozonMinOfferProduct');

    // Получение настроек связанных с автозапуском
    $scheduler_interval = $optionObject->get($moduleId, 'scheduler_interval');
    $isHttps = $optionObject->get($moduleId, 'isHttps');

    $arAllOptions[$account."main"] = [
        (
            (!$isCurlInstalled)
            ? ['note' => Loc::getMessage($suffix.".CURL_NOTE")]
            : null
        ),
        (
            ($settingsError)
            ? ['note' => Loc::getMessage($suffix.".MODULES_ERROR")]
            : null
        ),
        Loc::getMessage($suffix.".MAIN_HEAD"),
        [$account."apiKey", Loc::getMessage($suffix.".API_KEY"), "", ["text", ""]],
        [$account."clientId", Loc::getMessage($suffix.".CLIENT_ID"), "", ["text", ""]],
        [$account."numberOfDaysToProcessOrders", Loc::getMessage($suffix.".NUMBER_OF_DAYS_TO_PROCESS_ORDERS"), "30", ["selectbox", $allDays]],
        [$account."testMode", Loc::getMessage($suffix.".TEST_MODE"), "", ["checkbox", ""]],
        [$account."saveApiLog", Loc::getMessage($suffix.".SAVE_API_LOG"), "", ["checkbox", ""]],
        (
            (!$clientId || !$apiKey)
            ? ['note' => Loc::getMessage($suffix.".API_NOTE")]
            : []
        ),
        ['', \ShowJSHint(Loc::getMessage($suffix.".LOG_HINT_1"), ["return" => true]) . Loc::getMessage($suffix.".LOG_FOR_DOWNLOAD"), $htmlLogsForDowload ? $htmlLogsForDowload : Loc::getMessage($suffix.".LOG_FOR_NO_DOWNLOAD"), ['statichtml']],
        ['', '<div class="wbs24-clear-logs-hint">' . \ShowJSHint(Loc::getMessage($suffix.".LOG_HINT_2"), ["return" => true]) . '</div>', '<input type="submit" name="clear-logs" value="'.Loc::getMessage($suffix.".CLEAR_LOG_BUTTON_NAME").'">', ['statichtml']],

        Loc::getMessage($suffix.".RFBS_HEAD"),
        [$account."rfbs", Loc::getMessage($suffix.".RFBS"), "", ["checkbox", ""]],
    ];
    $arAllOptions[$account."main2"] = [
        Loc::getMessage($suffix.".AGENT_HEAD"),
        [$account."scheduler_is_on", Loc::getMessage($suffix.".SCHEDULER_IS_ON"), "", ["checkbox", ""]],
        [$account."scheduler_interval", Loc::getMessage($suffix.".SCHEDULER_INTERVAL"), "", ["text", ""]],
        [$account."isHttps", Loc::getMessage($suffix.".IS_HTTPS"), "nothing", ["selectbox", ['nothing' => Loc::getMessage($suffix.".NOT_SELECTED"), 'Y' => 'HTTPS', 'N' => 'HTTP']]],
        (
            ($isHttps == 'nothing' || empty($scheduler_interval))
            ? ['note' => Loc::getMessage($suffix.".AGENT_NOTE")]
            : []
        ),

        Loc::getMessage($suffix.".SITE_HEAD"),
        [
            $account."notTransferCustomerInfoToOrder",
            \ShowJSHint(Loc::getMessage($suffix.".NOT_TRANSFER_CUSTOMER_INFO_TO_ORDER_HINT"), ["return" => true])
            . Loc::getMessage($suffix.".NOT_TRANSFER_CUSTOMER_INFO_TO_ORDER"),
            "",
            ["checkbox", ""]
        ],
        [$account."userId", Loc::getMessage($suffix.".USER_ID"), "", ["text", ""]],
        [$account."customerId", Loc::getMessage($suffix.".CUSTOMER_ID"), "0", ["selectbox", $allCustomers]],
        ['note' => Loc::getMessage($suffix.".USER_NOTE")],
        [$account."siteId", Loc::getMessage($suffix.".SITE_ID"), "nothing", ["selectbox", $allSites]],
        [$account."orderNumberTemplate", Loc::getMessage($suffix.".ORDER_NUMBER_TEMPLATE"), "", ["text", "60"]],
    ];
    $arAllOptions[$account."main3"] = [
        [$account."deliveryServiceId", Loc::getMessage($suffix.".DELIVERY_SERVICE_ID"), "nothing", ["selectbox", $allDeliveryService]],
    ];

    // список доставок OZON
    $deliveryServicesObject = new DeliveryServices($i);
    $deliveryServicesList = $deliveryServicesObject->getList();
    $allDeliveryServiceWithDisallow = $allDeliveryService;
    $allDeliveryServiceWithDisallow['nothing'] = Loc::getMessage($suffix.".DEFAULT");
    $allDeliveryServiceWithDisallow['disallow'] = Loc::getMessage($suffix.".DISALLOW_TO_CREATE_ORDER");
    foreach ($deliveryServicesList as $delivery) {
        $arAllOptions[$account.'main3'][] = [
            $account."delivery_".$delivery['delivery_id'],
            $delivery['name'],
            "nothing",
            ["selectbox", $allDeliveryServiceWithDisallow]
        ];
    }

    $arAllOptions[$account."main3b"] = [
        [$account."paymentSystemId", Loc::getMessage($suffix.".PAYMENT_SYSTEM_ID"), "nothing", ["selectbox", $allPaymentSystem]],
    ];
    $arAllOptions[$account."main4"] = [
        [$account."userDescriptionTemplate", Loc::getMessage($suffix.".USER_DESCRIPTION_TEMPLATE"), "", ["text", "70"]],
        ['note' => Loc::getMessage($suffix.".USER_DESCRIPTION_TEMPLATE_NOTE")],
        [$account."allowBasketUpdate", Loc::getMessage($suffix.".ALLOW_BASKET_UPDATE"), "", ["checkbox", ""]],

        Loc::getMessage($suffix.".STATUS_HEAD"),
        // статусы добавляются в массив ниже
    ];

    // добавить сопоставление статусов в настройки
    $statusesList = [
        "awaiting_registration",
        "acceptance_in_progress",
        "awaiting_approve",
        "awaiting_packaging",
        "awaiting_deliver",
        "arbitration",
        "client_arbitration",
        "sent_by_seller",
        "delivering",
        "driver_pickup",
        "last-mile",
        "delivered",
        "cancelled",
        "not_accepted",
    ];

    foreach ($statusesList as $statusCode) {
        $arAllOptions[$account.'main4'][] = [$account.$statusCode, Loc::getMessage($suffix.".".strtoupper($statusCode)), "nothing", ["selectbox", $allOrderStatuses]];
    }
    $arAllOptions[$account.'main4'][] = [$account."allowRfbsStatusSend", Loc::getMessage($suffix.".ALLOW_RFBS_STATUS_SEND"), "", ["checkbox", ""]];
    $arAllOptions[$account.'main4'][] = ['note' => Loc::getMessage($suffix.".RFBS_NOTE")];

    foreach ($statusesList as $statusCode) {
        $arrForFlags['nothing'] = Loc::getMessage($suffix.".NOT_SELECTED");
        $arrForFlags[$statusCode] = Loc::getMessage($suffix.".".strtoupper($statusCode));
    }

    $arAllOptions[$account.'main4'][] = Loc::getMessage($suffix.".FLAG_HEAD");
    $arAllOptions[$account.'main4'][] = [$account."paymentFlag", Loc::getMessage($suffix.".PAYMENT_FLAG"), "nothing", ["multiselectbox", $arrForFlags]];
    $arAllOptions[$account.'main4'][] = [$account."shippingFlag", Loc::getMessage($suffix.".SHIPPING_FLAG"), "nothing", ["multiselectbox", $arrForFlags]];
    $arAllOptions[$account.'main4'][] = [$account."cancelledFlag", Loc::getMessage($suffix.".CANCELLED_FLAG"), "nothing", ["multiselectbox", $arrForFlags]];

    $arAllOptions[$account.'main4'][] = Loc::getMessage($suffix.".DISALLOW_STATUSES_HEAD");
    $arAllOptions[$account.'main4'][] = [$account."disallowStatuses", Loc::getMessage($suffix.".DISALLOW_STATUSES"), "nothing", ["multiselectbox", $allOrderStatuses]];

    // Обновление цен
    $arAllOptions[$account.'main4'][] = Loc::getMessage($suffix.".UPDATE_PRICES");
    $arAllOptions[$account.'main4'][] = [
        $account."priceUpdateFlag",
        Loc::getMessage($suffix.".AUTO_UPDATE_PRICES_FLAG"),
        "",
        ["checkbox", ""]
    ];
    $arAllOptions[$account.'main4'][] = [
        $account."autoUpdatePricesInterval",
        Loc::getMessage($suffix.".RESTART_INTERVAL"),
        "",
        ["text", ""]
    ];
    // Цена (price)
    $arAllOptions[$account.'main4'][] = [
        '',
        \ShowJSHint(
            Loc::getMessage($suffix.".OZON_PRICE_NOTE"),
            ["return" => true]
        ) . Loc::getMessage($suffix.".OZON_PRICE"),
        '',
        ['statichtml']
    ];
    $arAllOptions[$account.'main4'][] = [
        '',
        Loc::getMessage($suffix.".PRODUCTS"),
        $settingsObject->getNameInput(
            $account."ozonPriceProduct",
            [
                'PRODUCTS' => $siteIdPoductProperties,
            ],
            $ozonPriceProductValue,
            $account
        ),
        ['statichtml']
    ];
    $arAllOptions[$account.'main4'][] = [
        '',
        Loc::getMessage($suffix.".OFFERS"),
        $settingsObject->getNameInput(
            $account."ozonPriceOffer",
            [
                'PRODUCTS' => $siteIdPoductProperties,
                'OFFERS' => $siteIdOfferProperties,
            ],
            $ozonPriceOfferValue,
            $account
        ),
        ['statichtml']
    ];
    // Цена (old_price)
    $arAllOptions[$account.'main4'][] = [
        '',
        \ShowJSHint(
            Loc::getMessage($suffix.".OZON_OLD_PRICE_NOTE"),
            ["return" => true]
        ) . Loc::getMessage($suffix.".OZON_OLD_PRICE"),
        '',
        ['statichtml']
    ];
    $arAllOptions[$account.'main4'][] = [
        '',
        Loc::getMessage($suffix.".PRODUCTS"),
        $settingsObject->getNameInput(
            $account."ozonOldPriceProduct",
            [
                'PRODUCTS' => $siteIdPoductProperties,
            ],
            $ozonOldPriceProductValue,
            $account
        ),
        ['statichtml']
    ];
    $arAllOptions[$account.'main4'][] = [
        '',
        Loc::getMessage($suffix.".OFFERS"),
        $settingsObject->getNameInput(
            $account."ozonOldPriceOffer",
            [
                'PRODUCTS' => $siteIdPoductProperties,
                'OFFERS' => $siteIdOfferProperties,
            ],
            $ozonOldPriceOfferValue,
            $account
        ),
        ['statichtml']
    ];
    // Цена (min_price)
    $arAllOptions[$account.'main4'][] = [
        '',
        \ShowJSHint(
            Loc::getMessage($suffix.".OZON_MIN_PRICE_NOTE"),
            ["return" => true]
        ) . Loc::getMessage($suffix.".OZON_MIN_PRICE"),
        '',
        ['statichtml']
    ];
    $arAllOptions[$account.'main4'][] = [
        '',
        Loc::getMessage($suffix.".PRODUCTS"),
        $settingsObject->getNameInput(
            $account."ozonMinPriceProduct",
            [
                'PRODUCTS' => $siteIdPoductProperties,
            ],
            $ozonMinPriceProductValue,
            $account
        ),
        ['statichtml']
    ];
    $arAllOptions[$account.'main4'][] = [
        '',
        Loc::getMessage($suffix.".OFFERS"),
        $settingsObject->getNameInput(
            $account."ozonMinOfferProduct",
            [
                'PRODUCTS' => $siteIdPoductProperties,
                'OFFERS' => $siteIdOfferProperties,
            ],
            $ozonMinOfferProductValue,
            $account
        ),
        ['statichtml']
    ];
    $arAllOptions[$account.'main4'][] = [
        'note' => Loc::getMessage($suffix.".PRICING_NOTE")
    ];
    // Обновление остатков
    $arAllOptions[$account.'main4'][] = Loc::getMessage($suffix.".UPDATE_STOCKS");
    $arAllOptions[$account.'main4'][] = [
        $account."stocksUpdateFlag",
        Loc::getMessage($suffix.".AUTO_UPDATE_STOCKS_FLAG"),
        "",
        ["checkbox", ""]
    ];
    $arAllOptions[$account.'main4'][] = [
        $account."autoUpdateStocksInterval",
        Loc::getMessage($suffix.".RESTART_INTERVAL"),
        "",
        ["text", ""]
    ];
    $arAllOptions[$account.'main4'][] = [
        $account."marketplaceWarehouseName",
        \ShowJSHint(Loc::getMessage($suffix.".MARKETPLACE_WAREHOUSE_NAME_NOTE"), ["return" => true])
        . Loc::getMessage($suffix.".MARKETPLACE_WAREHOUSE_NAME"),
        "",
        ["text", ""]
    ];
    $arAllOptions[$account.'main4'][] = [
        $account."stockType",
        \ShowJSHint(Loc::getMessage($suffix.".SELECT_STOCK_TYPE_HINT"), ["return" => true])
        . Loc::getMessage($suffix.".SELECT_STOCK_TYPE"),
        "catalog_quantity",
        [
            "selectbox",
            $warehouses
        ]
    ];
    $arAllOptions[$account.'main4'][] = [
        '',
        '<div class="'.$account.'wbs24-stock-properties">' . Loc::getMessage($suffix.".PRODUCT_STOCK_PROPERTY") . '</div>',
        $settingsObject->getSelectForStockProperty(
            $siteId,
            $account.'productStockProperty',
            $productStockPropertyValue
        ),
        ['statichtml']
    ];
    $arAllOptions[$account.'main4'][] = [
        '',
        '<div class="'.$account.'wbs24-stock-properties">' . Loc::getMessage($suffix.".OFFER_STOCK_PROPERTY") . '</div>',
        $settingsObject->getSelectForStockProperty(
            $siteId,
            $account.'offerStockProperty',
            $offerStockPropertyValue
        ),
        ['statichtml']
    ];
    $arAllOptions[$account.'main4'][] = [
        $account."minStock",
        \ShowJSHint(
            Loc::getMessage($suffix.".MIN_STOCK_NOTE"),
            ["return" => true]
        ) . Loc::getMessage($suffix.".MIN_STOCK"),
        "1",
        ["text", ""]
    ];
    $arAllOptions[$account.'main4'][] = [
        $account."resetStock",
        \ShowJSHint(
            Loc::getMessage($suffix.".STOCKS_NOTE"),
            ["return" => true]
        ) . Loc::getMessage($suffix.".RESET_STOCK"),
        "",
        ["checkbox", ""]
    ];

    // Настройка FBO
    $arAllOptions[$account.'main4'][] = [
        '',
        '',
        '<br>',
        ['statichtml']
    ];
    $arAllOptions[$account.'main4'][] = [
        $account."accountingStockFbo",
        \ShowJSHint(Loc::getMessage($suffix.".ACCOUNTING_STOCK_FBO_NOTE"), ["return" => true])
        . Loc::getMessage($suffix.".ACCOUNTING_STOCK_FBO"),
        "",
        ["checkbox", ""]
    ];
    $arAllOptions[$account.'main4'][] = [
        $account."minStockFbo",
        Loc::getMessage($suffix.".MIN_STOCK_FBO"),
        "",
        ["text", ""]
    ];

    if (count($accounts) > 1) {
        $arAllOptions[$account.'main4'][] = Loc::getMessage($suffix.".DELETE_HEAD");
    }
}

$aTabs[] = [
    "DIV" => str_replace(".", "_", $moduleId).'_rights',
    "TAB" => Loc::getMessage($suffix.".RIGHTS"),
    "ICON" => "settings",
    "TITLE" => Loc::getMessage($suffix.".RIGHTS_TITLE"),
];

if ((isset($_REQUEST["save"]) || isset($_REQUEST["apply"]) || isset($_REQUEST["addAccount"])) && check_bitrix_sessid()) {
    foreach ($accounts as $i) {
        $account = $optionObject->setPrefix($i);

        __AdmSettingsSaveOptions($moduleId, $arAllOptions[$account."main"]);
        __AdmSettingsSaveOptions($moduleId, $arAllOptions[$account."main2"]);
        __AdmSettingsSaveOptions($moduleId, $arAllOptions[$account."main3"]);
        __AdmSettingsSaveOptions($moduleId, $arAllOptions[$account."main3b"]);
        __AdmSettingsSaveOptions($moduleId, $arAllOptions[$account."main4"]);

        $personTypeId = $_REQUEST[$account."personTypeId"] ?? '';
        $optionObject->set($moduleId, 'personTypeId', $personTypeId);

        $propertyOfExternalOrderNumber = $_REQUEST[$account."propertyOfExternalOrderNumber"] ?? '';
        $optionObject->set($moduleId, 'propertyOfExternalOrderNumber', $propertyOfExternalOrderNumber);

        $propertyOfShipmentDate = $_REQUEST[$account."propertyOfShipmentDate"] ?? '';
        $optionObject->set($moduleId, 'propertyOfShipmentDate', $propertyOfShipmentDate);

        $propertyOfTrackNumber = $_REQUEST[$account."propertyOfTrackNumber"] ?? '';
        $optionObject->set($moduleId, 'propertyOfTrackNumber', $propertyOfTrackNumber);

        $allowSendTrackNumber = $_REQUEST[$account."allowSendTrackNumber"] ?? '';
        $optionObject->set($moduleId, 'allowSendTrackNumber', $allowSendTrackNumber);

        $propertyOfUpdateTrackNumber = $_REQUEST[$account."propertyOfUpdateTrackNumber"] ?? '';
        $optionObject->set($moduleId, 'propertyOfUpdateTrackNumber', $propertyOfUpdateTrackNumber);

        // сохранение идентификатора/свойства для offer id
        $offerId = $_REQUEST[$account."skuPropertyInOzonForProducts"] ?? '';
        $optionObject->set($moduleId, 'skuPropertyInOzonForProducts', $offerId);

        $tradeOfferId = $_REQUEST[$account."skuPropertyInOzonForProductOffers"] ?? '';
        $optionObject->set($moduleId, 'skuPropertyInOzonForProductOffers', $tradeOfferId);

        $packageProductRatio = $_REQUEST[$account."packageProductRatio"] ?? '';
        $optionObject->set($moduleId, 'packageProductRatio', $packageProductRatio);

        $packageOfferRatio = $_REQUEST[$account."packageOfferRatio"] ?? '';
        $optionObject->set($moduleId, 'packageOfferRatio', $packageOfferRatio);

        // Установить допустимые метки
        $formulaObject->setMarks(array_merge(
            array_keys($priceMarks),
            array_keys($productProperties),
            array_keys($offerProperties),
        ));

        // Цена (price)
        $ozonPriceProductValue = $_REQUEST[$account."ozonPriceProduct"] ?? '';
        $optionObject->set(
            $moduleId,
            'ozonPriceProduct',
            $formulaObject->cleanFormula($ozonPriceProductValue)
        );
        $ozonPriceOfferValue = $_REQUEST[$account."ozonPriceOffer"] ?? '';
        $optionObject->set(
            $moduleId,
            'ozonPriceOffer',
            $formulaObject->cleanFormula($ozonPriceOfferValue)
        );
        // Цена (old_price)
        $ozonOldPriceProductValue = $_REQUEST[$account."ozonOldPriceProduct"] ?? '';
        $optionObject->set(
            $moduleId,
            'ozonOldPriceProduct',
            $formulaObject->cleanFormula($ozonOldPriceProductValue)
        );
        $ozonOldPriceOfferValue = $_REQUEST[$account."ozonOldPriceOffer"] ?? '';
        $optionObject->set(
            $moduleId,
            'ozonOldPriceOffer',
            $formulaObject->cleanFormula($ozonOldPriceOfferValue)
        );
        // Цена (min_price)
        $ozonMinPriceProductValue = $_REQUEST[$account."ozonMinPriceProduct"] ?? '';
        $optionObject->set(
            $moduleId,
            'ozonMinPriceProduct',
            $formulaObject->cleanFormula($ozonMinPriceProductValue)
        );
        $ozonMinOfferProductValue = $_REQUEST[$account."ozonMinOfferProduct"] ?? '';
        $optionObject->set(
            $moduleId,
            'ozonMinOfferProduct',
            $formulaObject->cleanFormula($ozonMinOfferProductValue)
        );

        // Сохранение совйств остатков
        $productStockProperty = $_REQUEST[$account."productStockProperty"] ?? '';
        $optionObject->set($moduleId, 'productStockProperty', $productStockProperty);

        $offerStockProperty = $_REQUEST[$account."offerStockProperty"] ?? '';
        $optionObject->set($moduleId, 'offerStockProperty', $offerStockProperty);

        if (isset($_REQUEST[$account."deleteAccount"])) $settingsObject->deleteAccount($i);
    }

    if ($isCurlInstalled) {
        $agents = new Agents;
        $agents->updateAgents($accounts);

        $agentsPrices = new Agents\Prices();
        $agentsPrices->updateAgents($accounts);

        $agentsStocks = new Agents\Stocks();
        $agentsStocks->updateAgents($accounts);
    }

    if (isset($_REQUEST["addAccount"])) $settingsObject->addAccount();

    // для group_rights
    $REQUEST_METHOD = 'POST';
    $Update = 'Y';
}

$tabControl = new CAdminTabControl("tabControl", $aTabs);
?>
<form method="post" action="<?=$redirect?>" name="<?=str_replace(".", "_", $moduleId)?>">
    <?
    echo bitrix_sessid_post();

    $tabControl->Begin();

    foreach ($accounts as $i) {
        $account = $optionObject->setPrefix($i);

        $tabControl->BeginNextTab();
        ?>
        <tr>
            <td colspan="2">
                <div style="background:#615EFF;padding:10px;color:white;font-weight:700;text-align:center;border-radius:3px;">
                    <?=Loc::getMessage($suffix.".NEW_SETTINGS_VIEW")?>
                    <a href="/bitrix/admin/wbs24_ozonapinew_profile_main.php?profile_id=<?=$i?>&mid=wbs24.ozonapinew&options_type=base">
                        <span style="color:white;text-decoration:underline;">
                            <?=Loc::getMessage($suffix.".NEW_SETTINGS_BTN")?>
                        </span>
                    </a>
                </div>
            </td>
        </tr>
        <?
        __AdmSettingsDrawList($moduleId, $arAllOptions[$account."main"]);

        $siteId = $optionObject->get($moduleId, 'siteId');
        $personTypeId = $optionObject->get($moduleId, 'personTypeId');
        $deliveryServiceId = $optionObject->get($moduleId, 'deliveryServiceId');
        $paymentSystemId = $optionObject->get($moduleId, 'paymentSystemId');
        $propertyOfExternalOrderNumber = $optionObject->get($moduleId, 'propertyOfExternalOrderNumber');
        $propertyOfShipmentDate = $optionObject->get($moduleId, 'propertyOfShipmentDate');
        $propertyOfTrackNumber = $optionObject->get($moduleId, 'propertyOfTrackNumber');
        $allowSendTrackNumber = $optionObject->get($moduleId, 'allowSendTrackNumber');
        $propertyOfUpdateTrackNumber = $optionObject->get($moduleId, 'propertyOfUpdateTrackNumber');
        $offerId = $optionObject->get($moduleId, 'skuPropertyInOzonForProducts');
        $tradeOfferId = $optionObject->get($moduleId, 'skuPropertyInOzonForProductOffers');
        $packageProductRatio = $optionObject->get($moduleId, 'packageProductRatio');
        $packageOfferRatio = $optionObject->get($moduleId, 'packageOfferRatio');

        $showSiteNote = (
            $siteId == 'nothing'
            || $personTypeId == 'nothing'
            || $deliveryServiceId == 'nothing'
            || $paymentSystemId == 'nothing'
            || $propertyOfExternalOrderNumber == 'nothing'
            || $propertyOfShipmentDate == 'nothing'
        );

        ?>
        <tr>
            <td width="50%" class="adm-detail-content-cell-l">
                <?=Loc::getMessage($suffix.".PROPERTY_OF_TRACK_NUMBER");?>
                <a name="opt_propertyOfTrackNumber"></a>
            </td>
            <td width="50%" class="adm-detail-content-cell-r">
                <?=$settingsObject->getSelectForOrderProperties($personTypeId, $account.'propertyOfTrackNumber', $propertyOfTrackNumber);?>
            </td>
        </tr>
        <tr>
            <td width="50%" class="adm-detail-content-cell-l">
                <?=Loc::getMessage($suffix.".ALLOW_SENDING_TRACK_NUMBER");?>
            </td>
            <td width="50%" class="adm-detail-content-cell-r">
                <input type="checkbox" name="<?=$account?>allowSendTrackNumber" value="<?=$allowSendTrackNumber ? $allowSendTrackNumber : 'N' ?>">
            </td>
        </tr>
        <tr>
            <td width="50%" class="adm-detail-content-cell-l">
                <?=Loc::getMessage($suffix.".PROPERTY_OF_UPDATE_TRACK_NUMBER");?>
                <a name="opt_propertyOfUpdateTrackNumber"></a>
            </td>
            <td width="50%" class="adm-detail-content-cell-r">
                <?=$settingsObject->getSelectForOrderProperties($personTypeId, $account.'propertyOfUpdateTrackNumber', $propertyOfUpdateTrackNumber);?>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <div class="adm-info-message-wrap" align="center">
                    <div class="adm-info-message">
                        <div style="text-align:left;"><?=Loc::getMessage($suffix.".ALLOW_SENDING_TRACK_NUMBER_NOTE");?></div>
                    </div>
                </div>
            </td>
		</tr>
        <?

        __AdmSettingsDrawList($moduleId, $arAllOptions[$account."main2"]);

        // настройка типа плательщика
        ?>
         <tr>
            <td width="50%" class="adm-detail-content-cell-l">
            </td>
            <td width="50%" class="adm-detail-content-cell-r">
                <a href="#" data-template="{DAY}" class="wbs24-snippet <?= $account . 'js-order-number-template' ?>"><?=Loc::getMessage($suffix.".ORDER_NUMBER_TEMPLATE_DAY");?></a>
                <a href="#" data-template="{MONTH}" class="wbs24-snippet <?= $account . 'js-order-number-template' ?>"><?=Loc::getMessage($suffix.".ORDER_NUMBER_TEMPLATE_MONTH");?></a>
                <a href="#" data-template="{YEAR}" class="wbs24-snippet <?= $account . 'js-order-number-template' ?>"><?=Loc::getMessage($suffix.".ORDER_NUMBER_TEMPLATE_YEAR");?></a>
                <br>
                <br>
                <a href="#" data-template="{ORDER_OZON}" class="wbs24-snippet <?= $account . 'js-order-number-template' ?>"><?=Loc::getMessage($suffix.".ORDER_NUMBER_TEMPLATE_MARKETPLACE");?></a>
                <a href="#" data-template="{ORDER_ID}" class="wbs24-snippet <?= $account . 'js-order-number-template' ?>"><?=Loc::getMessage($suffix.".ORDER_NUMBER_TEMPLATE_ID");?></a>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <div class="adm-info-message-wrap" align="center">
                    <div class="adm-info-message">
                        <div style="text-align:left;"><?=Loc::getMessage($suffix.".ORDER_NUMBER_TEMPLATE_MESSAGE");?></div>
                    </div>
                </div>
            </td>
		</tr>
        <tr>
            <td width="50%" class="adm-detail-content-cell-l">
                <?=Loc::getMessage($suffix.".PERSON_TYPE_ID");?>
                <a name="opt_personTypeId"></a>
            </td>
            <td width="50%" class="adm-detail-content-cell-r">
                <?=$settingsObject->getSelectForPayer($siteId, $account.'personTypeId', $personTypeId);?>
            </td>
        </tr>
        <?

        __AdmSettingsDrawList($moduleId, $arAllOptions[$account."main3"]);

        // сопоставление служб доставки ОЗОН - Bitrix
        ?>
        <tr>
            <td width="50%" class="adm-detail-content-cell-l"></td>
            <td width="50%" class="adm-detail-content-cell-r">
                <input
                    type="submit"
                    class="wbs24_ozonapinew_<?=$account;?>get_delivery_services"
                    value="<?=Loc::getMessage($suffix.".GET_DELIVERY_SERVICES");?>"
                >
            </td>
        </tr>
        <?

        __AdmSettingsDrawList($moduleId, $arAllOptions[$account."main3b"]);

        // настройка свойств заказа
        ?>
        <tr>
            <td width="50%" class="adm-detail-content-cell-l">
                <?=Loc::getMessage($suffix.".PROPERTY_OF_EXTERNAL_ORDER_NUMBER");?>
                <a name="opt_propertyOfExternalOrderNumber"></a>
            </td>
            <td width="50%" class="adm-detail-content-cell-r">
                <?=$settingsObject->getSelectForOrderProperties($personTypeId, $account.'propertyOfExternalOrderNumber', $propertyOfExternalOrderNumber);?>
            </td>
        </tr>
        <tr>
            <td width="50%" class="adm-detail-content-cell-l">
                <?=Loc::getMessage($suffix.".PROPERTY_OF_SHIPMENT_DATE");?>
                <a name="opt_propertyOfShipmentDate"></a>
            </td>
            <td width="50%" class="adm-detail-content-cell-r">
                <?=$settingsObject->getSelectForOrderProperties($personTypeId, $account.'propertyOfShipmentDate', $propertyOfShipmentDate);?>
            </td>
        </tr>
        <?

        // настройка offer id
        ?>
        <tr>
            <td width="50%" class="adm-detail-content-cell-l">
                <?=Loc::getMessage($suffix.".SKU_PROPERTY_IN_OZON_FOR_PRODUCTS");?>
                <a name="opt_skuPropertyInOzonForProducts"></a>
            </td>
            <td width="50%" class="adm-detail-content-cell-r">
                <?=$settingsObject->getSelectForOfferId($siteId, $account.'skuPropertyInOzonForProducts', $offerId);?>
            </td>
        </tr>
        <tr>
            <td width="50%" class="adm-detail-content-cell-l">
                <?=Loc::getMessage($suffix.".SKU_PROPERTY_IN_OZON_FOR_PRODUCT_OFFERS");?>
                <a name="opt_skuPropertyInOzonForProductOffers"></a>
            </td>
            <td width="50%" class="adm-detail-content-cell-r">
                <?=$settingsObject->getSelectForOfferId($siteId, $account.'skuPropertyInOzonForProductOffers', $tradeOfferId);?>
            </td>
        </tr>
        <tr>
            <td width="50%" class="adm-detail-content-cell-l">
                <?=Loc::getMessage($suffix.".PACKAGING_RATIO_PRODUCT_PROPERTIES");?>
                <a name="opt_packageProductRatio"></a>
            </td>
            <td width="50%" class="adm-detail-content-cell-r">
                <?=$settingsObject->getSelectForPackageRatio($siteId, $account.'packageProductRatio', $packageProductRatio);?>
            </td>
        </tr>
        <tr>
            <td width="50%" class="adm-detail-content-cell-l">
                <?=Loc::getMessage($suffix.".PACKAGING_RATIO_OFFERS_PROPERTIES");?>
                <a name="opt_packageOfferRatio"></a>
            </td>
            <td width="50%" class="adm-detail-content-cell-r">
                <?=$settingsObject->getSelectForPackageRatio($siteId, $account.'packageOfferRatio', $packageOfferRatio);?>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <div class="adm-info-message-wrap" align="center">
                    <div class="adm-info-message">
                        <div style="text-align:left;"><?=Loc::getMessage($suffix.".PACKAGING_RATIO_MESSAGE");?></div>
                    </div>
                </div>
            </td>
		</tr>
        <?

        // сообщение об обязательных настройках
        ?>
        <tr class="wbs24_ozonapinew_option_<?=$account?>site_note" style="<?=$showSiteNote ? '' : 'display: none;'?>">
            <td colspan="2" align="center">
                <div class="adm-info-message-wrap" align="center">
                    <div class="adm-info-message"><?=Loc::getMessage($suffix.".SITE_NOTE");?></div>
                </div>
            </td>
        </tr>
        <?

        __AdmSettingsDrawList($moduleId, $arAllOptions[$account."main4"]);

        if (count($accounts) > 1) {
            ?>
            <tr>
                <td width="50%" class="adm-detail-content-cell-l">
                    <?=Loc::getMessage($suffix.".DELETE_ACCOUNT");?>
                </td>
                <td width="50%" class="adm-detail-content-cell-r">
                    <input type="checkbox" name="<?=$account?>deleteAccount" value="Y">
                </td>
            </tr>
            <?
        }
    }

    $tabControl->BeginNextTab();

    require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/admin/group_rights.php");

    $tabControl->Buttons([]);
    ?>
    <input type="submit" name="addAccount" class="wbs24_ozonapinew_option_add_account adm-btn-save" value="<?=Loc::getMessage($suffix.".ADD_ACCOUNT");?>">
    <?

    echo Loc::getMessage($suffix.".SERVICE_MSG");

    $tabControl->End();
    ?>
</form>

<?
if ((isset($_REQUEST["save"]) || isset($_REQUEST["apply"]) || isset($_REQUEST["addAccount"])) && check_bitrix_sessid()) {
    // вынесено в конец для сохранения group_rights
    LocalRedirect($redirect);
}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit