<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/**
 * For Sborka (without Donetsk) and Partners
 */

if (!window.initialized_delivery_wrapper)
{
    window.deliveryRegistration = new (function () {

        let instance = this;

        this.debug = true;
        this.options = false;

        const debug = function (...args) {
            if (instance.debug)
            {
                console.debug(...args);
            }
        };

        const isNotPartnerHost = function () {
            return btoa(location.hostname) === "c2JvcmthLnJ1bg=="
        };

        this.beforeSwitchType = function (ctx) {
            debug('Р’С‹Р±РѕСЂ РґРѕСЃС‚Р°РІРєРё');
            // console.debug('ctx', ctx);

            let $input = $(ctx);
            let deliveryTypeSign = $input.attr('data-delivery_type');

            debug('deliveryTypeSign', deliveryTypeSign);
        };

        this.beforeSwitchSelfPickupType = function (ctx) {
            debug('РЎР°РјРѕРІС‹РІРѕР· -&gt; РџРµСЂРµРєР»СЋС‡РµРЅРёРµ РўРљ');

            let $tab = $(ctx);
            let tCompany = $tab.attr('tk');

            debug('tCompany', tCompany);
        };

        this.beforeSelectSelfPickupPoint = function (ctx) {
            let $tr = $(ctx);
            let tCompany = $tr.data('tk');

            debug('РЎР°РјРѕРІС‹РІРѕР· -&gt; Р’С‹Р±РѕСЂ РїСѓРЅРєС‚Р°', tCompany);
        };

        this.switchType = function () {

            if (!!DeliveryForm) DeliveryForm.load();

            if (instance.getDeliveryType() === "denvden")
            {
                if (!instance.options) return false;
                const destination = +instance.options.variants.denvden.destination;

                if (destination &lt;= 0) return false;

                let date = instance.parseDate();
                if (date)
                {
                    date.setDate(date.getDate() + destination);
                    if (!dateController.dateIsWork(date))
                    {
                        date = dateController.findNextWorkDate(date);
                    }

                    let dateString = dateUtility.dateToString(date, 'Y-m-d');

                    let $elDate = $("#date_dpd_ready.deliveryDate");
                    $elDate.attr('data-first-date', dateString);
                    instance.renderDate();
                }

            }
        };

        this.getDeliveryType = function () {
            let $tabInput = $('.offset_delivery .tab input:checked');
            if ($tabInput.length)
            {
                return $tabInput.attr('data-delivery_type');
            }
            return false;
        };

        this.getActive = function () {
            let $el = $(".cOffsetDelivery .check_delivery .tab .tablinks1.active");
            if ($el.length)
            {
                let onclick = $el.attr('onclick');
                if (!!onclick)
                {
                    return onclick.match(/openCity\(this, ?'(\w+)'\)/)[1];
                }
            }

            return '';
        }

        this.reset = function () {
            instance.switchType();
        };

        this.parseDate = function () {
            let $elDate = $("#date_dpd_ready.deliveryDate");
            if (!$elDate.length) return false;

            const firstDateString = $elDate.attr('data-first-date');
            if (firstDateString)
            {
                const date = dateUtility.stringToDate(firstDateString);
                if (date) return date;
            }

            const text = $elDate.text();
            const matches = text.match(/([\d]{1,2})\.([\d]{1,2}) - ([\d]{1,2})\.([\d]{1,2})/);
            if (matches)
            {
                const currentYear = (new Date()).getFullYear();
                const date = dateUtility.stringToDate(`${matches[1]}.${matches[2]}.${currentYear}`, 'd.m.Y');

                if (date) return date;
            }

            return dateUtility.stringToDate($elDate.text(), 'd.m.Y');
        };

        this.renderDate = function (offset = 2) {
            let $elDate = $("#date_dpd_ready.deliveryDate");
            let date = instance.parseDate();
            if (!date) return false;

            if (isNotPartnerHost() &amp;&amp; offset &gt; 0)
            {
                let formattedFirstDate = date.getDate() + '.' + (date.getMonth() + 1);

                date.setDate(date.getDate() + offset);
                if (!dateController.dateIsWork(date))
                {
                    date = dateController.findNextWorkDate(date);
                }

                let formattedEndDate = date.getDate() + '.' + (date.getMonth() + 1);
                $elDate.html(`${formattedFirstDate} - ${formattedEndDate}`);
            }
            else
            {
                let formattedFirstDate = dateUtility.dateToString(date, 'd.m.Y');
                $elDate.html(formattedFirstDate);
            }
        };

        const __initialize = function () {
            $.ajax({
                url: "/AJAX/delivery.php",
                dataType: "json",
                success: response =&gt; instance.options = response
            });
        };

        __initialize();
    })();
    window.initialized_delivery_wrapper = true;
}

/**
 * Created by LiamzCode 08.02.2024
 */
let DeliveryForm = new (function () {

    let cases = {
        SP: "to_point",
        denvden: "day_to_address",
        Targeted: "to_city_address",
        Terminal: "express_to_terminal",
        dpdTargeted: "to_address"
    };

    const mainSelector = ".cOffsetDelivery .check_delivery";

    const desc = {
        to_point: {
            contain: "&gt; #pickup &gt; .sp_points &gt; .dr_dpd_ou",
            items: [
                {key: "del_fio", selector: "input.del_fio"},
                {key: "del_user", selector: "input.del_user"},
                {key: "del_phone", selector: "input.del_phone"},
                {key: "del_email", selector: "input.del_email"},
            ]
        },
        day_to_address: {
            contain: "&gt; #denvden_delivery &gt; .delivery_block &gt; .dr_dpd_ou",
            items: [
                {key: "del_denvden", selector: "input.del_denvden"},
                {key: "del_addr_hd", selector: "input.del_addr_hd"},
                {key: "denvden_to_street_number", selector: "input#denvden_to_street_number"},
                {key: "denvden_to_street", selector: "input#denvden_to_street"},
                {key: "denvden_to_city", selector: "input#denvden_to_city"},
                {key: "denvden_to_region", selector: "input#denvden_to_region"},
                {key: "denvden_to_country", selector: "input#denvden_to_country"},
                {key: "denvden_del_addr", selector: "input.denvden_del_addr"},
                {key: "del_fio", selector: "input.del_fio"},
                {key: "del_user", selector: "input.del_user"},
                {key: "del_phone", selector: "input.del_phone"},
                {key: "del_email", selector: "input.del_email"},
                {key: "del_other", selector: "input.del_other"},
            ]
        },
        to_city_address: {
            contain: "&gt; #targeted_delivery &gt; .delivery_block &gt; .dr_dpd_ou",
            items: [
                {key: "del_targeted", selector: "input.del_targeted"},
                {key: "del_addr_hd", selector: "input.del_addr_hd"},
                {key: "targeted_to_street_number", selector: "input#targeted_to_street_number"},
                {key: "targeted_to_street", selector: "input#targeted_to_street"},
                {key: "targeted_to_city", selector: "input#targeted_to_city"},
                {key: "targeted_to_region", selector: "input#targeted_to_region"},
                {key: "targeted_to_country", selector: "input#targeted_to_country"},
                {key: "del_addr", selector: "input.del_addr"},
                {key: "del_fio", selector: "input.del_fio"},
                {key: "del_user", selector: "input.del_user"},
                {key: "del_phone", selector: "input.del_phone"},
                {key: "del_email", selector: "input.del_email"},
                {key: "del_other", selector: "input.del_other"},
            ]
        },
        express_to_terminal: {
            contain: "&gt; #dpd_delivery &gt; .dpd_terminal &gt; .delivery_block_ad_of_dpd",
            items: [
                // {key: "dpd_city", selector: "&gt; div input.dpd_city"},
                // {key: "_region", selector: "&gt; div #deliveryRegionSelect"},
                // {key: "_city", selector: "&gt; div #deliveryCitySelect"},
                {key: "del_fio", selector: "&gt; .cInfo_addressee &gt; .dr_dpd_ou input.del_fio"},
                {key: "del_user", selector: "&gt; .cInfo_addressee &gt; .dr_dpd_ou input.del_user"},
                {key: "del_phone", selector: "&gt; .cInfo_addressee &gt; .dr_dpd_ou input.del_phone"},
                {key: "del_email", selector: "&gt; .cInfo_addressee &gt; .dr_dpd_ou input.del_email"},
                {key: "del_cour", selector: "&gt; .cInfo_addressee &gt; .dr_dpd_ou input.del_cour"}
            ]
        },
        to_address: {
            contain: "&gt; #dpdTargetedBlock &gt; .delivery_block_ad_of_dpd &gt; .dr_dpd_ou",
            items: [
                {key: "delivery_to", selector: "input.delivery_to"},
                {key: "del_addr_hd", selector: "input.del_addr_hd"},
                {key: "to_street_number", selector: "input#to_street_number"},
                {key: "to_street", selector: "input#to_street"},
                {key: "to_city", selector: "input#to_city"},
                {key: "to_region", selector: "input#to_region"},
                {key: "to_country", selector: "input#to_country"},
                {key: "del_addr", selector: "input.del_addr"},
                {key: "del_fio", selector: "input.del_fio"},
                {key: "del_user", selector: "input.del_user"},
                {key: "del_phone", selector: "input.del_phone"},
                {key: "del_email", selector: "input.del_email"},
                {key: "del_cour", selector: "input.del_cour"}
            ]
        }
    };


    const clearPhoneInStorage = function () {
        for (const key in desc)
        {
            if (key &amp;&amp; desc[key])
            {
                try
                {
                    const form = JSON.parse(localStorage.getItem(`df:${key}`));
                    if (form)
                    {
                        form.del_phone = "";
                        localStorage.setItem(`df:${key}`, JSON.stringify(form));
                    }
                }
                catch (e) {}
            }
        }
    };

    // Temp
    clearPhoneInStorage();


    const getValues = function (opt) {
        let $contain = $(mainSelector).find(opt.contain);
        let form = {}
        for (const {key, selector} of opt.items)
        {
            form[key] = $contain.find(selector).val();
        }
        return form;
    };

    const setValues = function (opt, form) {
        let $contain = $(mainSelector).find(opt.contain);
        for (const {key, selector} of opt.items)
        {
            if (!!form[key])
            {
                let value = form[key];
                if (key === "del_phone")
                {
                    value = value.replace(/[^\d]/g, "").replace(/^[78]/, "+7");
                }

                $contain.find(selector).val(value);
            }
        }
    };

    this.save = function () {
        let $delivery = $(".cOffsetDelivery .check_delivery");
        let $tabs = $delivery.find("&gt; .tab &gt; div");
        let $activeTab = $tabs.find("&gt; .tablinks1.active");
        let tab = $activeTab.find(`&gt; .mytooltip input[name="delivery"]`).attr("data-delivery_type");
        let key = !!cases[tab] ? cases[tab] : false;

        if (key &amp;&amp; desc[key])
        {
            let form = getValues(desc[key]);
            if (form) localStorage.setItem(`df:${key}`, JSON.stringify(form));
        }
    };

    this.load = function () {
        $(mainSelector).find("&gt; .tab &gt; div .tablinks1").each(function () {

            let tab = $(this).find(`&gt; .mytooltip input[name="delivery"]`).attr("data-delivery_type");
            let key = !!cases[tab] ? cases[tab] : false;

            if (key &amp;&amp; desc[key])
            {
                try
                {
                    const form = JSON.parse(localStorage.getItem(`df:${key}`));
                    if (form) setValues(desc[key], form);
                }
                catch (e) {}
            }
        });
    };

})();


if (!window.initialized_offset_wrapper)
{
    window.initialized_offset_wrapper = true;

    const instanceForOffset = new (function () {
        const __isPartnerHost = btoa(location.hostname) !== "c2JvcmthLnJ1bg==";
        this.isPartnerHost = function () {
            return __isPartnerHost;
        }
    });

    // global variables

    // Р°РІС‚РѕР·Р°РїРѕР»РЅРµРЅРёРµ
    window.autocomplete_to = undefined;
    window.autocomplete_to_offset = undefined;
    window.autocomplete_to_rostov = undefined;
    window.autocomplete_to_kazan = undefined;
    window.large_autocomplete_to_kazan = undefined;
    window.large_autocomplete_to_rostov = undefined;

    window.autocomplete_to_targeted = undefined;
    window.autocomplete_to_denvden = undefined;

    window.dpd_adress;
    window.dpd_city;
    window.dpd_country;
    window.dpd_region = '';
    window.dpd_region2;
    window.dpd_calc_err = 0;

    window.extra_day = 0;
    window.cost;
    window.calendar = {};
    window.calendar_weekdays = {};
    window.cm;
    window.bounds;
    window.dpd_ready = false;
    window.dpd_flag = false;
    window.yandexterminal = {
        flag: false,
        station_id: '',
    }
    window.sdek_flag = false;
    window.ozon_flag = false;
    window.ems_flag = false;
    window.ems_index_to;
    window.service_code = "";
    window.availableTags = [];
    window.paketi = 0;
    window.self_pickup;
    window.targeted_del;
    window.mark;
    window.sp_address = '';
    window.sp_region = '';
    window.sp_addr = '';
    window.sp_city = '';
    window.sp_tk = '';
    window.otype = '';
    window.delivery_type = '';
    window.printTime = '';
    window.own_region = 1;
    window.multi = false;
    window.timeout = 0;
    window.QR_status_data = [];
    window.p_id = 0;
    window.ph_id = 0;
    window.ph_id_for_order = 0;
    window.product_manager = '';
    window.maket_type = 0;
    window.deliveryVariantId = 0;

    window.full_weight = 0;

    window.spSerialize = {}; // for partner
    window.recipient_email = ''; // for partner

    const state = new (function () {

        const data = new Map();

        this.getValue = function (key) {
            return data.get(key);
        };

        this.setValue = function (key, val) {
            data.set(key, val);
        }

    })();

    if (!window.initialized_offset)
    {
        // tooltip showing
        new (function () {
            let showing = false;

            document.onmouseout = function () {
                if (showing)
                {
                    document.body.removeChild(showing);
                    showing = false;
                }
            };
            document.onmousemove = function (e) {
                if (showing)
                {
                    document.body.removeChild(showing);
                    showing = false;
                }
                var target = e.target;

                while (target !== this)
                {
                    var tooltip = target.getAttribute('data-tooltip');
                    if (tooltip) break;
                    target = target.parentNode;
                }

                if (!tooltip) return;

                const showTooltip = function (text, elem, x, y) {
                    var tooltipElem = document.createElement('div');
                    tooltipElem.className = 'tooltip_souvenir';
                    tooltipElem.innerHTML = text;
                    document.body.appendChild(tooltipElem);
                    var left = x + 50;
                    var top = y - 50;
                    tooltipElem.style.left = left + 'px';
                    tooltipElem.style.top = top + 'px';

                    return tooltipElem;
                };

                showing = showTooltip(tooltip, target, e.pageX, e.pageY);
            };
        })();

        if (!jQuery.fn.onPositionChanged)
        {
            jQuery.fn.onPositionChanged = function (trigger, millis) {
                if (millis == null) millis = 100;
                var o = $(this[0]); // our jquery object
                if (o.length &lt; 1) return o;

                var lastPos = null;
                var lastOff = null;
                setInterval(function () {
                    if (o == null || o.length &lt; 1) return o; // abort if element is non existend eny more
                    if (lastPos == null) lastPos = o.position();
                    if (lastOff == null) lastOff = o.offset();
                    var newPos = o.position();
                    var newOff = o.offset();
                    if (lastPos.top !== newPos.top || lastPos.left !== newPos.left)
                    {
                        $(this).trigger('onPositionChanged', {lastPos: lastPos, newPos: newPos});
                        if (typeof (trigger) == "function") trigger(lastPos, newPos);
                        lastPos = o.position();
                    }
                    if (lastOff.top !== newOff.top || lastOff.left !== newOff.left)
                    {
                        $(this).trigger('onOffsetChanged', {lastOff: lastOff, newOff: newOff});
                        if (typeof (trigger) == "function") trigger(lastOff, newOff);
                        lastOff = o.offset();
                    }
                }, millis);

                return o;
            };
        }

        const _getDeliveryName = function (selector) {
            let $input = $(selector);
            if ($input.length &amp;&amp; $input.is(":visible"))
            {
                return $input.val();
            }
            return false;
        };

        // + large
        window.getDeliveryName = function (selector, fio)
        {
            let $input = $(selector);
            if ($input.length &amp;&amp; $input.is(":visible"))
            {
                const value = $input.val().trim();
                if (value) return value;
            }
            return fio;
        };

        window.OffsetProductInstance = new (function () {

            let instance = this;

            this.data = {};

            this.set = function (key, value) {
                instance.data[key] = value;
            }

            let state = {};
            const setState = function (newState) {
                state = JSON.parse(JSON.stringify(newState));
            };

            const genRandomString = function (size = 8) {
                let text = "";
                let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

                for (let i = 0; i &lt; size; i++)
                {
                    text += possible.charAt(Math.floor(Math.random() * possible.length));
                }

                return text;
            };

            const __initialize = function () {

                const initState = {
                    user: false,
                    sign: "",
                };

                setState({
                    ...initState,
                    sign: genRandomString(32),
                });
            };

            this.getSign = function () {
                return `${state.sign}`;
            };

            this.getData = function () {
                return JSON.parse(JSON.stringify(instance.data));
            };

            this.reload = function ()
            {
                __initialize();
            };

            __initialize();
        })();

        window.DeliveryInstance = new (function () {

            let instance = this;

            this.selectedCompany = '';
            this.selectedMethod = '';
            this.pointKey = '';

            this.reset = function () {
                instance.selectedCompany = '';
                instance.selectedMethod = '';
                instance.pointKey = '';
            };

            // $('.cDPD_terminal_selection:visible .tk_block.active').attr('tk');

            this.setMethod = function (name, company = '') {



                switch (name)
                {
                    case 'pickup':
                        instance.selectedCompany = company;
                        break;

                    case 'denvden_delivery':
                        instance.selectedCompany = 'YGo';
                        break;

                    case 'targeted_delivery':
                        instance.selectedCompany = 'DPD';
                        break;

                    case 'dpd_delivery':
                        instance.selectedCompany = company;
                        break;

                    case 'dpdTargetedBlock':
                        instance.selectedCompany = 'DPD';
                        break;

                    case 'large_dpd_delivery':
                        instance.selectedCompany = 'DPD';
                        break;

                    default:
                        console.debug(".setMethod", name, "=&gt;", company, "false");
                        console.debug(".setMethod", name, "=&gt;", instance.selectedCompany, "auto");
                        return false;
                }

                this.selectedMethod = name;

                console.debug(".setMethod", name, "=&gt;", company, "true");
                return true;
            };

            this.setCompany = function (company) {
                if (instance.selectedMethod === 'pickup' || instance.selectedMethod === 'dpd_delivery')
                {
                    instance.selectedCompany = `${company}`;
                    console.debug(".setCompany", company, "true");
                    return true;
                }

                console.debug(".setCompany", company, "false");
                return false;
            };

            this.forceSet = function (key, value) {
                if (key === "company")
                {
                    instance.selectedCompany = `${value}`;
                    console.debug(".forceSet", key, "=&gt;", value, "true");
                    return true;
                }

                console.debug(".forceSet", key, "=&gt;", value, "false");
                return false;
            };

            this.getSelectedCompany = function () {
                console.debug(".getSelectedCompany", instance.selectedCompany);
                return instance.selectedCompany;
            };

            this.setPointKey = function (key) {
                instance.pointKey = `${key}`;
            };

            this.getPointKey = function () {
                return instance.getSelectedCompany() === "YandexTerminal" ? instance.pointKey : "";
            };

            const requireDpdTerminals = function (large, _dpd_city_with_region, shipment_weight) {
                $.ajax({
                    type: 'POST',
                    data: {
                        'mark': large,
                        'city': _dpd_city_with_region,
                        'weight': shipment_weight,
                        'delivery_location': window.hasOwnProperty('deliveryLocationSelectorInstance') ? deliveryLocationSelectorInstance.getLocation() : {},

                        product: {
                            id: cost.id_product,
                            qty: cost.print,
                            print_id: cost.id_print,
                            name: cost.name,
                            width: cost.width,
                            height: cost.height,
                        },
                    },
                    url: "/AJAX/get_dpd_terminals_new.php",
                    async: true,
                    success: function (data) {

                        let resp = null;
                        try {
                            resp = JSON.parse(data);
                        }
                        catch (e) {
                            return;
                        }

                        let terminals = resp.term;

                        var str = '';
                        var x = "", y = "", k = 0;
                        for (var i = 0; i &lt; terminals.length; i++)
                        {
                            if (terminals[i]['ADDRESS_FULL'] !== "404105, Р’РѕР»РіРѕРіСЂР°РґСЃРєР°СЏ, Р’РѕР»Р¶СЃРєРёР№, РњРёСЂР° СѓР», Рґ. 74, РєРѕСЂРї. Рђ")
                            {

                                str += "&lt;tr id='td-is-" +
                                    i +
                                    "' location_id='" +
                                    terminals[i]['LOCATION_ID'] +
                                    "' data-address='" +
                                    terminals[i]['ADDRESS_SHORT'] +
                                    "' data-terminal_info='" +
                                    terminals[i]['ADDRESS_DESCR'] +
                                    "'&gt;&lt;td class='del1' &gt;" +
                                    terminals[i]['PARCEL_SHOP_TYPE'] +
                                    "&lt;/td&gt;&lt;td class='del2'&gt;" +
                                    terminals[i]['ADDRESS_FULL'] +
                                    "&lt;/td&gt;&lt;/tr&gt;";
                            }
                        }
                        if (str.length === 0)
                        {
                            if (resp.all_terminals === 0)
                            {
                                str = '&lt;tr&gt;&lt;td class="td-id-error"&gt;РќРµС‚ РїСѓРєС‚РѕРІ РІС‹РґР°С‡Рё РІ РЅ.Рї.: "' + $(".dpd_city").val() + '"&lt;/td&gt;&lt;/tr&gt;';
                                $('.tk_block[tk="sdek"]').click();
                            }
                            else
                            {
                                str = '&lt;tr&gt;&lt;td class="td-id-error"&gt;Р’РЅРёРјР°РЅРёРµ!  Р’РµСЃ РІР°С€РµРіРѕ Р·Р°РєР°Р·Р° РїСЂРµРІС‹С€Р°РµС‚ РґРѕРїСѓСЃС‚РёРјРѕРµ Р·РЅР°С‡РµРЅРёРµ РґР»СЏ РїСѓРЅРєС‚РѕРІ РІС‹РґР°С‡Рё.&lt;br&gt;РџРѕР¶Р°Р»СѓР№СЃС‚Р° СЂР°СЃСЃРјРѕС‚СЂРёС‚Рµ РґРѕСЃС‚Р°РІРєСѓ РґСЂСѓРіРѕР№ С‚СЂР°РЅСЃРїРѕСЂС‚РЅРѕР№ РєРѕРјРїР°РЅРёРµР№ РёР»Рё РѕС„РѕСЂРјРёС‚Рµ Р°РґСЂРµСЃРЅСѓСЋ РґРѕСЃС‚Р°РІРєСѓ.&lt;/td&gt;&lt;/tr&gt;';
                            }
                        }
                        $('.offset_delivery .cTerminal_list_dpd').html(str);
                    }
                });
            };

            this.requireDpd = function (large, _dpd_city, _dpd_region, coef, address_recognizer, _dpd_city_with_region, shipment_weight) {
                $.ajax({
                    type: 'POST',
                    data: {
                        'own_region': ph_id,
                        'mark': mark,
                        'otype': otype,
                        'product_id': p_id,
                        'country': 'Р&nbsp;РѕСЃСЃРёСЏ',
                        'city': _dpd_city,
                        'region': _dpd_region,
                        'region2': _dpd_region,
                        'length': Number($('.cDpdLen').html()) * coef,
                        'width': Number($('.cDpdWid').html()) * coef,
                        'height': Number($('.cDpdHgt').html()) * coef,
                        'weight': Number(Number($('.cDpdWgtAll').html()) + Number($('.cDpdWgtAllDop').html())).toFixed(2),
                        'product': 'РїРµС‡Р°С‚РЅР°СЏ РїСЂРѕРґСѓРєС†РёСЏ',
                        'cost': $('.printCost').html(),
                        'address_recognizer_result': address_recognizer,
                        'delivery_location': window.hasOwnProperty('deliveryLocationSelectorInstance') ? deliveryLocationSelectorInstance.getLocation() : {},
                    },
                    url: "/AJAX/get_dpd_price_terminal.php",
                    async: true,
                    success: function (data) {
                        var str;
                        try
                        {
                            var result = JSON.parse(data);
                            if (result['DPD'] == false)
                            {
                                $('.offset_delivery .dpd_del_period').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                                $('.offset_delivery .dpd_del_cost').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                            }
                            else
                            {
                                let __daysHtml = (result['DPD'].DAYS &gt; 0)
                                    ? `${result['DPD'].DAYS}-${result['DPD'].DAYS + 2} Рґ.`
                                    : '&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;';

                                $('.offset_delivery .dpd_del_period').html(__daysHtml);

                                let __cost = Math.ceil(Number(result['USER'].COST)),
                                    __costHtml = (__cost &gt; 0) ? __cost + ' СЂСѓР±.' : '&lt;i&gt;Р±РµСЃРїР»Р°С‚РЅРѕ&lt;/i&gt;';

                                $('.offset_delivery .dpd_del_cost').html(__costHtml);

                            }
                        } catch (e)
                        {
                            str = '&lt;tr&gt;&lt;td class="td-id-error"&gt;Р’РЅРёРјР°РЅРёРµ!  Р”Р°РЅРЅС‹Р№ С‚РёРї РґРѕСЃС‚Р°РІРєРё РЅРµРІРѕР·РјРѕР¶РµРЅ СЃ С‚РµРєСѓС‰РёРјРё РїР°СЂР°РјРµС‚СЂР°РјРё Р·Р°РєР°Р·Р°.&lt;br&gt;РџРѕР¶Р°Р»СѓР№СЃС‚Р° СЂР°СЃСЃРјРѕС‚СЂРёС‚Рµ РґРѕСЃС‚Р°РІРєСѓ РґСЂСѓРіРѕР№ С‚СЂР°РЅСЃРїРѕСЂС‚РЅРѕР№ РєРѕРјРїР°РЅРёРµР№ РёР»Рё РѕС„РѕСЂРјРёС‚Рµ Р°РґСЂРµСЃРЅСѓСЋ РґРѕСЃС‚Р°РІРєСѓ .&lt;/td&gt;&lt;/tr&gt;';
                            $('.offset_delivery .cTerminal_list_dpd').html(str);
                            $('.offset_delivery .dpd_del_period').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                            $('.offset_delivery .dpd_del_cost').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                        }
                    },
                    error: function () {
                        $('.offset_delivery .dpd_del_period').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                        $('.offset_delivery .dpd_del_cost').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                    }
                }).always(function () {
                    requireDpdTerminals(large, _dpd_city_with_region, shipment_weight);
                });
            };

            const requireSdekTerminals = function (_sdek_city_with_region) {
                $.ajax({
                    type: 'POST',
                    data: {
                        //'mark': large,
                        'city': _sdek_city_with_region,
                        'delivery_location': window.hasOwnProperty('deliveryLocationSelectorInstance') ? deliveryLocationSelectorInstance.getLocation() : {},
                        product: {
                            id: cost.id_product,
                            qty: cost.print,
                            print_id: cost.id_print,
                            name: cost.name,
                            width: cost.width,
                            height: cost.height,
                        },
                    },
                    url: "/AJAX/get_sdek_terminals.php",
                    async: true,
                    success: function (data) {
                        terminals = JSON.parse(data);
                        // console.log("sdek_terminals : ", terminals);
                        var str = '';
                        var x = "", y = "", k = 0;
                        for (var i = 0; i &lt; terminals.length; i++)
                        {
                            str += "&lt;tr id='td-is-" +
                                i +
                                "' location_id='" +
                                terminals[i]['city_code'] +
                                "' data-address='" +
                                terminals[i]['address'] +
                                "'&gt;&lt;td class='del1' &gt;" +
                                terminals[i]['type'] +
                                "&lt;/td&gt;&lt;td class='del2'&gt;" +
                                terminals[i]['address_ful'] +
                                "&lt;/td&gt;&lt;/tr&gt;";
                        }
                        if (str.length === 0)
                        {
                            str = '&lt;tr&gt;&lt;td class="td-id-error"&gt;РќРµС‚ РїСѓРєС‚РѕРІ РІС‹РґР°С‡Рё РІ РЅ.Рї.: "' + $(".dpd_city").val() + '"&lt;/td&gt;&lt;/tr&gt;';
                        }
                        $('.cTerminal_list_sdek').html(str);
                    }
                });
            };

            this.requireSdek = function (_sdek_city, _sdek_region, coef, _sdek_location_id, _sdek_city_with_region) {

                // console.log('requireSdek');

                $.ajax({
                    type: 'POST',
                    data: {
                        'own_region': ph_id,
                        'mark': mark,
                        'otype': otype,
                        'product_id': p_id,
                        'country': 'Р&nbsp;РѕСЃСЃРёСЏ',
                        'city': _sdek_city,
                        'region': _sdek_region,
                        'region2': _sdek_region,
                        'length': Number($('.cDpdLen').html()) * coef,
                        'width': Number($('.cDpdWid').html()) * coef,
                        'height': Number($('.cDpdHgt').html()) * coef,
                        'weight': Number(Number($('.cDpdWgtAll').html()) + Number($('.cDpdWgtAllDop').html())).toFixed(2),
                        'product': 'РїРµС‡Р°С‚РЅР°СЏ РїСЂРѕРґСѓРєС†РёСЏ',
                        'cost': $('.printCost').html(),
                        'sdek_location_id': _sdek_location_id,
                        'delivery_location': window.hasOwnProperty('deliveryLocationSelectorInstance') ? deliveryLocationSelectorInstance.getLocation() : {},
                    },
                    url: "/AJAX/get_sdek_price_terminal.php",
                    async: true,
                    success: function (data) {
                        // console.log("sdek success");
                        // console.log(data);
                        try
                        {

                            var result = JSON.parse(data);
                            // console.log("sdek_price : " + result.SDEK.price);
                            if (result.CONFIRM)
                            {

                                let __daysHtml = (result.SDEK.deliveryPeriodMin &gt; 0)
                                    ? `${result.SDEK.deliveryPeriodMin}-${result.SDEK.deliveryPeriodMin + 2} Рґ.`
                                    : '&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;';

                                $('.offset_delivery .sdek_del_period').html(__daysHtml);

                                let __cost = Math.ceil(Number(result.SDEK.price)),
                                    __costHtml = (__cost &gt; 0) ? __cost + ' СЂСѓР±.' : '&lt;i&gt;Р±РµСЃРїР»Р°С‚РЅРѕ&lt;/i&gt;';

                                $('.offset_delivery .sdek_del_cost').html(__costHtml);

                                requireSdekTerminals(_sdek_city_with_region);
                            }
                            else
                            {
                                // $('.offset_delivery .sdek_del_period').html('0-2 Рґ.');
                                // $('.offset_delivery .sdek_del_cost').html('0 СЂСѓР±.');
                                $('.offset_delivery .sdek_del_period').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                                $('.offset_delivery .sdek_del_cost').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                            }

                        } catch (e)
                        {
                            // $('.offset_delivery .sdek_del_period').html('0-2 Рґ.');
                            // $('.offset_delivery .sdek_del_cost').html('0 СЂСѓР±.');
                            $('.offset_delivery .sdek_del_period').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                            $('.offset_delivery .sdek_del_cost').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                        }
                    },
                    error: function () {
                        $('.offset_delivery .sdek_del_period').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                        $('.offset_delivery .sdek_del_cost').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                    }
                })
                    .always(function () {

                    });
            };

            this.requireYandextermminal = function ({location}) {

                let $tab = $('.offset_delivery .cDPD_terminal_selection .tk_block[tk="yandexterminal"]');
                let $tabContent = $(`.offset_delivery .cDPD_terminal_selection .yandexterminal_terminal_block`);
                if (!$tab.length || !$tabContent.length) return;

                let $table = $tabContent.find('.cTerminal_list_yandexterminal');
                $table.empty();

                const weight = Number(Number($('.cDpdWgtAll').html()) + Number($('.cDpdWgtAllDop').html())).toFixed(2);

                const updateTabInfo = function (
                    period_html = '&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;',
                    cost_html = '&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;'
                ) {
                    $tab.find('.yandexterminal_del_period').html(period_html);
                    $tab.find('.yandexterminal_del_cost').html(cost_html);
                };

                updateTabInfo('0', '0');

                $.ajax({
                    type: "POST",
                    url: "/data/delivery/yandexterminal/terminals.get",
                    data: {location, ph_id, weight},
                    dataType: "json",
                    success: function ({geo_id, points}) {

                        if (!geo_id || !points)
                        {
                            updateTabInfo();
                            return;
                        }

                        let $tbody = $(`&lt;tbody&gt;&lt;/tbody&gt;`);
                        $table.append($tbody);

                        for (const index in points)
                        {
                            const {id, name, full_address, display_address, comment} = points[index];

                            $tbody.append(`
                                &lt;tr id="td-is-${index}" 
                                    data-geo-id="${geo_id}" 
                                    data-station-id="${id}" 
                                    data-address="${full_address}" 
                                    data-comment="${comment}"
                                    &gt;
                                    &lt;td class="del1"&gt;${name}&lt;/td&gt;
                                    &lt;td class="del2"&gt;${display_address}&lt;/td&gt;
                                &lt;/tr&gt;
                            `);
                        }

                        updateTabInfo('1-3 Рґ.', '183 СЂСѓР±.');
                    },
                    error: function (e) {
                        updateTabInfo();
                    }
                });
            };
        })();

        window.deliveryLocationSelector = function () {
            let instance = this;

            this.hasRegion = false;
            this.selectedRegion = '';

            this.hasCity = false;
            this.selectedCity = '';
            this.location = {};

            this.selectors = {
                wrap: '#deliveryLocationSelector',
                region: '#deliveryRegionSelect',
                city: '#deliveryCitySelect',
                result: '#deliveryLocationString',

                oldField: '.dpd_city.cCityForDPD'
            };

            this.getLocation = function ()
            {
                return instance.location;
            }

            this.setRegion = function (item) {
                if (item)
                {
                    instance.selectedRegion = item.value;
                    instance.setHasRegion(true);
                }
                return instance.hasRegion;
            }

            this.setLocation = function (item) {
                if (item)
                {
                    instance.location = item.location;
                    $(instance.selectors.result).text(item.label);
                    instance.hasCity = true;

                    $(instance.selectors.oldField).val([item.value, instance.selectedRegion].join(', '));
                }
            };

            this.setHasRegion = function (bool) {
                instance.hasRegion = bool;
                $(instance.selectors.city).prop('disabled', !bool);
            };

            this.oncloseRegion = function (event) {
                if (instance.hasRegion)
                {
                    let $input = $(event.target);
                    $input.css({
                        color: '#000',
                        borderColor: '#ced4da'
                    });
                    $input.css('color', '#000');
                }
                else
                {
                    if (event)
                    {
                        $(event.target).css({
                            color: '#f00',
                            borderColor: '#f00'
                        });
                    }
                    instance.selectedRegion = '';
                    instance.selectedCity = '';
                    instance.location = {};
                    $(instance.selectors.result).empty();
                }
            };

            this.oncloseCity = function (event) {
                if (instance.hasCity)
                {
                    let $input = $(event.target);
                    $input.css({
                        color: '#000',
                        borderColor: '#ced4da'
                    });
                    $input.css('color', '#000');
                    instance.selectedCity = $input.val();
                }
                else
                {
                    if (event)
                    {
                        $(event.target).css({
                            color: '#f00',
                            borderColor: '#f00'
                        });
                    }
                    instance.selectedCity = '';
                    instance.location = {};
                    $(instance.selectors.result).empty();
                }
            };

            this.initRegionSelect = function () {
                $.ajax({
                    type: 'POST',
                    url: '/AJAX/location_search.php?action=getRegions',
                    dataType: 'json',
                    success: (response) =&gt; {
                        if (response.success) {
                            $(instance.selectors.region)
                                .on('input', function () {
                                    instance.setHasRegion(false);
                                    instance.hasCity = false;
                                    $(instance.selectors.city).val('');
                                    instance.oncloseCity()
                                })
                                .on('blur', function (event) {
                                    instance.oncloseRegion(event);
                                })
                                .autocomplete({
                                    source: response.regions,
                                    minLength: 3,
                                    search: function () {
                                        instance.setHasRegion(false);
                                        return true;
                                    },
                                    select: function (event, ui) {
                                        if (ui.hasOwnProperty('item'))
                                        {
                                            if (instance.setRegion(ui.item))
                                            {
                                                $(instance.selectors.city).focus();
                                            }
                                        }
                                    },
                                    close: function(event, ui) {
                                        instance.oncloseRegion(event);
                                    }
                                });
                        }
                    }
                })
            };

            this.formatLocation = function (location) {
                let {abbr, name, dist, distAbbr, reg, regAbbr, zipCode, countryCode, parentText} = location;
                let distLabel = dist &amp;&amp; distAbbr ? `${dist} ${distAbbr}, ` : '';
                distLabel = !distLabel &amp;&amp; parentText ? `${parentText}, ` : '';
                let zipPart = zipCode ? `, ${zipCode}` : '';
                if (countryCode === 'RU')
                {
                    return {
                        label: `${abbr}. ${name} (${distLabel}${reg} ${regAbbr})${zipPart}`,
                        value: name,
                        location: location,
                    }
                }
            }

            this.initCitySelect = function () {
                $(instance.selectors.city)
                    .keydown(function(event) {
                        if(event.keyCode === 8 &amp;&amp; event.target.value === '')
                        {
                            $(instance.selectors.region).focus();
                            return false;
                        }
                    })
                    .on('input', function () {
                        instance.hasCity = false;
                    })
                    .on('blur', function (event) {
                        instance.oncloseCity(event);
                    })
                    .autocomplete({
                        source: function(request, callback){
                            if (!instance.selectedRegion) callback([]);
                            $.ajax({
                                type: 'GET',
                                url: '/AJAX/location_search.php?action=queryLocation',
                                data: {
                                    region: instance.selectedRegion,
                                    query: request.term,
                                },
                                dataType: 'json',
                                success: function(locations) {
                                    callback(locations);

                                    callback($.map(locations, function (location) {
                                        return instance.formatLocation(location);
                                    }));

                                }
                            });
                        },
                        minLength: 3,
                        search: function () {
                            instance.hasCity = false;
                            return true;
                        },
                        select: function (event, ui) {
                            if (ui.hasOwnProperty('item'))
                            {
                                instance.setLocation(ui.item);
                                $(instance.selectors.city).blur();
                            }
                        },
                        close: function(event, ui) {
                            instance.oncloseCity(event);
                        }
                    });
            };

            this.initDefault = function () {
                $.ajax({
                    type: 'GET',
                    url: '/AJAX/location_search.php?action=queryUserLocation',
                    dataType: 'json',
                    success: function(location) {
                        if (location &amp;&amp; location.countryCode === 'RU')
                        {
                            instance.selectedRegion = `${location.reg} ${location.regAbbr}`;
                            instance.setLocation(instance.formatLocation(location));
                        }
                    }
                });
            };

            const __initialize = function () {
                $(document).ready(function () {
                    $(instance.selectors.wrap).show();
                    instance.initRegionSelect();
                    instance.initCitySelect();
                    instance.setHasRegion(false);
                    instance.initDefault();
                });
            }
            __initialize();
        };

        window.DeliverySection = new (function () {

            let instance = this;

            const afterHtmlSet = function (productType) {
                if (productType !== "large")
                {
                    $('.cOffsetDelivery .check_delivery .tab &gt; div &gt; div &gt; label &gt; div &gt; img').css({'top': '-135px'});
                    $('.cOffsetDelivery .check_delivery .tab &gt; div &gt; div').css({'height': '140px'});
                    $('.cOffsetDelivery .check_delivery .tab &gt; div div').css({'width': '210px'});
                }
            };

            const setHtml = function (productType, html) {
                if (productType === "large")
                {
                    $('.cLargeFormatDelivery .check_delivery').html(html);
                }
                else
                {
                    $('.cOffsetDelivery .check_delivery').html(html);
                }

                afterHtmlSet(productType);
            };

            const initVDev = function (productType) {
                DeliveryInstance.setMethod('pickup', 'DPD');

                $.ajax({
                    type: "POST",
                    data: {
                        ph_id, p_id,

                        ptype: productType,
                        sp: self_pickup,
                        target: targeted_del
                    },
                    url: "/AJAX/GetDeliveryBlock_vdev.php",
                    async: false,
                    success: data =&gt; setHtml(productType, data),
                    error: e =&gt; setHtml(productType, "")
                });

                DeliverySection.createAutocomplete("D");
            };

            const initV2b = function (productType) {
                // backward compatibility mode

                const builder = new (function () {

                    const tabs = function (response) {

                        let $tabs = $(`&lt;div class="tab"&gt;&lt;/div&gt;`);
                        let $container = $(`&lt;div&gt;&lt;/div&gt;`);
                        $tabs.append($container);

                        const eventAliases = {
                            denvden: "denvden_delivery",
                            pickup: "pickup",
                            targeted_city: "targeted_delivery",
                            targeted_country: "dpdTargetedBlock",
                            terminal: "dpd_delivery",
                        };

                        for (const name in response.templates.variants)
                        {
                            const variant = response.templates.variants[name];
                            $container.append(
                                $(variant.tab).click(function () {
                                    if (!!eventAliases[name]) openCity(this, eventAliases[name]);
                                })
                            )
                        }

                        return $tabs;
                    };

                    const contents = function (response) {
                        let items = [];

                        let position = 1;
                        for (const name in response.templates.variants)
                        {
                            const variant = response.templates.variants[name];
                            items.push(
                                $(variant.content).css("display", position === 1 ? "block" : "none")
                            );
                            position++;
                        }

                        return items;
                    }

                    this.build = function (productType, response) {
                        let $root = productType === "large"
                            ? $('.cLargeFormatDelivery .check_delivery')
                            : $('.cOffsetDelivery .check_delivery');

                        $root.empty().css({width: 'inherit', paddingRight: '20px'});

                        if (!!response.available)
                        {
                            $root.append(tabs(response));
                            $root.append(...contents(response))
                            $root.append($(response.templates.footer));

                            afterHtmlSet(productType);
                        }
                        else
                        {
                            $root.append(
                                $(`&lt;div&gt;&lt;/div&gt;`)
                                    .css({
                                        width: '100%',
                                        textAlign: 'center',
                                        fontSize: '1.2rem',
                                    })
                                    .text('РЎРІСЏР¶РёС‚РµСЃСЊ СЃ РјРµРЅРµРґР¶РµСЂРѕРј Р’Р°С€РµРіРѕ СЂРµРіРёРѕРЅР° РїРѕ РІРѕРїСЂРѕСЃР°Рј РґРѕСЃС‚Р°РІРєРё РїСЂРѕРґСѓРєС†РёРё РІ Р’Р°С€ РіРѕСЂРѕРґ.')
                            )
                        }

                    }
                })();

                DeliveryInstance.setMethod('pickup', 'DPD');
                setHtml(productType, "");

                $.ajax({
                    type: "POST",
                    data: {
                        ph_id, p_id,

                        ptype: productType,
                        sp: self_pickup,
                        target: targeted_del
                    },
                    url: "/AJAX/GetDeliveryBlock_v2.0b.php",
                    async: false,
                    dataType: "json",
                    success: response =&gt; builder.build(productType, response),
                    error: e =&gt; {}
                });

                DeliverySection.createAutocomplete("D");
            };

            this.DeliveryPhone = {};

            this.init = function (productType) {
                // initVDev(productType);
                initV2b(productType);

                this.DeliveryPhone = new (function () {

                    const values = {
                        pickup: '',
                        denvden: '',
                        targeted_city: '',
                        terminal: '',
                        targeted_country: '',
                    }

                    const inputs = {
                        pickup: $('.pickup .del_phone'),
                        denvden: $('.denvden_delivery .del_phone'),
                        targeted_city: $('.targeted_delivery .del_phone'),
                        terminal: $('.dpd_terminal .del_phone'),
                        targeted_country: $('.dpdTargetedBlock .del_phone')
                    };

                    let messages = {};

                    const createMessageElement = function () {
                        return $(`
                            &lt;div style="
                                color: red;
                                font-size: 0.8rem;
                                margin: 0 auto 0.5rem 265px;
                                display: none;
                                "&gt;РџРѕР¶Р°Р»СѓР№СЃС‚Р°, СѓРєР°Р¶РёС‚Рµ С‚РµР»РµС„РѕРЅ РїРѕР»СѓС‡Р°С‚РµР»СЏ&lt;/div&gt;
                        `);
                    }

                    for (const key in inputs)
                    {
                        messages[key] = createMessageElement();

                        if (inputs[key].length)
                        {
                            // inputs[key]
                            //     .after(messages[key])
                            //     .inputmask({
                            //         mask: `+7 (9{3}) 9{3}-9{2}-9{2}`,
                            //         oncomplete: function () {
                            //             let $input = $(this);
                            //             values[key] = $input.val();
                            //             messages[key].hide();
                            //             $input.css('border-color', '');
                            //         },
                            //         onincomplete: function () {
                            //             values[key] = '';
                            //             messages[key].show();
                            //             $(this).css('border-color', 'red');
                            //         },
                            //         onBeforePaste: function (pastedValue) {
                            //             let processedValue = pastedValue.replace(/[^\d]/g, "");
                            //             return processedValue.replace(/^[78]/, "+7");
                            //         }
                            //     });

                            inputs[key]
                                .after(messages[key])
                                .inputmask({
                                    mask: `9 (9{3}) 9{3}-9{2}-9{2}`,
                                    oncomplete: function () {
                                        let $input = $(this);
                                        values[key] = $input.val();
                                        messages[key].hide();
                                        $input.css('border-color', '');
                                    },
                                    onincomplete: function () {
                                        values[key] = '';
                                        messages[key].show();
                                        $(this).css('border-color', 'red');
                                    },
                                    onBeforePaste: function (pastedValue) {
                                        return pastedValue.replace(/[^\d]/g, "");
                                    }
                                });
                        }
                        else
                        {
                            delete inputs[key];
                        }
                    }

                    this.checkValue = function (key) {
                        if (inputs.hasOwnProperty(key))
                        {
                            const value = `${values[key]}`;
                            if (value) return value;

                            let $input = inputs[key];
                            const text = $input.val().trim();
                            const pattern = /^\d \(\d{3}\) \d{3}-\d{2}-\d{2}$/;
                            if (pattern.test(text))
                            {
                                $input.trigger('oncomplete');
                                return text;
                            }
                            else
                            {
                                $input.trigger('incomplete')
                            }
                        }

                        return '';
                    };
                })();
            }

            this.b_addDeliveryWarning = function () {

                if (!instanceForOffset.isPartnerHost()) return false;

                const addWarning = function (spanSelector) {
                    let $spanDate = $(spanSelector);
                    $spanDate.css('padding-left', '0');

                    let $td = $spanDate.parents('td.dpd_ready');
                    $td.css('text-align', 'center');

                    $td.append(`
            &lt;label style="display: inline-block;" class="mytooltip"&gt;
                &lt;div style="
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    width: 1.5rem;
                    height: 1.5rem;
                    text-align: center;
                    position: relative;
                    top: 2px;
                    "&gt;
                    &lt;img src="https://sborka.run/images/order/status/return_status.png"&gt;
                &lt;/div&gt;
                &lt;span class="tooltiptext" style="margin-left: -88px;color: #f00;font-weight: normal;"&gt;
                    Р’РќРРњРђРќРР•! Р’ СЃРІСЏР·Рё СЃ Р±РѕР»СЊС€РѕР№ Р·Р°РіСЂСѓР¶РµРЅРЅРѕСЃС‚СЊСЋ, С‚СЂР°РЅСЃРїРѕСЂС‚РЅС‹Рµ РєРѕРјРїР°РЅРёРё РЅРµ СѓСЃРїРµРІР°СЋС‚ СЃРІРѕРµРІСЂРµРјРµРЅРЅРѕ РѕР±СЂР°Р±Р°С‚С‹РІР°С‚СЊ Рё РѕСЃСѓС‰РµСЃС‚РІР»СЏС‚СЊ РґРѕСЃС‚Р°РІРєСѓ РІР°С€РёС… Р·Р°РєР°Р·РѕРІ. &lt;b&gt;Р’РѕР·РјРѕР¶РЅС‹ РёР·РјРµРЅРµРЅРёСЏ СЃСЂРѕРєРѕРІ РґРѕСЃС‚Р°РІРєРё&lt;/b&gt; РІ СЃС‚РѕСЂРѕРЅСѓ СѓРІРµР»РёС‡РµРЅРёСЏ РѕС‚ 2 РґРѕ 5 СЂР°Р±РѕС‡РёС… РґРЅРµР№!
                &lt;/span&gt;
            &lt;/label&gt;
        `);
                };

                //offset
                addWarning('#date_dpd_ready');

                //large
                addWarning('#date_dpd_ready_lf');
            }

            this.addListener = function (eventName) {

                if (eventName === "select_tc") // terminal
                {
                    // Р’С‹Р±РѕСЂ С‚СЂР°РЅСЃРїРѕСЂС‚РЅРѕР№ РєРѕРјРїР°РЅРёРё
                    $('.offset_delivery ').on('click', '.tk_block', function () {
                        $('.offset_delivery .tk_block').removeClass('active');
                        $(this).addClass('active');
                        $('.offset_delivery .cDPD_terminal_selection .dpd_terminal_block').css('display', 'none');
                        $('.offset_delivery .cDPD_terminal_selection .sdek_terminal_block').css('display', 'none');
                        $('.offset_delivery .cDPD_terminal_selection .ems_terminal_block').css('display', 'none');
                        $('.offset_delivery .cDPD_terminal_selection .ozon_terminal_block').css('display', 'none');
                        $('.offset_delivery .cDPD_terminal_selection .yandexterminal_terminal_block').css('display', 'none');
                        $('.offset_delivery .cDPD_terminal_selection .' + $(this).attr('tk') + '_terminal_block').css('display', 'block');

                        const tk = $(this).attr('tk');
                        if (tk === "dpd") DeliveryInstance.forceSet("company", "DPD");
                        else if (tk === "sdek") DeliveryInstance.forceSet("company", "SDEK");
                        else if (tk === "yandexterminal") DeliveryInstance.forceSet("company", "YandexTerminal");

                    });
                }
                else if (eventName === "select_terminal")
                {
                    // Р’С‹Р±РѕСЂ С‚РµСЂРјРёРЅР°Р»Р°

                    let $offsetDelivery = $(".offset_delivery");

                    // SDEK
                    $offsetDelivery.on('click', '.cTerminal_list_sdek tr', function () {

                        // console.log('Р’С‹Р±РѕСЂ С‚РµСЂРјРёРЅР°Р»Р° РЎР”Р•Рљ');

                        if ($(this).find('td').attr("class") !== "td-id-error")
                        {
                            $(".tr_act").removeClass();
                            $(this).removeClass().addClass("tr_act");
                            dpd_terminal = $(this).attr('data-address');
                            full_terminal = $(this).find(".del2").html();

                            //Р’Р°СЂРёР°РЅС‚ Р±РµР· РЇРЅРґРµРєСЃ РєР°СЂС‚С‹ РќРђР§РђР›Рћ
                            $('#dpd_delivery .block_is_ik .del_addk').html(dpd_terminal);
                            $('#dpd_delivery .block_is_ik .del_addr').html(full_terminal);

                            var city = $('.offset_delivery .dpd_city').val().split(', ');
                            dpd_country = 'Р&nbsp;РѕСЃСЃРёСЏ';

                            if (full_terminal)
                            {
                                // console.log({
                                //     'full_terminal': full_terminal
                                // });

                                let terminalArr = full_terminal.split(', ');
                                let regIndex = terminalArr[1] === 'Р&nbsp;РѕСЃСЃРёСЏ' ? 2 : 1;

                                dpd_region = terminalArr[regIndex];
                                dpd_region2 = terminalArr[regIndex];

                                if (instanceForOffset.isPartnerHost()) dpd_city = terminalArr[regIndex + 1];
                            }
                            else
                            {
                                dpd_region = city[1];
                                dpd_region2 = city[1];

                                if (instanceForOffset.isPartnerHost()) dpd_city = city[0];
                            }

                            dpd_city = city[0];
                            dpd_adress = dpd_terminal;
                            //Р’Р°СЂРёР°РЅС‚ Р±РµР· РЇРЅРґРµРєСЃ РєР°СЂС‚С‹ РљРћРќР•Р¦

                            $('.offset_delivery .delivery_block_dpd_dpdp').css('display', 'block');
                            dpd_ready = false;
                            dpd_flag = false;
                            sdek_flag = true;
                            ems_flag = false;
                            ozon_flag = false;
                            $('.totalCost').text($('.printCost').html());
                            $('.deliveryCost').text(0);

                            if (instanceForOffset.isPartnerHost())
                            {
                                // old variant
                                $('.deliveryDate').text($('.dateReady').html());
                            }
                            else
                            {
                                let dateReadySplit = $('.dateReady').html().split('.');
                                setDeliveryDate({d: dateReadySplit[0], m: dateReadySplit[1], y: dateReadySplit[2]}, 4);
                            }
                        }

                        DeliveryInstance.forceSet("company", "SDEK");
                    });

                    // DPD
                    $offsetDelivery.on('click', '.cTerminal_list_dpd tr', function () {

                        if ($(this).find('td').attr("class") !== "td-id-error")
                        {
                            $(".tr_act").removeClass();
                            $(this).removeClass().addClass("tr_act");
                            dpd_terminal = $(this).attr('data-address');
                            dpd_terminal_info = $(this).attr('data-terminal_info');
                            full_terminal = $(this).find(".del2").html();

                            //Р’Р°СЂРёР°РЅС‚ Р±РµР· РЇРЅРґРµРєСЃ РєР°СЂС‚С‹ РќРђР§РђР›Рћ
                            $('#dpd_delivery .block_is_ik .del_addk').html(dpd_terminal);
                            $('#dpd_delivery .block_is_ik .del_addr').html(dpd_terminal_info);
                            //$('#dpd_delivery .block_is_ik .del_addr').html(full_terminal);

                            var arr = full_terminal.split(', ');
                            //var city = $('.dpd_city').val().split(', ');
                            var city = $('.offset_delivery .dpd_city').val().split(', ');
                            dpd_country = 'Р&nbsp;РѕСЃСЃРёСЏ';
                            dpd_region = arr[1];
                            dpd_region2 = arr[1];
                            dpd_city = instanceForOffset.isPartnerHost() ? arr[2] : city[0];
                            dpd_adress = dpd_terminal;
                            //Р’Р°СЂРёР°РЅС‚ Р±РµР· РЇРЅРґРµРєСЃ РєР°СЂС‚С‹ РљРћРќР•Р¦

                            //$('.delivery_block_dpd_dpdp').css('display', 'block');
                            $('.offset_delivery .delivery_block_dpd_dpdp').css('display', 'block');
                            dpd_ready = false;
                            dpd_flag = true;
                            sdek_flag = false;
                            ems_flag = false;
                            ozon_flag = false;
                            $('.totalCost').text($('.printCost').html());
                            $('.deliveryCost').text(0);

                            if (instanceForOffset.isPartnerHost())
                            {
                                // old variant
                                $('.deliveryDate').text($('.dateReady').html());
                            }
                            else
                            {
                                let dateReadySplit = $('.dateReady').html().split('.');
                                setDeliveryDate({d: dateReadySplit[0], m: dateReadySplit[1], y: dateReadySplit[2]}, 5);
                            }
                        }

                        DeliveryInstance.forceSet("company", "DPD");
                    });

                    // EMS
                    $offsetDelivery.on('click', '.cTerminal_list_ems tr', function () {
                        if ($(this).find('td').attr("class") !== "td-id-error")
                        {
                            $(".tr_act").removeClass();
                            $(this).removeClass().addClass("tr_act");
                            dpd_terminal = $(this).attr('data-address');
                            full_terminal = $(this).find(".del2").html();

                            //Р’Р°СЂРёР°РЅС‚ Р±РµР· РЇРЅРґРµРєСЃ РєР°СЂС‚С‹ РќРђР§РђР›Рћ
                            $('#dpd_delivery .block_is_ik .del_addk').html(dpd_terminal);
                            $('#dpd_delivery .block_is_ik .del_addr').html(full_terminal);

                            var arr = full_terminal.split(', ');
                            //var city = $('.dpd_city').val().split(', ');
                            var city = $('.offset_delivery .dpd_city').val().split(', ');
                            dpd_country = 'Р&nbsp;РѕСЃСЃРёСЏ';
                            dpd_region = arr[1];
                            dpd_region2 = arr[1];
                            dpd_city = city[0];
                            dpd_adress = dpd_terminal;
                            //ems_index_to = arr[0].split('&lt;br&gt;')[1];
                            ems_index_to = arr[0];
                            //Р’Р°СЂРёР°РЅС‚ Р±РµР· РЇРЅРґРµРєСЃ РєР°СЂС‚С‹ РљРћРќР•Р¦

                            //$('.delivery_block_dpd_dpdp').css('display', 'block');
                            $('.offset_delivery .delivery_block_dpd_dpdp').css('display', 'block');
                            dpd_ready = false;
                            dpd_flag = false;
                            sdek_flag = false;
                            ems_flag = true;
                            ozon_flag = false;
                            $('.totalCost').text($('.printCost').html());
                            $('.deliveryCost').text(0);

                            if (instanceForOffset.isPartnerHost())
                            {
                                // old variant
                                $('.deliveryDate').text($('.dateReady').html());
                            }
                            else
                            {
                                let dateReadySplit = $('.dateReady').html().split('.');
                                setDeliveryDate({d: dateReadySplit[0], m: dateReadySplit[1], y: dateReadySplit[2]}, 6);
                            }
                        }
                        DeliveryInstance.forceSet("company", "EMS");
                    });

                    // OZON
                    $offsetDelivery.on('click', '.cTerminal_list_ozon tr', function () {
                        if ($(this).find('td').attr("class") !== "td-id-error")
                        {
                            $(".tr_act").removeClass();
                            $(this).removeClass().addClass("tr_act");
                            dpd_terminal = $(this).attr('data-address');
                            //full_terminal = $(this).find(".del2").html();
                            dpd_terminal_info = $(this).attr('data-terminal_info');

                            //Р’Р°СЂРёР°РЅС‚ Р±РµР· РЇРЅРґРµРєСЃ РєР°СЂС‚С‹ РќРђР§РђР›Рћ
                            $('#dpd_delivery .block_is_ik .del_addk').html(dpd_terminal);
                            $('#dpd_delivery .block_is_ik .del_addr').html(dpd_terminal_info);

                            dpd_country = 'Р&nbsp;РѕСЃСЃРёСЏ';
                            dpd_region = $(this).attr('data-region');
                            dpd_region2 = $(this).attr('data-region');
                            dpd_city = $(this).attr('data-city');
                            dpd_adress = dpd_terminal;
                            deliveryVariantId = $(this).attr('location_id');


                            //Р’Р°СЂРёР°РЅС‚ Р±РµР· РЇРЅРґРµРєСЃ РєР°СЂС‚С‹ РљРћРќР•Р¦

                            //$('.delivery_block_dpd_dpdp').css('display', 'block');
                            $('.offset_delivery .delivery_block_dpd_dpdp').css('display', 'block');
                            dpd_ready = false;
                            dpd_flag = false;
                            sdek_flag = false;
                            ems_flag = false;
                            ozon_flag = true;
                            $('.totalCost').text($('.printCost').html());
                            $('.deliveryCost').text(0);

                            if (instanceForOffset.isPartnerHost())
                            {
                                // old variant
                                $('.deliveryDate').text($('.dateReady').html());
                            }
                            else
                            {
                                let dateReadySplit = $('.dateReady').html().split('.');
                                setDeliveryDate({d: dateReadySplit[0], m: dateReadySplit[1], y: dateReadySplit[2]}, 7);
                            }
                        }
                        DeliveryInstance.forceSet("company", "OZON");
                    });

                    // YandexTerminal
                    $offsetDelivery.on('click', '.cTerminal_list_yandexterminal tr', function () {

                        if ($(this).find('td').attr("class") !== "td-id-error")
                        {
                            $(".tr_act").removeClass();
                            $(this).removeClass().addClass("tr_act");
                            dpd_terminal = $(this).attr('data-address');
                            dpd_terminal_info = $(this).attr('data-comment');
                            full_terminal = $(this).find(".del2").html();

                            //Р’Р°СЂРёР°РЅС‚ Р±РµР· РЇРЅРґРµРєСЃ РєР°СЂС‚С‹ РќРђР§РђР›Рћ
                            $('#dpd_delivery .block_is_ik .del_addk').html(dpd_terminal); // yandexterminal_terminal
                            $('#dpd_delivery .block_is_ik .del_addr').html(dpd_terminal_info); // yandexterminal_terminal_info (comment)
                            //$('#dpd_delivery .block_is_ik .del_addr').html(full_terminal);

                            var arr = full_terminal.split(', ');
                            //var city = $('.dpd_city').val().split(', ');
                            var city = $('.offset_delivery .dpd_city').val().split(', ');
                            dpd_country = 'Р&nbsp;РѕСЃСЃРёСЏ';
                            dpd_region = arr[1];
                            dpd_region2 = arr[1];
                            dpd_city = instanceForOffset.isPartnerHost() ? arr[2] : city[0];
                            dpd_adress = dpd_terminal;
                            //Р’Р°СЂРёР°РЅС‚ Р±РµР· РЇРЅРґРµРєСЃ РєР°СЂС‚С‹ РљРћРќР•Р¦

                            //$('.delivery_block_dpd_dpdp').css('display', 'block');
                            $('.offset_delivery .delivery_block_dpd_dpdp').css('display', 'block');
                            dpd_ready = false;
                            dpd_flag = false;
                            sdek_flag = false;
                            ems_flag = false;
                            ozon_flag = false;
                            yandexterminal.flag = true;
                            yandexterminal.station_id = $(this).attr('data-station-id')
                            $('.totalCost').text($('.printCost').html());
                            $('.deliveryCost').text(0);

                            if (instanceForOffset.isPartnerHost())
                            {
                                // old variant
                                $('.deliveryDate').text($('.dateReady').html());
                            }
                            else
                            {
                                let dateReadySplit = $('.dateReady').html().split('.');
                                setDeliveryDate({d: dateReadySplit[0], m: dateReadySplit[1], y: dateReadySplit[2]}, 5);
                            }
                        }
                        DeliveryInstance.forceSet("company", "YandexTerminal");
                    });

                }
                else if (eventName === "select_address_book")
                {
                    // Р’С‹Р±РѕСЂ РёР· Р°РґСЂРµСЃРЅРѕР№ РєРЅРёРіРё
                    $('#ABModal').on('click', '.address_table tr', function () {

                        $('#ABModal').modal('toggle');

                        if ($(this).attr('aid') !== '0')
                        {

                            if (delivery_type === 'sp')
                            {
                                $('.pickup .del_fio').val($(this).data('fio'));
                                $('.pickup .del_user').val($(this).data('name'));
                                $('.pickup .del_phone').val($(this).data('phone'));
                            }
                            if (delivery_type === 'terminal')
                            {
                                $('.dpd_terminal .del_fio').val($(this).data('fio'));
                                $('.dpd_terminal .del_user').val($(this).data('name'));
                                $('.dpd_terminal .del_phone').val($(this).data('phone'));
                                $('.dpd_terminal .del_cour').val($(this).data('courier'));
                            }
                            if (delivery_type === 'targeted')
                            {
                                $('.targeted_delivery .del_fio').val($(this).data('fio'));
                                $('.targeted_delivery .del_user').val($(this).data('name'));
                                $('.targeted_delivery .del_phone').val($(this).data('phone'));
                                $('.targeted_delivery .del_other').val($(this).data('courier'));

                                if ($(this).attr('data-adress'))
                                {
                                    $('.targeted_delivery .del_addr_hd').val($(this).data('house'));
                                    $('.targeted_delivery .del_targeted').val($(this).data('adress') + ', ' + $(this).data('city') + ', ' + $(this).data('region'));
                                    $('.targeted_delivery #targeted_to_street_number').val($(this).data('house'));
                                    $('.targeted_delivery #targeted_to_street').val($(this).data('street'));
                                    $('.targeted_delivery #targeted_to_region').val($(this).data('region'));
                                    $('.targeted_delivery #targeted_to_city').val($(this).data('city'));
                                    $('.targeted_delivery #targeted_to_country').val($(this).data('country'));
                                    $('.targeted_delivery .del_addr').val($(this).data('street'));
                                }

                            }
                            if (delivery_type === 'dpdTargeted')
                            {
                                $('.dpdTargetedBlock .del_fio').val($(this).data('fio'));
                                $('.dpdTargetedBlock .del_user').val($(this).data('name'));
                                $('.dpdTargetedBlock .del_phone').val($(this).data('phone'));
                                $('.dpdTargetedBlock .del_cour').val($(this).data('courier'));

                                if ($(this).attr('data-adress'))
                                {
                                    $('.dpdTargetedBlock .del_addr_hd').val($(this).data('house'));
                                    $('.dpdTargetedBlock .delivery_to').val($(this).data('adress') + ', ' + $(this).data('city') + ', ' + $(this).data('region'));
                                    $('.dpdTargetedBlock #to_street_number').val($(this).data('house'));
                                    $('.dpdTargetedBlock #to_street').val($(this).data('street'));
                                    $('.dpdTargetedBlock #to_region').val($(this).data('region'));
                                    $('.dpdTargetedBlock #to_city').val($(this).data('city'));
                                    $('.dpdTargetedBlock #to_country').val($(this).data('country'));
                                    $('.dpdTargetedBlock .del_addr').val($(this).data('street'));
                                }
                            }

                        }
                    });
                }
                else if (eventName === "listeners_group:1")
                {
                    let $offsetDelivery = $(".offset_delivery");

                    $offsetDelivery.on('click', '.ozon_switch span', function () {

                        $('.offset_delivery .ozon_switch span').removeClass('active_sw');
                        $('.cTerminal_list_ozon').css({'display': 'none'});
                        $('.cTerminal_map_ozon').css({'display': 'none'});
                        $(this).addClass('active_sw');
                        switch ($(this).attr('block'))
                        {
                            case 'cTerminal_list_ozon':
                            {
                                $('.cTerminal_list_ozon').css({'display': 'block'});
                                break;
                            }
                            case 'cTerminal_map_ozon':
                            {
                                $('.cTerminal_map_ozon').css({'display': 'block'});
                                break;
                            }
                        }
                    });

                    $offsetDelivery.on('click', '.sp_ozon_switch span', function () {

                        $('.offset_delivery .sp_ozon_switch span').removeClass('active_sw');
                        $('.SPP_List_ozon').css({'display': 'none'});
                        $('.cSPP_map_ozon').css({'display': 'none'});
                        $(this).addClass('active_sw');
                        switch ($(this).attr('block'))
                        {
                            case 'SPP_List_ozon':
                            {
                                $('.SPP_List_ozon').css({'display': 'block'});
                                break;
                            }
                            case 'cSPP_map_ozon':
                            {
                                $('.cSPP_map_ozon').css({'display': 'block'});
                                break;
                            }
                        }
                    });

                    $offsetDelivery.on('click', '.sSP_TK_block .sp_tk_block', function () {

                        if (!instanceForOffset.isPartnerHost()) deliveryRegistration.beforeSwitchSelfPickupType(this);
                        $('.offset_delivery .sSP_TK_block .sp_tk_block').removeClass('active');
                        $('.offset_delivery .spp_block_tk').css({'display': 'none'});
                        $(this).addClass('active');
                        $('.offset_delivery .' + $(this).attr('tk') + '_spp_block').css({'display': 'block'});

                    });

                    $offsetDelivery.on("click", ".dpd_delivery,  label", function () {
                        // РћСЃС‚Р°С‚РєРё С„СѓРЅРєС†РёРѕРЅР°Р»Р° РѕС‚ РѕС‡РµРЅСЊ СЃС‚Р°СЂРѕР№ РІРµСЂСЃС‚РєРё, РїРµСЂРµРґРµР»Р°С‚СЊ РїСЂРё РЅР°Р»РёС‡РёРё СЃРІРѕР±РѕРґРЅРѕРіРѕ РІСЂРµРјРµРЅРё
                        if ($(this).attr("class") === "dpd_act3none")
                        {
                            $(".offset_delivery .dpd_act3none").removeClass().addClass("dpd_act");
                            $(".offset_delivery .dpd_act3").removeClass().addClass("dpd_act3none");
                            $(".offset_delivery .dpd_act").removeClass().addClass("dpd_act3");
                        }
                    });
                }
                else if (eventName === "select_method")
                {
                    $('.offset_delivery').on('change', '.tab input', function () {

                        deliveryRegistration.beforeSwitchType(this);

                        getUserCityName();
                        dpd_ready = false;
                        dpd_flag = true;
                        sdek_flag = false;
                        dpd_country = '';
                        dpd_city = '';
                        dpd_region = '';
                        dpd_region2 = '';
                        dpd_adress = '';
                        sp_address = '';
                        sp_region = '';
                        sp_addr = '';
                        sp_city = '';

                        let $totalCost = $('.totalCost');
                        let $printCost = $('.printCost');
                        let $deliveryCost = $('.deliveryCost');

                        //РќРѕРІРѕРµ С‡РёСЃС‚РёРј РїРѕСЃР»Рµ DPD РќР°С‡Р°Р»Рѕ
                        $totalCost.text($printCost.html());
                        $deliveryCost.text(0);
                        $('.actualDeliveryCost').text(0);
                        if (instanceForOffset.isPartnerHost()) $('.realTotalCost').text($('.realPrintCost').html());

                        GetOwn();

                        let readyTimeByRegion = TimeControl.parseReadyTime(printTime, false);

                        prel_date = readyTimeByRegion;

                        readyTimeByRegion = TimeControl.parseReadyTime(printTime, true);

                        let time = readyTimeByRegion.split('-');
                        if (time[1].length === 1) time[1] = "0" + time[1];
                        if (time[2].length === 1) time[2] = "0" + time[2];

                        finaldate = time[2] + '.' + time[1] + '.' + time[0];

                        let $dateReady = $('.dateReady');
                        let $pickUpDate = $('.cPickUpDate');
                        $('.actualDateReady').val(prel_date);
                        $dateReady.html(finaldate);
                        $pickUpDate.html(finaldate);

                        if (instanceForOffset.isPartnerHost())
                        {
                            // old variant
                            $('.deliveryDate').text($('.dateReady').html());
                        }
                        else
                        {
                            let dateReadyDate = $dateReady.html().split('.');
                            setDeliveryDate({d: dateReadyDate[0], m: dateReadyDate[1], y: dateReadyDate[2]}, 10);
                        }

                        let $addrHd = $('.del_addr_hd');
                        $addrHd.val('');
                        $addrHd.css('border-color', '');
                        //РќРѕРІРѕРµ С‡РёСЃС‚РёРј РїРѕСЃР»Рµ DPD РљРћРќР•Р¦

                        var total_cost = Number($printCost.html());

                        var real_total_cost = 0;
                        if (instanceForOffset.isPartnerHost()) real_total_cost = Number($('.realPrintCost').html());

                        $('.dpd_delivery .cDPD_terminal_selection').css('display', 'none');
                        $('.check_delivery .sp_points').css('display', 'none');

                        var newDate = '';
                        // РЎР°РјРѕРІС‹РІРѕР·
                        if ($(this).hasClass("radioPickUp"))
                        {

                            $('.pickup .SPP_List').parent().find('tr').each(function () {
                                $(this).removeClass();
                            });

                            $('.deliveryCost').text(0);
                            $totalCost.text(total_cost);
                            if (instanceForOffset.isPartnerHost()) $('.realTotalCost').text(real_total_cost);

                            if ($('.pickup .SPP_List tr').length === 1)
                            {
                                $('.pickup .SPP_List tr').trigger('click');
                            }
                            else
                            {
                                newDate = TimeControl.readyTimeDelivery(0);
                                if (instanceForOffset.isPartnerHost())
                                {
                                    // old variant
                                    $('.deliveryDate').text(newDate['d'] + '.' + newDate['m'] + "." + newDate['y']);
                                }
                                else
                                {
                                    setDeliveryDate(newDate, 11);
                                }

                                $pickUpDate.html(newDate['d'] + '.' + newDate['m'] + "." + newDate['y']);
                            }

                        }

                        // РђРґСЂРµСЃРЅР°СЏ
                        if ($(this).hasClass("radioTargeted"))
                        {
                            total_cost += Number($(this).data('price'));
                            $('.deliveryCost').text($(this).data('price'));
                            $totalCost.text(total_cost);

                            newDate = TimeControl.readyTimeDelivery(Number($(this).data('deliveryperiod')));
                            if (instanceForOffset.isPartnerHost())
                            {
                                real_total_cost += Number($(this).data('price'));
                                $('.realTotalCost').text(real_total_cost);

                                // old variant
                                $('.deliveryDate').text(newDate['d'] + '.' + newDate['m'] + "." + newDate['y']);
                            }
                            else
                            {
                                setDeliveryDate(newDate, 12);
                            }
                        }

                        if ($(this).hasClass("radioPickUpDpd"))
                        {
                            $('.dpd_delivery .del_addr, .dpd_delivery .del_addk').html('');
                        }

                        // Р­РєСЃРїСЂРµСЃСЃ
                        if ($(this).hasClass("radioDenVDen"))
                        {
                            let deliveryPrice = $(this).attr("data-price");
                            deliveryPrice = deliveryPrice ? +deliveryPrice : 0;

                            if (deliveryPrice)
                            {
                                total_cost += deliveryPrice;
                                $totalCost.text(total_cost);
                                $deliveryCost.text(deliveryPrice);
                            }
                        }

                        deliveryRegistration.switchType();
                    });
                }

            };

            const addressAutocomplete = new (function () {

                let _this = this;

                this.autocomplete_provider = "yandex";
                this.autocomplete_loaded = true;

                let YandexAutocomplete = function (element, options = {}, property_name = 'ADDRESS_RECOGNIZER_RESULT') {

                    let instance = this;

                    this.state = {};

                    this.suggestView = null;

                    this.getPlace = function () {
                        return !!instance.state.google_format ? instance.state.google_format : {};
                    };

                    this.destroy = function () {
                        if (!!instance.suggestView) instance.suggestView.destroy();
                    };

                    const createSuggest = function ($info, $input, inputData) {

                        $input.on('input', function () {
                            $input.css('color', '#f00');
                            $input.attr('data-changed', 'true');
                        });

                        let SuggestViewOptions = {};

                        if (options.hasOwnProperty('before'))
                        {
                            let before = options.before;

                            SuggestViewOptions = {
                                provider: {
                                    suggest: (function (request, options) {
                                        return ymaps.suggest(before + request);
                                    })
                                }
                            }
                        }

                        instance.suggestView = new ymaps.SuggestView(element, SuggestViewOptions);

                        if (!!options.callbackSelect)
                        {
                            instance.suggestView.events.add('select', function (event) {

                                $info.hide();
                                $input.css('color', inputData.color).attr('data-changed', 'false');

                                let address = event.originalEvent.item.value.trim();

                                $.ajax({
                                    type: 'GET',
                                    url: '/AJAX/geocode.php',
                                    data: {address},
                                    dataType: 'json',
                                    success: (response) =&gt; {
                                        if (response.success)
                                        {
                                            instance.state = response.components;
                                            window[property_name] = response.components;
                                            options.callbackSelect(instance.state);
                                        }
                                    },
                                    error: () =&gt; {
                                        instance.state = {};
                                        options.callbackSelect(instance.state);
                                    }
                                });

                            });
                        }

                        $input.focus().blur();
                        setTimeout(function () {
                            $input.focus();
                        }, 25);
                    };

                    const __initialize = function () {
                        // notification
                        let $input = $(element),
                            inputData = {color: $input.css('color')};

                        let $info = $(`
                    &lt;div
                        class="__info"
                        style="
                            display: block;
                            position: absolute;
                            top: 0;
                            left: 0;
                            z-index: 40000;
        
                            margin: 0;
                            padding: 0.3rem;
                            width: 0;
                            box-sizing: border-box;
        
                            text-align: center;
                            font-size: 0.8rem;
                            font-style: normal;
                            font-weight: bold;
        
                            color: #482d1d;
                            background-color: #ffded1;
                            border: 1px solid #979797;
                            display: none;
                        "
                        &gt;РќР°С‡РЅРёС‚Рµ РІРІРѕРґРёС‚СЊ Р°РґСЂРµСЃ Рё Р’Р«Р‘Р•Р&nbsp;РРўР• РџР&nbsp;Р•Р”Р›РћР–Р•РќРќР«Р™ Р’РђР&nbsp;РРђРќРў.&lt;/div&gt;`);

                        $input.before($info);

                        let onResizeOrPos = function () {
                            let {top, left} = $input.position();

                            let infoData = {
                                w: +$info.outerWidth(),
                                h: +$info.outerHeight(),
                            };

                            $info.css('width', $input.outerWidth());
                            $info.css({
                                top: (+top - $info.outerHeight()),
                                left: left
                            });
                        };

                        $input
                            .onPositionChanged(function () {
                                onResizeOrPos();
                            })
                            .resize(function () {
                                onResizeOrPos();
                            })
                            .on('focus', function () {
                                $info.show();
                                onResizeOrPos();
                                if (!instance.suggestView) createSuggest($info, $input, inputData);
                            })
                            .on('blur focusout', function () {
                                if ($(this).attr('data-changed') !== 'true') $info.hide();
                            });
                    };

                    __initialize();
                };

                function fillInAddress_to_targeted() {

                    let targeted_componentForm_to = {
                        street_number: {
                            gid: 'short_name',
                            iid: 'targeted_to_street_number'
                        },
                        route: {
                            gid: 'long_name',
                            iid: 'targeted_to_street'
                        },
                        locality: {
                            gid: 'long_name',
                            iid: 'targeted_to_city'
                        },
                        administrative_area_level_1: {
                            gid: 'short_name',
                            iid: 'targeted_to_region'
                        },
                        country: {
                            gid: 'long_name',
                            iid: 'targeted_to_country'
                        }
                    };

                    let place = autocomplete_to_targeted.getPlace();

                    for (let component in targeted_componentForm_to)
                    {
                        document.getElementById(targeted_componentForm_to[component]['iid']).value = '';
                    }

                    for (let i = 0; i &lt; place.address_components.length; i++)
                    {
                        var addressType = place.address_components[i].types[0];
                        if (targeted_componentForm_to[addressType])
                        {
                            document.getElementById(targeted_componentForm_to[addressType]['iid']).value = place.address_components[i][targeted_componentForm_to[addressType]['gid']];
                        }
                    }

                    $('#targeted_delivery .del_addr_hd').val($('#targeted_to_street_number').val());
                    $('#targeted_delivery .del_addr').val($('#targeted_to_street').val());
                }

                function fillInAddress_to_denvden() {

                    let denvden_componentForm_to = {
                        street_number: {
                            gid: 'short_name',
                            iid: 'denvden_to_street_number'
                        },
                        route: {
                            gid: 'long_name',
                            iid: 'denvden_to_street'
                        },
                        locality: {
                            gid: 'long_name',
                            iid: 'denvden_to_city'
                        },
                        administrative_area_level_1: {
                            gid: 'short_name',
                            iid: 'denvden_to_region'
                        },
                        country: {
                            gid: 'long_name',
                            iid: 'denvden_to_country'
                        }
                    };

                    var place = autocomplete_to_denvden.getPlace();

                    for (var component in denvden_componentForm_to)
                    {
                        document.getElementById(denvden_componentForm_to[component]['iid']).value = '';
                    }

                    for (var i = 0; i &lt; place.address_components.length; i++)
                    {
                        var addressType = place.address_components[i].types[0];
                        if (denvden_componentForm_to[addressType])
                        {
                            document.getElementById(denvden_componentForm_to[addressType]['iid']).value = place.address_components[i][denvden_componentForm_to[addressType]['gid']];
                        }
                    }


                    $('#denvden_delivery .del_addr_hd').val($('#denvden_to_street_number').val());
                    $('#denvden_delivery .denvden_del_addr').val($('#denvden_to_street').val());
                }

                function fillInAddress_to_offset() {

                    let componentForm_to = {
                        street_number: {
                            gid: 'short_name',
                            iid: 'to_street_number'
                        },
                        route: {
                            gid: 'long_name',
                            iid: 'to_street'
                        },
                        locality: {
                            gid: 'long_name',
                            iid: 'to_city'
                        },
                        administrative_area_level_1: {
                            gid: 'short_name',
                            iid: 'to_region'
                        },
                        country: {
                            gid: 'long_name',
                            iid: 'to_country'
                        }
                    };


                    var place = autocomplete_to_offset.getPlace();

                    for (var component in componentForm_to)
                    {
                        document.getElementById(componentForm_to[component]['iid']).value = '';
                    }

                    for (var i = 0; i &lt; place.address_components.length; i++)
                    {
                        var addressType = place.address_components[i].types[0];
                        if (componentForm_to[addressType])
                        {
                            document.getElementById(componentForm_to[addressType]['iid']).value = place.address_components[i][componentForm_to[addressType]['gid']];
                        }
                    }

                    $('.dpdTargetedBlock .del_addr_hd').val($('.delivery_block_ad_of_dpd #to_street_number').val());
                    $('.dpdTargetedBlock .del_addr').val($('.delivery_block_ad_of_dpd #to_street').val());
                }

                function fillInAddress_to_rostov() {

                    let rostov_componentForm_to = {
                        street_number: {
                            gid: 'short_name',
                            iid: 'rostov_to_street_number'
                        },
                        route: {
                            gid: 'long_name',
                            iid: 'rostov_to_street'
                        },
                        locality: {
                            gid: 'long_name',
                            iid: 'rostov_to_city'
                        },
                        administrative_area_level_1: {
                            gid: 'short_name',
                            iid: 'rostov_to_region'
                        },
                        country: {
                            gid: 'long_name',
                            iid: 'rostov_to_country'
                        }
                    };


                    var place = autocomplete_to_rostov.getPlace();

                    for (var component in rostov_componentForm_to)
                    {
                        document.getElementById(rostov_componentForm_to[component]['iid']).value = '';
                    }

                    for (var i = 0; i &lt; place.address_components.length; i++)
                    {
                        var addressType = place.address_components[i].types[0];
                        if (rostov_componentForm_to[addressType])
                        {
                            document.getElementById(rostov_componentForm_to[addressType]['iid']).value = place.address_components[i][rostov_componentForm_to[addressType]['gid']];
                        }
                    }

                    $('#targeted_delivery .del_addr_hd').val($('#rostov_to_street_number').val());
                    $('#targeted_delivery .del_addr').val($('#rostov_to_street').val());
                }

                function fillInAddress_to_kazan() {

                    let kazan_componentForm_to = {
                        street_number: {
                            gid: 'short_name',
                            iid: 'kazan_to_street_number'
                        },
                        route: {
                            gid: 'long_name',
                            iid: 'kazan_to_street'
                        },
                        locality: {
                            gid: 'long_name',
                            iid: 'kazan_to_city'
                        },
                        administrative_area_level_1: {
                            gid: 'short_name',
                            iid: 'kazan_to_region'
                        },
                        country: {
                            gid: 'long_name',
                            iid: 'kazan_to_country'
                        }
                    };


                    var place = autocomplete_to_kazan.getPlace();

                    for (var component in kazan_componentForm_to)
                    {
                        document.getElementById(kazan_componentForm_to[component]['iid']).value = '';
                    }

                    for (var i = 0; i &lt; place.address_components.length; i++)
                    {
                        var addressType = place.address_components[i].types[0];
                        if (kazan_componentForm_to[addressType])
                        {
                            document.getElementById(kazan_componentForm_to[addressType]['iid']).value = place.address_components[i][kazan_componentForm_to[addressType]['gid']];
                        }
                    }


                    $('#kazan_delivery .del_addr_hd').val($('#kazan_to_street_number').val());
                    $('#kazan_delivery .del_addr').val($('#kazan_to_street').val());
                }

                function fillInAddress_to() {

                    let componentForm_to = {
                        street_number: {
                            gid: 'short_name',
                            iid: 'to_street_number'
                        },
                        route: {
                            gid: 'long_name',
                            iid: 'to_street'
                        },
                        locality: {
                            gid: 'long_name',
                            iid: 'to_city'
                        },
                        administrative_area_level_1: {
                            gid: 'short_name',
                            iid: 'to_region'
                        },
                        country: {
                            gid: 'long_name',
                            iid: 'to_country'
                        }
                    };

                    var place = autocomplete_to.getPlace();

                    for (var component in componentForm_to)
                    {
                        document.getElementById(componentForm_to[component]['iid']).value = '';
                    }

                    for (var i = 0; i &lt; place.address_components.length; i++)
                    {
                        var addressType = place.address_components[i].types[0];
                        if (componentForm_to[addressType])
                        {
                            document.getElementById(componentForm_to[addressType]['iid']).value = place.address_components[i][componentForm_to[addressType]['gid']];
                        }
                    }

                    $('.large_delivery #dpdTargetedBlock .del_addr_hd').val($('.delivery_block_ad_of_dpd #to_street_number').val());
                    $('#dpdTargetedBlock .del_addr').val($('.delivery_block_ad_of_dpd #to_street').val());
                }

                function large_fillInAddress_to_rostov() {

                    let large_rostov_componentForm_to = {
                        street_number: {
                            gid: 'short_name',
                            iid: 'large_rostov_to_street_number'
                        },
                        route: {
                            gid: 'long_name',
                            iid: 'large_rostov_to_street'
                        },
                        locality: {
                            gid: 'long_name',
                            iid: 'large_rostov_to_city'
                        },
                        administrative_area_level_1: {
                            gid: 'short_name',
                            iid: 'large_rostov_to_region'
                        },
                        country: {
                            gid: 'long_name',
                            iid: 'large_rostov_to_country'
                        }
                    };

                    var place = large_autocomplete_to_rostov.getPlace();

                    for (var component in large_rostov_componentForm_to)
                    {
                        document.getElementById(large_rostov_componentForm_to[component]['iid']).value = '';
                    }

                    for (var i = 0; i &lt; place.address_components.length; i++)
                    {
                        var addressType = place.address_components[i].types[0];
                        if (large_rostov_componentForm_to[addressType])
                        {
                            document.getElementById(large_rostov_componentForm_to[addressType]['iid']).value = place.address_components[i][large_rostov_componentForm_to[addressType]['gid']];
                        }
                    }
                    //РњРѕСЃРєРѕРІСЃРєР°СЏ РѕР±Р»Р°СЃС‚СЊ
                    if ($('#large_rostov_to_region').val() === 'РњРћ')
                    {
                        $('#large_rostov_to_region').val('РњРѕСЃРєРѕРІСЃРєР°СЏ РѕР±Р»Р°СЃС‚СЊ');
                    }
                    // РљРѕСЃС‚С‹Р»СЊ РґР»СЏ СЂРµРіРёРѕРЅРѕРІ РњРѕСЃРєРІС‹
                    var city_in_moscow = 'Р©РµСЂР±РёРЅРєР°';
                    if ($('#large_targeted_delivery .del_large_rostov').val().toLowerCase().indexOf(city_in_moscow.toLowerCase()) !== -1)
                    {
                        $('#large_rostov_to_city').val(city_in_moscow);
                    }
                    var city_in_moscow = 'РўСЂРѕРёС†Рє';
                    if ($('#large_targeted_delivery .del_large_rostov').val().toLowerCase().indexOf(city_in_moscow.toLowerCase()) !== -1)
                    {
                        $('#large_rostov_to_city').val(city_in_moscow);
                    }


                    $('#large_targeted_delivery .del_addr_hd').val($('#large_rostov_to_street_number').val());
                    $('#large_targeted_delivery .del_addr').val($('#large_rostov_to_street').val());
                }

                function large_fillInAddress_to_kazan() {

                    let large_kazan_componentForm_to = {
                        street_number: {
                            gid: 'short_name',
                            iid: 'large_kazan_to_street_number'
                        },
                        route: {
                            gid: 'long_name',
                            iid: 'large_kazan_to_street'
                        },
                        locality: {
                            gid: 'long_name',
                            iid: 'large_kazan_to_city'
                        },
                        administrative_area_level_1: {
                            gid: 'short_name',
                            iid: 'large_kazan_to_region'
                        },
                        country: {
                            gid: 'long_name',
                            iid: 'large_kazan_to_country'
                        }
                    };

                    var place = large_autocomplete_to_kazan.getPlace();

                    for (var component in large_kazan_componentForm_to)
                    {
                        document.getElementById(large_kazan_componentForm_to[component]['iid']).value = '';
                    }

                    for (var i = 0; i &lt; place.address_components.length; i++)
                    {
                        var addressType = place.address_components[i].types[0];
                        if (large_kazan_componentForm_to[addressType])
                        {
                            document.getElementById(large_kazan_componentForm_to[addressType]['iid']).value = place.address_components[i][large_kazan_componentForm_to[addressType]['gid']];
                        }
                    }
                    $('#large_kazan_delivery .del_addr').val($('#large_kazan_to_street').val() + ', ' + $('#large_kazan_to_street_number').val());
                }

                function YandexAutocompleteCreate(varname, callback) {
                    //YANDEX
                    if (window.hasOwnProperty(varname))
                    {
                        if (typeof window[varname] !== "undefined" &amp;&amp; window[varname].hasOwnProperty('destroy'))
                        {
                            window[varname].destroy();
                        }

                        let element = document.getElementsByClassName('del_targeted')[0];
                        if (element)
                        {
                            window[varname] = new YandexAutocomplete(element, {
                                before: 'Р&nbsp;РѕСЃСЃРёСЏ, ',
                                callbackSelect: callback
                            });
                        }
                    }
                }

                this.destroy = function (type = "") {
                    if (type === "D")
                    {
                        if (_this.autocomplete_provider === "yandex")
                        {
                            const names = [
                                "autocomplete_to_targeted",
                                "autocomplete_to_denvden",
                                "autocomplete_to_offset",
                            ];

                            for (const name of names)
                            {
                                if (window.hasOwnProperty(name))
                                {
                                    if (typeof window[name] !== "undefined" &amp;&amp; window[name].hasOwnProperty('destroy'))
                                    {
                                        // console.debug("destroy", name);
                                        window[name].destroy();
                                    }
                                }
                            }
                        }
                    }
                };

                this.create = function (type = "") {

                    _this.destroy(type);
                    if (!!window.DeliveryForm) DeliveryForm.load();

                    if (type === "D")
                    {
                        if (deliveryLocationSelector)
                        {
                            window.deliveryLocationSelectorInstance = new deliveryLocationSelector();
                        }
                        else
                        {
                            $('.dpd_city.cCityForDPD').show();
                        }

                        if (_this.autocomplete_provider === "yandex")
                        {
                            const names = [
                                ["autocomplete_to_targeted", "del_targeted", fillInAddress_to_targeted],
                                ["autocomplete_to_denvden", "del_denvden", fillInAddress_to_denvden],
                                ["autocomplete_to_offset", "delivery_to", fillInAddress_to_offset],
                            ];

                            for (const [name, className, callbackSelect] of names)
                            {
                                if (window.hasOwnProperty(name))
                                {
                                    let element = document.getElementsByClassName(className)[0];
                                    if (element)
                                    {
                                        window[name] = new YandexAutocomplete(element, {
                                            before: 'Р&nbsp;РѕСЃСЃРёСЏ, ',
                                            callbackSelect: callbackSelect
                                        });
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (_this.autocomplete_provider === "yandex")
                        {
                            YandexAutocompleteCreate('autocomplete_to_offset', fillInAddress_to_offset);
                            YandexAutocompleteCreate('autocomplete_to_rostov', fillInAddress_to_rostov);
                            YandexAutocompleteCreate('autocomplete_to_kazan', fillInAddress_to_kazan);
                            YandexAutocompleteCreate('autocomplete_to', fillInAddress_to);
                            YandexAutocompleteCreate('large_autocomplete_to_rostov', large_fillInAddress_to_rostov);
                            YandexAutocompleteCreate('large_autocomplete_to_kazan', large_fillInAddress_to_kazan);
                        }
                    }
                }
            })();

            this.createAutocomplete = type =&gt; addressAutocomplete.create(type);

            // dev-note: radioDenVDen
            this.openTab = function (element, deliveryTitle) {
                // Declare all variables
                let i, tabcontent, tablinks;
                // Get all elements with class="tabcontent" and hide them
                tabcontent = document.getElementsByClassName("tabcontent");
                for (i = 0; i &lt; tabcontent.length; i++)
                {
                    tabcontent[i].style.display = "none";

                }
                // Get all elements with class="tablinks" and remove the class "active"
                tablinks = document.getElementsByClassName(element.className);
                for (i = 0; i &lt; tablinks.length; i++)
                {
                    tablinks[i].className = tablinks[i].className.replace(" active", "");
                }

                // Show the current tab, and add an "active" class to the button that opened the tab
                //document.getElementById(deliveryTitle).style.display = "block";
                let tabs = document.getElementsByClassName(deliveryTitle);
                for (i = 0; i &lt; tabs.length; i++)
                {
                    tabs[i].style.display = "block";
                }
                //evt.currentTarget.className += " active";
                $(element).addClass('active');

                DeliveryInstance.setMethod(deliveryTitle);
            }


        })();

        // this + large
        window.TimeControl = new (function() {

            let instance = this;

            this.serverTime = false;

            this.getServerTime = function() {
                $.ajax({
                    type: 'POST',
                    data: {
                        CURRENT_PRODUCT_ID: $('#table_info').val(),
                        FORMAT: 'json'
                    },
                    url: "/AJAX/get_server_time.php",
                    async: false,
                    dataType: 'json',
                    success: function (response) {
                        instance.serverTime = {
                            requestTimestamp: Date.now(),
                            response: response
                        };
                    }
                });
            }

            // + РёСЃРїРѕР»СЊР·СѓРµС‚СЃСЏ РІ JS/kabinet_largeFormat_rostov.js
            this.parseReadyTime = function(duration, flag) {
                if (!instance.serverTime || Date.now() - instance.serverTime.requestTimestamp &gt; 100)
                {
                    instance.getServerTime();
                }

                var date = instance.serverTime.response.datetime;
                let dateOptions = instance.serverTime.response.options;


                // РґРѕР±Р°РІР»СЏРµРј С„Р»Р°Р¶РѕРє РґР»СЏ РїРµСЂРµРєР»СЋС‡РµРЅРёСЏ РјРµР¶РґСѓ РјРµРµРґР¶РµСЂСЃРєРёРј Рё РєР»РёРµРЅС‚СЃРєРёРј РІСЂРµРјРµРЅРµРј
                var weekDay = new Date(date);
                var curr_time = new Date(date);
                var time = new Date(date);
                var firstFlag = 0;
                var curr_dur = 0;
                var realy_dur = 0;

                let offset = curr_time.getHours() &gt;= 15 || (curr_time.getHours() == 14 &amp;&amp; curr_time.getMinutes() &gt;= 50) || !!dateOptions.offset;

                if (~duration.indexOf('С‡Р°СЃ')) {
                    duration = duration.split(' ')[2];
                    duration = duration / 24;
                    //Р”РѕР±Р°РІР»СЏРµРј РґРЅРё РЅР° РґРѕСЃС‚Р°РІРєСѓ
                    if (flag) {
                        duration += extra_day;
                    }


                    // -&gt;&gt;&gt;
                    if (offset)
                    {
                        calendar_weekdays.forEach(function (entry) {
                            var test = new Date(entry);
                            if (curr_time.getDay() == test.getDay())
                            {
                                firstFlag = 1;
                            }
                        });

                        if (firstFlag || (curr_time.getDay() != 0 &amp;&amp; curr_time.getDay() != 6))
                        {
                            var to_continue = true;
                            for (var i = 0; i &lt; calendar.length; i++)
                            {
                                var curr_day = calendar[i].split('-');
                                if (curr_time.getFullYear() == curr_day[0] &amp;&amp; (curr_time.getMonth() + 1) == curr_day[1] &amp;&amp; curr_time.getDate() == curr_day[2])
                                {
                                    to_continue = false;
                                }
                            }
                            if (to_continue)
                            {
                                duration++;
                            }
                        }

                    }
                    // &lt;&lt;&lt;-

                    while (curr_dur &lt;= duration) {
                        time = new Date(date);
                        time.setDate(curr_time.getDate() + realy_dur);
                        var weekDayFlag = -1;
                        calendar_weekdays.forEach(function (entry) {
                            weekDay = new Date(entry);
                            if (time.getDate() == weekDay.getDate() &amp;&amp; time.getMonth() == weekDay.getMonth() &amp;&amp; time.getFullYear() == weekDay.getFullYear()) {
                                weekDayFlag = 1;
                            }
                        });
                        if (weekDayFlag == 1) {
                            realy_dur++;
                            curr_dur++;
                            continue;
                        }
                        if (time.getDay() == 0 || time.getDay() == 6) {
                            realy_dur++;
                            continue;
                        }
                        var to_countinue = false;
                        for (var i = 0; i &lt; calendar.length; i++) {
                            var curr_day = calendar[i].split('-');
                            if (time.getFullYear() == curr_day[0] &amp;&amp; (time.getMonth() + 1) == curr_day[1] &amp;&amp; time.getDate() == curr_day[2]) {
                                realy_dur++;
                                to_countinue = true;
                                continue;
                            }
                        }
                        if (to_countinue) {
                            continue;
                        }
                        realy_dur++;
                        curr_dur++;
                    }
                    return time.getFullYear() + '-' + (time.getMonth() + 1) + '-' + time.getDate();
                }

                if (~duration.indexOf(' РЅРµРґРµР»')) // space is required!
                {
                    duration = duration.split(' ')[0];
                    duration = duration * 7;
                    //Р”РѕР±Р°РІР»СЏРµРј РґРЅРё РЅР° РґРѕСЃС‚Р°РІРєСѓ
                    if (flag) {
                        duration += extra_day;
                    }
                    if (curr_time.getHours() &gt;= 15 || (curr_time.getHours() === 14 &amp;&amp; curr_time.getMinutes() &gt;= 50)) {
                        realy_dur++;
                    }
                    time = new Date(date);
                    time.setDate(curr_time.getDate() + realy_dur);
                    while (time.getDay() !=  4)
                    {
                        realy_dur++;
                        time.setDate(curr_time.getDate() + realy_dur);
                    }
                    realy_dur = realy_dur + duration;

                    let exit = false;

                    while (!exit) {
                        time = new Date(date);
                        time.setDate(curr_time.getDate() + realy_dur);
                        var weekDayFlag = -1;
                        calendar_weekdays.forEach(function (entry) {
                            weekDay = new Date(entry);
                            if (time.getDate() == weekDay.getDate() &amp;&amp; time.getMonth() == weekDay.getMonth() &amp;&amp; time.getFullYear() == weekDay.getFullYear()) {
                                weekDayFlag = 1;
                            }
                        });
                        if (weekDayFlag == 1) {
                            realy_dur++;
                            continue;
                        }
                        if (time.getDay() == 0 || time.getDay() == 6) {
                            realy_dur++;
                            continue;
                        }
                        exit = true;
                    }
                    return time.getFullYear() + '-' + (time.getMonth() + 1) + '-' + time.getDate();
                }
                if (~duration.indexOf('РїРѕРЅРµРґ') || ~duration.indexOf('РІС‚РѕСЂ') || ~duration.indexOf('СЃСЂРµРґ') || ~duration.indexOf('С‡РµС‚РІ') || ~duration.indexOf('РїСЏС‚РЅ') || ~duration.indexOf('СЃСѓР±Р±') || ~duration.indexOf('РІРѕСЃРєСЂ')) {

                    var week = ['Р’СЃ', 'РџРЅ', 'Р’С‚', 'РЎСЂ', 'Р§С‚', 'РџС‚', 'РЎР±'];
                    var day_of_week = 0;
                    if (~duration.indexOf('РїРѕРЅРµРґ'))
                        day_of_week = 1;
                    if (~duration.indexOf('РІС‚РѕСЂ'))
                        day_of_week = 2;
                    if (~duration.indexOf('СЃСЂРµРґ'))
                        day_of_week = 3;
                    if (~duration.indexOf('С‡РµС‚РІ'))
                        day_of_week = 4;
                    if (~duration.indexOf('РїСЏС‚РЅ'))
                        day_of_week = 5;
                    if (~duration.indexOf('СЃСѓР±Р±'))
                        day_of_week = 6;
                    if (~duration.indexOf('РІРѕСЃРєСЂ'))
                        day_of_week = 0;
                    var counter = 1;
                    if (flag) {
                        counter += extra_day;
                    }
                    var time = new Date(date);
                    curr_time = new Date(date);
                    //console.log(curr_time);
                    //console.log(date);
                    if (day_of_week == curr_time.getDay() + 2 &amp;&amp; offset) {
                        counter++;
                    } else if (day_of_week == curr_time.getDay() + 1) {
                        counter++;
                    }
                    else {
                        if (day_of_week == 1 &amp;&amp; (curr_time.getDay() == 6 || curr_time.getDay() == 0)) {
                            counter += 2;
                        }
                        else {
                            if (day_of_week == 1 &amp;&amp; curr_time.getDay() == 5 &amp;&amp; offset) {
                                counter += 3;
                            }
                        }
                    }
                    var open = true;
                    if (counter == 1) {
                        var time = new Date(date);
                        time.setDate(time.getDate() + counter);
                        open = false;
                    }
                    if (time.getDay() == day_of_week &amp;&amp; open) {
                        var time = new Date(date);
                        counter++;
                        time.setDate(time.getDate() + counter);
                    }

                    for (var i = 0; i &lt; calendar.length; i++) {
                        var curr_day = calendar[i].split('-');
                        if (time.getFullYear() == curr_day[0] &amp;&amp; (time.getMonth() + 1) == curr_day[1] &amp;&amp; time.getDate() == curr_day[2]) {
                            counter++;
                            var time = new Date(date);
                            time.setDate(curr_time.getDate() + counter);
                        }
                    }

                    while (time.getDay() != day_of_week) {
                        var time = new Date(date);
                        counter++;
                        time.setDate(time.getDate() + counter);
                        for (var i = 0; i &lt; calendar.length; i++) {
                            var curr_day = calendar[i].split('-');
                            if (time.getFullYear() == curr_day[0] &amp;&amp; (time.getMonth() + 1) == curr_day[1] &amp;&amp; time.getDate() == curr_day[2]) {
                                counter++;
                                var time = new Date(date);
                                time.setDate(curr_time.getDate() + counter);
                            }
                        }
                    }
                    return time.getFullYear() + '-' + (time.getMonth() + 1) + '-' + time.getDate();
                }
            };

            this.parseReadyTimeByRegion = function(date, duration, flag) {
                // РґРѕР±Р°РІР»СЏРµРј С„Р»Р°Р¶РѕРє РґР»СЏ РїРµСЂРµРєР»СЋС‡РµРЅРёСЏ РјРµР¶РґСѓ РјРµРµРґР¶РµСЂСЃРєРёРј Рё РєР»РёРµРЅС‚СЃРєРёРј РІСЂРµРјРµРЅРµРј
                var weekDay = new Date(date);
                var curr_time = new Date(date);
                var time = new Date(date);
                var firstFlag = 0;
                var curr_dur = 0;
                var realy_dur = 0;
                if (~duration.indexOf('С‡Р°СЃ')) {
                    duration = duration.split(' ')[2];
                    duration = duration / 24;
                    //Р”РѕР±Р°РІР»СЏРµРј РґРЅРё РЅР° РґРѕСЃС‚Р°РІРєСѓ
                    if (flag) {
                        duration += extra_day;
                    }
                    if (curr_time.getHours() &gt;= 15 || (curr_time.getHours() == 14 &amp;&amp; curr_time.getMinutes() &gt;= 50)) {
                        calendar_weekdays.forEach(function (entry) {
                            var test = new Date(entry);
                            if (curr_time.getDay() == test.getDay()) {
                                firstFlag = 1;
                            }
                        });
                        if (firstFlag || (curr_time.getDay() != 0 &amp;&amp; curr_time.getDay() != 6)) {
                            var to_continue = true;
                            for (var i = 0; i &lt; calendar.length; i++) {
                                var curr_day = calendar[i].split('-');
                                if (curr_time.getFullYear() == curr_day[0] &amp;&amp; (curr_time.getMonth() + 1) == curr_day[1] &amp;&amp; curr_time.getDate() == curr_day[2]) {
                                    to_continue = false;
                                }
                            }
                            if (to_continue) {
                                duration++;
                            }
                        }

                    }

                    while (curr_dur &lt;= duration) {
                        time = new Date(date);
                        time.setDate(curr_time.getDate() + realy_dur);
                        var weekDayFlag = -1;
                        calendar_weekdays.forEach(function (entry) {
                            weekDay = new Date(entry);
                            if (time.getDate() == weekDay.getDate() &amp;&amp; time.getMonth() == weekDay.getMonth() &amp;&amp; time.getFullYear() == weekDay.getFullYear()) {
                                weekDayFlag = 1;
                            }
                        });
                        if (weekDayFlag == 1) {
                            realy_dur++;
                            curr_dur++;
                            continue;
                        }
                        if (time.getDay() == 0 || time.getDay() == 6) {
                            realy_dur++;
                            continue;
                        }
                        var to_countinue = false;
                        for (var i = 0; i &lt; calendar.length; i++) {
                            var curr_day = calendar[i].split('-');
                            if (time.getFullYear() == curr_day[0] &amp;&amp; (time.getMonth() + 1) == curr_day[1] &amp;&amp; time.getDate() == curr_day[2]) {
                                realy_dur++;
                                to_countinue = true;
                                continue;
                            }
                        }
                        if (to_countinue) {
                            continue;
                        }
                        realy_dur++;
                        curr_dur++;
                    }
                    return time.getFullYear() + '-' + (time.getMonth() + 1) + '-' + time.getDate();
                }

                if (~duration.indexOf(' РЅРµРґРµР»')) // space is required!
                {
                    duration = duration.split(' ')[0];
                    duration = duration * 7;
                    //Р”РѕР±Р°РІР»СЏРµРј РґРЅРё РЅР° РґРѕСЃС‚Р°РІРєСѓ
                    if (flag) {
                        duration += extra_day;
                    }
                    if (curr_time.getHours() &gt;= 15 || (curr_time.getHours() == 14 &amp;&amp; curr_time.getMinutes() &gt;= 50)) {
                        realy_dur++;
                    }
                    time = new Date(date);
                    time.setDate(curr_time.getDate() + realy_dur);
                    while (time.getDay() !=  4)
                    {
                        realy_dur++;
                        time.setDate(curr_time.getDate() + realy_dur);
                    }
                    realy_dur = realy_dur + duration;

                    let exit = false;

                    while (!exit) {
                        time = new Date(date);
                        time.setDate(curr_time.getDate() + realy_dur);
                        var weekDayFlag = -1;
                        calendar_weekdays.forEach(function (entry) {
                            weekDay = new Date(entry);
                            if (time.getDate() == weekDay.getDate() &amp;&amp; time.getMonth() == weekDay.getMonth() &amp;&amp; time.getFullYear() == weekDay.getFullYear()) {
                                weekDayFlag = 1;
                            }
                        });
                        if (weekDayFlag == 1) {
                            realy_dur++;
                            continue;
                        }
                        if (time.getDay() == 0 || time.getDay() == 6) {
                            realy_dur++;
                            continue;
                        }
                        exit = true;
                    }
                    return time.getFullYear() + '-' + (time.getMonth() + 1) + '-' + time.getDate();
                }

                if (~duration.indexOf('РїРѕРЅРµРґ') || ~duration.indexOf('РІС‚РѕСЂ') || ~duration.indexOf('СЃСЂРµРґ') || ~duration.indexOf('С‡РµС‚РІ') || ~duration.indexOf('РїСЏС‚РЅ') || ~duration.indexOf('СЃСѓР±Р±') || ~duration.indexOf('РІРѕСЃРєСЂ')) {

                    var week = ['Р’СЃ', 'РџРЅ', 'Р’С‚', 'РЎСЂ', 'Р§С‚', 'РџС‚', 'РЎР±'];
                    var day_of_week = 0;
                    if (~duration.indexOf('РїРѕРЅРµРґ'))
                        day_of_week = 1;
                    if (~duration.indexOf('РІС‚РѕСЂ'))
                        day_of_week = 2;
                    if (~duration.indexOf('СЃСЂРµРґ'))
                        day_of_week = 3;
                    if (~duration.indexOf('С‡РµС‚РІ'))
                        day_of_week = 4;
                    if (~duration.indexOf('РїСЏС‚РЅ'))
                        day_of_week = 5;
                    if (~duration.indexOf('СЃСѓР±Р±'))
                        day_of_week = 6;
                    if (~duration.indexOf('РІРѕСЃРєСЂ'))
                        day_of_week = 0;
                    var counter = 1;
                    if (flag) {
                        counter += extra_day;
                    }
                    var time = new Date(date);
                    curr_time = new Date(date);
                    //console.log(curr_time);
                    //console.log(date);
                    if (day_of_week == curr_time.getDay() + 2 &amp;&amp; (curr_time.getHours() &gt;= 15 || (curr_time.getHours() == 14 &amp;&amp; curr_time.getMinutes() &gt;= 50))) {
                        counter++;
                    } else if (day_of_week == curr_time.getDay() + 1) {
                        counter++;
                    }
                    else {
                        if (day_of_week == 1 &amp;&amp; (curr_time.getDay() == 6 || curr_time.getDay() == 0)) {
                            counter += 2;
                        }
                        else {
                            if (day_of_week == 1 &amp;&amp; curr_time.getDay() == 5 &amp;&amp; (curr_time.getHours() &gt; 15 || (curr_time.getHours() == 14 &amp;&amp; curr_time.getMinutes() &gt;= 50))) {
                                counter += 3;
                            }
                        }
                    }
                    var open = true;
                    if (counter == 1) {
                        var time = new Date(date);
                        time.setDate(time.getDate() + counter);
                        open = false;
                    }
                    if (time.getDay() == day_of_week &amp;&amp; open) {
                        var time = new Date(date);
                        counter++;
                        time.setDate(time.getDate() + counter);
                    }
                    while (time.getDay() != day_of_week) {
                        var time = new Date(date);
                        counter++;
                        time.setDate(time.getDate() + counter);
                        for (var i = 0; i &lt; calendar.length; i++) {
                            var curr_day = calendar[i].split('-');
                            if (time.getFullYear() == curr_day[0] &amp;&amp; (time.getMonth() + 1) == curr_day[1] &amp;&amp; time.getDate() == curr_day[2]) {
                                counter++;
                                var time = new Date(date);
                                time.setDate(curr_time.getDate() + counter);
                            }
                        }
                    }
                    return time.getFullYear() + '-' + (time.getMonth() + 1) + '-' + time.getDate();
                }
            };

            this.readyTimeDeliveryCT = function (date, input_date) {

                //РџРѕРґСЃС‡РµС‚ СЃСЂРѕРєР° РґРѕСЃС‚Р°РІРєРё
                var deliv_date = new Date(date[1] + "/" + date[2] + "/" + date[0]);
                var delive_day = 0;
                while (delive_day &lt; input_date) {
                    deliv_date.setDate(deliv_date.getDate() + 1);
                    var weekDayFlag = false;
                    //РџСЂРѕРІРµСЂСЏРµРј РѕС‚РјРµС‡РµРЅ РґР»СЏ СЃР»РµРґСѓСЋС‰РёР№ РґРµРЅСЊ РєР°Рє СЂР°Р±РѕС‡РёР№ РІ Р°РґРјРёРЅРєРµ
                    calendar_weekdays.forEach(function (entry) {
                        var weekDay = new Date(entry);
                        if (deliv_date.getDate() == weekDay.getDate() &amp;&amp; deliv_date.getMonth() == weekDay.getMonth() &amp;&amp; deliv_date.getFullYear() == weekDay.getFullYear()) {
                            weekDayFlag = true;
                        }
                    });
                    //Р•СЃР»Рё РѕС‚РјРµС‡РµРЅ РІ Р°РґРјРёРЅРєРµ РёР»Рё РЅРµ РІС‹С…РѕРґРЅРѕР№
                    if (weekDayFlag || (deliv_date.getDay() != 0 &amp;&amp; deliv_date.getDay() != 6)) {
                        var to_continue = true;
                        //РџСЂРѕРІРµСЂСЏРµС‚ РЅРµ РѕС‚РјРµС‡РµРЅ Р»Рё РґРµРЅСЊ РІ Р°РґРјРёРЅРєРµ РІС‹С…РѕРґРЅС‹Рј
                        for (var i = 0; i &lt; calendar.length; i++) {
                            var curr_day = calendar[i].split('-');
                            if (deliv_date.getFullYear() == curr_day[0] &amp;&amp; (deliv_date.getMonth() + 1) == curr_day[1] &amp;&amp; deliv_date.getDate() == curr_day[2]) {
                                to_continue = false;
                            }
                        }
                        if (to_continue) {
                            delive_day++;
                        }
                    }
                }

                /******РџСЂРѕРІРµСЂРєР° Р±РѕР»СЊС€Рµ РјРµР»СЊРјРµ Р»Рё СЃРєСЂС‹С‚РѕР№ (СЂРµР°Р»СЊРЅРѕР№) РґР°С‚С‹ РќРђР§РђР›Рћ ******/
                date = $('.dateReady').html().split('.');
                var control_date = new Date(date[1] + "/" + date[0] + "/" + date[2]);
                if (deliv_date &lt; control_date) {
                    deliv_date = control_date;
                }
                /******РџСЂРѕРІРµСЂРєР° Р±РѕР»СЊС€Рµ РјРµР»СЊРјРµ Р»Рё СЃРєСЂС‹С‚РѕР№ (СЂРµР°Р»СЊРЅРѕР№) РґР°С‚С‹ РќРђР§РђР›Рћ ******/

                var day = deliv_date.getDate();
                if (day &lt; 10) {
                    day = "0" + day;
                }
                var month = deliv_date.getMonth() + 1;
                if (month &lt; 10) {
                    month = "0" + month;
                }
                var res = [];
                res['d'] = day;
                res['m'] = month;
                res['y'] = deliv_date.getFullYear();
                return res;
            }

            // Р¤СѓРЅРєС†РёСЏ РґР»СЏ РІСЂРµРјРµРЅРё Р’РѕР»РіРѕРіСЂР°РґСЃРєРѕР№ РґРѕСЃС‚Р°РІРєРё
            this.readyTimeDelivery = function (input_date) {
                let res = [];
                $.ajax({
                    type: 'POST',
                    url: "/AJAX/get_delivery_date.php",
                    data: {
                        'dateReady': $('.dateReady').html(),
                        'delivery_days': input_date
                    },
                    async: false,
                    success: function (data) {
                        res = JSON.parse(data);
                    }
                });
                return res;
            };

            this.readyTimeWidthDelivery = function (arrayDateForUser, deliveryTimeInDays) {
                let withDeliveryDate = new Date(
                    parseInt(arrayDateForUser[0]),
                    parseInt(arrayDateForUser[1]) - 1,
                    parseInt(arrayDateForUser[2]) + parseInt(deliveryTimeInDays)
                );

                let year = withDeliveryDate.getFullYear(),
                    month = withDeliveryDate.getMonth() + 1,
                    day = withDeliveryDate.getDate();

                return {
                    year,
                    month: month.length === 1 ? `0${month}` : month,
                    day: day.length === 1 ? `0${day}`: day
                };
            };
        })();

        // in template (on load)
        window.initAutocomplete = () =&gt; DeliverySection.createAutocomplete();
        window.initAutocompleteD = () =&gt; DeliverySection.createAutocomplete("D"); // for large

        // global functions for block of delivery (used in layout)
        window.openCity = (element, deliveryTitle) =&gt; DeliverySection.openTab(element, deliveryTitle);
        window.openAB = function (deliveryTitle) {
            delivery_type = deliveryTitle;
            $.ajax({
                type: 'POST',
                url: "/AJAX/get_address_book.php",
                async: false,
                success: function (data) {
                    $('#ABModal .modal-body').html(data);
                    $('#ABModal').modal('toggle');
                }
            });
        };
        window.copyToClipboard = function (table, type) {
            // console.log(table);
            let row = '';
            let text = '';
            $('.offset_delivery .' + table).find('tr').each(function () {
                if (type === 'SPP')
                {
                    row = 'РџСѓРЅРєС‚ РІС‹РґР°С‡Рё ' + $(this).data('tk').toUpperCase() + ' ' + $(this).data('city') + ', ' + $(this).data('address');
                }
                else
                {
                    row = 'РџСѓРЅРєС‚ РІС‹РґР°С‡Рё ' + $(this).data('address');
                    row = 'РџСѓРЅРєС‚ РІС‹РґР°С‡Рё ' + $(this).find('td:last-child').text();
                }
                text += row + '\r\n';
            });
            const el = document.createElement('textarea');
            el.value = text;
            el.setAttribute('readonly', '');
            el.style.position = 'absolute';
            el.style.left = '-9999px';
            document.body.appendChild(el);
            el.select();
            document.execCommand('copy');
            document.body.removeChild(el);
        };

        // this + large
        window.GetOwn = function () {
            $.ajax({
                type: 'POST',
                url: "/AJAX/get_own.php",
                async: false,
                success: function (data) {
                    own_region = data;
                }
            });
        };
        // this + large
        window.getUserCityName = function () {
            $.ajax({
                type: 'POST',
                url: "/AJAX/get_user_city_name.php",
                async: false,
                success: function (data) {
                    var name = JSON.parse(data);
                    $('.dpd_city').val(name);
                }
            });
        };
        // this + large
        window.getDeliveryDateFirst = function (type = '') {
            let firstDate = $('.deliveryDate').attr('data-first-date'),
                result = firstDate,
                split = firstDate.split('-');

            if (type === 'assoc')
            {
                result = {d: split[2], m: split[1], y: split[0]};
            }
            else if (type === 'dmy')
            {
                result = `${split[2]}.${split[1]}.${split[0]}`;
            }

            return result;
        };
        // this + large
        window.setDeliveryDate = function (date_array, position = 0) {
            // console.debug('date_array', date_array, 'position', position);

            const dateAddZero = function (value) {
                return +value &lt; 10 ? `0${value}` : value;
            };

            let firstDate = new Date(date_array['y'], date_array['m'] - 1, date_array['d']),
                y = firstDate.getFullYear(),
                m = firstDate.getMonth() + 1,
                d = firstDate.getDate(),
                firstDateValue = `${y}-${dateAddZero(m)}-${dateAddZero(d)}`,
                secondDate = new Date(y, m - 1, d + 2);

            // console.debug('secondDate', secondDate);

            if (!dateController.dateIsWork(secondDate))
            {
                secondDate = dateController.findNextWorkDate(secondDate);
            }

            // console.debug('secondDate', secondDate);

            let deliveryDateText = `${dateAddZero(d)}.${dateAddZero(m)} - ${dateAddZero(secondDate.getDate())}.${dateAddZero(secondDate.getMonth() + 1)}`;

            let $el = $('.deliveryDate');
            $el.text(deliveryDateText).attr('data-first-date', firstDateValue);
            $el.css({
                'padding-left': 0,
                'color': '#d3292b'
            });
            $el.parent().css('text-align', 'center');
        };

        const hideCost = function () // РЎРєСЂС‹РІР°РµРј РґРѕРї РёРЅС„РѕСЂРјР°С†РёСЋ
        {
            $('.offset_info').css({'display': 'none'});
            $offsetPostWork = $('.offset_post_work');
            $offsetPostWork.find('div[data_display=dis]').each(function () {
                $(this).css({'display': 'none'});
            });
            $offsetPostWork.find('select').each(function () {
                $(this).selectedIndex = -1;
            });
            $offsetPostWork.find('input[type=checkbox]').each(function () {
                $(this).prop('checked', false);
            });
            //РћС‚С‡РёСЃС‚РєР° СЃС‚Р°РЅРґР°СЂС‚Р°
            $('.offset-floating-title').html("");
            $('.offset-materail-table').html("");
            $('.large-format-title').html("");
            //РћС‚С‡РёСЃС‚РєР° РјРЅРѕРіРѕСЃС‚СЂР°РЅРёС‡РєРё
            $('.cMultipageTitle').html("");
        };

        const citySelection = function (city, address_recognizer = null) {

            console.debug("TERMINAL", "FIND TERMINALS");
            // console.log({city, address_recognizer});

            dpd_ready = false;
            dpd_flag = true;
            sdek_flag = false;
            ems_flag = false;
            dpd_country = '';
            dpd_city = '';
            dpd_region = '';
            dpd_region2 = '';
            dpd_adress = '';
//dev
            //РћС‚РєСЂС‹РІР°РµРј РІС‹Р±РёСЂР°Р»РєСѓ РїСѓРЅРєС‚С‹ РёР»Рё РєР°СЂС‚Р°
            const selectors = [
                {
                    tc: 'dpd',
                    contentClassName: 'dpd_terminal_block',
                },
                {
                    tc: 'sdek',
                    contentClassName: 'sdek_terminal_block',
                },
                {
                    tc: 'ems',
                    contentClassName: 'ems_terminal_block',
                },
                {
                    tc: 'ozon',
                    contentClassName: 'ozon_terminal_block',
                },
                {
                    tc: 'yandexterminal',
                    contentClassName: 'yandexterminal_terminal_block',
                },
            ];

            $('.offset_delivery .cDPD_terminal_selection').css('display', 'block');
            for (const item of selectors)
            {
                $(`.offset_delivery .cDPD_terminal_selection .${item.contentClassName}`).hide();
            }

            $('.offset_delivery .cDPD_terminal_selection .tk_block').each(function () {
                if ($(this).hasClass('active'))
                {
                    $('.offset_delivery .cDPD_terminal_selection .' + $(this).attr('tk') + '_terminal_block').css('display', 'block');
                }
                else
                {
                    $('.offset_delivery .cDPD_terminal_selection .' + $(this).attr('tk') + '_terminal_block').css('display', 'none');
                }
            });




            //РћС‚РєСЂС‹РІР°РµРј РёРЅС„Сѓ Рѕ РїРѕР»СѓС‡Р°С‚РµР»Рµ
            //$('.offset_delivery .cInfo_addressee').css('dispaly', 'block');
            //РћС‚С‡РёС‰Р°РµРј СЃРїРёСЃР°РѕРє С‚РµСЂРјРёРЅР°Р»РѕРІ
            $('.offset_delivery .cTerminal_list').html('');
            //Р—Р°РїСѓСЃРєР°РµРј РєСЂСѓС‚РёР»РєСѓ
            $('.offset_delivery .city_update').css('display', 'block');
            //РљРёРґР°РµРј Р·Р°РїСЂРѕСЃ РЅР° РїРѕР»СѓС‡РµРЅРёРµ С‚РµСЂРјРёРЅР°Р»РѕРІ

            if (window.hasOwnProperty('large'))
            {
                large = otype == 'large' ? 1 : 0;
            }
            else
            {
                var large = otype === 'large' ? 1 : 0;
            }

            ///
            var coef = Math.cbrt(Number($('.cDpdNum').html()) + Number($('.cDpdNumDop').html()));
            var city_t = $('.offset_delivery .dpd_city').val().split(', ');

            if (address_recognizer &amp;&amp; address_recognizer.hasOwnProperty('city') &amp;&amp; address_recognizer.hasOwnProperty('region'))
            {
                city = `${address_recognizer.city}, ${address_recognizer.region}`.toLowerCase();
                city_t = city.split(', ');
            }

            let shipment_weight = $('.cOffsetDelivery .cDpdWgtAll').text();

            if (otype === 'offset' || otype === 'calendar')
            {
                mark = 0;
                if (multi)
                {
                    mark = 1;
                }
            }
            else
            {
                mark = 1;
            }

            let id_print = 0;
            let name = '';
            let id_material = 0;
            let tir_value = 0;
            let id_time = 0;

            if (otype === 'offset')
            {
                id_print = cost.id_print;
                name = cost.name;
                id_material = cost.id_material;
                tir_value = cost.value;
                id_time = cost.id_time;
            }

            $.ajax({
                type: 'POST',
                data: {
                    'mark': mark,
                    'otype': otype,
                    'city': city_t[0],
                    'region': city_t[1],
                    'printTime': printTime,
                    'id_time': id_time,
                    'tir': id_print,
                    'name': name,
                    'material': id_material,
                    'cost': tir_value
                },
                url: "/AJAX/get_server_time_by_region.php",
                async: false,
                success: function (data) {
                    let result = JSON.parse(data);
                    own_region = result.own;

                    let readyTimeByRegion = TimeControl.parseReadyTimeByRegion(result.time, printTime, false);

                    prel_date = readyTimeByRegion;

                    readyTimeByRegion = TimeControl.parseReadyTimeByRegion(result.time, printTime, true);

                    let time = readyTimeByRegion.split('-');
                    if (time[1].length === 1)
                    {
                        time[1] = "0" + time[1];
                    }
                    if (time[2].length === 1)
                    {
                        time[2] = "0" + time[2];
                    }

                    finaldate = time[2] + '.' + time[1] + '.' + time[0];

                    $('.actualDateReady').val(prel_date);
                    $('.dateReady').html(finaldate);
                    $('.cPickUpDate').html(finaldate);

                    if (instanceForOffset.isPartnerHost())
                    {
                        // old variant
                        $('.deliveryDate').html(finaldate);
                    }
                    else
                    {
                        setDeliveryDate({d: time[2], m: time[1], y: time[0]}, 25);
                    }
                }
            });

            let iframe = document.getElementById('OZON_iframe');
            iframe.src = iframe.src.split('defaultcity')[0] + 'defaultcity=' + encodeURIComponent(city);

            if (otype === 'large')
            {
                own_region = 5;
            }

            if (ph_id == 0)
            {
                ph_id = own_region;
            }


            let _dpd_city = city_t[0];
            let _dpd_region = city_t[1];
            let _dpd_city_with_region = city;

            if (address_recognizer &amp;&amp; address_recognizer.hasOwnProperty('dpd_location'))
            {
                _dpd_city = address_recognizer.dpd_location.CITY_NAME;
                _dpd_region = address_recognizer.dpd_location.REGION_NAME;

                _dpd_city_with_region = `${_dpd_city}, ${_dpd_region}`.toLowerCase();
            }

            DeliveryInstance.requireDpd(large, _dpd_city, _dpd_region, coef, address_recognizer, _dpd_city_with_region, shipment_weight);

            /// РЎР”Р•Рљ
            //console.log('SDEK');

            let _sdek_city = city_t[0];
            let _sdek_region = city_t[1];
            let _sdek_city_with_region = city;
            let _sdek_location_id = 0;

            if (address_recognizer &amp;&amp; address_recognizer.hasOwnProperty('sdek_location'))
            {
                _sdek_city = address_recognizer.sdek_location.city;
                _sdek_region = address_recognizer.sdek_location.region;

                _sdek_city_with_region = `${_dpd_city}, ${_dpd_region}`.toLowerCase();
                _sdek_location_id = address_recognizer.sdek_location.id;
            }

            DeliveryInstance.requireSdek(_sdek_city, _sdek_region, coef, _sdek_location_id, _sdek_city_with_region);

            DeliveryInstance.requireYandextermminal({
                location: {
                    name: city_t.join(", "),
                }
            });

            const requireEMS = function ()
            {
                $('.cTerminal_list_ems').html(`&lt;tr&gt;&lt;td class="td-id-error"&gt;РќРµ РґРѕСЃС‚СѓРїРЅРѕ РґР»СЏ РґР°РЅРЅРѕРіРѕ С‚РёРїР° РїСЂРѕРґСѓРєС†РёРё.&lt;/td&gt;&lt;/tr&gt;`);

                // if (otype === 'offset' || otype === 'multipage' || otype === 'visechka' || otype === 'pakety')
                // {
                //     // EMS
                //
                //     $.ajax({
                //         type: 'POST',
                //         data: {
                //             'own_region': own_region,
                //             //'mark': large,
                //             'city': city
                //         },
                //         url: "/data/ems/terminal/list",
                //         async: false,
                //         success: function (data) {
                //             resp = JSON.parse(data);
                //             terminals = resp.term;
                //             var str = '';
                //             if (terminals.length &gt; 0)
                //             {
                //
                //                 $.ajax({
                //                     type: 'POST',
                //                     data: {
                //                         'own_region': ph_id,
                //                         'mark': mark,
                //                         'otype': otype,
                //                         'product_id': p_id,
                //                         //'country': 'Р&nbsp;РѕСЃСЃРёСЏ',
                //                         'city': city_t[0],
                //                         'region': city_t[1],
                //                         //'region2': city_t[1],
                //                         'index_to': terminals[0]['postal_code'],
                //                         'length': Number($('.cDpdLen').html()) * coef,
                //                         'width': Number($('.cDpdWid').html()) * coef,
                //                         'height': Number($('.cDpdHgt').html()) * coef,
                //                         'weight': Number(Number($('.cDpdWgtAll').html()) + Number($('.cDpdWgtAllDop').html())).toFixed(2),
                //                         'product': 'РїРµС‡Р°С‚РЅР°СЏ РїСЂРѕРґСѓРєС†РёСЏ',
                //                         'cost': $('.printCost').html()
                //                     },
                //                     url: "/data/ems/terminal/price",
                //                     async: false,
                //                     success: function (data) {
                //                         try
                //                         {
                //                             var result = JSON.parse(data);
                //                             // console.log(result);
                //
                //                             if (result.CONFIRM)
                //                             {
                //
                //                                 let __daysHtml = (result.EMS.delTimeMin &gt; 0)
                //                                     ? `${result.EMS.delTimeMin}-${result.EMS.delTimeMin + 2} Рґ.`
                //                                     : '&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;';
                //
                //                                 $('.offset_delivery .ems_del_period').html(__daysHtml);
                //
                //                                 let __cost = Math.ceil(Number(result.EMS.COST2)),
                //                                     __costHtml = (__cost &gt; 0) ? __cost + ' СЂСѓР±.' : '&lt;i&gt;Р±РµСЃРїР»Р°С‚РЅРѕ&lt;/i&gt;';
                //
                //                                 $('.offset_delivery .ems_del_cost').html(__costHtml);
                //
                //                                 for (var i = 0; i &lt; terminals.length; i++)
                //                                 {
                //                                     str += "&lt;tr id='td-is-" + i + "' location_id='" + terminals[i]['place'] + "' data-address='" + terminals[i]['address'] + "'&gt;&lt;td class='del1' &gt;" + terminals[i]['type'] + "&lt;/td&gt;&lt;td class='del2'&gt;" + terminals[i]['address_full'] + "&lt;/td&gt;&lt;/tr&gt;";
                //                                 }
                //                             }
                //                             else
                //                             {
                //                                 if (result.EMS.code == 1003)
                //                                 {
                //                                     str = '&lt;tr&gt;&lt;td class="td-id-error"&gt;РњР°СЃСЃР° РіСЂСѓР·Р° Р±РѕР»СЊС€Рµ РґРѕРїСѓСЃС‚РёРјРѕР№.&lt;/td&gt;&lt;/tr&gt;';
                //                                 }
                //                             }
                //                         } catch (e)
                //                         {
                //                             // console.log(e);
                //                             $('.offset_delivery .ems_del_period').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                //                             $('.offset_delivery .ems_del_cost').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                //                         }
                //                     }
                //                 });
                //
                //             }
                //             else
                //             {
                //                 str = '&lt;tr&gt;&lt;td class="td-id-error"&gt;Р”Р°РЅРЅС‹Р№ РіРѕСЂРѕРґ РЅРµ Р±С‹Р» РЅР°Р№РґРµРЅ: "' + $(".dpd_city").val() + '"&lt;/td&gt;&lt;/tr&gt;';
                //                 if (resp.error == '1')
                //                 {
                //                     str = '&lt;tr&gt;&lt;td class="td-id-error"&gt;' + resp.msg + '&lt;/td&gt;&lt;/tr&gt;';
                //                 }
                //
                //                 $('.offset_delivery .ems_del_period').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                //                 $('.offset_delivery .ems_del_cost').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                //             }
                //
                //             $('.cTerminal_list_ems').html(str);
                //         }
                //     });
                // }
                // else
                // {
                //     $('.cTerminal_list_ems').html(`&lt;tr&gt;&lt;td class="td-id-error"&gt;РќРµ РґРѕСЃС‚СѓРїРЅРѕ РґР»СЏ РґР°РЅРЅРѕРіРѕ С‚РёРїР° РїСЂРѕРґСѓРєС†РёРё.&lt;/td&gt;&lt;/tr&gt;`);
                // }
            }

            requireEMS();

            const requireOzon = function () {

                const requireOzonInfo = function () {

                    const badRequestHandler = function () {
                        $('.offset_delivery .ozon_del_period').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                        $('.offset_delivery .ozon_del_cost').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                    };

                    return $.ajax({
                        type: 'POST',
                        data: {
                            'own_region': ph_id,
                            'mark': mark,
                            'otype': otype,
                            'product_id': p_id,
                            //'country': 'Р&nbsp;РѕСЃСЃРёСЏ',
                            'city': city_t[0],
                            'region': city_t[1],
                            'deliveryVariantId': ozon_terminals[0]['variant_id'],
                            //'length': Number($('.cDpdLen').html()) * coef,
                            //'width': Number($('.cDpdWid').html()) * coef,
                            //'height': Number($('.cDpdHgt').html()) * coef,
                            'weight': Number(Number($('.cDpdWgtAll').html()) + Number($('.cDpdWgtAllDop').html())).toFixed(2),
                            'cost': $('.printCost').html()
                        },
                        url: "/AJAX/get_OZON_price_terminal.php",
                        async: false,
                        success: function (data) {
                            try
                            {
                                const result = JSON.parse(data);

                                if (result.Confirm)
                                {

                                    let __days = result.OZON.days,
                                        __daysHtml = (__days &gt; 0)
                                            ? `${__days}-${__days + 2} Рґ.`
                                            : '&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;';

                                    $('.offset_delivery .ozon_del_period').html(__daysHtml);

                                    let __cost = Math.ceil(Number(result.OZON.amount)),
                                        __costHtml = (__cost &gt; 0) ? __cost + ' СЂСѓР±.' : '&lt;i&gt;Р±РµСЃРїР»Р°С‚РЅРѕ&lt;/i&gt;';

                                    $('.offset_delivery .ozon_del_cost').html(__costHtml);

                                    for (var i = 0; i &lt; ozon_terminals.length; i++)
                                    {
                                        str += "&lt;tr id='td-is-" + i + "' location_id='" + ozon_terminals[i]['variant_id'] + "' data-city='" + ozon_terminals[i]['settlement'] + "' data-region='" + ozon_terminals[i]['region'] + "' data-address='" + ozon_terminals[i]['address'] + "' data-terminal_info='" + ozon_terminals[i]['howToGet'] + "'&gt;&lt;td class='del1' &gt;" + ozon_terminals[i]['objectTypeName'] + "&lt;/td&gt;&lt;td class='del2'&gt;" + ozon_terminals[i]['address'] + "&lt;/td&gt;&lt;/tr&gt;";
                                    }
                                }
                            }
                            catch (e)
                            {
                                badRequestHandler();
                            }
                        },
                        error: e =&gt; {
                            badRequestHandler();
                        }
                    });
                };

                return $.ajax({
                    type: 'POST',
                    data: {
                        'own_region': own_region,
                        'city': city
                    },
                    url: "/AJAX/get_OZON_terminals.php",
                    async: false,
                    dataType: "json",
                    success: function (resp)
                    {
                        let ozon_terminals = resp.term ? resp.term : [];
                        let str = '';

                        if(!!ozon_terminals &amp;&amp; ozon_terminals.length &gt; 0)
                        {
                            requireOzonInfo();
                        }
                        else
                        {
                            str = '&lt;tr&gt;&lt;td class="td-id-error"&gt;Р”Р°РЅРЅС‹Р№ РіРѕСЂРѕРґ РЅРµ Р±С‹Р» РЅР°Р№РґРµРЅ: "' + $(".dpd_city").val() + '"&lt;/td&gt;&lt;/tr&gt;';
                            if (resp.error == '1')
                            {
                                str = '&lt;tr&gt;&lt;td class="td-id-error"&gt;' + resp.msg + '&lt;/td&gt;&lt;/tr&gt;';
                            }

                            $('.offset_delivery .ozon_del_period').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                            $('.offset_delivery .ozon_del_cost').html('&lt;i style="color:#f00;"&gt;РЅРµС‚ РёРЅС„Рѕ&lt;/i&gt;');
                        }

                        $('.cTerminal_list_ozon').html(str);

                    }
                });
            };


            $('.offset_delivery .del_addk').html('');
            $('.offset_delivery .del_addr').html('');
            $(".city_update").css('display', 'none');


        };
        const setDefaultDelivery = function () {
            $('.offset_delivery .tab').find('.tablinks1').each(function () {
                if ($(this).hasClass("active"))
                {
                    $(this).trigger('click');
                    $(this).find('input').prop('checked', true);
                    $(this).find('input').trigger('change');
                    $(this).find('.radioTargeted').each(function () {
                        newDate = TimeControl.readyTimeDelivery(Number($(this).data('deliveryperiod')));
                        $('.deliveryCost').text($(this).data('price'));
                        if (instanceForOffset.isPartnerHost())
                        {
                            // old variant
                            $('.deliveryDate').text(newDate['d'] + '.' + newDate['m'] + "." + newDate['y']);
                        }
                        else
                        {
                            setDeliveryDate(newDate, 24);
                        }
                    });
                    if ($(this).find('input').attr('id') === 'dpdTerminal')
                    {
                        citySelection($('.offset_params_order .dpd_city').val().toLowerCase());
                    }
                }
            });
        };

        const MultiPage = new (function () {

            const get = function (filterClassName, isArray) {
                let array = [];

                $(`.${filterClassName} label.active`).each(function (index, value) {
                    array.push($(this).siblings('input').attr('val'));
                });

                return isArray ? array : array.join(',');
            };

            this.coverSide = function (isArray = true) {
                return get('cCoverSide', isArray)
            };

            this.decorSelect = function (isArray = true) {
                return get('cDecorSelect', isArray);
            };

        })();

        const __initListenerChangeMaterial = function () {
            //Р’С‹Р±РѕСЂ РјР°С‚РµСЂРёР°Р»Р°
            $('.offset-floating-title input[type = "checkbox"]').on("change", function (e) {
                hideCost();
                /*if ($('.main_page-phone_number-bottom').offset().top+$('.main_page-phone_number-bottom').height() - $('.offset-floating-title').offset().top &lt; $(window).height()) {
             var new_height = $('.main_page-phone_number-bottom').offset().top+$('.main_page-phone_number-bottom').height() - $(window).height();
             $('html,body').animate( { scrollTop: new_height }, 1100 );
             }
             else {
             $('html,body').animate( { scrollTop: $('.offset-title').offset().top }, 1100 );
             }*/
                var text = '';
                if ($(this).attr("id") === "allcheck")
                {
                    $('.offset-floating-title input[type = "checkbox"]').each(function (i, elem) {
                        if (i !== 0)
                            $(elem).attr("checked", false);
                    });
                }
                else
                    document.getElementById('allcheck').checked = false;

                var objects = $('.offset-floating-title input[type = "checkbox"]:checked');
                //var objectsUnCheck = $('.offset-floating-title input[type = "checkbox"]:not(:checked)');
                for (var i = 0; i &lt; objects.length; i++)
                {
                    if ($(objects[i]).attr("id") !== "allcheck")
                    {
                        if (i == 0)
                            text += " id=" + $(objects[i]).attr("id");
                        else
                            text += " OR id=" + $(objects[i]).attr("id");
                    }
                    else
                        text += " 1";
                }

                if (!instanceForOffset.isPartnerHost())
                {
                    FileLoader.deleteAll(['kabinet_offset_rostov', 'kabinet_offset_get_title', '2']);
                }

                let getTitleUrl = "/AJAX/kabinet_offset_get_title.php";
                if (instanceForOffset.isPartnerHost()) getTitleUrl = `/CMS/${getTitleUrl}`;

                $.ajax({
                    type: 'POST',
                    data: {
                        'filter': text,
                        'productid': $('#table_info').val(),
                        'flag': 0
                    },
                    url: getTitleUrl,
                    async: false,
                    success: function (data) {
                        var result = JSON.parse(data);
                        //$('.offset-floating-title').html(result.title);
                        $('.offset-materail-table').html(result.block);
                        $(".offset-materail-table").find('.time_to_parse').each(function () {
                            //Р’СЂРµРјСЏ РґР»СЏ РјРµРЅРµРґР¶РµСЂР°

                            var readyTime = TimeControl.parseReadyTime($(this).text(), false);

                            var time = readyTime.split('-');
                            if (time[1].length === 1)
                            {
                                time[1] = "0" + time[1];
                            }
                            if (time[2].length === 1)
                            {
                                time[2] = "0" + time[2];
                            }
                            $(this).attr("preldate", time[2] + '.' + time[1] + '.' + time[0]);

                            //Р’СЂРµРјСЏ РґР»СЏ РєР»РёРµРЅС‚Р°
                            readyTime = TimeControl.parseReadyTime($(this).text(), true);

                            time = readyTime.split('-');

                            if (instanceForOffset.isPartnerHost())
                            {
                                partnerTools.updateDate(ctx, time);
                            }
                            else
                            {
                                if (time[1].length === 1)
                                {
                                    time[1] = "0" + time[1];
                                }
                                if (time[2].length === 1)
                                {
                                    time[2] = "0" + time[2];
                                }
                                $(this).attr("finaldate", time[2] + '.' + time[1] + '.' + time[0]);
                                $(this).text("Р“РѕС‚РѕРІРЅРѕСЃС‚СЊ РЅР° " + time[2] + '.' + time[1]);
                                $(this).attr('withoutDelivery', "Р“РѕС‚РѕРІРЅРѕСЃС‚СЊ РЅР° " + time[2] + '.' + time[1]);

                                // Р’СЂРµРјСЏ РґР»СЏ РєР»РёРµРЅС‚Р° РЎ Р”РћРЎРўРђР’РљРћР™
                                let {day, month} = TimeControl.readyTimeWidthDelivery(time, $(this).attr('delivery'));
                                $(this).attr('withDelivery', "Р“РѕС‚РѕРІРЅРѕСЃС‚СЊ РЅР° " + day + '.' + month);
                            }
                        });
                    }
                });
                //Р&nbsp;РµРґР°РєС‚РёСЂСѓРµРј С‚Р°Р±Р»РёС†Сѓ РїРѕ РЅР°Р»РёС‡РёСЋ/РѕС‚СЃСѓС‚СЃС‚РІРёСЋ СЃС‚РѕСЂРѕРЅС‹ РїРµС‡Р°С‚Рё
                $('.offset-materail-table div[class=material]').each(function () {
                    if ($(this).find(".one").length === 2)
                    {
                        $(this).find(".one").remove();
                    }
                    if ($(this).find(".two").length === 2)
                    {
                        $(this).find(".two").remove();
                    }
                    if ($(this).find("tr").length === 1)
                    {
                        $(this).remove();
                    }
                })
            });
        };

        let partnerTools = null;

        if (instanceForOffset.isPartnerHost())
        {
            window.CorPartnerCost_old = function (material_id, percent) {

                $('#of_mat_' + material_id).find('.print_extra_charge').each(function(){
                    $(this).val(percent);
                });

                $('#of_mat_' + material_id).find('span.user_cost').each(function(){
                    let real_cost = +$(this).attr('tir_val').replace(/\s+/g, '');
                    let new_cost = Math.ceil(real_cost * (1 + percent/100));
                    $(this).text(new_cost);
                });

            };

            window.CorPartnerCost = function (material_id, percent) {

                let el_id = (material_id == 'M') ? '.material_partner' : '#of_mat_' + material_id ;

                $(el_id).find('.print_extra_charge').each(function(){
                    $(this).val(percent);
                });

                $(el_id).find('span.user_cost').each(function(){
                    let real_cost = +$(this).attr('tir_val').replace(/\s+/g, '');
                    let new_cost = Math.ceil(real_cost * (1 + percent/100));
                    $(this).text(new_cost);
                });

            };

            window.CorPartnerCostForTir = function (material_id, tir, percent) {

                let el_id = (material_id == 'M') ? '.material_partner' : '#of_mat_' + material_id ;

                $(el_id).find('span.user_cost[tir="' + tir + '"]').each(function(){
                    let real_cost = +$(this).attr('tir_val').replace(/\s+/g, '');
                    let percent_all = +percent;
                    if(material_id != 'M')
                    {
                        let time_id = +$(this).attr('time_id');
                        let percent_time = +$(el_id).find('input.time_extra_charge[time_id="' + time_id + '"]').val();
                        percent_all = +percent + percent_time;
                    }
                    let new_cost = Math.ceil(real_cost * (1 + percent_all/100));
                    $(this).text(new_cost);
                });

            };

            window.CorPartnerCostForTime = function (material_id, time_id, percent) {

                let el_id = (material_id == 'M') ? '.material_partner' : '#of_mat_' + material_id ;

                $(el_id).find('span.user_cost[time_id="' + time_id + '"]').each(function(){
                    let real_cost = +$(this).attr('tir_val').replace(/\s+/g, '');
                    let tir = +$(this).attr('tir');
                    let percent_tir = +$(el_id).find('input.print_extra_charge[tir="' + tir + '"]').val();
                    let percent_all = +percent + percent_tir;
                    let new_cost = Math.ceil(real_cost * (1 + percent_all/100));
                    $(this).text(new_cost);

                });

            };

            partnerTools = new (function () {
                let ptInstance = this;
                this.ClientInform = new (function () {
                    let checked = false;
                    let className = 'status-inform-checkbox';
                    let wrapperClassName = 'js-recipient-control';
                    let costWrapperClassName = 'js-cost-for-recipient-wrapper';
                    let costClassName = 'js-cost-for-recipient';
                    const paidClassName = 'js-cost-paid-recipient';
                    const statusClassName = 'js-quene-status';

                    let values = {
                        costValue: 0,
                        paidValue: 0,
                        statusValue: '',
                    };

                    const __paidUpdate = function ($offsetInfo, $wrapper) {

                        let $paidInput = $wrapper.find(`.${paidClassName}`);
                        if (!$paidInput.length)
                        {
                            values.paidValue = 0;
                        }
                        else
                        {
                            $offsetInfo.find(`.${paidClassName}`).val(
                                Number(`${values.paidValue}`.replace(/[^0-9]/g, ""))
                            );
                        }
                    };

                    const __statusUpdate = function ($offsetInfo, $wrapper) {

                        let $statusSelect = $wrapper.find(`.${statusClassName}`);
                        if (!$statusSelect.length)
                        {
                            values.statusValue = '';
                        }
                        else
                        {
                            $offsetInfo.find(`.${statusClassName}`).val(`${values.statusValue}`);
                        }
                    }

                    const __clearValues = function () {
                        values.costValue = 0;
                        values.paidValue = 0;
                        values.statusValue = '';
                    };

                    const __numericValue = function (value) {
                        return Number(`${value}`.replace(/[^0-9]/g, ""))
                    };

                    const __inputNumberListener = function(value, name, className, $offsetInfo) {
                        const formattedValue = value.replace(/[^0-9]/g, "");
                        values[name] = Number(formattedValue);
                        $offsetInfo.find(`.${className}`).val(formattedValue);
                    };

                    const __initialize = function () {
                        $(document).ready(function () {
                            const $offsetInfo = $('.offset_info');
                            $offsetInfo.on('change' , `.${className}`, function() {
                                let $checkbox = $(this);
                                let isChecked = $checkbox.is(':checked');
                                checked = isChecked;
                                $(`.${className}`).addClass(`${className}__update-waiting`).removeClass(className);
                                $checkbox.addClass(className).removeClass(`${className}__update-waiting`);
                                $(`.${className}__update-waiting`)
                                    .prop('checked', isChecked)
                                    .addClass(className)
                                    .removeClass(`${className}__update-waiting`);
                                let $wrapper = $checkbox.closest(`.${wrapperClassName}`);
                                let $costWrapper = $wrapper.find(`.${costWrapperClassName}`);
                                if (!$costWrapper.length)
                                {
                                    __clearValues();
                                }
                                else
                                {
                                    let $costInput = $costWrapper.find(`.${costClassName}`);
                                    if (!$costInput.length)
                                    {
                                        __clearValues();
                                        $costWrapper.hide();
                                    }
                                    else
                                    {
                                        $offsetInfo.find(`.${costWrapperClassName}`).toggle(checked);
                                        if (checked)
                                        {
                                            $offsetInfo.find(`.${costClassName}`).val(__numericValue(values.costValue));
                                            __paidUpdate($offsetInfo, $wrapper);
                                        }
                                    }
                                }
                            })
                            .on('input', `.${costClassName}`, function () {
                                __inputNumberListener(this.value, 'costValue', costClassName, $offsetInfo);
                            })
                            .on('input', `.${paidClassName}`, function () {
                                __inputNumberListener(this.value, 'paidValue', paidClassName, $offsetInfo);
                            })
                            .on('change', `.${statusClassName}`, function () {
                                const value = $(this).val();
                                values.statusValue = value;
                                $offsetInfo.find(`.${statusClassName}`).val(`${value}`);
                            })
                        });
                    }
                    this.getChecked = function() {
                        return checked;
                    };
                    this.getCost = function () {
                        return values.costValue;
                    };
                    this.getPaid = function () {
                        return values.paidValue;
                    };
                    this.getStatus = function () {
                        return values.statusValue;
                    };
                    __initialize();
                })();
                this.btnImagePng = new (function() {

                    let instance = this;

                    this.getDataForSave = function() {
                        let $contain = $('.product-image-upload'),
                            currentSrc = $contain.find('img.product-image-button').attr('src'),
                            defaultSrc = $contain.find('#use-default-image').attr('data-default-image');

                        return {
                            image: currentSrc,
                            useDefault: currentSrc == defaultSrc
                        };
                    };


                    this.useChangeListener = function(context) {

                        let $inputFile = $(context);

                        let file = context.files[0];
                        let format = file.type.split('/')[1].toLowerCase();
                        let accept_formats = ['png'];

                        if ( accept_formats.indexOf(format) === -1 ) {
                            $inputFile.val('');
                            alert('РР·РѕР±СЂР°Р¶РµРЅРёРµ РґРѕР»Р¶РЅРѕ Р±С‹С‚СЊ РІ С„РѕСЂРјР°С‚Рµ PNG');
                            return false;
                        }

                        if ( file.size &gt; 1024 * 1024 * 3 ) {
                            $inputFile.val('');
                            alert( 'Р&nbsp;Р°Р·РјРµСЂ РёР·РѕР±СЂР°Р¶РµРЅРёСЏ РЅРµ РґРѕР»Р¶РµРЅ РїСЂРµРІС‹С€Р°С‚СЊ 3 РњР±' );
                            return false;
                        }

                        let reader = new FileReader();
                        let $img = $inputFile.parents('.product-image-upload').find('img.product-image-button');

                        reader.addEventListener('load', function(event)
                        {
                            $img.attr('src', event.target.result);
                        });

                        reader.readAsDataURL(file);
                    };
                })();
                this.toggleWaitingServerTime = function () {
                    $('#waitingServerTime').toggle();
                };
                this.priceTagUpdateFormat = function (event, props = {}) {
                    let $cell = $(event);

                    if ($cell.attr("data-currency-visible"))
                    {
                        const forUnit = props.hasOwnProperty("forUnit")
                            ? !!props.forUnit
                            : $cell.parents('.material').find('.cost_visor .switch-component input[type=checkbox]').prop('checked')

                        let text = $cell.attr(forUnit ? "one" : "tir_val").replace(/\B(?=(\d{3})+(?!\d))/g, " ");
                        let icon = $cell.attr("data-currency-icon");
                        $cell.text(`${text} ${icon}`);
                    }
                };
                this.updateDate = function (ctx, time) {
                    if (time[1].toString().length === 1) time[1] = `0${time[1]}`;
                    if (time[2].toString().length === 1) time[2] = `0${time[2]}`;

                    $(ctx).attr("finaldate", `${time[2]}.${time[1]}.${time[0]}`);
                    $(ctx).text(`Р“РѕС‚РѕРІРЅРѕСЃС‚СЊ РЅР° ${time[2]}.${time[1]}`);
                    $(ctx).attr('withoutDelivery', `Р“РѕС‚РѕРІРЅРѕСЃС‚СЊ РЅР° ${time[2]}.${time[1]}`);

                    // Р’СЂРµРјСЏ РґР»СЏ РєР»РёРµРЅС‚Р° РЎ Р”РћРЎРўРђР’РљРћР™
                    let {day, month} = TimeControl.readyTimeWidthDelivery(time, $(ctx).attr('delivery'));
                    if (day.toString().length === 1) day = `0${day}`;
                    if (month.toString().length === 1) month = `0${month}`;
                    $(ctx).attr('withDelivery', `Р“РѕС‚РѕРІРЅРѕСЃС‚СЊ РЅР° ${day}.${month}`);
                };
                this.readyTimeDelivery = function(input_date) {
                    // Р¤СѓРЅРєС†РёСЏ РґР»СЏ РІСЂРµРјРµРЅРё Р’РѕР»РіРѕРіСЂР°РґСЃРєРѕР№ РґРѕСЃС‚Р°РІРєРё
                    let res = [];
                    $.ajax({
                        type: 'POST',
                        url: "AJAX/get_delivery_date.php",
                        data: {
                            'dateReady': $('.dateReady').html(),
                            'delivery_days': input_date
                        },
                        async: false,
                        success: function (data) {
                            //console.log(data);
                            res = JSON.parse(data);
                            //console.log(res1);
                        }
                    });
                    return res;
                };
                this.offsetProductTable = function (group_id, attrProductid) {
                    let url = (group_id === 9)
                        ? "CMS/AJAX/kabinet_offset_get_Partner_title.php"
                        : "CMS/AJAX/kabinet_offset_get_title.php";

                    ptInstance.toggleWaitingServerTime();

                    $.ajax({
                        type: 'POST',
                        data: {
                            'productid': attrProductid,
                            'flag': 1,
                            'ismobile': (window.innerWidth &gt; 767 ? 0 : 1)
                        },
                        url: url,
                        async: true,
                        success: function (data) {

                            var result = JSON.parse(data);

                            let $offsetFloatingTitle = $(`.offset-floating-title`);
                            $offsetFloatingTitle.html(result.title);

                            if ($('.offset-content .product_onoff #enable_product').prop('checked'))
                            {
                                $('.offset-floating-title .product_onoff .left').css('color', '#cdc5bf');
                                $('.offset-floating-title .product_onoff .right').css('color', '#482e1b');
                            }
                            else
                            {
                                $('.offset-floating-title .product_onoff .left').css('color', '#482e1b');
                                $('.offset-floating-title .product_onoff .right').css('color', '#cdc5bf');
                            }

                            $('.offset-materail-table').html(result.block);
                            $('#title_img_new').attr('src', result.descr_img);
                            $('#title_draw').attr('href', result.descr_draw);

                            let $materialTable = $(".offset-materail-table");
                            $materialTable.find('.time_to_parse').each(function () {
                                //Р”РѕР±Р°РІР»СЏРµРј Рє td СЌР»РµРјРµРЅС‚Сѓ РµС‰С‘ РґРІР° Р°С‚СЂРёР±СѓС‚ РґР»СЏ С…СЂР°РЅРµРЅРёСЏ РјРµРЅРµРґР¶РµСЂСЃРєРѕР№ Рё РєР»РёРµРЅС‚СЃРєРѕР№ РґР°С‚С‹ РіРѕС‚РѕРІРЅРѕСЃС‚Рё
                                //Р’СЂРµРјСЏ РґР»СЏ РјРµРЅРµРґР¶РµСЂР°
                                var readyTime = TimeControl.parseReadyTime($(this).text(), false);
                                $(this).attr("preldate", readyTime);
                                //Р’СЂРµРјСЏ РґР»СЏ РєР»РёРµРЅС‚Р°
                                readyTime = TimeControl.parseReadyTime($(this).text(), true);

                                var time = readyTime.split('-');
                                partnerTools.updateDate(this, time);
                            });


                            $materialTable.find('.price-tag').each(function () {
                                partnerTools.priceTagUpdateFormat(this);
                            });


                            let $footerFirstLine = $('.footer_first_line');

                            if ($footerFirstLine.offset().top + $footerFirstLine.height() - $('.offset-floating-title').offset().top &lt; $(window).height())
                            {
                                var new_height = $footerFirstLine.offset().top + $footerFirstLine.height() - $(window).height();
                                $('html,body').animate({scrollTop: new_height}, 1100);
                            }
                            else
                            {
                                $('html,body').animate({scrollTop: $('.offset-title').offset().top}, 1100);
                            }

                            partnerTools.toggleWaitingServerTime();
                        },
                    });

                    __initListenerChangeMaterial();

                    //Р&nbsp;РµРґР°РєС‚РёСЂСѓРµРј С‚Р°Р±Р»РёС†Сѓ РїРѕ РЅР°Р»РёС‡РёСЋ/РѕС‚СЃСѓС‚СЃС‚РІРёСЋ СЃС‚РѕСЂРѕРЅС‹ РїРµС‡Р°С‚Рё
                    $('.offset-materail-table div[class=material]').each(function () {
                        let $one = $(this).find(".one");
                        if ($one.length === 2) $one.remove();

                        let $two = $(this).find(".two");
                        if ($two.length === 2) $two.remove();

                        let $tr = $(this).find("tr");
                        if ($tr.length === 1) $(this).remove();
                    });
                };
            })();
        }

        // universal offset
        new (function () {

            let save_offset_order_clickable = true;

            const Maker = new (function () {
                let instance = this;

                const datesUpdate = function () {
                    let $dateReady = $('#actual_date_ready');
                    const dateReady = $dateReady.val();
                    const wording = $('#leadTime').val();
                    if (!wording)
                    {
                        return false
                    }
                    const dateString = TimeControl.parseReadyTime(wording, true);
                    $dateReady.val(dateString);

                    const dateString_dmY = dateString.split('-').reverse().join('.')
                    $('.dateReady').html(dateString_dmY);
                    $('.cPickUpDate').html(dateString_dmY);

                    if (dateReady !== dateString)
                    {
                        let $deliveryDate = $('#date_dpd_ready');
                        const currentDeliveryDate = $deliveryDate.attr('data-first-date');
                        const diffDays = Math.max(dateUtility.diffDays(new Date(dateString), new Date(currentDeliveryDate)), 0);

                        let dateMutable = new Date(dateString);
                        dateMutable.setDate(dateMutable.getDate() + diffDays);

                        const [y, m, d] = currentDeliveryDate.split('-');
                        setDeliveryDate({y, m, d});
                    }
                };

                const toggleButton = function() {

                    $btn = $('#save_offset_order');

                    if ($btn.prop('disabled'))
                    {
                        $btn.prop('disabled', false);
                        $btn.css('opacity', '1');
                        $btn.css('cursor', 'pointer');
                    }
                    else
                    {
                        $btn.prop('disabled', true);
                        $btn.css('opacity', '0.1');
                        $btn.css('cursor', 'default');
                    }
                };

                this.showAlertModal = function (message) {
                    let $alertModal = $('#alertModal');
                    $alertModal.find('.modal-body p').html(message);
                    $alertModal.modal('toggle');
                    $('.download_out').hide();
                    return false;
                };

                this.getFormEmail = function () {

                    let $offsetDelivery = $('.offset_delivery');
                    let $largeDelivery = $('.large_delivery');

                    const getDeliveryInstanceName = () =&gt; {
                        if ($offsetDelivery.length &amp;&amp; $offsetDelivery.is(":visible"))
                        {
                            return 'offset';
                        }

                        if ($largeDelivery.length &amp;&amp; $largeDelivery.is(":visible"))
                        {
                            return 'large';
                        }

                        return null;
                    };

                    const deliveryInstanceName = getDeliveryInstanceName();
                    if (!deliveryInstanceName) return '';

                    let $deliveryInstance = deliveryInstanceName === 'offset' ? $offsetDelivery : $largeDelivery;

                    let variantName = $deliveryInstance.find('.tablinks1.active').attr('data-variant');

                    let $content = $deliveryInstance.find(`.tabcontent[data-variant="${variantName}"]`);

                    if (!$content.length) return '';

                    let $emailInput = $content.find('input.del_email');

                    if (!$emailInput.length) return '';

                    return $emailInput.val();
                };

                this.makeOrderOffset = function () {

                    if (!APC.printinOrderFiles())
                    {
                        //РџСЂРѕРІРµСЂРєР° РЅР°Р»РёС‡РёСЏ СЃРїРѕСЃРѕР±Р° РґРѕСЃС‚Р°РІРєРё
                        var replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&amp;@#\/%?=~_|!:,.;]*[-A-Z0-9+&amp;@#\/%=~_|])/gim;


                        if (!myDropzone['offsetTemplate'].getAcceptedFiles().length &amp;&amp; !replacePattern1.test($(".offset_maket input[name=linkInternet]").val()) &amp;&amp; maket_type &gt; 0)
                        {
                            if (!myDropzone['offsetTemplate'].getAcceptedFiles().length)
                            {
                                return instance.showAlertModal("Р—Р°РєР°Р· РЅРµ СЃРѕР·РґР°РЅ. Р&nbsp;Р°Р·РјРµСЂ РјР°РєРµС‚Р° РґРѕР»Р¶РµРЅ Р±С‹С‚СЊ РѕС‚ 0 РґРѕ 256 РјР±!");
                            }
                            else
                            {
                                return instance.showAlertModal("Р—Р°РєР°Р· РЅРµ СЃРѕР·РґР°РЅ. РџСЂРѕР±Р»РµРјС‹ СЃ РјР°РєРµС‚РѕРј!");
                            }
                        }
                    }

                    //РџСЂРѕРІРµСЂРєР° СЃР°РјРѕРІС‹РІРѕР·Р° РќРђР§РђР›Рћ
                    if ($(".cOffsetDelivery .radioPickUp").prop('checked') &amp;&amp; sp_address == '')
                    {
                        return instance.showAlertModal("РџРѕР¶Р°Р»СѓР№СЃС‚Р°, РІС‹Р±РµСЂРёС‚Рµ РїСѓРЅРєС‚ РІС‹РґР°С‡Рё РёР· СЃРїРёСЃРєР°.!");
                    }
                    //РџСЂРѕРІРµСЂРєР° СЃР°РјРѕРІС‹РІРѕР·Р° РљРћРќР•Р¦

                    //РџСЂРѕРІРµСЂРєР° Р­РєСЃРїСЂРµСЃСЃ РґРѕСЃС‚Р°РІРєРё РІ РґРµРЅСЊ РіРѕС‚РѕРІРЅРѕСЃС‚Рё РЅР° РїСѓСЃС‚РѕС‚Сѓ РќРђР§РђР›Рћ
                    let $checkDelivery = $('.offset_delivery .check_delivery .dvd_deliv');

                    if ($checkDelivery.prop('checked') &amp;&amp; ($('#denvden_delivery .denvden_del_addr').val() == ''))
                    {
                        return instance.showAlertModal('Р—Р°РєР°Р· РЅРµР»СЊР·СЏ РѕС„РѕСЂРјРёС‚СЊ Р±РµР· СѓРєР°Р·Р°РЅРёСЏ "РђРґСЂРµСЃ РїРѕР»СѓС‡Р°С‚РµР»СЏ"!');
                    }


                    var denvden_city = $('#denvden_to_city').val();

                    if (jQuery.inArray($('#denvden_to_city').val(), ['Р©РµСЂР±РёРЅРєР°', 'РўСЂРѕРёС†Рє', 'Р—РµР»РµРЅРѕРіСЂР°Рґ']) !== -1)
                    {
                        denvden_city = 'РњРѕСЃРєРІР°';
                    }

                    if (denvden_city !== $(".cOffsetDelivery .check_delivery .dvd_deliv").data('city') &amp;&amp; $checkDelivery.prop('checked'))
                    {
                        return instance.showAlertModal(`Р•СЃС‚СЊ РѕС€РёР±РєР°!&lt;br&gt;
                &lt;br&gt;
                &lt;p style='text-align: justify;'&gt;
                    1) Р›РёР±Рѕ СѓРєР°Р·Р°РЅ Р°РґСЂРµСЃ, РєРѕС‚РѕСЂС‹Р№ РЅР°С…РѕРґРёС‚СЃСЏ Р·Р° РїСЂРµРґРµР»Р°РјРё Р’Р°С€РµРіРѕ РіРѕСЂРѕРґР° Рё РѕРЅ РЅРµ РїРѕРїР°РґР°РµС‚ РІ РїСЂРµРґРµР»С‹ Р°РґСЂРµСЃРЅРѕР№ РґРѕСЃС‚Р°РІРєРё
                &lt;/p&gt;
                &lt;p style='text-align: justify;'&gt;
                    2) Р›РёР±Рѕ РІРІРµРґРµРЅРЅС‹Р№ Р’Р°РјРё Р°РґСЂРµСЃ РЅРµ СЂР°СЃРїРѕР·РЅР°РЅ РЅР°С€РµР№ СЃРёСЃС‚РµРјРѕР№ (РµРіРѕ РЅРµРѕР±С…РѕРґРёРјРѕ РІС‹Р±СЂР°С‚СЊ РёР· РІС‹РїР°РґР°СЋС‰РµРіРѕ СЃРїРёСЃРєР° РІР°СЂРёР°РЅС‚РѕРІ). 
                    РџРѕР¶Р°Р»СѓР№СЃС‚Р°, РїРѕРїСЂРѕР±СѓР№С‚Рµ РµРіРѕ РїРѕРґРєРѕСЂСЂРµРєС‚РёСЂРѕРІР°С‚СЊ. 
                &lt;/p&gt;
            `);
                    }

                    if ($(".cOffsetDelivery .check_delivery .dvd_deliv").prop('checked') &amp;&amp; $('.cOffsetDelivery #denvden_delivery .del_addr_hd').val() == '')
                    {
                        $('.cOffsetDelivery #denvden_delivery .del_addr_hd').css('border-color', 'red');
                        return instance.showAlertModal("РќРµ РІСЃРµ РїРѕР»СЏ Р·Р°РїРѕР»РЅРµРЅС‹");
                    }

                    //РџСЂРѕРІРµСЂРєР° РµРєСЃРїСЂРµСЃСЃ РґРѕСЃС‚Р°РІРєРё РІ РґРµРЅСЊ РіРѕС‚РѕРІРЅРѕСЃС‚Рё РЅР° РїСѓСЃС‚РѕС‚Сѓ РљРћРќР•Р¦


                    //РџСЂРѕРІРµСЂРєР° Р°РґСЂРµСЃРЅРѕ РґРѕСЃС‚Р°РІРєРё РЅР° РїСѓСЃС‚РѕС‚Сѓ РќРђР§РђР›Рћ
                    if ($('.offset_delivery .check_delivery .deliv').prop('checked') &amp;&amp; ($('#targeted_delivery .del_addr').val() == ''))
                    {
                        return instance.showAlertModal("Р—Р°РєР°Р· РЅРµР»СЊР·СЏ РѕС„РѕСЂРјРёС‚СЊ Р±РµР· СѓРєР°Р·Р°РЅРёСЏ \"РђРґСЂРµСЃ РїРѕР»СѓС‡Р°С‚РµР»СЏ\"!");
                    }

                    var target_city = $('#targeted_to_city').val();

                    if (jQuery.inArray($('#targeted_to_city').val(), ['Р©РµСЂР±РёРЅРєР°', 'РўСЂРѕРёС†Рє', 'Р—РµР»РµРЅРѕРіСЂР°Рґ']) !== -1)
                    {
                        target_city = 'РњРѕСЃРєРІР°';
                    }

                    if (target_city !== $(".cOffsetDelivery .check_delivery .deliv").data('city') &amp;&amp; $('.offset_delivery .check_delivery .deliv').prop('checked'))
                    {

                        return instance.showAlertModal(`Р•СЃС‚СЊ РѕС€РёР±РєР°!&lt;br&gt;
                &lt;br&gt;
                &lt;p style='text-align: justify;'&gt;
                    1) Р›РёР±Рѕ СѓРєР°Р·Р°РЅ Р°РґСЂРµСЃ, РєРѕС‚РѕСЂС‹Р№ РЅР°С…РѕРґРёС‚СЃСЏ Р·Р° РїСЂРµРґРµР»Р°РјРё Р’Р°С€РµРіРѕ РіРѕСЂРѕРґР° Рё РѕРЅ РЅРµ РїРѕРїР°РґР°РµС‚ РІ РїСЂРµРґРµР»С‹ Р°РґСЂРµСЃРЅРѕР№ РґРѕСЃС‚Р°РІРєРё
                &lt;/p&gt;
                &lt;p style='text-align: justify;'&gt;
                    2) Р›РёР±Рѕ РІРІРµРґРµРЅРЅС‹Р№ Р’Р°РјРё Р°РґСЂРµСЃ РЅРµ СЂР°СЃРїРѕР·РЅР°РЅ РЅР°С€РµР№ СЃРёСЃС‚РµРјРѕР№ (РµРіРѕ РЅРµРѕР±С…РѕРґРёРјРѕ РІС‹Р±СЂР°С‚СЊ РёР· РІС‹РїР°РґР°СЋС‰РµРіРѕ СЃРїРёСЃРєР° РІР°СЂРёР°РЅС‚РѕРІ). 
                    РџРѕР¶Р°Р»СѓР№СЃС‚Р°, РїРѕРїСЂРѕР±СѓР№С‚Рµ РµРіРѕ РїРѕРґРєРѕСЂСЂРµРєС‚РёСЂРѕРІР°С‚СЊ. 
                &lt;/p&gt;
            `);
                    }

                    if ($(".cOffsetDelivery .check_delivery .deliv").prop('checked') &amp;&amp; $('.cOffsetDelivery #targeted_delivery .del_addr_hd').val() == '')
                    {
                        $('.cOffsetDelivery #targeted_delivery .del_addr_hd').css('border-color', 'red');

                        return instance.showAlertModal("РќРµ РІСЃРµ РїРѕР»СЏ Р·Р°РїРѕР»РЅРµРЅС‹");
                    }


                    //РџСЂРѕРІРµСЂРєР° Р°РґСЂРµСЃРЅРѕР№ РґРѕСЃС‚Р°РІРєРё РЅР° РїСѓСЃС‚РѕС‚Сѓ РљРћРќР•Р¦

                    // РџСЂРѕРІРµСЂРєР° РЅР°Р»РёС‡РёСЏ РґРѕСЃС‚Р°РІРєРё
                    if ($('.tab input[name=delivery]:checked').length &lt; 1)
                    {
                        return instance.showAlertModal("РџРѕР¶Р°Р»СѓР№СЃС‚Р°, РІС‹Р±РµСЂРёС‚Рµ СЃРїРѕСЃРѕР± РґРѕСЃС‚Р°РІРєРё");
                    }

                    if ($('.cDpdWgtAll:first').text() &gt; 30
                        &amp;&amp; (DeliveryInstance.getSelectedCompany() === "YandexTerminal"
                            || DeliveryInstance.getSelectedCompany() === "YGo"))
                    {
                        return instance.showAlertModal("Р’РµСЃ Р·Р°РєР°Р·Р° РїСЂРµРІС‹С€Р°РµС‚ 30 РєРі. РџРѕР¶Р°Р»СѓР№СЃС‚Р°, РІРѕСЃРїРѕР»СЊР·СѓР№С‚РµСЃСЊ РґСЂСѓРіРѕР№ С‚СЂР°РЅСЃРїРѕСЂС‚РЅРѕР№ РєРѕРјРїР°РЅРёРµР№.");
                    }

                    const deliveryKey = $('.cOffsetDelivery .check_delivery .tab .tablinks1.active').attr('data-variant');

                    const __phone = DeliverySection.DeliveryPhone.checkValue(deliveryKey);
                    if (!__phone)
                    {
                        return instance.showAlertModal("РџРѕР¶Р°Р»СѓР№СЃС‚Р°, СѓРєР°Р¶РёС‚Рµ РЅРѕРјРµСЂ С‚РµР»РµС„РѕРЅР° РїРѕР»СѓС‡Р°С‚РµР»СЏ");
                    }
                    else
                    {
                        state.setValue('delivery_phone', __phone);
                    }

                    if (myDropzone['offsetTemplate'].getUploadingFiles().length &gt; 0 || myDropzone['offsetPreview'].getUploadingFiles().length &gt; 0)
                    {
                        return instance.showAlertModal("РќРµРѕР±С…РѕРґРёРјРѕ РґРѕР¶РґР°С‚СЊСЃСЏ РїРѕР»РЅРѕР№ Р·Р°РіСЂСѓР·РєРё С„Р°Р№Р»РѕРІ");
                    }
                    else
                    {
                        // if ($('.cOffsetDelivery .cDPDSelected:checked').length)
                        const deliveryVariant = $('.tablinks1.active').attr('data-variant');
                        if (deliveryVariant !== "pickup" &amp;&amp; deliveryVariant !== "targeted_city" &amp;&amp; deliveryVariant !== "denvden")
                        {
                            if (dpd_ready)
                            {

                                if (APC.states.activate)
                                {
                                    console.log('e001');
                                    APC.moveSuccess(() =&gt; bonus.modalPay(instance.ajaxOrderOffset));
                                }
                                else
                                {
                                    console.log('e002');
                                    bonus.modalPay(() =&gt; instance.ajaxOrderOffset());
                                }
                            }
                            else
                            {
                                return instance.showAlertModal('РќРµРѕР±С…РѕРґРёРјРѕ СЂР°СЃСЃС‡РёС‚Р°С‚СЊ СЃС‚РѕРёРјРѕСЃС‚СЊ Рё СЃСЂРѕРє РґРѕСЃС‚Р°РІРєРё. Р’С‹Р±РµСЂРёС‚Рµ РїСѓРЅРєС‚ "Р&nbsp;РђРЎР§РРўРђРўР¬ РЎРўРћРРњРћРЎРўР¬ Р”РћРЎРўРђР’РљР"');
                            }
                        }
                        else
                        {
                            if (APC.states.activate)
                            {
                                console.log('e003');
                                APC.moveSuccess(() =&gt; bonus.modalPay(() =&gt; instance.ajaxOrderOffset()));
                            }
                            else
                            {
                                console.log('e004');
                                bonus.modalPay(() =&gt; instance.ajaxOrderOffset());
                            }
                        }
                    }

                };

                this.ajaxOrderOffset = function () {

                    let $actionLoader = $('.download_out');
                    $actionLoader.find('.cDownloadAuto p').empty();
                    $actionLoader.show();

                    if (!instanceForOffset.isPartnerHost()) datesUpdate();

                    let $alertModal = $('#alertModal');

                    let tCompany = '';
                    let isPickup = $(".cOffsetDelivery .radioPickUp").prop('checked'); // for partner

                    var date = $('#date_offset_ready').html().split('.');
                    var readyTime = date[2] + "-" + date[1] + "-" + date[0];

                    var delTime = "";
                    if (instanceForOffset.isPartnerHost())
                    {
                        date = $('#date_dpd_ready').html().split('.');

                        delTime = isPickup
                            ? spSerialize['tkDate']['y'] + "-" + spSerialize['tkDate']['m'] + "-" + spSerialize['tkDate']['d']
                            : date[2] + "-" + date[1] + "-" + date[0];
                    }
                    else
                    {
                        let dateAssoc = getDeliveryDateFirst('assoc');
                        date = [dateAssoc['y'], dateAssoc['m'], dateAssoc['d']];
                        delTime = date[2] + "-" + date[1] + "-" + date[0];
                    }

                    var postPrint = "";
                    $('.offset-checks').find('input').each(function () {
                        if ($(this).prop('checked'))
                        {
                            var parent = $(this).parents('.offset_check_one');
                            if (!!postPrint)
                            {
                                postPrint += ", " + parent.find('span').html();
                            }
                            else
                            {
                                postPrint += parent.find('span').html();
                            }
                        }
                    });

                    var deliv = '';
                    var del_us = '';

                    var dpd = 0;
                    var sdek = 0;
                    var ems = 0;
                    let ozon = 0;

                    if ($('.cOffsetDelivery .cDPDSelected:checked').length &amp;&amp; dpd_flag)
                    {
                        dpd = 1;
                        tCompany = 'DPD';
                    }
                    else if ($('.cOffsetDelivery .cDPDSelected:checked').length &amp;&amp; sdek_flag)
                    {
                        sdek = 1;
                        tCompany = 'SDEK';
                    }
                    else if ($('.cOffsetDelivery .cDPDSelected:checked').length &amp;&amp; ems_flag)
                    {
                        ems = 1;
                        tCompany = 'EMS';
                    }
                    else if ($('.cOffsetDelivery .cDPDSelected:checked').length &amp;&amp; ozon_flag)
                    {
                        ozon = 1;
                        tCompany = 'OZON';
                    }

                    // РџСЂРѕР±СѓРµРј РѕР±СЂР°Р±РѕС‚Р°С‚СЊ РєРѕР»РёР·РёСЋ СЃ СЃРѕР·РґР°РЅРёРµРј Р·Р°РєР°Р·Р° РїРѕ Р°РґСЂРµСЃРЅРѕР№ РґРѕСЃС‚Р°РІРєРµ, РєРѕС‚РѕСЂР°СЏ РЅР° СЃР°РјРѕРј РґРµР»Рµ СЏРІР»СЏРµС‚СЃСЏ РґРѕСЃС‚Р°РІРєРѕР№ DPD
                    let $radioPickUpDpd = $('.cOffsetDelivery .radioPickUpDpd');

                    let isRadioPickUpDpdChecked = $radioPickUpDpd.prop('checked');

                    var dpd_FIO = isRadioPickUpDpdChecked ? $('.cOffsetDelivery .dpd_terminal .del_fio').val() : $('.cOffsetDelivery .dpdTargetedBlock .del_fio').val();


                    var dpd_name = getDeliveryName(
                        isRadioPickUpDpdChecked
                            ? '.cOffsetDelivery .dpd_terminal .del_user'
                            : '.cOffsetDelivery .dpdTargetedBlock .del_user'
                        , dpd_FIO
                    );

                    // var dpd_phone = isRadioPickUpDpdChecked ? $('.cOffsetDelivery .dpd_terminal .del_phone').val() : $('.cOffsetDelivery .dpdTargetedBlock .del_phone').val();
                    var dpd_phone = state.getValue('delivery_phone');
                    var dpd_courier = isRadioPickUpDpdChecked ? $('.cOffsetDelivery .dpd_terminal .del_cour').val() : $('.cOffsetDelivery .dpdTargetedBlock .del_cour').val();

                    // РєРѕСЂСЂРµРєС‚РёСЂРѕРІРєР° РѕРїСЂРµРґРµР»РµРЅРёСЏ dpd РґРѕСЃС‚Р°РІРєРё (СЃРєРѕСЂРµРµ РІСЃРµРіРѕ С‚СЂРµР±СѓРµС‚ РїРµСЂРµСЃРјРѕС‚СЂР°)
                    var terminal = isRadioPickUpDpdChecked ? 1 : 0;


                    // Р­РєСЃРїСЂРµСЃСЃ РґРѕСЃС‚Р°РІРєР° (variant denvden)
                    if ($(".cOffsetDelivery .check_delivery .dvd_deliv").prop('checked')) {
                        tCompany = 'YGo';

                        del_us = $('.cOffsetDelivery #denvden_delivery .denvden_del_addr').val() + ', ' + $('.cOffsetDelivery #denvden_delivery .del_addr_hd').val();
                        dpd_adress = del_us;
                        dpd_city = $('#denvden_to_city').val();
                        dpd_country = 'Р&nbsp;РѕСЃСЃРёСЏ';

                        if (instanceForOffset.isPartnerHost())
                        {
                            dpd_region = $(".cOffsetDelivery .check_delivery #denvden_to_region").val();
                        }
                        else
                        {
                            dpd_region = $(".cOffsetDelivery .check_delivery .deliv").data('region');
                            if (!dpd_region)
                            {
                                // РљРѕСЃС‚С‹Р»СЊ 2023-10-12 12:30
                                dpd_region = $('.dpd_city').val().split(', ')[0];
                            }
                        }

                        terminal = 0;

                        dpd_FIO = $('.cOffsetDelivery #denvden_delivery  .del_fio').val();
                        dpd_name = getDeliveryName('.cOffsetDelivery #denvden_delivery  .del_user', dpd_FIO);
                        // dpd_phone = $('.cOffsetDelivery #denvden_delivery  .del_phone').val();
                        dpd_courier = $('.cOffsetDelivery #denvden_delivery .del_other').val();

                        if (instanceForOffset.isPartnerHost())
                        {
                            recipient_email = $('.cOffsetDelivery #denvden_delivery  .del_email').val();
                            deliv = 'Р•РєСЃРїСЂРµСЃСЃ РґРѕСЃС‚Р°РІРєР° РІ РґРµРЅСЊ РіРѕС‚РѕРІРЅРѕСЃС‚Рё РїРѕ Рі. ' + dpd_city + '; РђРґСЂРµСЃ: ' + dpd_adress + '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' + dpd_FIO + '; РўРµР»РµС„РѕРЅ: ' + dpd_phone + '; Р”РѕРїРѕР»РЅРёС‚РµР»СЊРЅРѕ: ' + dpd_courier;
                        }
                        else
                        {
                            deliv = 'Р•РєСЃРїСЂРµСЃСЃ РґРѕСЃС‚Р°РІРєР° Рі. ' + dpd_city + '; РђРґСЂРµСЃ: ' + dpd_adress + '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' + dpd_FIO + '; РўРµР»РµС„РѕРЅ: ' + dpd_phone + '; Р”РѕРїРѕР»РЅРёС‚РµР»СЊРЅРѕ: ' + dpd_courier;
                        }
                    }

                    // РђРґСЂРµСЃРЅР°СЏ РґРѕСЃС‚Р°РІРєР° (varinat targeted_city)
                    if ($(".cOffsetDelivery .check_delivery .deliv").prop('checked'))
                    {

                        deliv = 'РђРґСЂРµСЃРЅР°СЏ РґРѕСЃС‚Р°РІРєР° РїРѕ Рі. ' + $('#targeted_to_city').val() + '; РђРґСЂРµСЃ: ' + $('.cOffsetDelivery #targeted_delivery .del_addr').val() + ', ' + $('.cOffsetDelivery #targeted_delivery .del_addr_hd').val() + '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' + $('.cOffsetDelivery #targeted_delivery .del_fio').val() + '; РўРµР»РµС„РѕРЅ: ' + $('.cOffsetDelivery #targeted_delivery .del_phone').val() + '; Р”РѕРїРѕР»РЅРёС‚РµР»СЊРЅРѕ: ' + $('.cOffsetDelivery #targeted_delivery .del_other').val();
                        del_us = $('.cOffsetDelivery #targeted_delivery .del_addr').val() + ', ' + $('.cOffsetDelivery #targeted_delivery .del_addr_hd').val();
                        dpd_adress = del_us;
                        dpd_city = $('#targeted_to_city').val();
                        dpd_country = 'Р&nbsp;РѕСЃСЃРёСЏ';

                        if ($('#targeted_to_city').val() === 'Р&nbsp;РѕСЃС‚РѕРІ-РЅР°-Р”РѕРЅСѓ')
                        {
                            //sdek = 1;
                            //tCompany = 'SDEK';
                            dpd = 1;
                            tCompany = 'DPD';
                            dpd_region = $(".cOffsetDelivery .check_delivery .deliv").data('region');
                        }
                        else
                        {

                            dpd_country = 'Р&nbsp;РѕСЃСЃРёСЏ';
                            dpd_region = $(".cOffsetDelivery .check_delivery .deliv").data('region');
                            dpd_city = $('#targeted_to_city').val();
                            dpd_adress = $('.cOffsetDelivery #targeted_delivery .del_addr').val() + ', ' + $('.cOffsetDelivery #targeted_delivery .del_addr_hd').val();
                            dpd = 1;
                            tCompany = 'DPD';
                            service_code = 'PCL';
                            // РљРѕСЃС‚С‹Р»СЊ РґР»СЏ Р©РµСЂР±РёРЅРєРё
                            if (dpd_city == 'Р©РµСЂР±РёРЅРєР°')
                            {
                                dpd_city = 'Рі. Р©РµСЂР±РёРЅРєР°';
                                dpd_region = 'РњРѕСЃРєРѕРІСЃРєР°СЏ';
                            }

                        }


                        terminal = 0;

                        dpd_FIO = $('.cOffsetDelivery #targeted_delivery .del_fio').val();
                        dpd_name = getDeliveryName('.cOffsetDelivery #targeted_delivery  .del_user', dpd_FIO);
                        // dpd_phone = $('.cOffsetDelivery #targeted_delivery  .del_phone').val();
                        dpd_courier = $('.cOffsetDelivery #targeted_delivery  .del_other').val();
                        recipient_email = $('.cOffsetDelivery #targeted_delivery  .del_email').val();

                    }

                    // РЎР°РјРѕРІС‹РІРѕР· (variant pickup)
                    if ($(".cOffsetDelivery .radioPickUp").prop('checked')) {

                        if(sp_tk === 'dpd')
                        {
                            dpd = 1;
                            tCompany = 'DPD';
                        }
                        else if(sp_tk === 'sdek')
                        {
                            sdek =1;
                            tCompany = 'SDEK';
                        }
                        else if(sp_tk === 'ems')
                        {
                            ems = 1;
                            tCompany = 'EMS';
                        }
                        else if(sp_tk === 'ozon')
                        {
                            tCompany = 'OZON';
                        }
                        deliv = 'РЎР°РјРѕРІС‹РІРѕР· СЃРѕ СЃРєР»Р°РґР° ' + tCompany + ' РІ Рі. ' + sp_address;
                        if(sp_tk === 'ozon')
                        {
                            deliv = 'РЎР°РјРѕРІС‹РІРѕР· СЃРѕ СЃРєР»Р°РґР° OZON ' + sp_address;
                        }

                        dpd_country = 'Р&nbsp;РѕСЃСЃРёСЏ';
                        dpd_region = sp_region;
                        dpd_adress = sp_addr;
                        dpd_city = sp_city;

                        dpd_FIO = $('.cOffsetDelivery .pickup  .del_fio').val();
                        dpd_name = getDeliveryName('.cOffsetDelivery .pickup  .del_user', dpd_FIO);
                        // dpd_phone = $('.cOffsetDelivery .pickup .del_phone').val();
                        dpd_courier = $('.cOffsetDelivery .pickup  .del_other').val();
                        recipient_email = $('.cOffsetDelivery .pickup .del_email').val();

                        terminal = 1;
                        service_code = 'PCL';
                    }

                    // РўРµСЂРјРёРЅР°Р» (variant terminal)
                    if ($('.cOffsetDelivery .cDPDSelected:checked').length)
                    {
                        if (instanceForOffset.isPartnerHost())
                        {
                            if ($(".cOffsetDelivery .radioTargetedDpd").prop('checked')) {
                                if ($('.cOffsetDelivery .dpdTargetedBlock .del_addr_hd').val() == '') {
                                    $('.cOffsetDelivery .dpdTargetedBlock .del_addr_hd').css('border-color','red');
                                    $('#alertModal').find('.modal-body p').text("РќРµ РІСЃРµ РїРѕР»СЏ Р·Р°РїРѕР»РЅРµРЅС‹");
                                    $('#alertModal').modal('toggle');
                                    $('.download_out').css('display', 'none');
                                    return;
                                }
                                if (window.hasOwnProperty('ADDRESS_RECOGNIZER_RESULT'))
                                {
                                    let ADDRESS_RECOGNIZER_RESULT = window['ADDRESS_RECOGNIZER_RESULT'];

                                    if (ADDRESS_RECOGNIZER_RESULT.hasOwnProperty('dpd_location'))
                                    {
                                        let address = ADDRESS_RECOGNIZER_RESULT.dpd_location.ORIG_NAME;

                                        if (ADDRESS_RECOGNIZER_RESULT.hasOwnProperty('street_address'))
                                        {
                                            address += ', ' + ADDRESS_RECOGNIZER_RESULT.street_address;
                                        }

                                        const deliveryFIO = $('.cOffsetDelivery .dpdTargetedBlock .del_fio').val();
                                        deliv = `DPD РђРґСЂРµСЃРЅР°СЏ РґРѕСЃС‚Р°РІРєР° РђРґСЂРµСЃ: ${address}`;
                                        deliv += '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                            deliveryFIO +
                                            '; РќР°РёРјРµРЅРѕРІР°РЅРёРµ: ' +
                                            getDeliveryName('.cOffsetDelivery .dpdTargetedBlock .del_user', deliveryFIO) +
                                            '; РўРµР»РµС„РѕРЅ: ' +
                                            $('.cOffsetDelivery .dpdTargetedBlock .del_phone').val() +
                                            '; Р”РѕРїРѕР»РЅРёС‚РµР»СЊРЅРѕ: ' +
                                            $('.cOffsetDelivery .dpdTargetedBlock .del_cour').val();
                                    }

                                }
                                else
                                {
                                    const deliveryFIO = $('.cOffsetDelivery .dpdTargetedBlock .del_fio').val();
                                    deliv = 'DPD РђРґСЂРµСЃРЅР°СЏ РґРѕСЃС‚Р°РІРєР° РђРґСЂРµСЃ: ' +
                                        dpd_country +
                                        "," +
                                        dpd_region +
                                        ',' +
                                        dpd_city +
                                        ',' +
                                        dpd_adress +
                                        '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                        deliveryFIO +
                                        '; РќР°РёРјРµРЅРѕРІР°РЅРёРµ: ' +
                                        getDeliveryName('.cOffsetDelivery .dpdTargetedBlock .del_user', deliveryFIO) +
                                        '; РўРµР»РµС„РѕРЅ: ' +
                                        $('.cOffsetDelivery .dpdTargetedBlock .del_phone').val() +
                                        '; Р”РѕРїРѕР»РЅРёС‚РµР»СЊРЅРѕ: ' +
                                        $('.cOffsetDelivery .dpdTargetedBlock .del_cour').val();
                                }
                                del_us = $('.cOffsetDelivery .dpdTargetedBlock .del_addr').val()+', '+$('.cOffsetDelivery .dpdTargetedBlock .del_addr_hd').val();
                            }
                            else {
                                //console.log(dpd_terminal);
                                if (dpd_terminal === 'РџСѓРЅРєС‚ РІС‹РґР°С‡Рё')
                                {
                                    const deliveryFIO = $('.cOffsetDelivery .dpd_terminal .del_fio').val();
                                    deliv = 'DPD Р”РѕСЃС‚Р°РІРєР° РІ С‚РµСЂРјРёРЅР°Р» РђРґСЂРµСЃ: ' +
                                        dpd_country +
                                        "," +
                                        pd_region +
                                        ',' +
                                        full_terminal +
                                        '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                        deliveryFIO +
                                        '; РќР°РёРјРµРЅРѕРІР°РЅРёРµ: ' +
                                        getDeliveryName('.cOffsetDelivery .dpd_terminal .del_user', deliveryFIO) +
                                        '; РўРµР»РµС„РѕРЅ: ' +
                                        $('.cOffsetDelivery .dpd_terminal .del_phone').val();
                                    del_us = $('.cOffsetDelivery .dpd_terminal .del_addr').val();
                                } else {
                                    dpd_adress = dpd_terminal;
                                    if (dpd)
                                    {
                                        const deliveryFIO = $('.cOffsetDelivery .dpd_terminal .del_fio').val();
                                        deliv = 'DPD Р”РѕСЃС‚Р°РІРєР° РІ С‚РµСЂРјРёРЅР°Р» РђРґСЂРµСЃ: ' +
                                            dpd_country +
                                            "," +
                                            dpd_region +
                                            ',' +
                                            dpd_city +
                                            ',' +
                                            dpd_adress +
                                            '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                            deliveryFIO +
                                            '; РќР°РёРјРµРЅРѕРІР°РЅРёРµ: ' +
                                            getDeliveryName('.cOffsetDelivery .dpd_terminal .del_user', deliveryFIO) +
                                            '; РўРµР»РµС„РѕРЅ: ' +
                                            $('.cOffsetDelivery .dpd_terminal .del_phone').val();
                                    }
                                    if (sdek)
                                    {
                                        const deliveryFIO = $('.cOffsetDelivery .dpd_terminal .del_fio').val();
                                        deliv = 'РЎР”Р•Рљ Р”РѕСЃС‚Р°РІРєР° РІ С‚РµСЂРјРёРЅР°Р» РђРґСЂРµСЃ: ' +
                                            dpd_country +
                                            "," +
                                            dpd_region +
                                            ',' +
                                            dpd_city +
                                            ',' +
                                            dpd_adress +
                                            '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                            deliveryFIO +
                                            '; РќР°РёРјРµРЅРѕРІР°РЅРёРµ: ' +
                                            getDeliveryName('.cOffsetDelivery .dpd_terminal .del_user', deliveryFIO) +
                                            '; РўРµР»РµС„РѕРЅ: ' +
                                            $('.cOffsetDelivery .dpd_terminal .del_phone').val();
                                    }
                                    if (ems)
                                    {
                                        const deliveryFIO = $('.cOffsetDelivery .dpd_terminal .del_fio').val();
                                        deliv = 'EMS Р”РѕСЃС‚Р°РІРєР° РІ С‚РµСЂРјРёРЅР°Р» РђРґСЂРµСЃ: ' +
                                            dpd_country +
                                            "," +
                                            dpd_region +
                                            ',' +
                                            dpd_city +
                                            ',' +
                                            dpd_adress +
                                            '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                            deliveryFIO +
                                            '; РќР°РёРјРµРЅРѕРІР°РЅРёРµ: ' +
                                            getDeliveryName('.cOffsetDelivery .dpd_terminal .del_user', dekiveryFIO) +
                                            '; РўРµР»РµС„РѕРЅ: ' +
                                            $('.cOffsetDelivery .dpd_terminal .del_phone').val();
                                    }
                                    if (ozon)
                                    {
                                        const deliveryFIO = $('.cOffsetDelivery .dpd_terminal .del_fio').val();
                                        deliv = 'OZON Р”РѕСЃС‚Р°РІРєР° РІ С‚РµСЂРјРёРЅР°Р» РђРґСЂРµСЃ: ' +
                                            dpd_adress +
                                            '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                            deliveryFIO +
                                            '; РќР°РёРјРµРЅРѕРІР°РЅРёРµ: ' +
                                            getDeliveryName('.cOffsetDelivery .dpd_terminal .del_user', deliveryFIO) +
                                            '; РўРµР»РµС„РѕРЅ: ' +
                                            $('.cOffsetDelivery .dpd_terminal .del_phone').val();
                                    }
                                    del_us = $('.cOffsetDelivery .dpd_terminal .del_addr').val();
                                }
                            }
                        }
                        else
                        {
                            if ($(".cOffsetDelivery .radioTargetedDpd").prop('checked'))
                            {
                                let $addressInput = $('.cOffsetDelivery .dpdTargetedBlock .del_addr_hd');

                                if ($addressInput.val() == '')
                                {
                                    $addressInput.css('border-color', 'red');

                                    $alertModal.find('.modal-body p').text("РќРµ РІСЃРµ РїРѕР»СЏ Р·Р°РїРѕР»РЅРµРЅС‹");
                                    $alertModal.modal('toggle');
                                    $actionLoader.hide();
                                    return;
                                }

                                if (window.hasOwnProperty('ADDRESS_RECOGNIZER_RESULT'))
                                {
                                    let ADDRESS_RECOGNIZER_RESULT = window['ADDRESS_RECOGNIZER_RESULT'];

                                    if (ADDRESS_RECOGNIZER_RESULT.hasOwnProperty('dpd_location'))
                                    {
                                        let address = ADDRESS_RECOGNIZER_RESULT.dpd_location.ORIG_NAME;

                                        if (ADDRESS_RECOGNIZER_RESULT.hasOwnProperty('street_address'))
                                        {
                                            address += ', ' + ADDRESS_RECOGNIZER_RESULT.street_address;
                                        }

                                        const deliveryFIO = $('.cOffsetDelivery .dpdTargetedBlock .del_fio').val();
                                        deliv = `DPD РђРґСЂРµСЃРЅР°СЏ РґРѕСЃС‚Р°РІРєР° РђРґСЂРµСЃ: ${address}`;
                                        deliv += '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                            deliveryFIO +
                                            '; РќР°РёРјРµРЅРѕРІР°РЅРёРµ: ' +
                                            getDeliveryName('.cOffsetDelivery .dpdTargetedBlock .del_user', deliveryFIO) +
                                            '; РўРµР»РµС„РѕРЅ: ' +
                                            $('.cOffsetDelivery .dpdTargetedBlock .del_phone').val() +
                                            '; Р”РѕРїРѕР»РЅРёС‚РµР»СЊРЅРѕ: ' +
                                            $('.cOffsetDelivery .dpdTargetedBlock .del_cour').val();
                                    }

                                }
                                else
                                {
                                    const deliveryFIO = $('.cOffsetDelivery .dpdTargetedBlock .del_fio').val();
                                    deliv = 'DPD РђРґСЂРµСЃРЅР°СЏ РґРѕСЃС‚Р°РІРєР° РђРґСЂРµСЃ: ' +
                                        dpd_country +
                                        "," +
                                        dpd_region +
                                        ',' +
                                        dpd_city +
                                        ',' +
                                        dpd_adress +
                                        '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                        deliveryFIO +
                                        '; РќР°РёРјРµРЅРѕРІР°РЅРёРµ: ' +
                                        getDeliveryName('.cOffsetDelivery .dpdTargetedBlock .del_user', deliveryFIO) +
                                        '; РўРµР»РµС„РѕРЅ: ' +
                                        $('.cOffsetDelivery .dpdTargetedBlock .del_phone').val() +
                                        '; Р”РѕРїРѕР»РЅРёС‚РµР»СЊРЅРѕ: ' +
                                        $('.cOffsetDelivery .dpdTargetedBlock .del_cour').val();
                                }

                                del_us = $('.cOffsetDelivery .dpdTargetedBlock .del_addr').val() + ', ' + $('.cOffsetDelivery .dpdTargetedBlock .del_addr_hd').val();

                            }
                            else
                            {
                                if (dpd_terminal === 'РџСѓРЅРєС‚ РІС‹РґР°С‡Рё')
                                {
                                    const deliveryFIO = $('.cOffsetDelivery .dpd_terminal .del_fio').val();
                                    deliv = 'DPD Р”РѕСЃС‚Р°РІРєР° РІ С‚РµСЂРјРёРЅР°Р» РђРґСЂРµСЃ: ' +
                                        dpd_country +
                                        "," +
                                        dpd_region +
                                        ',' +
                                        full_terminal +
                                        '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                        deliveryFIO +
                                        '; РќР°РёРјРµРЅРѕРІР°РЅРёРµ: ' +
                                        getDeliveryName('.cOffsetDelivery .dpd_terminal .del_user', deliveryFIO) +
                                        '; РўРµР»РµС„РѕРЅ: ' +
                                        $('.cOffsetDelivery .dpd_terminal .del_phone').val();
                                    del_us = $('.cOffsetDelivery .dpd_terminal .del_addr').val();
                                }
                                else
                                {
                                    dpd_adress = dpd_terminal;
                                    const deliveryFIO = $('.cOffsetDelivery .dpd_terminal .del_fio').val();
                                    const deliveryName = getDeliveryName('.cOffsetDelivery .dpd_terminal .del_user', deliveryFIO);
                                    if (dpd)
                                    {
                                        deliv = 'DPD Р”РѕСЃС‚Р°РІРєР° РІ С‚РµСЂРјРёРЅР°Р» РђРґСЂРµСЃ: ' +
                                            dpd_country +
                                            "," +
                                            dpd_region +
                                            ',' +
                                            dpd_city +
                                            ',' +
                                            dpd_adress +
                                            '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                            deliveryFIO +
                                            '; РќР°РёРјРµРЅРѕРІР°РЅРёРµ: ' +
                                            deliveryName +
                                            '; РўРµР»РµС„РѕРЅ: ' +
                                            $('.cOffsetDelivery .dpd_terminal .del_phone').val();
                                    }
                                    if (sdek)
                                    {
                                        deliv = 'РЎР”Р•Рљ Р”РѕСЃС‚Р°РІРєР° РІ С‚РµСЂРјРёРЅР°Р» РђРґСЂРµСЃ: ' +
                                            dpd_country +
                                            "," +
                                            dpd_region +
                                            ',' +
                                            dpd_city +
                                            ',' +
                                            dpd_adress +
                                            '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                            deliveryFIO +
                                            '; РќР°РёРјРµРЅРѕРІР°РЅРёРµ: ' +
                                            deliveryName +
                                            '; РўРµР»РµС„РѕРЅ: ' +
                                            $('.cOffsetDelivery .dpd_terminal .del_phone').val();
                                    }
                                    if (ems)
                                    {
                                        deliv = 'EMS Р”РѕСЃС‚Р°РІРєР° РІ С‚РµСЂРјРёРЅР°Р» РђРґСЂРµСЃ: ' +
                                            dpd_country +
                                            "," +
                                            dpd_region +
                                            ',' +
                                            dpd_city +
                                            ',' +
                                            dpd_adress +
                                            '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                            deliveryFIO +
                                            '; РќР°РёРјРµРЅРѕРІР°РЅРёРµ: ' +
                                            deliveryName +
                                            '; РўРµР»РµС„РѕРЅ: ' +
                                            $('.cOffsetDelivery .dpd_terminal .del_phone').val();
                                    }
                                    if (ozon)
                                    {
                                        deliv = 'OZON Р”РѕСЃС‚Р°РІРєР° РІ С‚РµСЂРјРёРЅР°Р» РђРґСЂРµСЃ: ' +
                                            dpd_adress +
                                            '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                            deliveryFIO +
                                            '; РќР°РёРјРµРЅРѕРІР°РЅРёРµ: ' +
                                            deliveryName +
                                            '; РўРµР»РµС„РѕРЅ: ' +
                                            $('.cOffsetDelivery .dpd_terminal .del_phone').val();
                                    }
                                    del_us = $('.cOffsetDelivery .dpd_terminal .del_addr').val();
                                }
                            }
                        }
                    }



                    var coef = Math.cbrt(Number($('.check_delivery table .cDpdNum').html()) + Number($('.check_delivery table .cDpdNumDop').html()));


                    toggleButton();

                    if (!window["prefix"]) window["prefix"] = '_file';

                    // console.log(window.outbox_pdf + '_' + window.prefix + '.pdf');

                    if (!instanceForOffset.isPartnerHost())
                    {
                        if (!!window.DeliveryForm) DeliveryForm.save();
                    }

                    let prepData = {
                        ph_id: ph_id_for_order,
                        own_region: own_region,
                        name: $('.title_order textarea').val(),
                        product: cost['name'],
                        product_manager: product_manager,
                        size: $('.offset_info #size_info').html(),
                        material: cost['text'],
                        plot: cost['total_plot'],
                        print: cost['print'] + ' С€С‚.',
                        side: $('#sideIcon').html(),
                        postPrint: postPrint,
                        readyDate: readyTime,
                        leadTime: instanceForOffset.isPartnerHost() ? $('.leadTime').val() : $('#leadTime').val(),
                        actualDate: $('#actual_date_ready').val(),
                        printCost: /*$('.offset_cost #offset_print_cost').html() +*/ '0',
                        postPrintCost: /*$('.offset_cost #offset_post_cost').html() +*/ '0',
                        deliverCost: instanceForOffset.isPartnerHost() ? $('.offset_cost #ofset_cost_dppd').html() : $('.offset_cost #ofset_cost_onle_dpd').html() /*deliv_cost*/,
                        actualDeliverCost: $('#ofset_actual_delivery_cost').val(),
                        delivery: deliv,
                        del_user: del_us,
                        mass: $('.offset_info_head #mass_info').html(),
                        comment: $('.comment textarea').val(),
                        user_link: "",
                        kabinet: 'offset',
                        pay: $('.offset_cost .pay-block input:checked').val(),
                        print_name: cost['print_name'],
                        frontauto: /*$('.cFrontAuto').val()*/'',
                        backauto: /*$('.cBackAuto').val()*/'',
                        dpd_country: dpd_country,
                        dpd_region: dpd_region.replace(/вЂ”/g, "-"),
                        dpd_city: dpd_city,
                        dpd_adress: dpd_adress,
                        dpd_is_terminal: terminal,
                        dpd_FIO: dpd_FIO,
                        //'dpd_name': dpd_FIO,
                        dpd_name: dpd_name,
                        dpd_phone: dpd_phone,
                        dpd_courier: dpd_courier,
                        dpd_length: Number($('.cDpdLen').html()) * coef,
                        dpd_width: Number($('.cDpdWid').html()) * coef,
                        dpd_height: Number($('.cDpdHgt').html()) * coef,
                        dpd_weight: Number(Number($('.cDpdWgtAll').html()) + Number($('.cDpdWgtAllDop').html())).toFixed(2),
                        dpd_service_code: service_code,
                        recipient_email: instance.getFormEmail(),
                        dpd: dpd,
                        sdek: sdek,
                        ems: ems,
                        dpd_calc_err: dpd_calc_err,
                        deliveryDate: delTime,
                        noBonus: cost['noBonus'],
                        outbox_pdf: APC.file_id,
                        prefix_pdf: APC.getProductPrefixForSave(),
                        ap: APC.states.activate,
                        orderLog: _orderLog,
                        payBonus: $('#bonus_amount').val(),
                        tCompany: !!tCompany ? tCompany : DeliveryInstance.getSelectedCompany(),
                        CURRENT_PRODUCT_ID: $('#table_info').val(),
                        autoprocess: {preview_files: APC.getPreviewFiles()},
                        ADDRESS_RECOGNIZER_RESULT: window.ADDRESS_RECOGNIZER_RESULT,
                        descriptionFiles: !!FileLoader ? FileLoader.descriptions : null,
                        user: appInstance.getUser(),
                        ps: {
                            delivery: {
                                point_key: DeliveryInstance.getPointKey(),
                            }
                        }
                    };

                    let url;

                    if (instanceForOffset.isPartnerHost())
                    {
                        url = "/AJAX/makeOrderVtorge.php";
                        prepData.totalCost = Math.ceil($('.offset_cost #real_ofset_cost_dpd').text());
                        prepData.userTotalCost = Math.ceil($('.offset_cost #ofset_cost_dpd').text());
                        prepData.recipient_email = recipient_email;
                        prepData.partnerNoBonus = cost['partnerNoBonus'];
                        prepData.spSerialize = (isPickup ? spSerialize : {});
                        prepData.printin = {orderFiles: APC.printinOrderFiles()};
                        prepData.client_inform = partnerTools.ClientInform.getChecked() ? 'on' : 'off';
                        prepData.client_cost_value = partnerTools.ClientInform.getCost();
                        prepData.client_paid_value = partnerTools.ClientInform.getPaid();
                        prepData.client_status_value = partnerTools.ClientInform.getStatus();
                        prepData.upload_ids = !!FileLoader ? FileLoader.getUploads() : {};
                        prepData.orderSign = OffsetProductInstance.getSign();
                    }
                    else
                    {
                        url = "/AJAX/makeOrderRostov.php";
                        prepData.totalCost = Math.ceil($('.offset_cost #ofset_cost_dpd').text());
                        prepData.OFFSET_PRODUCT_INSTANCE = OffsetProductInstance.getData();
                        prepData.upload_ids = FileLoader.getUploads();
                        prepData.orderSign = OffsetProductInstance.getSign();
                    }

                    const partnerCallback = function (response) {
                        switch (response.type) {
                            case 'done':
                                if (!!response['payment_page'])
                                {
                                    location.href = response['payment_page'];
                                }
                                else
                                {
                                    location.href = '/order';
                                }
                                break;
                            case 'card':
                                var info = response.info;
                                let _data = {
                                    'service': 'card',
                                    'orderNumber': info.id,
                                    'amount': info.totalCost,
                                    'partner': info.partner,
                                    'clientId': info.user_id,
                                    'description': info.name,
                                    'email': info.email
                                };

                                $.ajax({
                                    type: 'POST',
                                    data: _data,
                                    url: "/AJAX/partner_user_doPayment.php",
                                    async: true,
                                    success: function (data) {
                                        console.log(data);
                                        var response = JSON.parse(data);
                                        console.log(response);
                                        if (response['orderId'] &amp;&amp; response['formUrl']) {
                                            location.href = response['formUrl'];
                                        } else {
                                            if (response['errorMessage']) {

                                                // console.log(response['errorMessage']);
                                                location.href = '/order';
                                            }
                                            // РґРѕР±Р°РІРёС‚СЊ РІС‹РІРѕРґ РѕС€РёР±РєРё
                                        }

                                    }
                                });
                                break;

                            case 'cash':
                                location.href = '/order';
                                break;
                            case 'invoice':
                                if (!!response.info.id)
                                {
                                    $.ajax({
                                        type: 'POST',
                                        data: {
                                            id: response.info.id
                                        },
                                        url: "/AJAX/partner_order_generate_schet.php",
                                        async: true,
                                    }).always(() =&gt; {
                                        location.href = '/order';
                                    });
                                }
                                break;
                            case 'yookassa':
                                let $form = $('#YooKassa-Payment-Form form');
                                if ($form.length)
                                {
                                    let orderInfo = response.info;

                                    $form.find('input[name="customerNumber"]').val(orderInfo.yookassa['customerNumber']);
                                    $form.find('input[name="sum"]').val(orderInfo.totalCost);
                                    $form.find('input[name="orderNumber"]').val(orderInfo.yookassa['orderNumber']);

                                    let $success = $form.find('input[name="shopSuccessURL"]');
                                    $success.val($success.val() + `/${orderInfo.id}/${response.yookassa}/${orderInfo.totalCost}`);

                                    let $fail = $form.find('input[name="shopFailURL"]');
                                    $fail.val($fail.val() + `/${orderInfo.id}/${response.yookassa}/${orderInfo.totalCost}`);

                                    $form.submit();
                                }
                                else
                                {
                                    location.href = '/order';
                                }
                                break;

                            case 'robokassa':
                                let $formContainer = $('#Robokassa-Payment-Form');
                                if ($formContainer.length &amp;&amp; response.robokassa &amp;&amp; response.robokassa.form)
                                {
                                    $formContainer.html(response.robokassa.form);
                                    let $form = $formContainer.find('form');
                                    if ($form.length)
                                    {
                                        $form.submit();
                                    }
                                    else
                                    {
                                        location.href = '/order';
                                    }
                                }
                                else
                                {
                                    location.href = '/order';
                                }
                                break;

                            case 'time':
                                //alert("Р’Рѕ РІСЂРµРјСЏ СЃРѕР·РґР°РЅРёСЏ Р·Р°РєР°Р·Р° РІРѕР·РЅРёРєР»Рё РЅРµРёСЃРїСЂР°РІРЅРѕСЃС‚Рё. РџСЂРёРЅРѕСЃРёРј СЃРІРѕРё РёР·РІРёРЅРµРЅРёСЏ.");
                                $('#alertModal').find('.modal-body p').text("Р’Рѕ РІСЂРµРјСЏ СЃРѕР·РґР°РЅРёСЏ Р·Р°РєР°Р·Р° РІРѕР·РЅРёРєР»Рё РЅРµРёСЃРїСЂР°РІРЅРѕСЃС‚Рё. РџСЂРёРЅРѕСЃРёРј СЃРІРѕРё РёР·РІРёРЅРµРЅРёСЏ.");
                                $('#alertModal').modal('toggle');

                                toggleButton();
                                break;
                            case 'guest':
                                $('#alertModal').find('.modal-body p').text("Р”Р»СЏ РѕС„РѕСЂРјР»РµРЅРёСЏ Р·Р°РєР°Р·Р° РЅРµРѕР±С…РѕРґРёРјРѕ РїСЂРѕР№С‚Рё СЂРµРіРёСЃС‚СЂР°С†РёСЋ Р»РёР±Рѕ РІРѕР№С‚Рё РІ Р»РёС‡РЅС‹Р№ РєР°Р±РёРЅРµС‚!");
                                $('#alertModal').modal('toggle');

                                toggleButton();
                                break;

                        }
                    };

                    const callback = function (response)  {
                        switch (response.type)
                        {
                            case 'done':
                                location.href = '/payment?order_id=' + response.info.id;
                                break;
                            case 'time':
                                $alertModal.find('.modal-body p')
                                    .text("Р’Рѕ РІСЂРµРјСЏ СЃРѕР·РґР°РЅРёСЏ Р·Р°РєР°Р·Р° РІРѕР·РЅРёРєР»Рё РЅРµРёСЃРїСЂР°РІРЅРѕСЃС‚Рё. РџСЂРёРЅРѕСЃРёРј СЃРІРѕРё РёР·РІРёРЅРµРЅРёСЏ.");
                                $alertModal.modal('toggle');

                                toggleButton();
                                break;
                            case 'guest':
                                $alertModal.find('.modal-body p')
                                    .text("Р”Р»СЏ РѕС„РѕСЂРјР»РµРЅРёСЏ Р·Р°РєР°Р·Р° РЅРµРѕР±С…РѕРґРёРјРѕ РїСЂРѕР№С‚Рё СЂРµРіРёСЃС‚СЂР°С†РёСЋ Р»РёР±Рѕ РІРѕР№С‚Рё РІ Р»РёС‡РЅС‹Р№ РєР°Р±РёРЅРµС‚!");
                                $alertModal.modal('toggle');

                                toggleButton();
                                break;

                            case 'fail':
                                $alertModal.find('.modal-body p')
                                    .text("Р’Рѕ РІСЂРµРјСЏ СЃРѕР·РґР°РЅРёСЏ Р·Р°РєР°Р·Р° РІРѕР·РЅРёРєР»Рё РЅРµРёСЃРїСЂР°РІРЅРѕСЃС‚Рё. РџСЂРёРЅРѕСЃРёРј СЃРІРѕРё РёР·РІРёРЅРµРЅРёСЏ.");
                                $alertModal.modal('toggle');

                                toggleButton();
                                break;
                        }
                    };

                    $.ajax({
                        type: 'POST',
                        data: prepData,
                        url: url,
                        async: true,
                        dataType: 'json',
                        success: function (response) {

                            $actionLoader.hide();
                            myDropzone['offsetTemplate'].removeAllFiles();
                            myDropzone['offsetPreview'].removeAllFiles();

                            if (response)
                            {
                                if (instanceForOffset.isPartnerHost())
                                {
                                    partnerCallback(response);
                                }
                                else
                                {
                                    callback(response);
                                }
                            }
                            else
                            {
                                $alertModal.find('.modal-body p').text("Р’Рѕ РІСЂРµРјСЏ СЃРѕР·РґР°РЅРёСЏ Р·Р°РєР°Р·Р° РІРѕР·РЅРёРєР»Рё РЅРµРёСЃРїСЂР°РІРЅРѕСЃС‚Рё. РџСЂРёРЅРѕСЃРёРј СЃРІРѕРё РёР·РІРёРЅРµРЅРёСЏ.");
                                $alertModal.modal('toggle');
                            }
                        },
                        error: () =&gt; alert('error!'),
                    });
                };
            })();

            const __initListenerMultiCostTable = function () {
                // РЎРѕР·РґР°РЅРёРµ РїСЂР°Р№СЃР° С†РµРЅ РјРЅРѕРіРѕСЃС‚СЂР°РЅРёС‡РЅРѕР№ РїРµС‡Р°С‚Рё
                var pages = [];
                $('.cMultipageTitle input[name=id_page]:checked').each(function (i, elem) {
                    pages.push($(elem).attr('val'));
                });

                //  COVER
                //$('.cMultipageTitle input[name=id_cover_material]:checked').attr('val')
                var id_cover = [];

                $('.cMultipageTitle input[name=id_cover_material]:checked').each(function (i, elem) {
                    id_cover.push($(elem).attr('val'));
                });

                // DECOR
                var id_decor = MultiPage.decorSelect();

                // INSIDE
                var inside = '';
                var id_inside = [];
                $('.cMultipageTitle input[name=id_inside_material]:checked').each(function (i, elem) {
                    id_inside.push($(elem).attr('val'));
                    // if (inside == '') {
                    //     inside = $(elem).attr('text');
                    // } else {
                    //     inside += ' '+$(elem).attr('text');
                    // }
                    inside += ' ' + $(elem).attr('text');

                    // console.log("INSIDE Mutation");

                });

                let _tmp_data = {
                    'otype': otype,
                    'id_real_prod': $('.cMultipageTitle input[name=id_real_product]:checked').attr('id'),
                    'id_cover': id_cover,
                    'cover_side': MultiPage.coverSide(false),
                    'id_decor': id_decor,
                    'decor_side': $('.cMultipageTitle input[name=decor_side]:checked').attr('val'),
                    'id_inside': id_inside,
                    'size_pack': $('.cMultipageTitle input[name=cover_side]:checked').attr('text'),
                    'size_pack_pvd': $('.cMultipageTitle input[name=id_cover_material]:checked').attr('pvd_pack'),
                    //'id_inside': $('.cMultipageTitle input[name=id_inside_material]:checked').attr('val'),
                    'inside_side': (() =&gt; {
                        let _check = $('.cMultipageTitle input[name=inside_side]:checked').attr('val');
                        return _check ? _check : ''
                    })(),
                    'id_bond': $('.cMultipageTitle input[name=bond]:checked').attr('val'),
                    //'id_bond': $('.cMultipageTitle input[name=bond]').attr('val'),
                    'pages': pages,
                    'cover': $('.cMultipageTitle input[name=id_cover_material]:checked').attr('text') + ' ' + $('.cMultipageTitle input[name=cover_side]:checked').attr('text'),
                    'inside': inside
                        ? inside + ', ' + $('.cInsideSide .filter_title').html() + ': ' + $('.cMultipageTitle input[name=inside_side]:checked').attr('text')
                        : '',
                    'inside2': inside
                        ? inside + ', ' + $('.cInsideSide .filter_title').html() + ': ' + $('.cMultipageTitle input[name=inside_side]:checked').attr('text')
                        : '',
                    //'inside': $('.cMultipageTitle input[name=id_inside_material]:checked').attr('text') + ', ' + $('.cInsideSide .filter_title').html() + ': ' + $('.cMultipageTitle input[name=inside_side]:checked').attr('text'),
                    'decor': $('.cMultipageTitle input[name=id_decor]:checked').attr('text') + ' ' + $('.cMultipageTitle input[name=decor_side]:checked').attr('text'),
                    'bond': $('.cMultipageTitle input[name=bond]:checked').attr('text')
                }
//console.log(_tmp_data);
                let url = "/AJAX/multipage_get_cost_table_new.php";
                let group_id = $('#group_id').val();
                if (instanceForOffset.isPartnerHost() &amp;&amp; group_id === "9")
                {
                    url = "/AJAX/multipage_get_cost_partner_table_new.php";
                }

                $.ajax({
                    type: 'POST',
                    data: _tmp_data,
                    url: url,
                    async: true,
                    success: function (data) {
                        //console.log(data);
                        var result = JSON.parse(data);
                        var numRow = 0;
                        //console.log(result);
                        $('.offset-materail-table').html(result.block);
                        $('.offset-materail-table').find('table').each(function (item, id) {
                            numRow = id.rows.length;
                        });
                        if (numRow &lt; 2)
                        {
                            $('.offset-materail-table').html('&lt;div style="text-align: center;"&gt;РџСЂРёРЅРѕСЃРёРј СЃРІРѕРё РёР·РІРёРЅРµРЅРёСЏ, РЅР° РґР°РЅРЅС‹Р№ РјРѕРјРµРЅС‚ РїСЂРѕРґСѓРєС†РёСЏ СЃ РІС‹Р±СЂР°РЅРЅС‹РјРё РІР°РјРё РїР°СЂР°РјРµС‚СЂР°РјРё РЅРµ РґРѕСЃС‚СѓРїРЅР°.&lt;/div&gt;');
                        }
                        $(".offset-materail-table").find('.time_multi').each(function () {

                            var readyTime = TimeControl.parseReadyTime($(this).text(), false);

                            printTime = $(this).text();
                            $(this).attr("preldate", readyTime);

                            //Р’СЂРµРјСЏ РґР»СЏ РєР»РёРµРЅС‚Р°
                            readyTime =  TimeControl.parseReadyTime($(this).text(), true);

                            var time = readyTime.split('-');
                            if (time[1].length == 1)
                            {
                                time[1] = "0" + time[1];
                            }
                            if (time[2].length == 1)
                            {
                                time[2] = "0" + time[2];
                            }
                            $(this).attr("finaldate", time[2] + '.' + time[1] + '.' + time[0]);

                            ph_id = $(this).attr('ph_num');
                            ph_id_for_order = ph_id;
                            if ($(this).attr('ph_preintaled') === '1' &amp;&amp; Math.ceil($(this).attr('delivery_time')) &gt; 0)
                            {
                                let del_date = TimeControl.readyTimeDeliveryCT(time, Math.ceil($(this).attr('delivery_time')));

                                let day = del_date['d'].length === 1 ? `0${del_date['d']}` : del_date['d'];
                                let month = del_date['m'].length === 1 ? `0${del_date['m']}` : del_date['m'];

                                $(this).css('font-size', '11px');
                                $(this).text(`РџР»Р°РЅРёСЂСѓРµРјР°СЏ РґР°С‚Р° РґРѕСЃС‚Р°РІРєРё ${day}.${month}`);

                            }
                            else
                            {
                                $(this).text(`Р“РѕС‚РѕРІРЅРѕСЃС‚СЊ РЅР° ${time[2]}.${time[1]}`);
                            }


                        });

                    }
                });
            };

            const __initialize = function () {

                const __initListenerSearchAB = function () {
                    $("#search_ab").keyup(function () {
                        _this = this;
                        $.each($(".address_table tbody tr"), function () {
                            if ($(this).text().toLowerCase().indexOf($(_this).val().toLowerCase()) === -1)
                            {
                                $(this).hide();
                            }
                            else
                            {
                                $(this).show();
                            }
                        });
                    });
                };

                const __initFancyboxProductImg = function () {
                    $('#product_preview_img').fancybox({
                        helpers: {
                            title: {
                                type: 'float'
                            }
                        }
                    });
                };

                const __initAvailableTags = function () {
                    $.ajax({
                        type: 'POST',
                        url: "/AJAX/search_city.php",
                        async: false,
                        success: function (data) {
                            availableTags = JSON.parse(data);
                        }
                    });
                };

                const __initListenerMessage = function () {
                    $(window).on("message", function (e) {

                        if (e.originalEvent.origin !== "https://rocket.ozon.ru") return;
                        let data = e.originalEvent.data;
                        try
                        {
                            let resp = JSON.parse(data);
                            $('.download_out').css('display', 'block');
                            $.ajax({
                                type: 'POST',
                                data: {
                                    'id': resp.id
                                },
                                url: "/AJAX/get_OZON_terminal_info.php",
                                async: false,
                                success: function (data) {
                                    let Terminal_info = JSON.parse(data);
                                    if ($('.check_delivery .tab input:checked').data('delivery_type') === 'SP')
                                    {
                                        if (Terminal_info.settlement == $('#SPPOZON_iframe').data('city'))
                                        {
                                            sp_region = Terminal_info.region;
                                            sp_addr = Terminal_info.address;
                                            sp_address = Terminal_info.address;
                                            sp_city = Terminal_info.settlement;
                                            sp_tk = $('#SPPOZON_iframe').data('tk');

                                            newDate = TimeControl.readyTimeDelivery(Number($('#SPPOZON_iframe').data('deliveryperiod')));

                                            if (instanceForOffset.isPartnerHost())
                                            {
                                                // old variant
                                                $('.deliveryDate').text(newDate['d'] + '.' + newDate['m'] + "." + newDate['y']);
                                            }
                                            else
                                            {
                                                setDeliveryDate(newDate, 1);
                                            }
                                            $('.cPickUpDate').html(newDate['d'] + '.' + newDate['m'] + "." + newDate['y']);
                                            $('.SPP_address').html('&lt;font color="red"&gt;' + sp_address + '&lt;/font&gt;');
                                            $('.SPP_comment').html(Terminal_info.howToGet);

                                            $('.check_delivery .sp_points .spp_block').css('display', 'block');
                                            $('.check_delivery .sp_points').css('display', 'block');
                                        }
                                        else
                                        {
                                            sp_region = '';
                                            sp_addr = '';
                                            sp_address = '';
                                            sp_city = '';
                                            sp_tk = '';
                                            $('.check_delivery .sp_points').css('display', 'none');

                                            if (instanceForOffset.isPartnerHost())
                                            {
                                                // old variant
                                                $('.deliveryDate').text($('.dateReady').html());
                                            }
                                            else
                                            {
                                                let dateReadySplit = $('.dateReady').html().split('.');
                                                setDeliveryDate({
                                                    d: dateReadySplit[0],
                                                    m: dateReadySplit[1],
                                                    y: dateReadySplit[2]
                                                }, 2);
                                            }

                                            $('.cPickUpDate').html($('.dateReady').html());
                                            $('.SPP_address').html('&lt;font color="red"&gt;' + sp_address + '&lt;/font&gt;');
                                            $('.SPP_comment').html('');
                                            dpd_ready = false;
                                            dpd_flag = false;
                                            sdek_flag = false;
                                            ems_flag = false;
                                            ozon_flag = false;
                                            $('.download_out').css('display', 'none');
                                            $('#alertModal').find('.modal-body p').html("&lt;b&gt;РЎР°РјРѕРІС‹РІРѕР·&lt;/b&gt; РґРѕСЃС‚СѓРїРµРЅ С‚РѕР»СЊРєРѕ РІ &lt;b&gt;" + $('#SPPOZON_iframe').data('city') + "&lt;/b&gt;.&lt;br&gt;Р”Р»СЏ РґРѕСЃС‚Р°РІРєРё РІ РґСЂСѓРіРёРµ РіРѕСЂРѕРґР° РёСЃРїРѕР»СЊР·СѓР№С‚Рµ РїСѓРЅРєС‚ &amp;rdquo;Р­РєСЃРїСЂРµСЃСЃ-Р”РѕСЃС‚Р°РІРєР° РґРѕ РїСѓРєС‚Р°&amp;rdquo;");
                                            $('#alertModal').modal('toggle');

                                        }

                                    }
                                    else
                                    {
                                        dpd_terminal = Terminal_info.address;
                                        dpd_terminal_info = Terminal_info.howToGet;

                                        $('#dpd_delivery .block_is_ik .del_addk').html(dpd_terminal);
                                        $('#dpd_delivery .block_is_ik .del_addr').html(dpd_terminal_info);

                                        dpd_country = 'Р&nbsp;РѕСЃСЃРёСЏ';
                                        dpd_region = Terminal_info.region;
                                        dpd_region2 = Terminal_info.region;
                                        dpd_city = Terminal_info.settlement;
                                        dpd_adress = dpd_terminal;
                                        deliveryVariantId = Terminal_info.variant_id;

                                        $('.offset_delivery .delivery_block_dpd_dpdp').css('display', 'block');
                                        dpd_ready = false;
                                        dpd_flag = false;
                                        sdek_flag = false;
                                        ems_flag = false;
                                        ozon_flag = true;
                                        $('.totalCost').text($('.printCost').html());
                                        $('.deliveryCost').text(0);

                                        if (instanceForOffset.isPartnerHost())
                                        {
                                            // old variant
                                            $('.deliveryDate').text($('.dateReady').html());
                                        }
                                        else
                                        {
                                            let dateReadySplit = $('.dateReady').html().split('.');
                                            setDeliveryDate({d: dateReadySplit[0], m: dateReadySplit[1], y: dateReadySplit[2]}, 3);
                                        }
                                    }


                                }
                            });


                        } catch (e)
                        {

                        }
                        $('.download_out').css('display', 'none');
                    });
                };

                const __initCalendar = function () {
                    $.ajax({
                        type: 'POST',
                        url: "/AJAX/get_not_calendar.php",
                        async: true,
                        success: function (data) {
                            calendar = JSON.parse(data);

                            calendar_weekdays = calendar[1];
                            calendar = calendar[0];
                        }
                    });
                };

                const __initExtraDay = function () {
                    $.ajax({
                        type: 'POST',
                        url: "/AJAX/get_user_city_data.php",
                        data: "ajx=1",
                        async: false,
                        success: function (data) {
                            extra_day = parseInt(JSON.parse(data)['delivery_time']);
                        }
                    });
                };

                const __initListenerImageOptionsInput = function () {
                    $('.image_options_form input').change(function () {
                        $('.image_section .image_after img').attr('src', $(this).val());
                        $('.image_section .images_dis a').attr('href', $(this).attr('for_dis'));
                        //$('.image_section .image_after a').attr('href',$(this).val());
                    });
                };

                const __initListenerOffsetChecks = function () {
                    $('.offset-checks input').change(function () {
                        if ($(this).attr('name') === 'designer')
                        {
                            const isChecked = $(this).prop('checked');

                            const currentCost = Number($('.printCost').html());
                            const deliveryCost = Number($('.deliveryCost').html());

                            const price = 70;
                            const value = isChecked ? price : price * -1;

                            const newCost = currentCost + value;
                            const newSum = newCost + deliveryCost;

                            $('#offset_print_cost').html(newCost);
                            $('#ofset_cost_dpd').html(newSum);

                            if (instanceForOffset.isPartnerHost())
                            {
                                const realCost = Number($('.realPrintCost').html());
                                const newRealCost = realCost + value;
                                const newRealSum = newRealCost + deliveryCost;

                                $('#real_offset_print_cost').html(newRealCost);
                                $('#real_ofset_cost_dpd').html(newRealSum);
                            }
                        }
                    });
                };

                const __initListenerCreateOrder = function () {
                    $('#save_offset_order').on('click', function () {

                        if (save_offset_order_clickable)
                        {
                            save_offset_order_clickable = false;

                            var stop = false;

                            let cost = $('.printCost').html();

                            if (cost &lt; 1)
                            {
                                alert('РџСЂРѕРІРµСЂСЊС‚Рµ РїРѕР¶Р°Р»СѓР№СЃС‚Р° РїР°СЂР°РјРµС‚СЂС‹ РїСЂРѕРґСѓРєС†РёРё');
                                return false;
                            }
                            $.ajax({
                                type: 'POST',
                                url: "/AJAX/kabinet_checkContinue.php",
                                async: false,
                                data: {
                                    'cost': cost
                                },
                                success: function (data) {
                                    if (data.localeCompare("continue") != 0)
                                    {
                                        //alert('Р’С‹ РЅРµ РјРѕР¶РµС‚Рµ СЃРґРµР»Р°С‚СЊ Р·Р°РєР°Р·. РќРµРѕР±С…РѕРґРёРјРѕ РїРѕРїРѕР»РЅРёС‚СЊ СЃС‡РµС‚ Р»РёР±Рѕ СЃРІСЏР¶РёС‚РµСЃСЊ СЃ РјРµРЅРµРґР¶РµСЂРѕРј РґР»СЏ Р°РєС‚РёРІР°С†РёРё Р°РєРєР°СѓРЅС‚Р°.');
                                        $('#alertModal').find('.modal-body p').text("Р’С‹ РЅРµ РјРѕР¶РµС‚Рµ РѕС„РѕСЂРјРёС‚СЊ Р·Р°РєР°Р·. РќРµРѕР±С…РѕРґРёРјРѕ РїРѕРїРѕР»РЅРёС‚СЊ СЃС‡РµС‚, Р»РёР±Рѕ СЃРІСЏР¶РёС‚РµСЃСЊ СЃ РјРµРЅРµРґР¶РµСЂРѕРј, РґР»СЏ Р°РєС‚РёРІР°С†РёРё Р°РєРєР°СѓРЅС‚Р°.");
                                        $('#alertModal').modal('toggle');
                                        stop = true;
                                    }
                                }
                            });

                            if (stop)
                            {
                                save_offset_order_clickable = true;
                                $(this).prop('disabled', false);
                                return false;
                            }

                            APC.accessSave(Maker.makeOrderOffset);

                            save_offset_order_clickable = true;
                            $(this).prop('disabled', false);
                        }
                    });
                };

                const __initListenersSwitchVisibleFormat = function () {
                    $('.offset-materail-table').on('change', '.switch-component input[type=checkbox]', function () {

                        let $el = $(this),
                            $left = $el.siblings('.left'),
                            $right = $el.siblings('.right');

                        if ($el.prop('checked'))
                        {
                            $left.css('color', '#cdc5bf');
                            $right.css('color', '#fff');
                        }
                        else
                        {
                            $right.css('color', '#cdc5bf');
                            $left.css('color', '#fff');
                        }

                    })
                        .on('change', '.cost_visor input[type=checkbox]', function () {
                            let $el = $(this),
                                $parent = $el.parents('.material');

                            if ($el.prop('checked'))
                            {
                                $parent.find('table span[clickable=click]').each(function () {
                                    $(this).text($(this).attr('one'));
                                });
                            }
                            else
                            {
                                $parent.find('table span[clickable=click]').each(function () {
                                    $(this).text($(this).attr('tir_val'));
                                });
                            }
                            if (instanceForOffset.isPartnerHost())
                            {
                                $parent.find(".price-tag").each(function() {
                                    partnerTools.priceTagUpdateFormat(this, {
                                        forUnit: $el.prop('checked')
                                    });
                                });
                            }
                        })
                        .on('change', '.cost_visor .one_vis', function () {
                            if ($(this).prop('checked'))
                            {
                                var parent = $(this).parents('.material');
                                parent.find('table span[clickable=click]').each(function () {
                                    $(this).text($(this).attr('one'));
                                });

                            }
                        })
                        .on('change', '.cost_visor .tir_vis', function () {
                            if ($(this).prop('checked'))
                            {
                                var parent = $(this).parents('.material');
                                parent.find('table span[clickable=click]').each(function () {
                                    $(this).text($(this).attr('tir_val'));
                                });
                            }
                        })
                        .on('change', '.custom_tir_select', function () {

                            let $el = $(this),
                                $material = $el.parents('.material'),
                                $switch = $material.find('.cost_visor .switch-component');

                            let trigger = false;

                            if ($switch.length)
                            {
                                trigger = !$switch.find('input[type=checkbox]').prop('checked');
                            }
                            else
                            {
                                trigger = $(this).closest('.material').find('.cost_visor input:checked').hasClass('tir_vis');
                            }

                            if (trigger)
                            {
                                let val = $(this).val();

                                let $table = $(this).closest('table');

                                $table.find('span.custom_tir').each(function () {

                                    let one = parseFloat($(this).attr('one'));

                                    let sum = one * val;
                                    $(this).attr('tir', val);
                                    $(this).attr('tir_val', parseInt(sum));
                                    if (instanceForOffset.isPartnerHost())
                                    {
                                        $(this).text(sum.toLocaleString() + $(this).attr('rub'));
                                        if ($(this).attr('multi'))
                                        {
                                            let real_one = parseFloat($(this).attr('real_one'));
                                            let real_sum = real_one * val;
                                            $(this).attr('real_tir_val', parseInt(real_sum));
                                        }
                                    }
                                    else
                                    {
                                        $(this).text(sum.toLocaleString());
                                    }
                                });

                                if (instanceForOffset.isPartnerHost())
                                {
                                    $material.find(".price-tag").each(function () {
                                        partnerTools.priceTagUpdateFormat(this, {
                                            forUnit: $switch.length &amp;&amp; $switch.find('input[type=checkbox]').prop('checked'),
                                        });
                                    });
                                }
                            }
                        })
                        .on('change', '.delivery_visor input[type=checkbox]', function () {
                            let $el = $(this),
                                $parent = $el.parents('.material');

                            if ($el.prop('checked'))
                            {
                                $parent.find('table .time_to_parse').each(function () {
                                    $(this).text($(this).attr('withDelivery'));
                                });
                            }
                            else
                            {
                                $parent.find('table .time_to_parse').each(function () {
                                    $(this).text($(this).attr('withoutDelivery'));
                                });
                            }
                        });
                };

                const __initListenerPopularProduct = function () {
                    // РџРµСЂРµС…РѕРґ Рє РЅСѓР¶РЅРѕРјСѓ РїСЂРѕРґСѓРєС‚Сѓ РёР· РїРѕРїСѓР»СЏСЂРЅС‹С…
                    $('span[table=popularProductClick]').bind('click', function (e) {
                        var product_id = $(this).attr('productid');
                        var tab_id = $(this).attr('tabs_id');
                        otype = $(this).attr('otype');

                        if (otype != '')
                        {
                            $('#tabs-' + tab_id + ' .first_block_product span').css('display', 'none');
                            $('#tabs-' + tab_id + ' .first_block_product').find('span').each(function () {
                                if ($(this).attr('otype') == otype)
                                {
                                    $(this).css('display', 'block');
                                }
                            });
                        }

                        window.location = window.location.toString().split('#')[0] + '#' + tab_id;

                        $('#tabs_container #tabs-' + tab_id + ' .first_block_product').children('div, span').each(function () {
                            if ($(this).attr('productid') == product_id || $(this).attr('id') == product_id)
                            {
                                $(this).trigger('click');
                            }
                        });
                    });
                };

                const __initListenerPromoProduct = function () {
                    // РџРµСЂРµС…РѕРґ Рє РЅСѓР¶РЅРѕРјСѓ РїСЂРѕРґСѓРєС‚Сѓ РёР· Р°РєС†РёР№
                    $('span[table=promoutionProductClick]').bind('click', function (e) {
                        var product_id = $(this).attr('productid');
                        var tab_id = $(this).attr('tabs_id');
                        otype = $(this).attr('otype');

                        if (otype != '') {
                            $('#tabs-'+tab_id+' .first_block_product span').css('display', 'none');
                            $('#tabs-'+tab_id+' .first_block_product').find('span').each(function(){
                                if ($(this).attr('otype') == otype) {
                                    $(this).css('display', 'block');
                                }
                            });
                        }

                        window.location = window.location.toString().split('#')[0] + '#' + tab_id;

                        $('#tabs_container #tabs-'+tab_id+' .first_block_product').children('div, span').each(function() {
                            if ($(this).attr('productid') == product_id || $(this).attr('id') == product_id) {
                                $(this).trigger('click');
                            }
                        });

                    });
                };

                const __initLargeTab = function () {
                    if ($(`#tabs-3 .first_block_product`).find(`div[table="productClick"]`).length &lt; 1)
                    {
                        $(`#tabs a[href="#tabs-3"]`).hide();
                        $(`#tabs-3`).hide();
                    }
                };

                const __initListenerTitleImg = function () {
                    $('#title_img_new').on('click', function () {
                        window.location.href = $('#title_draw').attr('href');
                    });
                };

                const __initListenerChangeMultipageParams = function () {
                    // Р¤СѓРЅРєС†РёРѕРЅРёСЂРѕРІР°РЅРёРµ РјРЅРѕРіРѕСЃС‚СЂР°РЅРёС‡РЅРѕР№ С„РёР»СЊС‚СЂР°С†РёРё
                    $('.cMultipageTitle').on('change', '.cPageSelect input, .cInsideSelect input, .cCoverSelect input, .cDecorSelect input', function () {
                        __initListenerMultiCostTable();
                    });
                };

                const __initListenerSelectPrice = function () {
                    // Р’С‹Р±РѕСЂ СЃС‚РѕРёРјРѕСЃС‚Рё
                    $('.offset-materail-table').on('click', 'span[clickable=click]', function () {

                        if (!instanceForOffset.isPartnerHost()) OffsetProductInstance.reload();

                        let $selectedItem = $(this),
                            tir_val = Number($selectedItem.attr('tir_val').replace(/[^0-9]/g, '')),
                            number_of_sides = $selectedItem.attr('id').split('-')[0] === 'two' ? 2 : 1,
                            is_promotion = $selectedItem.attr('is-promotion') == '1' ? 1 : 0;

                        //  --from partner
                        const isCustomTir = $selectedItem.hasClass('custom_tir');
                        let custom_tir = isCustomTir ? +$selectedItem.attr('tir') : 0;
                        // end -- from partner

                        if (instanceForOffset.isPartnerHost())
                        {
                            if ($(this).attr("tir_val") == '0') {

                                if (isCustomTir &amp;&amp; !custom_tir)
                                {
                                    let $td = $selectedItem.parents(".material").find(".custom_tir_select").parent();
                                    const _k1 = {"box-shadow": $td.css("box-shadow"), "background-color": $td.css("background")};
                                    const _k2 = {"box-shadow": "inset 0 0 1px 1px red", "background-color": "#b11028"};
                                    $td.animate(_k2, 50).animate(_k1, 200).animate(_k2, 50).animate(_k1, 1200);
                                }
                                else
                                {
                                    alert('РџСЂРѕРІРµСЂСЊС‚Рµ РїРѕР¶Р°Р»СѓР№СЃС‚Р° РїР°СЂР°РјРµС‚СЂС‹ РїСЂРѕРґСѓРєС†РёРё');
                                }

                                return;
                            }
                        }
                        else
                        {
                            if ($(this).attr("tir_val") == '0')
                            {
                                alert('РџСЂРѕРІРµСЂСЊС‚Рµ РїРѕР¶Р°Р»СѓР№СЃС‚Р° РїР°СЂР°РјРµС‚СЂС‹ РїСЂРѕРґСѓРєС†РёРё');
                                return;
                            }
                        }

                        if (instanceForOffset.isPartnerHost()) partnerTools.toggleWaitingServerTime();

                        if (!instanceForOffset.isPartnerHost())
                        {
                            FileLoader.deleteAll(['kabinet_offset_rostov', 'CHANGE_COST']);
                            OffsetProductInstance.set('tir_count', $selectedItem.attr("tir"));
                            OffsetProductInstance.set('number_of_sides', number_of_sides);
                            OffsetProductInstance.set('is_promotion', is_promotion);
                        }


                        maket_type = number_of_sides;

                        //$('.check_delivery').html('');
                        $('.cOffsetDelivery .check_delivery').html('');
                        DeliverySection.init(otype);


                        getUserCityName();
                        //РќРѕРІРѕРµ РїРѕСЃР»Рµ РјРЅРѕРіРѕСЃС‚СЂР°РЅРёС‡РєРё РќРђР§РђР›Рћ
                        var prel_date = '';
                        var finaldate = '';
                        $('.cForWidth').attr('style', '');
                        $('.cCecretMaterials').attr('style', '');
                        $('.cCecretMaterials').html('&lt;span&gt;РњР°С‚РµСЂРёР°Р»:&lt;/span&gt;&lt;span id="material_info"&gt;&lt;/span&gt;');
                        $('.cForTemplate').css({'display': 'block'});
                        $('#help_to_maket').css({'display': 'block'});
                        $('.cMass').css({'display': 'block'});
                        //РќРѕРІРѕРµ РїРѕСЃР»Рµ РјРЅРѕРіРѕСЃС‚СЂР°РЅРёС‡РєРё РљРћРќР•Р¦

                        // Р’СЂРµРјРµРЅРЅРѕ
                        $('.offset_info').css({'display': 'block'});
                        if ($('.user_order_text_out').css('display') == 'none')
                        {
                            $('.circle').click();
                        }
                        $('.offset_post_work').find('div[data_display=dis]').each(function () {
                            $(this).css({'display': 'none'});
                        });
                        $('.offset_post_work').find('select').each(function () {
                            $(this).selectedIndex = -1;
                        });
                        $('.offset_post_work').find('input[type=checkbox]').each(function () {
                            $(this).prop('checked', false);
                        });

                        let $__OrderInfoBlock = $('.offset_info');
                        if ($__OrderInfoBlock.length)
                        {
                            $('html,body').animate({scrollTop: $('.offset_info').offset().top}, 1100);
                        }

                        if (instanceForOffset.isPartnerHost()) partnerTools.toggleWaitingServerTime();

                        if ($(this).attr('id').split('-')[0] === 'two' || otype === 'pcard')
                        {
                            $('.not-display').css('display', 'inline-block');
                            $('.front-block').css('display', 'inline-block');
                            $('.front-block').css('width', '492px');
                            oneSide = false;
                        }
                        else
                        {
                            $('.not-display').css('display', 'none');
                            $('.front-block').css('display', 'block');
                            $('.front-block').css('width', '100%');
                            oneSide = true;
                        }


                        product_manager = '';
                        $('.offset_nomaket').css('display', 'none');
                        $('.offset_maket').css('display', 'block');

                        if ($(this).attr('multi') == 'true')
                        {
                            maket_type = Number($(this).attr('maket_type'));

                            if (maket_type &gt; 0)
                            {
                                APC.productSelect(p_id, maket_type);

                            }
                            else
                            {
                                $('.offset_nomaket').css('display', 'block');
                                $('.offset_maket').css('display', 'none');
                            }

                            $('.title-blocks').css('display', 'none');
                            myDropzone['offsetTemplate'].hiddenFileInput.setAttribute("accept", '.pdf');
                            /************************РќРѕРІРѕРµ РІСЂРµРјСЏ РќРђР§РђР›Рћ**************************************/
                            prel_date = $(this).closest('tr').find('.time_multi').attr('preldate');
                            finaldate = $(this).closest('tr').find('.time_multi').attr('finaldate');


                            $('.leadTime').val($(this).closest('tr').find('.time_to_parse').attr('leadtime'));

                            $('.actualDateReady').val(prel_date);
                            $('.dateReady').html(finaldate);
                            $('.cPickUpDate').html(finaldate);

                            if (instanceForOffset.isPartnerHost())
                            {
                                // old variant
                                $('.deliveryDate').html(finaldate);
                            }
                            else
                            {
                                let finalDateSplit = finaldate.split('.');
                                setDeliveryDate({d: finalDateSplit[0], m: finalDateSplit[1], y: finalDateSplit[2]}, 8);
                            }


                            dpd_ready = false;
                            /************************РќРѕРІРѕРµ РІСЂРµРјСЏ РљРћРќР•Р¦***************************************/
                            var decInfo = '';
                            var decOrder = '';

                            let id_inside_table = (typeof $('.cMultipageTitle input[name=inside_side]:checked').attr('val') === 'undefined') ? '' : $('.cMultipageTitle input[name=inside_side]:checked').attr('val');
                            let id_cover_mass = $('.cMultipageTitle input[name=cover_side]:checked').attr('val') + '_' + $('.cMultipageTitle input[name=id_cover_material]:checked').attr('val');
                            let id_inside_mass = id_inside_table + '_' + $('.cMultipageTitle input[name=id_inside_material]:checked').attr('val');

                            $.ajax({
                                type: 'POST',
                                data: {
                                    'id_real_prod': $('.cMultipageTitle input[name=id_real_product]:checked').attr('id'),
                                    'covid': $(this).attr('covid'),
                                    'insid': $(this).attr('insid'),
                                    'pages': $(this).attr('pages'),
                                    'id_cover_mass': id_cover_mass,
                                    'id_inside_mass': id_inside_mass,
                                    'tir': $(this).attr('tir')
                                },
                                url: "/AJAX/multi_additional_info.php",
                                async: false,
                                success: function (data) {

                                    var container = (JSON.parse(data));
//console.log(container);
                                    if (container.dpd.length != 0)
                                    {
                                        if (container.dpd.dpd_num &gt; 0)
                                        {
                                            $('.cDPDfullpack').css('display', 'table-row');
                                        }
                                        else
                                        {
                                            $('.cDPDfullpack').css('display', 'none');
                                        }
                                        $('.check_delivery .cDpdLen').text(container.dpd.dpd_len);
                                        $('.check_delivery .cDpdWid').text(container.dpd.dpd_wid);
                                        $('.check_delivery .cDpdHgt').text(container.dpd.dpd_hgt);
                                        $('.check_delivery .cDpdNum').text(container.dpd.dpd_num);
                                        $('.check_delivery .cDpdWgt').text(container.dpd.dpd_wgt);
                                        $('.check_delivery .cDpdWgtAll').text(container.dpd.dpd_wgt_all);
                                        if (container.dop_dpd.length != 0)
                                        {
                                            $('.cDpdNone').css('display', 'table-row');
                                        }
                                        else
                                        {
                                            $('.cDpdNone').css('display', 'none');
                                        }
                                        $('.check_delivery .cDpdLenDop').text(container.dop_dpd.dop_dpd_len);
                                        $('.check_delivery .cDpdWidDop').text(container.dop_dpd.dop_dpd_wid);
                                        $('.check_delivery .cDpdHgtDop').text(container.dop_dpd.dop_dpd_hgt);
                                        $('.check_delivery .cDpdNumDop').text(container.dop_dpd.dop_dpd_num);
                                        $('.check_delivery .cDpdWgtDop').text(container.dop_dpd.dop_dpd_wgt);
                                        $('.check_delivery .cDpdWgtAllDop').text(container.dop_dpd.dop_dpd_wgt_all);

                                        // console.log('cDpdWgtAllDop', container.dop_dpd.dop_dpd_wgt_all);
                                        // console.log('container', container)
                                        full_weight = container.dpd.dpd_wgt_all + container.dop_dpd.dop_dpd_wgt_all;
                                    }
                                    $('.offset_info_head #help_to_maket').html(container['description']);
                                    //$('.offset_info_head #time_info').html(container['time']);
                                    $('#title_img_new').attr('src', container.descr_img);
                                    $('#title_draw').attr('href', container.descr_draw);
                                }
                            });
                            cost = {};
                            //$('.cForTemplate').css({'display':'none'});
                            //$('#help_to_maket').css({'display':'none'});
                            $('.cMass').css({'display': 'none'});
                            $('.offset_info_head #mass_info').html('');
                            $('.cCecretMaterials').css({'display': 'block'});
                            $('.cForWidth').attr('width', '350px');

                            if ($(this).attr("decor") != '')
                            {
                                decInfo = '&lt;div class="cMultiInfoMagic"&gt;&lt;span&gt;РћС‚РґРµР»РєР°:&lt;/span&gt;&lt;span&gt;' + $(this).attr("decor") + '&lt;/span&gt;&lt;/div&gt;';
                                decOrder = 'РћС‚РґРµР»РєР°: ' + $(this).attr("decor") + '&lt;br&gt;'
                            }

                            var block = '';

                            if (otype == 'multipage')
                            {
                                block = '&lt;div class="cMultiInfoMagic"&gt;&lt;span&gt;РћР±Р»РѕР¶РєР°:&lt;/span&gt;&lt;span&gt;' + $(this).attr("cover") + '&lt;/span&gt;&lt;/div&gt;' +
                                    decInfo +
                                    '&lt;div class="cMultiInfoMagic"&gt;&lt;span&gt;Р’РЅСѓС‚СЂРµРЅРЅРёР№ Р±Р»РѕРє:&lt;/span&gt;&lt;span&gt;' + $(this).attr("inside") + '&lt;/span&gt;&lt;/div&gt;' +
                                    '&lt;div class="cMultiInfoMagic"&gt;&lt;span&gt;РљСЂРµРїР»РµРЅРёРµ:&lt;/span&gt;&lt;span&gt;' + $(this).attr("bond") + '&lt;/span&gt;&lt;/div&gt;' +
                                    '&lt;div class="cMultiInfoMagic"&gt;&lt;span&gt;РљРѕР»РёС‡РµСЃС‚РІРѕ СЃС‚СЂР°РЅРёС†:&lt;/span&gt;&lt;span&gt;' + $(this).attr("page") + '&lt;/span&gt;&lt;/div&gt;';
                            }
                            else
                            {
                                block = '&lt;div class="cMultiInfoMagic"&gt;&lt;span&gt;РћР±Р»РѕР¶РєР°:&lt;/span&gt;&lt;span&gt;' + $(this).attr("cover") + '&lt;/span&gt;&lt;/div&gt;' +
                                    decInfo;
                            }

                            $('.cCecretMaterials').html(block);

                            cost['name'] = $(this).attr("prod_name");
                            if (instanceForOffset.isPartnerHost())
                            {
                                cost['noBonus'] = true;
                                cost['partnerNoBonus'] = ($(this).attr("nobonus") == '1') ? true : false;
                            }
                            else
                            {
                                cost['noBonus'] = ($(this).attr("nobonus") == '1') ? true : false;
                            }

                            product_manager = $(this).attr("prod_name_manager");
                            $('.offset_info #size_info').html($(this).attr("prod_size"));
                            $('.offset_info_head #title_info').html(cost['name'] + " ( " + $(this).attr("prod_size") + " )");

                            if (otype === 'multipage')
                            {
                                cost['text'] = 'РћР±Р»РѕР¶РєР°: ' + $(this).attr("cover") + '&lt;br&gt;' +
                                    decOrder +
                                    'Р’РЅСѓС‚СЂРµРЅРЅРёР№ Р±Р»РѕРє: ' + $(this).attr("inside") + '&lt;br&gt;' +
                                    'РљСЂРµРїР»РµРЅРёРµ: ' + $(this).attr("bond") + '&lt;br&gt;' +
                                    'РљРѕР»РёС‡РµСЃС‚РІРѕ СЃС‚СЂР°РЅРёС†: ' + $(this).attr("page");
                            }
                            else if (cost['name'].indexOf('РљСѓСЂСЃРѕСЂ') !== -1)
                            {
                                cost['text'] = $('.cCoverSide .filter_title').text() + ': ' + $('.cCoverSide input[name=cover_side]:checked').attr("text") + '&lt;br&gt;';
                                cost['text'] = cost['text'] + $('.cInsideSelect .filter_title').text() + ': ' + $('.cInsideSelect input[name=id_inside_material]:checked').attr("text");
                            }
                            else
                            {
                                cost['text'] = 'РћР±Р»РѕР¶РєР°: ' + $(this).attr("cover") + '&lt;br&gt;' +
                                    decOrder;
                                if (typeof $(this).attr("inside") !== 'undefined')
                                {
                                    cost['text'] = cost['text'] + $('.cInsideSelect .filter_title').text() + ': ' + $(this).attr("inside") + '&lt;br&gt;';
                                }

                                if (cost['name'].indexOf('РљР°Р»РµРЅРґР°СЂСЊ РґРѕРјРёРє РїРµСЂРµРєРёРґРЅРѕР№') !== -1)
                                {
                                    cost['text'] = cost['text'] + $('.cBondSelect .filter_title').text() + ': ' + $(this).attr("bond") + '&lt;br&gt;';
                                    cost['text'] = cost['text'] + 'Р›РёСЃС‚РѕРІ : ' + $(this).attr("pages");

                                    if (instanceForOffset.isPartnerHost()) cost['text'] += '&lt;br&gt;';
                                }

                            }

                            cost['total_plot'] = '';
                            cost['print'] = $(this).attr("tir");
                            $('.offset_info_head #print_info').html(cost['print'] + ' С€С‚.');
                            //РІСЂРµРјСЏ
                            //$('.offset_info_head #time_info').html('РџРµС‡Р°С‚СЊ Р·Р° 48 С‡Р°СЃРѕРІ');

                            //РЈСЃС‚Р°РЅР°РІР»РёРІР°РµРј СЃС‚РѕРёРјРѕСЃС‚СЊ РїРµС‡Р°С‚Рё
                            $('.printCost').html($(this).attr("tir_val"));
                            $('.totalCost').html($(this).attr("tir_val"));
                            if (instanceForOffset.isPartnerHost())
                            {
                                $('.realPrintCost').html($(this).attr("real_tir_val"));
                                $('.realTotalCost').html($(this).attr("real_tir_val"));
                            }
                            $('#sideIcon').html('');
                            cost['print_name'] = 'РњРЅРѕРіРѕСЃС‚СЂР°РЅРёС‡РЅР°СЏ РїРµС‡Р°С‚СЊ';
                            //cost['print_name'] = 'РњРЅРѕРіРѕСЃС‚СЂР°РЅРёС‡РЅР°СЏ РїРµС‡Р°С‚СЊ';

                        }
                        else
                        {
                            if (!instanceForOffset.isPartnerHost())
                            {
                                ph_id = $(this).closest('tr').find('.time_to_parse').attr('ph_num');
                                ph_id_for_order = ph_id;
                            }

                            $('.title-blocks').css('display', 'block');
                            myDropzone['offsetTemplate'].hiddenFileInput.setAttribute("accept", ".tiff,.tif,.cdr,.pdf,.eps,.jpeg,.jpg");
                            /************************РќРѕРІРѕРµ РІСЂРµРјСЏ РќРђР§РђР›Рћ**************************************/
                            printTime = $(this).closest('tr').find('.time_to_parse').attr('leadtime');
                            var readyTime = TimeControl.parseReadyTime($(this).closest('tr').find('.time_to_parse').attr('leadtime'), false);
                            //prel_date = $(this).closest('tr').find('.time_to_parse').attr('preldate');
                            prel_date = readyTime;

                            readyTime = TimeControl.parseReadyTime($(this).closest('tr').find('.time_to_parse').attr('leadtime'), true);
                            var time = readyTime.split('-');
                            if (time[1].length === 1)
                            {
                                time[1] = "0" + time[1];
                            }
                            if (time[2].length === 1)
                            {
                                time[2] = "0" + time[2];
                            }

                            //finaldate = $(this).closest('tr').find('.time_to_parse').attr('finaldate');
                            finaldate = time[2] + '.' + time[1] + '.' + time[0];

                            $('.leadTime').val($(this).closest('tr').find('.time_to_parse').attr('leadtime'));
                            $('.actualDateReady').val(prel_date);
                            $('.dateReady').html(finaldate);
                            $('.cPickUpDate').html(finaldate);

                            if (instanceForOffset.isPartnerHost())
                            {
                                // old variant
                                $('.deliveryDate').html(finaldate);
                            }
                            else
                            {
                                let finalDateSplit = finaldate.split('.');
                                setDeliveryDate({d: finalDateSplit[0], m: finalDateSplit[1], y: finalDateSplit[2]}, 9);
                            }

                            dpd_ready = false;
                            /************************РќРѕРІРѕРµ РІСЂРµРјСЏ РљРћРќР•Р¦***************************************/

                            if (!instanceForOffset.isPartnerHost())
                            {
                                custom_tir = 0;
                                if ($(this).hasClass('custom_tir'))
                                {
                                    custom_tir = $selectedItem.attr('tir');
                                }
                            }

                            $.ajax({
                                type: 'POST',
                                data: {
                                    'id': ($(this).attr("id")).split('-')[1],
                                    'tir_val': tir_val,
                                    'custom_tir': custom_tir
                                },
                                url: "/AJAX/kabinet_offset_get_cost.php",
                                async: false,
                                success: function (data) {
                                    cost = (JSON.parse(data));

                                    // console.log("COST", cost);

                                    if ($selectedItem.hasClass('custom_tir'))
                                    {
                                        cost.value = tir_val;
                                        cost.valueTwo = tir_val;

                                        cost.print = $selectedItem.attr('tir');
                                    }

                                    if (cost.dpd != null)
                                    {
                                        if (cost.dpd.num_seats &gt; 0)
                                        {
                                            $('.cDPDfullpack').css('display', 'table-row');
                                        }
                                        else
                                        {
                                            $('.cDPDfullpack').css('display', 'none');
                                        }
                                        $('.check_delivery .cDpdLen').text(cost.dpd.length);
                                        $('.check_delivery .cDpdWid').text(cost.dpd.width);
                                        $('.check_delivery .cDpdHgt').text(cost.dpd.height);
                                        $('.check_delivery .cDpdNum').text(cost.dpd.num_seats);
                                        $('.check_delivery .cDpdWgt').text(cost.dpd.weight);
                                        $('.check_delivery .cDpdWgtAll').text(cost.dpd.weight * cost.dpd.num_seats);
                                        if (cost.dpd.paket == 1)
                                        {
                                            $('.cDpdNone').css('display', 'table-row');
                                        }
                                        else
                                        {
                                            $('.cDpdNone').css('display', 'none');
                                        }
                                        $('.check_delivery .cDpdLenDop').text(cost.dpd.dop_length);
                                        $('.check_delivery .cDpdWidDop').text(cost.dpd.dop_width);
                                        $('.check_delivery .cDpdHgtDop').text(cost.dpd.dop_height);
                                        $('.check_delivery .cDpdNumDop').text(cost.dpd.dop_num_seats);
                                        $('.check_delivery .cDpdWgtDop').text(cost.dpd.dop_weight);
                                        $('.check_delivery .cDpdWgtAllDop').text(cost.dpd.dop_weight * cost.dpd.dop_num_seats);

                                        // console.log('cDpdWgtAllDop', cost.dpd.dop_weight);
                                        // console.log('cost', cost);

                                        full_weight = (cost.dpd.weight * cost.dpd.num_seats) + (cost.dpd.dop_weight * cost.dpd.dop_num_seats);
                                    }

                                    $('.offset-checks').find('input').each(function () {
                                        $(this).prop('checked', false);
                                    });
                                    $('.offset_info_head #help_to_maket').html(cost.description);
                                    //Рћ РїСЂРѕРґСѓРєС‚Рµ
                                    /*$('.offset_info_head #title_img').html(cost['name']+' ('+cost['width']+'x'+cost['height']+'РјРј)');*/
                                    $('.offset_info_head #title_info').html(cost['name'] + ' (' + cost['width'] + 'x' + cost['height'] + 'РјРј)');
                                    $('.offset_info_head #print_info').html(cost['print'] + ' С€С‚');
                                    $('.offset_info_head #size_info').html(cost['width'] + ' x ' + cost['height'] + ' РјРј');


                                    // $('.cForAutoPreview').attr('width', cost['width']);
                                    // $('.cForAutoPreview').attr('height', cost['height']);

                                    if (instanceForOffset.isPartnerHost())
                                    {
                                        APC.productSelect(cost['id_product'], number_of_sides, cost['printin_format']);
                                    }
                                    else
                                    {
                                        APC.productSelect(cost['id_product'], number_of_sides);
                                    }


                                    cost['total_plot'] = cost['plot'] + ' Рі/Рј&lt;sup&gt;2&lt;/sup&gt;';
                                    cost['print_name'] = 'РћС„СЃРµС‚РЅР°СЏ РїРµС‡Р°С‚СЊ';
                                    var plot = cost['plot'];
                                    var tooltip = plot + " Рі/Рј&lt;sup&gt;2&lt;/sup&gt;";
                                    if (tooltip.indexOf('+lam') != -1)
                                    {
                                        plot = plot.replace('+lam', '');
                                        tooltip = plot + " Рі/Рј&lt;sup&gt;2&lt;/sup&gt; + РіР». Р»Р°РјРёРЅР°С†РёСЏ РЅР° Р»РёС†РµРІРѕР№ СЃС‚РѕСЂРѕРЅРµ";
                                    }
                                    tooltip = cost['text'] + " " + tooltip;
                                    var prod_name = cost['name'].toLowerCase();

                                    if (instanceForOffset.isPartnerHost())
                                    {
                                        // old variant

                                        $.post("/AJAX/del_upload_template.php", {
                                            'name': 'offsetTemplate',
                                            'type_of_del': 'all'
                                        }, function (data) {
                                        });
                                        $.post("/AJAX/del_upload_template.php", {
                                            'name': 'offsetPreview',
                                            'type_of_del': 'all'
                                        }, function (data) {
                                        });
                                    }
                                    else
                                    {
                                        FileLoader.deleteAll(['kabinet_offset_rostov', 'kabinet_offset_get_cost']);
                                    }

                                    if (prod_name.indexOf('Р±Р»РѕРєРЅРѕС‚') !== -1)
                                    {
                                        tooltip = "РћР±Р»РѕР¶РєР°, РїРѕРґР»РѕР¶РєР° 300Рі/Рј&lt;sup&gt;2&lt;/sup&gt; 4+4 Р’РЅСѓС‚СЂРµРЅРЅРѕСЃС‚СЊ 80Рі/Рј&lt;sup&gt;2&lt;/sup&gt; 4+4";

                                        $('.cForNotebook').css({'display': 'block'});
                                        $('.cForNotebookSpan').css({'display': 'inline-block'});
                                    }
                                    else
                                    {
                                        $('.cForNotebook').css({'display': 'none'});
                                        $('.cForNotebookSpan').css({'display': 'none'});
                                    }

                                    $('.offset_info_head #material_info').html(tooltip);
                                    $('.offset_info_head #mass_info').html('~' + cost['mass'] + ' РєРі');
                                    //РњРµРЅСЏРµРј РґР°РЅРЅС‹Рµ Рѕ РІСЂРµРјРµРЅРё
                                    //$('.offset_info_head #time_info').html(cost['time']);

                                    //Р”Р»СЏ user_order_text_in
                                    $('#stampinfo').html('&lt;div&gt;' + cost['name'] + ' (' + cost['width'] + 'x' + cost['height'] + 'РјРј)' + '&lt;/div&gt;');
                                    $('#vidinfo').html('&lt;div&gt;РњР°С‚РµСЂРёР°Р»: ' + cost['text'] + ' ' + cost['plot'] + ' Рі/Рј&lt;sup&gt;2&lt;/sup&gt;&lt;/div&gt;');
                                    $('#tirazhinfo').html(cost['print']);
                                    $('#weight').html(cost['mass'] + ' ');
                                    myDropzone['offsetTemplate'].removeAllFiles();
                                    myDropzone['offsetPreview'].removeAllFiles();
                                    $('.title_order textarea').val('');
                                    $('.comment textarea').val('');

                                    //РџРѕcС‚СЂР°Р±РѕС‚С‹
                                    //Р›Р°РјРёРЅР°С†РёСЏ
                                    if (cost['lam'] != "")
                                    {
                                        $('.offset_post_work #lam').css({'display': 'flex'});
                                        $('.offset_post_work #lam #cost').html(parseFloat(cost['lam']).toFixed(2));
                                    }
                                    else
                                    {
                                        $('.offset_post_work #lam').css({'display': 'none'});
                                    }
                                    //Р¤Р°Р»СЊС†РѕРІРєР°
                                    if (cost['folding'] != "")
                                    {
                                        $('.offset_post_work #folding').css({'display': 'flex'});
                                        var foldingText = '';
                                        for (var i = 1; i &lt; 10; i++)
                                        {
                                            if (i == 1)
                                            {
                                                foldingText += '&lt;option value="' + (cost['folding'] * i).toFixed(2) + '" number="' + i + '-С„Р°Р»СЊС†"&gt;' + i + ' С„Р°Р»СЊС† - ' + (cost['folding'] * i).toFixed(2) + ' СЂСѓР±.&lt;/option&gt;';
                                            }
                                            else if (i &gt; 1 &amp;&amp; i &lt; 5)
                                            {
                                                foldingText += '&lt;option value="' + (cost['folding'] * i).toFixed(2) + '" number="' + i + '-С„Р°Р»СЊС†Р°"&gt;' + i + ' С„Р°Р»СЊС†Р° - ' + (cost['folding'] * i).toFixed(2) + ' СЂСѓР±.&lt;/option&gt;';
                                            }
                                            else
                                            {
                                                foldingText += '&lt;option value="' + (cost['folding'] * i).toFixed(2) + '" number="' + i + '-С„Р°Р»СЊС†РѕРІ"&gt;' + i + ' С„Р°Р»СЊС†РѕРІ - ' + (cost['folding'] * i).toFixed(2) + ' СЂСѓР±.&lt;/option&gt;';
                                            }
                                        }
                                        $('.offset_post_work #folding div[data_check=folding] select').html(foldingText);
                                        //$('.offset_post_work #folding div[data_check=folding] #cost').html(cost['folding']);
                                    }
                                    else
                                    {
                                        $('.offset_post_work #folding').css({'display': 'none'});
                                    }
                                    //Р‘РёРіРѕРІРєР°
                                    if (cost['creasing'] != "")
                                    {
                                        $('.offset_post_work #creasing').css({'display': 'flex'});
                                        var creasingText = '';
                                        for (var i = 1; i &lt; 10; i++)
                                        {
                                            if (i == 1)
                                            {
                                                creasingText += '&lt;option value="' + (cost['creasing'] * i).toFixed(2) + '" number="' + i + '-Р±РёРі"&gt;' + i + ' Р±РёРі - ' + (cost['creasing'] * i).toFixed(2) + ' СЂСѓР±.&lt;/option&gt;';
                                            }
                                            else if (i &gt; 1 &amp;&amp; i &lt; 5)
                                            {
                                                creasingText += '&lt;option value="' + (cost['creasing'] * i).toFixed(2) + '" number="' + i + '-Р±РёРіР°"&gt;' + i + ' Р±РёРіР° - ' + (cost['creasing'] * i).toFixed(2) + ' СЂСѓР±.&lt;/option&gt;';
                                            }
                                            else
                                            {
                                                creasingText += '&lt;option value="' + (cost['creasing'] * i).toFixed(2) + '" number="' + i + '-Р±РёРіРѕРІ"&gt;' + i + ' Р±РёРіРѕРІ - ' + (cost['creasing'] * i).toFixed(2) + ' СЂСѓР±.&lt;/option&gt;';
                                            }
                                        }
                                        $('.offset_post_work #creasing div[data_check=creasing] select').html(creasingText);
                                        //$('.offset_post_work #creasing div[data_check=creasing] #cost').html(cost['creasing']);
                                    }
                                    else
                                    {
                                        $('.offset_post_work #creasing').css({'display': 'none'});
                                    }

                                    //РџРµСЂС„РѕСЂР°С†РёСЏ
                                    if (cost['perf'] != "")
                                    {
                                        $('.offset_post_work #perf').css({'display': 'flex'});
                                        var perfText = '';
                                        for (var i = 1; i &lt; 10; i++)
                                        {
                                            if (i == 1)
                                            {
                                                perfText += '&lt;option value="' + (cost['perf'] * i).toFixed(2) + '" number="' + i + '-РїСЂРѕС…РѕРґ"&gt;' + i + ' РїСЂРѕС…РѕРґ - ' + (cost['perf'] * i).toFixed(2) + ' СЂСѓР±.&lt;/option&gt;';
                                            }
                                            else if (i &gt; 1 &amp;&amp; i &lt; 5)
                                            {
                                                perfText += '&lt;option value="' + (cost['perf'] * i).toFixed(2) + '" number="' + i + '-РїСЂРѕС…РѕРґР°"&gt;' + i + ' РїСЂРѕС…РѕРґР° - ' + (cost['perf'] * i).toFixed(2) + ' СЂСѓР±.&lt;/option&gt;';
                                            }
                                            else
                                            {
                                                perfText += '&lt;option value="' + (cost['perf'] * i).toFixed(2) + '" number="' + i + '-РїСЂРѕС…РѕРґРѕРІ"&gt;' + i + ' РїСЂРѕС…РѕРґРѕРІ - ' + (cost['perf'] * i).toFixed(2) + ' СЂСѓР±.&lt;/option&gt;';
                                            }

                                        }
                                        $('.offset_post_work #perf div[data_check=perf] select').html(perfText);
                                        //$('.offset_post_work #perf div[data_check=perf] #cost').html(cost['perf']);
                                    }
                                    else
                                    {
                                        $('.offset_post_work #perf').css({'display': 'none'});
                                    }

                                    //РЎРІРµСЂР»РµРЅРёРµ
                                    if (cost['boring'] != "")
                                    {
                                        $('.offset_post_work #boring').css({'display': 'flex'});
                                        $('.offset_post_work #boring #cost').html(Number(cost['boring']).toFixed(2));
                                        var boringText = '&lt;option value="' + Number(cost['boring']).toFixed(2) + '" number="1-РґС‹СЂРєР°"&gt;1 РґС‹СЂРєР° - ' + Number(cost['boring']).toFixed(2) + ' СЂСѓР±.&lt;/option&gt;';
                                        boringText += '&lt;option value="' + (cost['boring'] * 2).toFixed(2) + '" number="2-РґС‹СЂРєРё"&gt;2 РґС‹СЂРєРё - ' + (cost['boring'] * 2).toFixed(2) + ' СЂСѓР±.&lt;/option&gt;';
                                        $('.offset_post_work #boring div[data_check=boring] select').html(boringText);
                                    }
                                    else
                                    {
                                        $('.offset_post_work #boring').css({'display': 'none'});
                                    }

                                    //Р—Р°РєСЂСѓРіР»РµРЅРёРµ СѓРіР»РѕРІ
                                    if (cost['roundCor'] != "")
                                    {
                                        $('.offset_post_work #roundCor').css({'display': 'flex'});
                                        $('.offset_post_work #roundCor #cost').html(Number(cost['roundCor']).toFixed(2));
                                    }
                                    else
                                    {
                                        $('.offset_post_work #roundCor').css({'display': 'none'});
                                    }
                                }
                            });
                            //РЎС‚РѕРёРјРѕСЃС‚СЊ РїРµС‡Р°С‚Рё
                            var sum = 0;
                            var real_sum = 0; // for partner

                            if (($(this).attr("id")).split('-')[0] == 'one')
                            {
                                sum = Number(cost['value']);
                                $('#sideIcon').html("РћРґРЅРѕСЃС‚РѕСЂРѕРЅРЅСЏСЏ 4+0");

                                if (instanceForOffset.isPartnerHost()) real_sum = Number(cost['real_value']);
                            }
                            else
                            {
                                sum = Number(cost['valueTwo']);
                                $('#sideIcon').html("Р”РІСѓС…СЃС‚РѕСЂРѕРЅРЅСЏСЏ 4+4");

                                if (instanceForOffset.isPartnerHost()) real_sum = Number(cost['real_valueTwo']);
                            }
                            if (sum &lt; 0) sum = 0;
                            if (instanceForOffset.isPartnerHost() &amp;&amp; real_sum &lt; 0) real_sum = 0;
                            $('.printCost').html(sum);
                            $('.totalCost').html(sum);
                            if (instanceForOffset.isPartnerHost())
                            {
                                if (real_sum &lt; 0) real_sum = 0;

                                $('.realPrintCost').html(real_sum);
                                $('.realTotalCost').html(real_sum);
                            }
                        }

                        let curr_weigt = $('.offset_delivery .cDpdWgtAll').text();

                        $('.offset_delivery .SPP_List').find('tr').each(function () {

                            let spp_weight = $(this).data('weight');

                            if (curr_weigt &gt; spp_weight &amp;&amp; spp_weight != 0)
                            {
                                let item_id = $(this).index();
                                $('.offset_delivery .SPP_List tr:eq(' + item_id + ')').remove();
                            }
                        });

                        let spp_list_count = $('.offset_delivery .SPP_List tr').length;


                        // Р’Р°СЂРёР°РЅС‚ РѕР±РµСЂРЅСѓС‚СЊ РІ С„СѓРЅРєС†РёСЋ РґР»СЏ РёСЃРїРѕР»СЊР·РѕРІР°РЅРёСЏ РІ С€РёСЂРѕРєРѕС„РѕСЂРјР°С‚Рµ
                        // РЈСЃС‚Р°РЅРѕРІРєР° СЃРїРѕСЃРѕР±Р° РґРѕСЃС‚Р°РІРєРё РїРѕ СѓРјРѕР»С‡Р°РЅРёСЋ
                        setDefaultDelivery();
                    });
                };

                const __initListenerChangeTab = function () {
                    // РїРµСЂРµС…РѕРґ
                    $('#tabs li a').click(function () {
                        $('.offset-floating-title').html("");
                        $('.offset-materail-table').html("");
                        hideCost();
                    });
                };

                const __initListenerConfirmPreviewsFiles = function () {
                    $('#image_options_agree').change(function () {
                        if (this.checked) {

                            if ($('.cForAutoPreview').attr('side') == 'offsetTemplate') {
                                cup1 = $('.image_options_form input[name=image_options]:checked').attr('for_dis').split('/');
                                $('.cFrontAuto').val(cup1[cup1.length - 1]);
                                $('.cAcceptFront').css('display', 'block');
                            } else {
                                cup1 = $('.image_options_form input[name=image_options]:checked').attr('for_dis').split('/');
                                $('.cBackAuto').val(cup1[cup1.length - 1]);
                                $('.cAcceptBack').css('display', 'block');
                            }

                            $('#box_img_block').css('display', 'none');
                            $('.image_section .image_before img').attr('src', '');
                            $('.image_section .image_after img').attr('src', '');
                            $('#first_size').attr('value', '');
                            $('#second_size').attr('value', '');
                            $('#third_size').attr('value', '');
                            $('#fourth_size').attr('value', '');

                            $('#first_size').attr('for_dis', '');
                            $('#second_size').attr('for_dis', '');
                            $('#third_size').attr('for_dis', '');
                            $('#fourth_size').attr('for_dis', '');

                            $('.cResolution .cOriginal').html('');
                            $('.cResolution .cStandard').html('300');
                            $('.cResolution .cResult').html('300');

                            $('.cColour .cOriginal').html('');
                            $('.cColour .cStandard').html('CMYK');
                            $('.cColour .cResult').html('CMYK');

                            $('.cSize .cOriginal').html('');
                            $('.cSize .cStandard').html('');
                            $('.cSize .cResult').html('');

                            $('#image_options_agree').prop('checked', false);
                        }
                    });
                };

                const __initTimer = function () {

                    const max__of = function (start, finish, obj) {
                        var max = 0;
                        for (let i = start + 1; i &lt;= finish; i++)
                        {
                            if (obj[i].offsetHeight &gt; max) max = obj[i].offsetHeight;
                        }
                        for (let i = start + 1; i &lt;= finish; i++)
                        {
                            obj[i].style.height = max + "px";
                        }
                    };
                    const max__of_st = function (start, finish, obj) {
                        var max = 0;
                        for (let i = start; i &lt; finish; i++)
                        {
                            if (obj[i].offsetHeight &gt; max) max = obj[i].offsetHeight;
                        }
                        for (let i = start; i &lt; finish; i++)
                        {
                            obj[i].style.height = max + "px";
                        }
                    };

                    var timer_of = 200;
                    var flag_of = false;
                    setTimeout(function () {

                        if (!$('#tabs-2').hasClass('default_show'))
                        {
                            $('#tabs-2').addClass('default_show_');
                            flag_of = true;
                        }
                        timer_of += 1;
                    }, timer_of);
                    setTimeout(function () {
                        var tabs_of = $('#tabs_container .offset-content-in div[data=offset_tab]');
                        var step_of = 4;
                        if (tabs_of.length &gt; step_of)
                        {
                            for (var i = 0; i &lt; tabs_of.length; i++)
                            {
                                if ((i + 1) % step_of == 0)
                                {
                                    max__of(i - step_of, i, tabs_of);
                                }
                            }
                        }
                        else
                        {
                            max__of_st(0, tabs_of.length, tabs_of);
                        }
                        timer_of += 1;
                    }, timer_of);
                    setTimeout(function () {
                        if (flag_of)
                        {
                            $('#tabs-2').removeClass('default_show_');
                        }
                    }, timer_of);
                };

                const __initListenerChangeOffsetMaterial = function () {
                    $('.offset-floating-title').on('click', 'label', function () {
                        var obj = $(this);
                        var for_ = obj.attr('for');

                        if (instanceForOffset.isPartnerHost() &amp;&amp; for_ === "enable_product") return;

                        if (for_ === "allcheck")
                        {
                            if (!obj.hasClass('active'))
                            {
                                $('.offset-floating-title label[data-child]').each(function () {
                                    $(this).removeClass('active');
                                });
                                obj.addClass('active');
                                $('.material').css('display', 'flex');
                            }
                            else
                            {
                                obj.removeClass('active');
                                $('.material').css('display', 'none');
                            }
                        }
                        else
                        {
                            if (!obj.hasClass('active'))
                            {
                                var all_check = $('.offset-floating-title label[for=allcheck]');
                                if (all_check.hasClass('active'))
                                {
                                    all_check.removeClass('active');
                                    $('.material').css('display', 'none');
                                }
                                obj.addClass('active');
                                $('#of_mat_' + for_).css('display', 'flex');
                            }
                            else
                            {
                                obj.removeClass('active');
                                $('#of_mat_' + for_).css('display', 'none');
                            }
                        }
                    });
                };

                const __initListenerChangeMultipageRealProduct = function () {
                    $('.cMultipageTitle').on('change', '.cRealProdFilter input', function () {
                        var obj = $(this);
                        obj.closest('div.cRealProdFilter').find('div.cSmall_block').each(function () {
                            $(this).removeClass('cActive');
                        });
                        obj.closest('div.cSmall_block').addClass('cActive');

                        let url = "/AJAX/kabinet_offset_get_multi_title_new.php";
                        if (instanceForOffset.isPartnerHost()) url = `/CMS/${url}`;

                        $.ajax({
                            type: 'POST',
                            data: {
                                'productid': $(this).attr('productid'),
                                'id_real_prod': obj.attr('id'),
                                'flag': 2
                            },
                            url: url,
                            async: true,
                            success: function (data) {
                                var result = JSON.parse(data);
                                $('.cFilterForRealProd').html(result.title);
                                console.log("3");
                                // $('html,body').animate({scrollTop: $('.offset-title').offset().top}, 1100);
                                //$('.offset-materail-table').html("&lt;span class='cMultiMessage'&gt;Р”Р»СЏ С„РѕСЂРјРёСЂРѕРІР°РЅРёСЏ РїСЂР°Р№СЃ-Р»РёСЃС‚Р° РІС‹Р±РµСЂРёС‚Рµ РјР°С‚РµСЂРёР°Р» РѕР±Р»РѕР¶РєРё, С†РІРµС‚РЅРѕСЃС‚СЊ РѕР±Р»РѕР¶РєРё, РјР°С‚РµСЂРёР°Р» РІРЅСѓС‚СЂРµРЅРЅРµРіРѕ Р±Р»РѕРєР°, С†РІРµС‚РЅРѕСЃС‚СЊ РІРЅСѓС‚СЂРµРЅРЅРµРіРѕ Р±Р»РѕРєР°, РєРѕР»-РІРѕ СЃС‚СЂР°РЅРёС†&lt;/span&gt;");
                                //    console.log("test");
                                //    if ($('.main_page-phone_number-bottom').offset().top + $('.main_page-phone_number-bottom').height() - $('.offset-floating-title').offset().top &lt; $(window).height()) {
                                // var new_height = $('.main_page-phone_number-bottom').offset().top + $('.main_page-phone_number-bottom').height() - $(window).height();
                                // $('html,body').animate({scrollTop: new_height}, 1100);
                                // }
                                // else {
                                // $('html,body').animate({scrollTop: $('.offset-title').offset().top}, 1100);
                                // }
                                __initListenerMultiCostTable();

                            }
                        });
                    });
                };

                const __initListenerChangeMultipageFilter = function () {
                    $('.cMultipageTitle').on('click', '.wrap_filter label', function (e) {
                        var obj = $(this);
                        if (~obj.attr('for').indexOf('decor-'))
                        {
                            if (obj.closest('div').find('input').prop('checked'))
                            {
                                obj.removeClass('active');
                            }
                            else
                            {
                                obj.closest('div.wrap_filter').find('label').each(function () {
                                    if (obj.attr('for') != $(this).attr('for'))
                                    {
                                        $(this).removeClass('active');
                                    }
                                });
                            }
                            $('.cMultipageTitle').find('input[name=id_decor]').each(function () {
                                if (obj.attr('for') != $(this).attr('id'))
                                {
                                    $(this).prop("checked", false);
                                }
                            });

                        }
                        if (obj.closest('.filter_item').find('input').attr('type') == 'radio')
                        {
                            obj.closest('div.wrap_filter').find('label').each(function () {
                                if (obj.attr('for') != $(this).attr('for'))
                                {
                                    $(this).removeClass('active');
                                }
                            });
                            if (!obj.closest('div').find('input').prop("checked"))
                            {
                                obj.addClass('active');
                            }
                        }
                        else
                        {
                            if (obj.closest('div').find('input').prop("checked"))
                            {
                                obj.removeClass('active');
                            }
                            else
                            {
                                obj.addClass('active');
                            }
                        }
                        if (obj.closest('.filter_item_img').find('input').attr('type') == 'radio')
                        {
                            obj.closest('div.wrap_filter').find('label').each(function () {
                                if (obj.attr('for') != $(this).attr('for'))
                                {
                                    $(this).removeClass('active');
                                    $(this).parents('.filter_item_img').removeClass('activeChild');
                                }
                            });
                            if (!obj.closest('div').find('input').prop("checked"))
                            {
                                obj.addClass('active');
                                obj.closest('div').addClass('activeChild');
                            }
                        }
                        else
                        {
                            if (obj.closest('div').find('input').prop("checked"))
                            {
                                obj.removeClass('active');
                            }
                            else
                            {
                                obj.addClass('active');
                            }
                        }

                        // SHOW BIG IMAGE
                        let data_img = obj.children();
                        let img_src = data_img.attr('large');
                        img_src = (img_src != '') ? img_src : data_img.attr('src');

                        let bigImageBlock = $('.big_img');

                        if (img_src != '' &amp;&amp; img_src != undefined)
                        {
                            // bigImageBlock.find('img').attr('src', img_src);
                            bigImageBlock.css('background-image', `url('${img_src}')`);
                            // bigImageBlock.find('a').attr('href', img_src);
                            bigImageBlock.parents('#product_preview_img').attr('href', img_src);
                            bigImageBlock.css('height', '300px');
                        }
                    });
                };

                const __initListenerChangeMultipageCoverSide = function () {
                    $('.cMultipageTitle').on('change', '.cCoverSide input', function () {
                        $.ajax({
                            type: 'POST',
                            data: {
                                'id': $(this).attr('val')
                            },
                            url: "/AJAX/multipage_change_cover_side.php",
                            async: true,
                            success: function (data) {
                                var result = JSON.parse(data);
                                $('.cCoverSelect').html(result);
                                __initListenerMultiCostTable();
                            }
                        });
                    });
                };

                const __initListenerChangeMultipageDecorSide = function () {
                    $('.cMultipageTitle').on('change', '.cDecorSide input', function () {
                        $.ajax({
                            type: 'POST',
                            data: {
                                'id': $(this).attr('val')
                            },
                            url: "/AJAX/multipage_change_decor_side.php",
                            async: true,
                            success: function (data) {
                                var result = JSON.parse(data);
                                $('.cDecorSelect').html(result);
                                __initListenerMultiCostTable();
                            }
                        });
                    });
                };

                const __initListenerChangeMultipageInsideSide = function () {
                    $('.cMultipageTitle').on('change', '.cInsideSide input', function () {
                        $.ajax({
                            type: 'POST',
                            data: {
                                'id': $(this).attr('val')
                            },
                            url: "/AJAX/multipage_change_inside_side.php",
                            async: true,
                            success: function (data) {
                                var result = JSON.parse(data);
                                $('.cInsideSelect').html(result);
                                __initListenerMultiCostTable();
                            }
                        });
                    });
                };

                const __initListenerChangeMultipageBondSide = function () {
                    $('.cMultipageTitle').on('change', '.cBondSelect input', function () {
                        $.ajax({
                            type: 'POST',
                            data: {
                                'id': $(this).attr('val')
                            },
                            url: "/AJAX/multipage_change_bond.php",
                            async: true,
                            success: function (data) {
                                var result = JSON.parse(data);
                                $('.cPageSelect').html(result);
                                __initListenerMultiCostTable();
                            }
                        });
                    });
                };

                const __initListenerClosePayQR = function () {
                    $('.closeQRpay').on('click', function () {
                        if (confirm('РћС‚РєР°Р·Р°С‚СЊСЃСЏ РѕС‚ РѕРїР»Р°С‚С‹')) location.href = '/order';
                    });
                };

                const __initListenerDeliveryCalcCostTargetedCountry = function () {
                    // РћР±СЂР°Р±Р°С‚С‹РІР°РµРј СЃС‚РѕРёРјРѕСЃС‚СЊ "РђРґСЂРµСЃРЅРѕР№ РґРѕСЃС‚Р°РІРєРё DPD"
                    $('.check_delivery').on('click', '#dpdTargetedBlock button.dpdTargetedButton', function () {
                        dpd_country = $('.delivery_block_ad_of_dpd #to_country').val();
                        dpd_city = $('.delivery_block_ad_of_dpd #to_city').val();
                        dpd_region = $('.delivery_block_ad_of_dpd #to_region').val();
                        dpd_region2 = $('.delivery_block_ad_of_dpd #to_city').val();


                        if ($('#dpdTargetedBlock .del_addr_hd').val() == '' &amp;&amp; $('.cLargeFormatDelivery .dpdTargetedBlock .del_addr_hd').val() == '')
                        {
                            $('#dpdTargetedBlock .del_addr_hd').css('border-color', 'red');
                            $('#alertModal').find('.modal-body p').text("РќРµ РІСЃРµ РїРѕР»СЏ Р·Р°РїРѕР»РЅРµРЅС‹");
                            $('#alertModal').modal('toggle');
                            return;
                        }
                        if (dpd_city == 'Р©РµСЂР±РёРЅРєР°')
                        {
                            dpd_city = 'Рі. Р©РµСЂР±РёРЅРєР°';
                            dpd_region = 'РњРѕСЃРєРѕРІСЃРєР°СЏ';
                        }
                        if (dpd_city == 'РњРѕСЃРєРІР°')
                        {
                            dpd_region = 'РњРѕСЃРєРІР°';
                        }

                        if (dpd_city == 'РўСЂРѕРёС†Рє')
                        {
                            dpd_region = 'РњРѕСЃРєРѕРІСЃРєР°СЏ РѕР±Р»Р°СЃС‚СЊ';
                        }

                        if (dpd_city == 'РЎРёРјС„РµСЂРѕРїРѕР»СЊ')
                        {
                            dpd_region = 'РљСЂС‹Рј';
                            dpd_country = 'Р&nbsp;РѕСЃСЃРёСЏ';
                        }
                        if (dpd_city == 'РЎС–РјС„РµСЂРѕРїРѕР»СЊ')
                        {
                            dpd_city = 'РЎРёРјС„РµСЂРѕРїРѕР»СЊ'
                            dpd_region = 'РљСЂС‹Рј';
                            dpd_country = 'Р&nbsp;РѕСЃСЃРёСЏ';
                        }

                        //dpd_adress = $('#dpdTargetedBlock .del_addr').val() + ', ' + $('#dpdTargetedBlock .del_addr_hd').val()+$('.cLargeFormatDelivery .dpdTargetedBlock .del_addr_hd').val();
                        dpd_adress = $('#dpdTargetedBlock .del_addr').val() + ', ' + $('#dpdTargetedBlock .del_addr_hd').val();

                        if (otype === 'large')
                        {
                            mark = 1;
                            ph_id = $('.cPrintTerm input:checked').data('ph_id');
                        }
                        else
                        {
                            mark = 0;
                        }

                        //

                        let id_print = 0;
                        let name = '';
                        let id_material = 0;
                        let tir_value = 0;
                        let id_time = 0;

                        if (otype === 'offset')
                        {
                            id_print = cost.id_print;
                            name = cost.name;
                            id_material = cost.id_material;
                            tir_value = cost.value;
                            id_time = cost.id_time;
                        }

                        if ($('.dpdTargetedBlock .del_addr').val().length &gt; 0)
                        {
                            $('.download_out').css('display', 'block');
                            var coef = Math.cbrt(Number($('.cDpdNum').html()) + Number($('.cDpdNumDop').html()));
                            // console.log(dpd_city);
                            // console.log(dpd_region);

                            let ADDRESS_RECOGNIZER_RESULT = {};
                            if (window.hasOwnProperty('ADDRESS_RECOGNIZER_RESULT'))
                            {
                                ADDRESS_RECOGNIZER_RESULT = window['ADDRESS_RECOGNIZER_RESULT'];
                            }

                            $.ajax({
                                type: 'POST',
                                data: {
                                    //'mark': $(this).data('mark'),
                                    'mark': mark,
                                    'otype': otype,
                                    'product_id': p_id,
                                    'own_region': ph_id,
                                    'country': dpd_country,
                                    'city': dpd_city,
                                    'region': dpd_region,
                                    'region2': dpd_region2,
                                    'length': Number($('.cDpdLen').html()) * coef,
                                    'width': Number($('.cDpdWid').html()) * coef,
                                    'height': Number($('.cDpdHgt').html()) * coef,
                                    'weight': Number(Number($('.cDpdWgtAll').html()) + Number($('.cDpdWgtAllDop').html())).toFixed(2),
                                    'product': cost['name'],
                                    'cost': $('.printCost').html(),

                                    'address_recognizer_result': ADDRESS_RECOGNIZER_RESULT
                                },
                                url: "/AJAX/get_dpd_price_adress.php",
                                async: true,
                                success: function (data) {
                                    // console.log(data);
                                    try
                                    {
                                        var result = JSON.parse(data);
                                        // console.log(result);
                                        if (result['DPD'] == false)
                                        {
                                            dpd_ready = false;
                                            $('.totalCost').text($('.printCost').html());
                                            $('.deliveryCost').text(0);

                                            if (instanceForOffset.isPartnerHost())
                                            {
                                                ('.realTotalCost').text($('.realPrintCost').html());
                                                $('.RealtotalCost').text($('.RealprintCost').html());

                                                // old variant
                                                $('.deliveryDate').text($('.dateReady').html());
                                            }
                                            else
                                            {
                                                let dateReadyDate = $('.dateReady').html().split('.');
                                                setDeliveryDate({
                                                    d: dateReadyDate[0],
                                                    m: dateReadyDate[1],
                                                    y: dateReadyDate[2]
                                                }, 13);
                                            }

                                            //alert('РЎСЋРґР° РґРѕСЃС‚Р°РІРєР° РЅРµ РІРѕР·РјРѕР¶РЅР°');
                                            $('#alertModal').find('.modal-body p').text("РЎРѕР¶Р°Р»РµРµРј, РЅРѕ РґР°СЃС‚Р°РІРєР° РІ РІС‹Р±СЂР°РЅРЅС‹Р№ РїСѓРЅРєС‚ РЅРµРІРѕР·РјРѕР¶РЅР°");
                                            $('#alertModal').modal('toggle');
                                        }
                                        else
                                        {
                                            dpd_ready = true;

                                            service_code = result['DPD'].SERVICE_CODE;
                                            //console.log(result);
                                            dpd_flag = result['CONFIRM'];
                                            if (result['USER_DAY'])
                                            {
                                                var new_date = TimeControl.readyTimeDelivery(Math.ceil(result['USER'].DAYS));
                                                if (instanceForOffset.isPartnerHost())
                                                {
                                                    // old variant
                                                    $('.deliveryDate').text(new_date['d'] + '.' + new_date['m'] + "." + new_date['y']);
                                                }
                                                else
                                                {
                                                    setDeliveryDate(new_date, 14);
                                                }
                                            }
                                            else
                                            {
                                                var new_date = TimeControl.readyTimeDelivery(Math.ceil(result['DPD'].DAYS));

                                                if (instanceForOffset.isPartnerHost())
                                                {
                                                    // old variant
                                                    $('.deliveryDate').text(new_date['d'] + '.' + new_date['m'] + "." + new_date['y']);
                                                }
                                                else
                                                {
                                                    setDeliveryDate(new_date, 15);
                                                }
                                            }

                                            //РЎС‚РѕРёРјРѕСЃС‚СЊ РґРѕСЃС‚Р°РІРєРё
                                            var user_cost = Math.ceil(Number(result['USER'].COST));
                                            var dpd_cost = Math.ceil(Number(result['DPD'].COST));
                                            //Р”Р»СЏ РєР»РёРµРЅС‚Р°
                                            $('.deliveryCost').text(user_cost);
                                            //Р”Р»СЏ РјРµРЅРµРґР¶РµСЂР°
                                            $('.actualDeliveryCost').val(dpd_cost);
                                            //РЎСѓРјР°СЂРЅР°СЏ СЃС‚РѕРёРјРѕСЃС‚СЊ
                                            var total_cost = user_cost + Number($('.printCost').html());
                                            $('.totalCost').text(total_cost);

                                            if (instanceForOffset.isPartnerHost())
                                            {
                                                $('.realTotalCost').text(user_cost + Number($('.realPrintCost').html()));
                                                $('.RealtotalCost').text(user_cost + Number($('.RealprintCost').html()));
                                            }
                                        }
                                    } catch (e)
                                    {
                                        $('#alertModal').find('.modal-body p').text("Р’Рѕ РІСЂРµРјСЏ СЂР°СЃС‡РµС‚Р° СЃС‚РѕРёРјРѕСЃС‚Рё РґРѕСЃС‚Р°РІРєРё РІРѕР·РЅРёРєР»Рё РЅРµРїСЂРµРґРІРёРґРµРЅРЅС‹Рµ С‚СЂСѓРґРЅРѕСЃС‚Рё. РџРѕР¶Р°Р»СѓР№СЃС‚Р°, СЃРІСЏР¶РёС‚РµСЃСЊ СЃ РЅР°С€РёРј РјРµРЅРµРґР¶РµСЂРѕРј.");
                                        $('#alertModal').modal('toggle');
                                    }
                                    $('.download_out').css('display', 'none');
                                }
                            });
                        }
                        else
                        {
                            $('#alertModal').find('.modal-body p').text("РќРµРѕР±С…РѕРґРёРјРѕ Р·Р°РїРѕР»РЅРёС‚СЊ Р°РґСЂРµСЃ");
                            $('#alertModal').modal('toggle');
                        }
                    });
                };

                const __initListenerDeliverySelectPointPickup = function () {
                    // РћР±СЂР°Р±Р°С‚С‹РІР°РµРј СЃРѕР±С‹С‚РёРµ РІС‹Р±РѕСЂР° С‚РѕС‡РєРё СЃР°РјРѕРІС‹РІРѕР·Р°
                    $('.offset_params_order .check_delivery').on('click', '.SPP_List tr', function () {

                        deliveryRegistration.beforeSelectSelfPickupPoint(this);

                        let $tr = $(this);
                        // DeliveryInstance.setCompany('DPD');

                        //$(this).parent().find('tr').each (function() {
                        $tr.closest('#pickup').find('tr').each(function () {
                            $(this).removeClass();
                        });
                        var spp_table = $(this).parent();

                        $(this).addClass('spp_act');
                        //$('.check_delivery .sp_points .spp_block').css('display', 'none');
                        sp_address = $(this).data('city') + ', ' + $(this).data('address');

                        let dataCompanyName = $(this).data('tk');
                        if (dataCompanyName === 'ozon' || dataCompanyName === 'sdek')
                        {
                            sp_address = $(this).data('address');
                        }

                        let tCompanySign = '';
                        if (dataCompanyName === 'dpd')
                        {
                            tCompanySign = 'DPD';
                            DeliveryInstance.forceSet("company", tCompanySign);
                        }
                        else if (dataCompanyName === 'ozon')
                        {
                            tCompanySign = 'OZON';
                            DeliveryInstance.forceSet("company", tCompanySign);
                        }
                        else if (dataCompanyName === 'sdek')
                        {
                            tCompanySign = 'SDEK';
                            DeliveryInstance.forceSet("company", tCompanySign);
                        }
                        else if (dataCompanyName === 'yandexterminal')
                        {
                            tCompanySign = 'YandexTerminal';
                            const pointKey = $tr.attr('data-point-key');

                            DeliveryInstance.setPointKey(pointKey);
                            DeliveryInstance.forceSet("company", "YandexTerminal");
                        }

                        sp_region = $(this).data('region');
                        sp_addr = $(this).data('address');
                        sp_city = $(this).data('city');
                        sp_tk = $(this).data('tk');
                        newDate = TimeControl.readyTimeDelivery(Number($(this).data('deliveryperiod')));
                        // $('.deliveryDate').text(newDate['d'] + '.' + newDate['m'] + "." + newDate['y']);
                        setDeliveryDate(newDate, 16);
                        $('.cPickUpDate').html(newDate['d'] + '.' + newDate['m'] + "." + newDate['y']);
                        $('.SPP_address').html('&lt;font color="red"&gt;' + sp_address + '&lt;/font&gt;');
                        $('.SPP_comment').html($(this).data('comment'));

                        $('.check_delivery .sp_points .spp_block').css('display', 'block');
                        $('.check_delivery .sp_points').css('display', 'block');

                    });
                };

                const __initPartnerListenerDeliverySelectPointPickup = function () {
                    // РћР±СЂР°Р±Р°С‚С‹РІР°РµРј СЃРѕР±С‹С‚РёРµ РІС‹Р±РѕСЂР° С‚РѕС‡РєРё СЃР°РјРѕРІС‹РІРѕР·Р°
                    $('.offset_params_order .check_delivery').on('click', '.SPP_List tr', function () {

                        const tk = $(this).attr('data-tk');
                        // console.debug("CLICK", tk);
                        // console.debug("element", $(this));
                        if (tk === "dpd") DeliveryInstance.forceSet("company", "DPD");
                        else if (tk === "sdek") DeliveryInstance.forceSet("company", "SDEK");
                        else if (tk === "yandexterminal") {
                            DeliveryInstance.forceSet("company", "YandexTerminal");
                            const pointKey = $(this).attr('data-point-key');
                            DeliveryInstance.setPointKey(pointKey);
                        }

                        spSerialize = $(this).data();
                        let partnerPickup = spSerialize['tk'] === 'partner-pickup';

                        //$(this).parent().find('tr').each (function() {
                        $(this).closest('#pickup').find('tr').each (function() {
                            $(this).removeClass();
                        });
                        var spp_table = $(this).parent();

                        $(this).addClass('spp_act');
                        //$('.check_delivery .sp_points .spp_block').css('display', 'none');

                        if (partnerPickup)
                        {
                            sp_address = spSerialize['tkAddress'];
                            sp_addr = spSerialize['tkAddress'];
                            sp_tk = spSerialize['tkOriginal'];

                            spSerialize['tkDate'] = TimeControl.readyTimeDelivery(Number(spSerialize['tkDelay']));
                            spSerialize['partnerDate'] = TimeControl.readyTimeDelivery(Number(spSerialize['deliveryperiod']));
                            newDate = {...spSerialize['partnerDate']};
                        }
                        else
                        {
                            let dataCompanyName = $(this).data('tk');
                            if(dataCompanyName === 'ozon' || dataCompanyName === 'sdek')
                            {
                                sp_address = $(this).data('address');
                            }
                            else
                            {
                                sp_address = $(this).data('city') + ', ' + $(this).data('address');
                            }

                            sp_addr = $(this).data('address');
                            sp_tk = $(this).data('tk');

                            spSerialize['tkDate'] = TimeControl.readyTimeDelivery(Number(spSerialize['deliveryperiod']));
                            newDate = {...spSerialize['tkDate']};
                        }

                        sp_region = $(this).data('region');
                        sp_city = $(this).data('city');


                        $('.deliveryDate').text(newDate['d'] + '.' + newDate['m'] + "." + newDate['y']);
                        $('.cPickUpDate').html(newDate['d'] + '.' + newDate['m'] + "." + newDate['y']);
                        $('.SPP_address').html('&lt;font color="red"&gt;' + spSerialize['address'] + '&lt;/font&gt;');
                        $('.SPP_comment').html(spSerialize['comment']);

                        $('.check_delivery .sp_points .spp_block').css('display', 'block');
                        $('.check_delivery .sp_points').css('display', 'block');


                        // console.log(spSerialize);
                    });
                };

                const __initListenerDeliverySelectCityForTerminal = function () {
                    // РћР±СЂР°Р±Р°С‚С‹РІР°РµРј СЃРѕР±С‹С‚РёРµ РІС‹Р±РѕСЂР° РіРѕСЂРѕРґР° РґР»СЏ С‚РµСЂРјРёРЅР°Р»СЊРЅРѕР№ РґРѕСЃС‚Р°РІРєРё
                    $('.offset_params_order .check_delivery').on('click', '.dpd_but_city', function () {
                        citySelection($('.offset_params_order .dpd_city').val().toLowerCase());
                        // return;
                        // if (window.hasOwnProperty('recipient_location_recognize'))
                        // {
                        //     citySelection('', recipient_location_recognize);
                        // }
                    });
                };

                const __initListenerDeliveryCalcCostTerminal = function () {
                    // РћР±СЂР°Р±Р°С‚С‹РІР°РµРј СЃС‚РѕРёРјРѕСЃС‚СЊ "РўРµСЂРјРёРЅР°Р»СЊРЅРѕР№ РґРѕСЃС‚Р°РІРєРё DPD"
                    $('.offset_delivery').on('click', '.cInfo_addressee button.terminalButton', function () {
                        //$('.offset_delivery .cInfo_addressee button').on('click', function () {

                        //if ($('.dpd_terminal .del_addr').html().length &gt; 0) {
                        if ($('.offset_delivery .dpd_terminal .del_addr').html().length &gt; 0)
                        {
                            $('.download_out').css('display', 'block');
                            var coef = Math.cbrt(Number($('.check_delivery table .cDpdNum').html()) + Number($('.check_delivery table .cDpdNumDop').html()));
                            // console.log(multi);
                            if (otype === 'offset' || otype === 'calendar')
                            {
                                mark = 0;
                                if (multi)
                                {
                                    mark = 1;
                                }
                            }
                            else
                            {
                                mark = 1;
                            }

                            //console.log(cost);
                            // console.log('mark ' + mark);
                            if (dpd_flag)
                            {
                                DeliveryInstance.setCompany('DPD');

                                $.ajax({
                                    type: 'POST',
                                    data: {
                                        'own_region': ph_id,
                                        'mark': mark,
                                        'otype': otype,
                                        'product_id': p_id,
                                        'country': dpd_country,
                                        'city': dpd_city,
                                        'region': dpd_region,
                                        'region2': dpd_region2,
                                        'length': Number($('.cDpdLen').html()) * coef,
                                        'width': Number($('.cDpdWid').html()) * coef,
                                        'height': Number($('.cDpdHgt').html()) * coef,
                                        'weight': Number(Number($('.cDpdWgtAll').html()) + Number($('.cDpdWgtAllDop').html())).toFixed(2),
                                        'product': cost['name'],
                                        'cost': $('.printCost').html(),
                                        'delivery_location': window.hasOwnProperty('deliveryLocationSelectorInstance') ? deliveryLocationSelectorInstance.getLocation() : {},
                                    },
                                    url: "/AJAX/get_dpd_price_terminal.php",
                                    async: true,
                                    success: function (data) {
                                        // console.log(data);
                                        try
                                        {
                                            var result = JSON.parse(data);
                                            // console.log(result);
                                            if (result['DPD'] == false)
                                            {
                                                dpd_ready = false;

                                                $('#alertModal').find('.modal-body p').text("РќРµРѕР±С…РѕРґРёРјРѕ РІС‹Р±СЂР°С‚СЊ РїСѓРЅРєС‚ РЅР°Р·РЅР°С‡РµРЅРёСЏ");
                                                $('#alertModal').modal('toggle');

                                                $('.totalCost').text($('.printCost').html());
                                                $('.deliveryCost').text(0);

                                                if (instanceForOffset.isPartnerHost())
                                                {
                                                    $('.realTotalCost').text($('.realPrintCost').html());
                                                    $('.deliveryDate').text($('.dateReady').html()); // old variant
                                                }
                                                else
                                                {
                                                    let dateReadyDate = $('.dateReady').html().split('.');
                                                    setDeliveryDate({
                                                        d: dateReadyDate[0],
                                                        m: dateReadyDate[1],
                                                        y: dateReadyDate[2]
                                                    }, 17);
                                                }
                                            }
                                            else
                                            {
                                                dpd_ready = true;
                                                service_code = result['DPD'].SERVICE_CODE;
                                                dpd_flag = result['CONFIRM'];
                                                sdek_flag = false;
                                                ems_flag = false;
                                                if (result['USER_DAY'])
                                                {
                                                    var new_date = TimeControl.readyTimeDelivery(Math.ceil(result['USER'].DAYS));
                                                    if (instanceForOffset.isPartnerHost())
                                                    {
                                                        // old variant
                                                        $('.deliveryDate').text(new_date['d'] + '.' + new_date['m'] + "." + new_date['y']);
                                                    }
                                                    else
                                                    {
                                                        setDeliveryDate(new_date, 18);
                                                    }
                                                }
                                                else
                                                {
                                                    /**
                                                     * Р&nbsp;Р°Р±РѕС‚Р° СЃ РґР°С‚РѕР№ РґРѕСЃС‚Р°РІРєРё DPD
                                                     */
                                                    var date = $('.actualDateReady').val().split('-');
                                                    var dpd_date = new Date(date[1] + "/" + date[2] + "/" + date[0]);

                                                    dpd_date.setDate(dpd_date.getDate() + result['DPD'].DAYS);
                                                    /******РџСЂРѕРІРµСЂРєР° Р±РѕР»СЊС€Рµ РјРµР»СЊРјРµ Р»Рё СЃРєСЂС‹С‚РѕР№ (СЂРµР°Р»СЊРЅРѕР№) РґР°С‚С‹ РќРђР§РђР›Рћ ******/
                                                    date = $('.dateReady').html().split('.');
                                                    var control_date = new Date(date[1] + "/" + date[0] + "/" + date[2]);

                                                    if (dpd_date &lt; control_date)
                                                    {
                                                        dpd_date = control_date;
                                                    }
                                                    /******РџСЂРѕРІРµСЂРєР° Р±РѕР»СЊС€Рµ РјРµР»СЊРјРµ Р»Рё СЃРєСЂС‹С‚РѕР№ (СЂРµР°Р»СЊРЅРѕР№) РґР°С‚С‹ РќРђР§РђР›Рћ ******/
                                                    var day = dpd_date.getDate();
                                                    if (day &lt; 10)
                                                    {
                                                        day = "0" + day;
                                                    }
                                                    var month = dpd_date.getMonth() + 1;
                                                    if (month &lt; 10)
                                                    {
                                                        month = "0" + month;
                                                    }

                                                    if (instanceForOffset.isPartnerHost())
                                                    {
                                                        // old variant
                                                        $('.deliveryDate').text(day + '.' + month + "." + dpd_date.getFullYear());
                                                    }
                                                    else
                                                    {
                                                        setDeliveryDate({d: day, m: month, y: dpd_date.getFullYear()}, 19);
                                                    }
                                                    /**
                                                     * Р&nbsp;Р°Р±РѕС‚Р° СЃ РґР°С‚РѕР№ РґРѕСЃС‚Р°РІРєРё DPD
                                                     */
                                                }
                                                //РЎС‚РѕРёРјРѕСЃС‚СЊ РґРѕСЃС‚Р°РІРєРё
                                                var user_cost = Math.ceil(Number(result['USER'].COST));
                                                var dpd_cost = Math.ceil(Number(result['DPD'].COST));
                                                //Р”Р»СЏ РєР»РёРµРЅС‚Р°
                                                $('.deliveryCost').text(user_cost);
                                                //Р”Р»СЏ РјРµРЅРµРґР¶РµСЂР°
                                                $('.actualDeliveryCost').val(dpd_cost);
                                                //РЎСѓРјР°СЂРЅР°СЏ СЃС‚РѕРёРјРѕСЃС‚СЊ
                                                var total_cost = user_cost + Number($('.printCost').html());
                                                $('.totalCost').text(total_cost);

                                                if (instanceForOffset.isPartnerHost())
                                                {
                                                    var real_total_cost = user_cost + Number($('.realPrintCost').html());
                                                    $('.realTotalCost').text(real_total_cost);
                                                }
                                            }
                                        } catch (e)
                                        {
                                            //$('#alertModal').find('.modal-body p').text("Р’Рѕ РІСЂРµРјСЏ СЂР°СЃС‡РµС‚Р° СЃС‚РѕРёРјРѕСЃС‚Рё РґРѕСЃС‚Р°РІРєРё РІРѕР·РЅРёРєР»Рё РЅРµРїСЂРµРґРІРёРґРµРЅРЅС‹Рµ С‚СЂСѓРґРЅРѕСЃС‚Рё. РџРѕР¶Р°Р»СѓР№СЃС‚Р°, СЃРІСЏР¶РёС‚РµСЃСЊ СЃ РЅР°С€РёРј РјРµРЅРµРґР¶РµСЂРѕРј.");
                                            //$('#alertModal').modal('toggle');
                                            //РєРѕСЃС‚С‹Р»СЊ
                                            dpd_calc_err = 1;
                                            dpd_ready = true;
                                            service_code = 'PCL';
                                            dpd_flag = true;
                                            sdek_flag = false;
                                            ozon_flag = false;
                                            /**
                                             * Р&nbsp;Р°Р±РѕС‚Р° СЃ РґР°С‚РѕР№ РґРѕСЃС‚Р°РІРєРё DPD
                                             */
                                            var date = $('.actualDateReady').val().split('-');
                                            var dpd_date = new Date(date[1] + "/" + date[2] + "/" + date[0]);

                                            dpd_date.setDate(dpd_date.getDate() + 2);
                                            /******РџСЂРѕРІРµСЂРєР° Р±РѕР»СЊС€Рµ РјРµР»СЊРјРµ Р»Рё СЃРєСЂС‹С‚РѕР№ (СЂРµР°Р»СЊРЅРѕР№) РґР°С‚С‹ РќРђР§РђР›Рћ ******/
                                            date = $('.dateReady').html().split('.');
                                            var control_date = new Date(date[1] + "/" + date[0] + "/" + date[2]);

                                            if (dpd_date &lt; control_date)
                                            {
                                                dpd_date = control_date;
                                            }
                                            /******РџСЂРѕРІРµСЂРєР° Р±РѕР»СЊС€Рµ РјРµР»СЊРјРµ Р»Рё СЃРєСЂС‹С‚РѕР№ (СЂРµР°Р»СЊРЅРѕР№) РґР°С‚С‹ РќРђР§РђР›Рћ ******/
                                            var day = dpd_date.getDate();
                                            if (day &lt; 10)
                                            {
                                                day = "0" + day;
                                            }
                                            var month = dpd_date.getMonth() + 1;
                                            if (month &lt; 10)
                                            {
                                                month = "0" + month;
                                            }

                                            if (instanceForOffset.isPartnerHost())
                                            {
                                                // old variant
                                                $('.deliveryDate').text(day + '.' + month + "." + dpd_date.getFullYear());
                                            }
                                            else
                                            {
                                                setDeliveryDate({d: day, m: month, y: dpd_date.getFullYear()}, 20);
                                            }

                                            /**
                                             * Р&nbsp;Р°Р±РѕС‚Р° СЃ РґР°С‚РѕР№ РґРѕСЃС‚Р°РІРєРё DPD
                                             */
                                                //РЎС‚РѕРёРјРѕСЃС‚СЊ РґРѕСЃС‚Р°РІРєРё
                                            var user_cost = 0;
                                            var dpd_cost = 0;
                                            //Р”Р»СЏ РєР»РёРµРЅС‚Р°
                                            $('.deliveryCost').text(user_cost);
                                            //Р”Р»СЏ РјРµРЅРµРґР¶РµСЂР°
                                            $('.actualDeliveryCost').val(dpd_cost);
                                            //РЎСѓРјР°СЂРЅР°СЏ СЃС‚РѕРёРјРѕСЃС‚СЊ
                                            var total_cost = user_cost + Number($('.printCost').html());
                                            $('.totalCost').text(total_cost);

                                            if (instanceForOffset.isPartnerHost())
                                            {
                                                var real_total_cost = user_cost + Number($('.realPrintCost').html());
                                                $('.realTotalCost').text(real_total_cost);
                                            }
                                        }
                                        $('.download_out').css('display', 'none');
                                    }
                                });

                            }
                            else if (sdek_flag)
                            {
                                DeliveryInstance.setCompany('SDEK');
                                $.ajax({
                                    type: 'POST',
                                    data: {
                                        //'mark': $(this).data('mark'),
                                        'own_region': ph_id,
                                        'mark': mark,
                                        'otype': otype,
                                        'product_id': p_id,
                                        'country': dpd_country,
                                        'city': dpd_city,
                                        'region': dpd_region,
                                        'region2': dpd_region2,
                                        'length': Number($('.cDpdLen').html()) * coef,
                                        'width': Number($('.cDpdWid').html()) * coef,
                                        'height': Number($('.cDpdHgt').html()) * coef,
                                        'weight': Number(Number($('.cDpdWgtAll').html()) + Number($('.cDpdWgtAllDop').html())).toFixed(2),
                                        'product': cost['name'],
                                        'cost': $('.printCost').html(),
                                        'delivery_location': window.hasOwnProperty('deliveryLocationSelectorInstance') ? deliveryLocationSelectorInstance.getLocation() : {},
                                    },
                                    url: "/AJAX/get_sdek_price_terminal.php",
                                    async: true,
                                    success: function (data) {
                                        //console.log(data);
                                        try
                                        {

                                            var result = JSON.parse(data);
                                            // console.log(result);

                                            dpd_ready = true;
                                            service_code = '';
                                            dpd_flag = false;
                                            sdek_flag = true;
                                            ems_flag = false;
                                            ozon_flag = false;

                                            var new_date = TimeControl.readyTimeDelivery(Math.ceil(result.SDEK.deliveryPeriodMin));
                                            if (instanceForOffset.isPartnerHost())
                                            {
                                                // old variant
                                                $('.deliveryDate').text(new_date['d'] + '.' + new_date['m'] + "." + new_date['y']);
                                            }
                                            else
                                            {
                                                setDeliveryDate(new_date, 21);
                                            }

                                            /*
                                            if (result['USER_DAY']) {

                                                var new_date = TimeControl.readyTimeDelivery(Math.ceil(result['USER'].DAYS));
                                                $('.deliveryDate').text(new_date['d'] + '.' + new_date['m'] + "." + new_date['y']);

                                            } else {

                                                var date = $('.actualDateReady').val().split('-');
                                                var dpd_date = new Date(date[1] + "/" + date[2] + "/" + date[0]);

                                                dpd_date.setDate(dpd_date.getDate() + result['DPD'].DAYS);

                                                date = $('.dateReady').html().split('.');
                                                var control_date = new Date(date[1] + "/" + date[0] + "/" + date[2]);

                                                if (dpd_date &lt; control_date) {
                                                    dpd_date = control_date;
                                                }

                                                var day = dpd_date.getDate();
                                                if (day &lt; 10) {
                                                    day = "0" + day;
                                                }
                                                var month = dpd_date.getMonth() + 1;
                                                if (month &lt; 10) {
                                                    month = "0" + month;
                                                }
                                                $('.deliveryDate').text(day + '.' + month + "." + dpd_date.getFullYear());

                                            }
                                            */
                                            //РЎС‚РѕРёРјРѕСЃС‚СЊ РґРѕСЃС‚Р°РІРєРё

                                            //var user_cost = Math.ceil(Number(result['USER'].COST));
                                            var sdek_cost = Math.ceil(Number(result.SDEK.price));
                                            //Р”Р»СЏ РєР»РёРµРЅС‚Р°
                                            $('.deliveryCost').text(sdek_cost);
                                            //Р”Р»СЏ РјРµРЅРµРґР¶РµСЂР°
                                            $('.actualDeliveryCost').val(sdek_cost);
                                            //РЎСѓРјР°СЂРЅР°СЏ СЃС‚РѕРёРјРѕСЃС‚СЊ
                                            var total_cost = sdek_cost + Number($('.printCost').html());
                                            $('.totalCost').text(total_cost);


                                        } catch (e)
                                        {
                                            // console.log('err_sdek_price');
                                            // console.log(e);
                                            $('#alertModal').find('.modal-body p').text("Р’Рѕ РІСЂРµРјСЏ СЂР°СЃС‡РµС‚Р° СЃС‚РѕРёРјРѕСЃС‚Рё РґРѕСЃС‚Р°РІРєРё РІРѕР·РЅРёРєР»Рё РЅРµРїСЂРµРґРІРёРґРµРЅРЅС‹Рµ С‚СЂСѓРґРЅРѕСЃС‚Рё. РџРѕР¶Р°Р»СѓР№СЃС‚Р°, СЃРІСЏР¶РёС‚РµСЃСЊ СЃ РЅР°С€РёРј РјРµРЅРµРґР¶РµСЂРѕРј.");
                                            $('#alertModal').modal('toggle');
                                        }
                                        $('.download_out').css('display', 'none');
                                    }
                                });

                            }
                            else if (ems_flag)
                            {
                                DeliveryInstance.setCompany('EMS');

                                $.ajax({
                                    type: 'POST',
                                    data: {
                                        'own_region': ph_id,
                                        'mark': mark,
                                        'otype': otype,
                                        'product_id': p_id,
                                        'country': dpd_country,
                                        'city': dpd_city,
                                        'region': dpd_region,
                                        //'region2': dpd_region2,
                                        'index_to': ems_index_to,
                                        'length': Number($('.cDpdLen').html()) * coef,
                                        'width': Number($('.cDpdWid').html()) * coef,
                                        'height': Number($('.cDpdHgt').html()) * coef,
                                        'weight': Number(Number($('.cDpdWgtAll').html()) + Number($('.cDpdWgtAllDop').html())).toFixed(2),
                                        'product': cost['name'],
                                        'cost': $('.printCost').html()
                                    },
                                    url: "/data/ems/terminal/price",
                                    async: true,
                                    success: function (data) {
                                        try
                                        {

                                            var result = JSON.parse(data);
                                            // console.log(result);

                                            if (result.CONFIRM)
                                            {

                                                dpd_ready = true;
                                                service_code = '';
                                                dpd_flag = false;
                                                sdek_flag = false;
                                                ems_flag = true;
                                                ozon_flag = false;

                                                var new_date = TimeControl.readyTimeDelivery(Math.ceil(result.EMS.delTimeMin));
                                                if (instanceForOffset.isPartnerHost())
                                                {
                                                    // old variant
                                                    $('.deliveryDate').text(new_date['d'] + '.' + new_date['m'] + "." + new_date['y']);
                                                }
                                                else
                                                {
                                                    setDeliveryDate(new_date, 22);
                                                }


                                                //РЎС‚РѕРёРјРѕСЃС‚СЊ РґРѕСЃС‚Р°РІРєРё

                                                var ems_cost = Math.ceil(Number(result.EMS.COST2));
                                                //Р”Р»СЏ РєР»РёРµРЅС‚Р°
                                                $('.deliveryCost').text(ems_cost);
                                                //Р”Р»СЏ РјРµРЅРµРґР¶РµСЂР°
                                                $('.actualDeliveryCost').val(Math.ceil(Number(result.EMS.COST)));
                                                //РЎСѓРјР°СЂРЅР°СЏ СЃС‚РѕРёРјРѕСЃС‚СЊ
                                                var total_cost = ems_cost + Number($('.printCost').html());
                                                $('.totalCost').text(total_cost);

                                            }
                                            else
                                            {
                                                $('#alertModal').find('.modal-body p').text("Р’Рѕ РІСЂРµРјСЏ СЂР°СЃС‡РµС‚Р° СЃС‚РѕРёРјРѕСЃС‚Рё РґРѕСЃС‚Р°РІРєРё РІРѕР·РЅРёРєР»Рё РЅРµРїСЂРµРґРІРёРґРµРЅРЅС‹Рµ С‚СЂСѓРґРЅРѕСЃС‚Рё. РџРѕР¶Р°Р»СѓР№СЃС‚Р°, СЃРІСЏР¶РёС‚РµСЃСЊ СЃ РЅР°С€РёРј РјРµРЅРµРґР¶РµСЂРѕРј.");
                                                $('#alertModal').modal('toggle');
                                            }


                                        } catch (e)
                                        {
                                            // console.log('err_ems_price');
                                            // console.log(e);
                                            $('#alertModal').find('.modal-body p').text("Р’Рѕ РІСЂРµРјСЏ СЂР°СЃС‡РµС‚Р° СЃС‚РѕРёРјРѕСЃС‚Рё РґРѕСЃС‚Р°РІРєРё РІРѕР·РЅРёРєР»Рё РЅРµРїСЂРµРґРІРёРґРµРЅРЅС‹Рµ С‚СЂСѓРґРЅРѕСЃС‚Рё. РџРѕР¶Р°Р»СѓР№СЃС‚Р°, СЃРІСЏР¶РёС‚РµСЃСЊ СЃ РЅР°С€РёРј РјРµРЅРµРґР¶РµСЂРѕРј.");
                                            $('#alertModal').modal('toggle');
                                        }
                                        $('.download_out').css('display', 'none');

                                    }
                                });

                            }
                            else if (ozon_flag)
                            {
                                DeliveryInstance.setCompany('OZON');

                                $.ajax({
                                    type: 'POST',
                                    data: {
                                        'own_region': ph_id,
                                        'mark': mark,
                                        'otype': otype,
                                        'product_id': p_id,
                                        'city': dpd_city,
                                        'region': dpd_region,
                                        'deliveryVariantId': deliveryVariantId,
                                        //'length': Number($('.cDpdLen').html()) * coef,
                                        //'width': Number($('.cDpdWid').html()) * coef,
                                        //'height': Number($('.cDpdHgt').html()) * coef,
                                        'weight': Number(Number($('.cDpdWgtAll').html()) + Number($('.cDpdWgtAllDop').html())).toFixed(2),
                                        'cost': $('.printCost').html()
                                    },
                                    url: "/AJAX/get_OZON_price_terminal.php",
                                    async: false,
                                    success: function (data) {
                                        try
                                        {

                                            let result = JSON.parse(data);

                                            if (result.Confirm)
                                            {

                                                dpd_ready = true;
                                                service_code = '';
                                                dpd_flag = false;
                                                sdek_flag = false;
                                                ems_flag = false;
                                                ozon_flag = true;

                                                let new_date = TimeControl.readyTimeDelivery(Math.ceil(result.OZON.days));
                                                if (instanceForOffset.isPartnerHost())
                                                {
                                                    // old variant
                                                    $('.deliveryDate').text(new_date['d'] + '.' + new_date['m'] + "." + new_date['y']);
                                                }
                                                else
                                                {
                                                    setDeliveryDate(new_date, 23);
                                                }

                                                let ozon_cost = Math.ceil(Number(result.OZON.amount));

                                                $('.deliveryCost').text(ozon_cost);

                                                $('.actualDeliveryCost').val(Math.ceil(Number(result.OZONO.amount)));

                                                let total_cost = ozon_cost + Number($('.printCost').html());
                                                $('.totalCost').text(total_cost);

                                            }
                                            else
                                            {
                                                $('#alertModal').find('.modal-body p').text("Р’Рѕ РІСЂРµРјСЏ СЂР°СЃС‡РµС‚Р° СЃС‚РѕРёРјРѕСЃС‚Рё РґРѕСЃС‚Р°РІРєРё РІРѕР·РЅРёРєР»Рё РЅРµРїСЂРµРґРІРёРґРµРЅРЅС‹Рµ С‚СЂСѓРґРЅРѕСЃС‚Рё. РџРѕР¶Р°Р»СѓР№СЃС‚Р°, СЃРІСЏР¶РёС‚РµСЃСЊ СЃ РЅР°С€РёРј РјРµРЅРµРґР¶РµСЂРѕРј.");
                                                $('#alertModal').modal('toggle');
                                            }


                                        } catch (e)
                                        {
                                            // console.log(e);
                                            $('#alertModal').find('.modal-body p').text("Р’Рѕ РІСЂРµРјСЏ СЂР°СЃС‡РµС‚Р° СЃС‚РѕРёРјРѕСЃС‚Рё РґРѕСЃС‚Р°РІРєРё РІРѕР·РЅРёРєР»Рё РЅРµРїСЂРµРґРІРёРґРµРЅРЅС‹Рµ С‚СЂСѓРґРЅРѕСЃС‚Рё. РџРѕР¶Р°Р»СѓР№СЃС‚Р°, СЃРІСЏР¶РёС‚РµСЃСЊ СЃ РЅР°С€РёРј РјРµРЅРµРґР¶РµСЂРѕРј.");
                                            $('#alertModal').modal('toggle');
                                        }

                                        $('.download_out').css('display', 'none');

                                    }
                                });

                            }
                            else if (yandexterminal.flag)
                            {
                                DeliveryInstance.setCompany('YandexTerminal');

                                $.ajax({
                                    type: 'POST',
                                    data: {
                                        station_id: yandexterminal.station_id,
                                        'own_region': ph_id,
                                        'mark': mark,
                                        'otype': otype,
                                        'product_id': p_id,
                                        'country': dpd_country,
                                        'city': dpd_city,
                                        'region': dpd_region,
                                        'region2': dpd_region2,
                                        'length': Number($('.cDpdLen').html()) * coef,
                                        'width': Number($('.cDpdWid').html()) * coef,
                                        'height': Number($('.cDpdHgt').html()) * coef,
                                        'weight': Number(Number($('.cDpdWgtAll').html()) + Number($('.cDpdWgtAllDop').html())).toFixed(2),
                                        'product': cost['name'],
                                        'cost': $('.printCost').html(),
                                        'delivery_location': window.hasOwnProperty('deliveryLocationSelectorInstance') ? deliveryLocationSelectorInstance.getLocation() : {},
                                    },
                                    url: "/data/delivery/yandexterminal/calculate",
                                    async: true,
                                    dataType: "json",
                                    success: function ({result}) {

                                        dpd_ready = true;
                                        service_code = '';
                                        dpd_flag = false;
                                        sdek_flag = true;
                                        ems_flag = false;
                                        ozon_flag = false;

                                        var new_date = TimeControl.readyTimeDelivery(Math.ceil(result.deliveryPeriodMin));
                                        if (instanceForOffset.isPartnerHost())
                                        {
                                            // old variant
                                            $('.deliveryDate').text(new_date['d'] + '.' + new_date['m'] + "." + new_date['y']);
                                        }
                                        else
                                        {
                                            setDeliveryDate(new_date, 321);
                                        }

                                        // РЎС‚РѕРёРјРѕСЃС‚СЊ РґРѕСЃС‚Р°РІРєРё

                                        var sdek_cost = Math.ceil(Number(result.price));
                                        // Р”Р»СЏ РєР»РёРµРЅС‚Р°
                                        $('.deliveryCost').text(sdek_cost);
                                        // Р”Р»СЏ РјРµРЅРµРґР¶РµСЂР°
                                        $('.actualDeliveryCost').val(sdek_cost);
                                        // РЎСѓРјРјР°СЂРЅР°СЏ СЃС‚РѕРёРјРѕСЃС‚СЊ
                                        var total_cost = sdek_cost + Number($('.printCost').html());
                                        $('.totalCost').text(total_cost);
                                        $('.download_out').css('display', 'none');
                                    },
                                    error: (e) =&gt; {
                                        let $alertModal = $(`#alertModal`);
                                        $alertModal.find('.modal-body p').text("Р’Рѕ РІСЂРµРјСЏ СЂР°СЃС‡РµС‚Р° СЃС‚РѕРёРјРѕСЃС‚Рё РґРѕСЃС‚Р°РІРєРё РІРѕР·РЅРёРєР»Рё РЅРµРїСЂРµРґРІРёРґРµРЅРЅС‹Рµ С‚СЂСѓРґРЅРѕСЃС‚Рё. РџРѕР¶Р°Р»СѓР№СЃС‚Р°, СЃРІСЏР¶РёС‚РµСЃСЊ СЃ РЅР°С€РёРј РјРµРЅРµРґР¶РµСЂРѕРј.");
                                        $alertModal.modal('toggle');
                                        $('.download_out').css('display', 'none');
                                    }
                                });
                            }

                        }
                        else
                        {
                            //alert('Р—Р°РїРѕР»РЅРёС‚Рµ Р°РґСЂРµСЃ');
                            $('#alertModal').find('.modal-body p').text("РџРѕР¶Р°Р»СѓР№СЃС‚Р°, РІС‹Р±РµСЂРёС‚Рµ РїСѓРЅРєС‚ РІС‹РґР°С‡Рё РёР· СЃРїРёСЃРєР°.");
                            $('#alertModal').modal('toggle');
                        }
                    });
                };

                const __initPartnerListenerSaveProductProps = function () {
                    $('.offset-content').on('click', '.save_product_properties', function(){

                        // console.log('save_product_properties');

                        let product_id = $(this).attr('product_id');
                        let product_on = ($('.offset-content .product_onoff #enable_product').prop('checked')) ? 1:0;
                        let materials = [];
                        let extra_charge_by_time = [];
                        $('.offset-content input[type=range]').each(function () {
                            let cup = [$(this).attr('material_id'), 0, $(this).val()];
                            materials.push(cup);
                        });

                        $('.offset-content input.print_extra_charge').each(function () {
                            //console.log($(this));
                            let cup_tir = [$(this).attr('material_id'), $(this).attr('tir_id'), $(this).val()];
                            materials.push(cup_tir);
                        });

                        $('.offset-content input.time_extra_charge').each(function () {
                            let cup_time = [$(this).attr('material_id'), $(this).attr('time_id'), $(this).val()];
                            extra_charge_by_time.push(cup_time);
                        });

                        let product_image_button = partnerTools.btnImagePng.getDataForSave();
                        $.ajax({
                            type: 'POST',
                            data: {
                                'product_id': product_id,
                                'product_on': product_on,
                                'materials': materials,
                                'extra_charge_by_time': extra_charge_by_time,
                                'product_image_button': product_image_button,
                            },
                            url: "/AJAX/save_product_partner_property.php",
                            async: true,
                            success: function (data) {
                                if(data === "DONE")
                                {

                                    $('.first_block_product span').each(function () {
                                        if($(this).attr('productid') == product_id)
                                        {
                                            let $img = $(this).find('img');
                                            $img.attr('src', product_image_button.image);

                                            if(product_on == 1)
                                            {
                                                $img.removeClass('off');
                                                $(this).find('.small_block &gt; div:nth-child(2)').css('opacity', '1');
                                            }
                                            else
                                            {
                                                $img.addClass('off');
                                                $(this).find('.small_block &gt; div:nth-child(2)').css('opacity', '25%');
                                            }
                                        }
                                    });
                                    $('.offset-materail-table').html('');
                                    $('.offset-floating-title').html('');
                                    $('.cMultipageTitle').html('');
                                    $('html, body').animate({scrollTop: 0}, 600);

                                    $('#noticeModal').find('.modal-body p').text("Р”Р°РЅС‹Рµ СЃРѕС…СЂР°РЅРµРЅС‹");
                                    $('#noticeModal').modal('toggle');
                                }
                                else
                                {
                                    $('#alertModal').find('.modal-body p').text("РћС€РёР±РєР° СЃРѕС…СЂР°РЅРµРЅРёСЏ");
                                    $('#alertModal').modal('toggle');
                                }
                            }
                        });

                    });
                };

                const __initListenerProductClick = function () {
                    // Р’С‹РІРѕРґРёРј Р·Р°РіРѕР»РѕРІРѕРє Рё СЃРїРёСЃРѕРє РјР°С‚РµСЂРёР°Р»РѕРІ
                    $('span[table=productClick]').bind('click', function (e) {
                        e.preventDefault();
                        hideCost();
                        var current = $(this);
                        if ($(this).attr('paketi') == 1)
                        {
                            paketi = 1;
                        }
                        else
                        {
                            paketi = 0;
                        }
                        // console.log($(this).attr('otype'));
                        otype = $(this).attr('otype');
                        multi = false;
                        if ($(this).attr('otype') == 'offset' || $(this).attr('otype') == 'calendar')
                        {
                            //if ($(this).attr('otype') == 'offset' || $(this).attr('otype') == 'multipage' ) {
                            self_pickup = 1;
                            targeted_del = 1;
                            if ($(this).attr('multipage') == 1)
                            {
                                self_pickup = 0;
                                targeted_del = 0;
                                multi = true;
                            }
                        }
                        else
                        {
                            self_pickup = 0;
                            targeted_del = 0;
                        }

                        if ($(this).attr('productid') == 448)
                        {
                            self_pickup = 0;
                            targeted_del = 0;
                        }

                        p_id = $(this).attr('productid');
                        ph_id = 0;
                        ph_id_for_order = 0;

                        FileLoader.deleteAll(['kabinet_offset_rostov', 'kabinet_offset_get_title', '1']);

                        if ($(this).attr('multipage') == 0)
                        {
                            // console.log('kabinet_offset_get_title: 1');
                            $.ajax({
                                type: 'POST',
                                data: {
                                    'productid': $(this).attr('productid'),
                                    'flag': 1
                                },
                                url: "/AJAX/kabinet_offset_get_title.php",
                                async: true,
                                success: function (data) {
                                    var result = JSON.parse(data);
                                    $('.offset-floating-title').html(result.title);
                                    $('.offset-materail-table').html(result.block);
                                    $('#title_img_new').attr('src', result.descr_img);
                                    $('#title_draw').attr('href', result.descr_draw);
                                    $(".offset-materail-table").find('.time_to_parse').each(function () {
                                        //Р”РѕР±Р°РІР»СЏРµРј Рє td СЌР»РµРјРµРЅС‚Сѓ РµС‰С‘ РґРІР° Р°С‚СЂРёР±СѓС‚ РґР»СЏ С…СЂР°РЅРµРЅРёСЏ РјРµРЅРµРґР¶РµСЂСЃРєРѕР№ Рё РєР»РёРµРЅС‚СЃРєРѕР№ РґР°С‚С‹ РіРѕС‚РѕРІРЅРѕСЃС‚Рё
                                        //Р’СЂРµРјСЏ РґР»СЏ РјРµРЅРµРґР¶РµСЂР°
                                        var readyTime = TimeControl.parseReadyTime($(this).text(), false);
                                        $(this).attr("preldate", readyTime);
                                        //Р’СЂРµРјСЏ РґР»СЏ РєР»РёРµРЅС‚Р°
                                        readyTime = TimeControl.parseReadyTime($(this).text(), true);
                                        var time = readyTime.split('-');
                                        if (time[1].length == 1)
                                        {
                                            time[1] = "0" + time[1];
                                        }
                                        if (time[2].length == 1)
                                        {
                                            time[2] = "0" + time[2];
                                        }
                                        $(this).attr("finaldate", time[2] + '.' + time[1] + '.' + time[0]);
                                        $(this).text("Р“РѕС‚РѕРІРЅРѕСЃС‚СЊ РЅР° " + time[2] + '.' + time[1]);
                                        $(this).attr('withoutDelivery', "Р“РѕС‚РѕРІРЅРѕСЃС‚СЊ РЅР° " + time[2] + '.' + time[1]);

                                        // Р’СЂРµРјСЏ РґР»СЏ РєР»РёРµРЅС‚Р° РЎ Р”РћРЎРўРђР’РљРћР™
                                        let {day, month} = TimeControl.readyTimeWidthDelivery(time, $(this).attr('delivery'));
                                        $(this).attr('withDelivery', "Р“РѕС‚РѕРІРЅРѕСЃС‚СЊ РЅР° " + day + '.' + month);
                                    });
                                    /*if ($('.main_page-phone_number-bottom').offset().top + $('.main_page-phone_number-bottom').height() - $('.offset-floating-title').offset().top &lt; $(window).height()) {
                                 var new_height = $('.main_page-phone_number-bottom').offset().top + $('.main_page-phone_number-bottom').height() - $(window).height();
                                 $('html,body').animate({scrollTop: new_height}, 1100);
                                 }*/
                                    if ($('.footer_first_line').offset().top + $('.footer_first_line').height() - $('.offset-floating-title').offset().top &lt; $(window).height())
                                    {
                                        var new_height = $('.footer_first_line').offset().top + $('.footer_first_line').height() - $(window).height();
                                        $('html,body').animate({scrollTop: new_height}, 1100);
                                    }
                                    else
                                    {
                                        $('html,body').animate({scrollTop: $('.offset-title').offset().top}, 1100);
                                    }

                                }
                            });
                            __initListenerChangeMaterial();
                            //Р&nbsp;РµРґР°РєС‚РёСЂСѓРµРј С‚Р°Р±Р»РёС†Сѓ РїРѕ РЅР°Р»РёС‡РёСЋ/РѕС‚СЃСѓС‚СЃС‚РІРёСЋ СЃС‚РѕСЂРѕРЅС‹ РїРµС‡Р°С‚Рё
                            $('.offset-materail-table div[class=material]').each(function () {
                                if ($(this).find(".one").length == 2)
                                {
                                    $(this).find(".one").remove();
                                }
                                if ($(this).find(".two").length == 2)
                                {
                                    $(this).find(".two").remove();
                                }
                                if ($(this).find("tr").length == 1)
                                {
                                    $(this).remove();
                                }

                            });
                        }
                        else
                        {
                            let url = "/AJAX/kabinet_offset_get_multi_title_new.php";

                            $.ajax({
                                type: 'POST',
                                data: {
                                    'productid': $(this).attr('productid'),
                                    'id_real_prod': '',
                                    'flag': 1
                                },
                                url: url,
                                async: true,
                                success: function (data) {
                                    var result = JSON.parse(data);
                                    $('.cMultipageTitle').html(result.title);
                                    __initListenerMultiCostTable();

                                    //$('.offset-materail-table').html("&lt;span class='cMultiMessage'&gt;Р”Р»СЏ С„РѕСЂРјРёСЂРѕРІР°РЅРёСЏ РїСЂР°Р№СЃ-Р»РёСЃС‚Р° РІС‹Р±РµСЂРёС‚Рµ РјР°С‚РµСЂРёР°Р» РѕР±Р»РѕР¶РєРё, С†РІРµС‚РЅРѕСЃС‚СЊ РѕР±Р»РѕР¶РєРё, РјР°С‚РµСЂРёР°Р» РІРЅСѓС‚СЂРµРЅРЅРµРіРѕ Р±Р»РѕРєР°, С†РІРµС‚РЅРѕСЃС‚СЊ РІРЅСѓС‚СЂРµРЅРЅРµРіРѕ Р±Р»РѕРєР°, РєРѕР»-РІРѕ СЃС‚СЂР°РЅРёС†&lt;/span&gt;");
                                    if ($('.main_page-phone_number-bottom').offset().top + $('.main_page-phone_number-bottom').height() - $('.offset-floating-title').offset().top &lt; $(window).height())
                                    {

                                        /*var new_height = $('.main_page-phone_number-bottom').offset().top+$('.main_page-phone_number-bottom').height() - $(window).height();
                                     $('html,body').animate( { scrollTop: new_height }, 1100 );*/
                                        var new_height = $('.footer_first_line').offset().top + $('.footer_first_line').height() - $(window).height();
                                        $('html,body').animate({scrollTop: new_height}, 1100);
                                    }else
                                    {

                                        $('html,body').animate({scrollTop: $('.offset-title').offset().top}, 1100);
                                    }
                                }
                            });
                        }
                    });
                };

                const __initPartnerListenerProductClick = function () {
                    // Р’С‹РІРѕРґРёРј Р·Р°РіРѕР»РѕРІРѕРє Рё СЃРїРёСЃРѕРє РјР°С‚РµСЂРёР°Р»РѕРІ
                    $('span[table=productClick]').bind('click', function (e) {
                        e.preventDefault();
                        hideCost();

                        let $price = $(this);

                        const group_id = +$('#group_id').val();
                        const attrOtype = $price.attr("otype");
                        const attrMultipage = +$price.attr("multipage");
                        const attrProductid = +$price.attr("productid");

                        paketi = +$price.attr('paketi') === 1 ? 1 : 0;
                        otype = $(this).attr('otype');
                        multi = false;

                        if (attrOtype === "offset" || attrOtype === "calendar" || attrOtype === "multipage")
                        {
                            self_pickup = 1;
                            targeted_del = 1;
                            if (attrMultipage === 1)
                            {
                                self_pickup = 1;
                                targeted_del = 0;
                                multi = true;
                            }
                        }
                        else
                        {
                            self_pickup = 0;
                            targeted_del = 0;
                        }

                        if (attrProductid === 448)
                        {
                            self_pickup = 0;
                            targeted_del = 0;
                        }

                        p_id = $(this).attr('productid');
                        ph_id = 0;
                        ph_id_for_order = 0;

                        if (attrMultipage === 0)
                        {
                            partnerTools.offsetProductTable(group_id, attrProductid);
                        }
                        else
                        {
                            partnerTools.toggleWaitingServerTime();
                            let url = (group_id === 9)
                                ? "CMS/AJAX/kabinet_offset_get_multi_partner_title_new.php"
                                : "CMS/AJAX/kabinet_offset_get_multi_title_new.php";

                            $.ajax({
                                type: 'POST',
                                data: {
                                    'productid': $(this).attr('productid'),
                                    'id_real_prod': '',
                                    'flag': 1
                                },
                                url: url,
                                async: true,
                                success: function (data) {
                                    partnerTools.toggleWaitingServerTime();
                                    var result = JSON.parse(data);
                                    $('.cMultipageTitle').html(result.title);
                                    if ($('.offset-content .product_onoff #enable_product').prop('checked'))
                                    {
                                        $('.cMultipageTitle .product_onoff .left').css('color', '#cdc5bf');
                                        $('.cMultipageTitle .product_onoff .right').css('color', '#482e1b');
                                    }
                                    else
                                    {
                                        $('.cMultipageTitle .product_onoff .left').css('color', '#482e1b');
                                        $('.cMultipageTitle .product_onoff .right').css('color', '#cdc5bf');
                                    }
                                    __initListenerMultiCostTable();

                                    let $footerPhone = $('.main_page-phone_number-bottom');
                                    if ($('.footer_first_line').offset().top + $('.footer_first_line').height() - $('.offset-floating-title').offset().top &lt; $(window).height())
                                    {
                                        var new_height = $('.footer_first_line').offset().top + $('.footer_first_line').height() - $(window).height();
                                        $('html,body').animate({scrollTop: new_height}, 1100);
                                    }
                                    else
                                    {
                                        $('html,body').animate({scrollTop: $('.offset-title').offset().top}, 1100);
                                    }
                                    // if ($footerPhone.offset().top + $footerPhone.height() - $('.offset-floating-title').offset().top &lt; $(window).height())
                                    // {
                                    //     console.log($footerPhone.offset().top);
                                    //     console.log($footerPhone.height());
                                    //     console.log($('.offset-floating-title').offset().top );
                                    //     console.log($(window).height());
                                    //
                                    //     let $footerFirstLine = $('.footer_first_line');
                                    //     var new_height = $footerFirstLine.offset().top + $footerFirstLine.height() - $(window).height();
                                    //     $('html,body').animate({scrollTop: new_height}, 1100);
                                    // }
                                    // else
                                    // {
                                    //     console.log("7");
                                    //     $('html,body').animate({scrollTop: $('.offset-title').offset().top}, 1100);
                                    // }
                                }
                            });
                        }
                    });
                };

                const __initPartnerListenerProductProps = function () {
                    $('.offset-content')
                        .on('change', '.product_onoff input[type=checkbox]', function () {
                            let $el = $(this),
                                $left = $el.siblings('.left'),
                                $right = $el.siblings('.right');

                            if ($el.prop('checked'))
                            {
                                $left.css('color', '#cdc5bf');
                                $right.css('color', '#482e1b');
                            }
                            else
                            {
                                $right.css('color', '#cdc5bf');
                                $left.css('color', '#482e1b');
                            }
                        })
                        .on('change', '#product_img_button', function() {
                            partnerTools.btnImagePng.useChangeListener(this);
                        })
                        .on('click', '#use-default-image', function() {
                            let $btn = $(this),
                                $parent = $btn.parents('.product-image-upload');

                            $parent.find('img.product-image-button').attr('src', $btn.attr('data-default-image'));
                            $parent.find('input[type="file"]').val('');
                        });
                };

                $(document).ready(function () {

                    if (instanceForOffset.isPartnerHost()) DeliverySection.b_addDeliveryWarning();

                    __initListenerSearchAB();

                    __initFancyboxProductImg();

                    __initAvailableTags();

                    __initListenerMessage();

                    DeliverySection.addListener("listeners_group:1");
                    DeliverySection.addListener("select_address_book");
                    DeliverySection.addListener("select_terminal");

                    __initCalendar();

                    __initExtraDay();

                    __initListenerImageOptionsInput();
                    __initListenerOffsetChecks();

                    __initListenerCreateOrder();

                    __initListenersSwitchVisibleFormat();

                    __initListenerPopularProduct();
                    __initListenerPromoProduct();
                    __initLargeTab();

                    __initListenerTitleImg();
                    __initListenerChangeMultipageParams();
                    __initListenerSelectPrice();

                    __initListenerChangeTab();
                    __initListenerConfirmPreviewsFiles();

                    __initTimer();

                    __initListenerChangeOffsetMaterial();

                    __initListenerChangeMultipageRealProduct();
                    __initListenerChangeMultipageFilter();
                    __initListenerChangeMultipageCoverSide();
                    __initListenerChangeMultipageDecorSide();
                    __initListenerChangeMultipageInsideSide();
                    __initListenerChangeMultipageBondSide();

                    __initListenerClosePayQR();

                    DeliverySection.addListener("select_tc");
                    __initListenerDeliveryCalcCostTargetedCountry();
                    __initListenerDeliverySelectCityForTerminal();
                    __initListenerDeliveryCalcCostTerminal();
                    DeliverySection.addListener("select_method");

                    if (instanceForOffset.isPartnerHost())
                    {
                        __initPartnerListenerDeliverySelectPointPickup();
                        __initPartnerListenerSaveProductProps();
                        __initPartnerListenerProductClick();
                        __initPartnerListenerProductProps();
                    }
                    else
                    {
                        __initListenerDeliverySelectPointPickup();
                        __initListenerProductClick();
                    }
                });
            };

            __initialize();
        })();

        window.initialized_offset = true;
    }



    // used?
    window.mainTimeoutQR = function () {
        clearTimeout(timeout);
        GetStatusQR();
    };

    // used?
    window.GetStatusQR = function () {
        $.ajax({
            type: 'POST',
            data: QR_status_data,
            url: "/AJAX/SBPGetQRStatus.php",
            async: true,
            success: function (data) {
                let response = JSON.parse(data);
                if (response.state === 'WAIT')
                {
                    timeout = setTimeout(mainTimeoutQR, 3000);
                    if (response.qrStatus === 'CONFIRMED')
                    {
                        $('.download_out').css('display', 'block');
                        $('.SBP_QR').css({'display': 'none'});
                    }
                }
                else
                {
                    clearTimeout(timeout);
                    location.href = '/order';
                }
            }
        });
    };
}

if (!window.initialized_large)
{
    new (function () {
        const instanceForLarge = new (function () {
            this.isPartnerHost = function () {
                return btoa(location.hostname) !== "c2JvcmthLnJ1bg==";
            }
        });
        var cost = {};
        // var calendar = {};
        // var calendar_weekdays = {};
        var largeFormatFlag = true;
        var solderFlag = false;
        var solderCost = 0;
        let laminationFlag = false;
        let laminationCost = 0;
        var gluingCost = 0;
        var pruningCost = 0;
        var bannerRailCost = 0;
        var strenghtGluingCost = 0;
        var bannerRailFlag = false;
        var strenghtGluingFlag = false;
        var PruningFlag = false;
        let min_cost = 300;
        let real_min_cost = 300; // for partner hosts
        let num_solder = 0;

        let btnImagePng = null;
        if (instanceForLarge.isPartnerHost())
        {
            btnImagePng = new (function() {

                let instance = this;

                this.getDataForSave = function() {
                    let $contain = $('.product-image-upload'),
                        currentSrc = $contain.find('img.product-image-button').attr('src'),
                        defaultSrc = $contain.find('#use-default-image').attr('data-default-image');

                    return {
                        image: currentSrc,
                        useDefault: currentSrc == defaultSrc
                    };
                };


                this.useChangeListener = function(context) {

                    let $inputFile = $(context);

                    let file = context.files[0];
                    let format = file.type.split('/')[1].toLowerCase();
                    let accept_formats = ['png'];

                    if ( accept_formats.indexOf(format) === -1 ) {
                        $inputFile.val('');
                        alert('РР·РѕР±СЂР°Р¶РµРЅРёРµ РґРѕР»Р¶РЅРѕ Р±С‹С‚СЊ РІ С„РѕСЂРјР°С‚Рµ PNG');
                        return false;
                    }

                    if ( file.size &gt; 1024 * 1024 * 3 ) {
                        $inputFile.val('');
                        alert( 'Р&nbsp;Р°Р·РјРµСЂ РёР·РѕР±СЂР°Р¶РµРЅРёСЏ РЅРµ РґРѕР»Р¶РµРЅ РїСЂРµРІС‹С€Р°С‚СЊ 3 РњР±' );
                        return false;
                    }

                    let reader = new FileReader();
                    let $img = $inputFile.parents('.product-image-upload').find('img.product-image-button');

                    reader.addEventListener('load', function(event)
                    {
                        $img.attr('src', event.target.result);
                    });

                    reader.readAsDataURL(file);
                };
            })();
        }

        /**
         *  РЈСЃС‚Р°РЅР°РІР»РёРІР°РµРј Р·РЅР°С‡РµРЅРёСЏ РїРѕ СѓРјРѕР»С‡Р°РЅРёСЋ Р±РµР· РґРѕСЃС‚Р°РІРєРё
         */
        const settingDefaults = function () {
            dpd_ready = false;

            let $cPrintTerm = $('.cPrintTerm input:checked');

            const total = getAreaCost($cPrintTerm.attr('data-value'), cost['widthLimit'], cost['density']) + getPostWorkSum();
            let largeFormatCostOfDelivery = Number($('#largeFormatCostOfDelivery').text());
            $('.totalCost').html(Number(total) + largeFormatCostOfDelivery);
            $('.printCost').html(total);

            if (instanceForLarge.isPartnerHost())
            {
                const realTotal = getAreaRealCost($cPrintTerm.attr('data-real_value'), cost['widthLimit'], cost['density']) + getPostWorkSum();
                $('.RealtotalCost').html(Number(realTotal) + largeFormatCostOfDelivery);
                $('.RealprintCost').html(realTotal);
            }

            const date = $cPrintTerm.data('date');
            $('.dateReady').html(date);

            if (instanceForLarge.isPartnerHost())
            {
                // old variant
                $('.deliveryDate').html(date);
                $('.actualDateReady').val($cPrintTerm.data('preldate'));
                $('.leadTime').val($cPrintTerm.data('leadtime'));
            }
            else
            {
                let dateSplit = date.split('.');
                setDeliveryDate({d: dateSplit[0], m: dateSplit[1], y: dateSplit[2]});
                $('.actualDateReady').val($cPrintTerm.data('preldate'));
                $('.leadTime').val($cPrintTerm.data('leadtime'));
            }

            largeSetDefaultDelivery();
        };

        /**
         * РџРѕР»СѓС‡Р°РµРј СЃС‚РѕРёРјРѕСЃС‚СЊ РїРµС‡Р°С‚Рё СЃРѕРіР»Р°СЃРЅРѕ РІС‹Р±СЂР°РЅРЅС‹С… РєР»РёРµРЅС‚РѕРј СЂР°Р·РјРµСЂРѕРІ
         *
         * @param cost СЃС‚РѕРёРјРѕСЃС‚СЊ Р·Р° РєРІР°РґСЂР°С‚РЅС‹Р№ РјРµС‚СЂ
         * @param limit Р»РёРјРёС‚ РјР°С‚РµСЂРёР°Р»Р°
         * @param density РјР°СЃСЃР° РѕРґРЅРѕРіРѕ РєРІР°РґСЂР°С‚РЅРѕРіРѕ РјРµС‚СЂР° РјР°С‚РµСЂРёР°Р»Р°
         *
         * Р’РѕР·РјРѕР¶РЅРѕСЃС‚СЊ Р·Р°РјРµРЅРёС‚СЊ РІС…РѕРґРЅС‹Рµ РїР°СЂР°РјРµС‚СЂС‹ РЅР° РёР· Р·РЅР°С‡РµРЅРёСЏ РЅРµРїРѕСЃСЂРµРґСЃС‚РІРµРЅРЅРѕ РёР· DOM СЃС‚СЂСѓРєС‚СѓСЂС‹
         *
         * @return number СЂРµР·СѓР»СЊС‚Р°С‚ СЃС‚РѕРёРјРѕСЃС‚Рё
         */
        const getAreaCost = function (cost, limit, density) {

            const width = Number($('#largeFormatWidth').val()); // С€РёСЂРёРЅР° РІС‹Р±СЂР°РЅРЅР°СЏ РєР»РёРµРЅС‚РѕРј
            const height = Number($('#largeFormatHeight').val()); // РІС‹СЃРѕС‚Р° РІС‹Р±СЂР°РЅРЅР°СЏ РєР»РёРµРЅС‚РѕРј
            const count = Number($('#largeFormatCount').val()); // РєРѕР»-РІРѕ РїСЂРѕРґСѓРєС†РёРё

            let $cWrongSize = $('.cWrongSize');
            let $cBadPrice = $('.cBadPrice');

            if (!solderFlag &amp;&amp; width &gt; limit &amp;&amp; height &gt; limit)
            {
                $cWrongSize.css('display', 'inline-block');
                $cWrongSize.html(`РќРµСЃРєРѕР»СЊРєРѕ РїР°СЂР°РјРµС‚СЂРѕРІ СѓРєР°Р·Р°РЅС‹ Р±РѕР»СЊС€Рµ, С‡РµРј С‚РµРєСѓС‰РёР№ Р»РёРјРёС‚ ${limit} РјРј!`);
                largeFormatFlag = false;
            }
            else if (!solderFlag &amp;&amp; (width &lt; 1 || height &lt; 1 || count &lt; 1))
            {
                $cWrongSize.css('display', 'inline-block');
                $$cWrongSize.html('РћРґРёРЅ РёР»Рё РЅРµСЃРєРѕР»СЊРєРѕ РїР°СЂР°РјРµС‚СЂРѕРІ СѓРєР°Р·Р°РЅС‹ РЅРµРІРµСЂРЅРѕ!');
                largeFormatFlag = false;
            }
            else
            {
                $cWrongSize.hide().empty();
                largeFormatFlag = true;
            }

            const areaOfUnit = (width / 1000.0) * (height / 1000.0);
            const usersArea = (width / 1000.0) * (height / 1000.0); // limitArea

            // РЈСЃС‚Р°РЅР°РІР»РёРІР°РµРј РЅРёР¶РЅРёР№ Р»РёРјРёС‚ СЃС‚РѕРёРјРѕСЃС‚СЊ РїРѕ РјРёРЅРёРјР°Р»СЊРЅРѕР№ РґРѕСЃС‚СѓРїРЅРѕР№ РїР»РѕС‰Р°РґРё 0.13 Рј2

            // СЃС‚Р°СЂС‹Р№ РІР°СЂРёР°РЅС‚
            // const limitArea = usersArea &lt; 0.13 ? 0.13 : usersArea;

            // РЅРѕРІС‹Р№ РІР°СЂРёР°РЅС‚
            let total = Math.round(usersArea * cost * count);
            const minPriceLimit = min_cost;
            if (total &lt; minPriceLimit)
            {
                $cBadPrice.html(`РњРёРЅРёРјР°Р»СЊРЅР°СЏ СЃС‚РѕРёРјРѕСЃС‚СЊ РїРµС‡Р°С‚Рё: ${minPriceLimit} СЂСѓР±.`);
                $cBadPrice.css('display', 'inline-block');
                total = minPriceLimit;
            }
            else
            {
                $cBadPrice.hide();
            }

            //$('#sizeCost').html(total + ' СЂСѓР±. (' + (usersArea * count).toFixed(2) + 'Рј&lt;sup&gt;2&lt;/sup&gt;)');

            $('#sizeCost').html(`${total} СЂСѓР±.`);
            $('#areaOfUnit').html((areaOfUnit).toFixed(2) + 'Рј&lt;sup&gt;2&lt;/sup&gt;');
            $('#totalArea').html((usersArea * count).toFixed(2) + 'Рј&lt;sup&gt;2&lt;/sup&gt;');

            //Р”РѕР±Р°РІР»СЏРµРј РїРѕРґСЃС‡РµС‚ РјР°СЃСЃС‹ РїСЂРѕРґСѓРєС†РёРё
            var mass = ((density * usersArea * count + 500) / 1000).toFixed(2);
            $('.cDpdLen').text('');
            $('.cDpdWid').text('');
            $('.cDpdHgt').text('');
            $('.cDpdNum').text(1);
            $('.cDpdWgt').text(mass);
            $('.cDpdWgtAll').text(mass);

            return total;
        };

        // for partners
        const getAreaRealCost = function (cost, limit, density) {
            var width = $('#largeFormatWidth').val();
            var height = $('#largeFormatHeight').val();
            var count = $('#largeFormatCount').val();

            if (!solderFlag)
            {
                if (Number(width) &gt; Number(limit) &amp;&amp; Number(height) &gt; Number(limit))
                {
                    $('.cWrongSize').css('display', 'inline-block');
                    $('.cWrongSize').html('РќРµСЃРєРѕР»СЊРєРѕ РїР°СЂР°РјРµС‚СЂРѕРІ СѓРєР°Р·Р°РЅС‹ Р±РѕР»СЊС€Рµ, С‡РµРј С‚РµРєСѓС€РёР№ Р»РёРјРёС‚ ' + limit + ' РјРј!');
                    largeFormatFlag = false;
                }
                else if (Number(width) &lt; 1 || Number(height) &lt; 1 || Number(count) &lt; 1)
                {
                    $('.cWrongSize').css('display', 'inline-block');
                    $('.cWrongSize').html('РћРґРёРЅ РёР»Рё РЅРµСЃРєРѕР»СЊРєРѕ РїР°СЂР°РјРµС‚СЂРѕРІ СѓРєР°Р·Р°РЅС‹ РЅРµРІРµСЂРЅРѕ!');
                    largeFormatFlag = false;
                }
                else
                {
                    $('.cWrongSize').css('display', 'none');
                    $('.cWrongSize').html('');
                    largeFormatFlag = true;
                }
            }
            else
            {
                $('.cWrongSize').css('display', 'none');
                $('.cWrongSize').html('');
                largeFormatFlag = true;
            }

            var areaOfUnit = (width / 1000.0) * (height / 1000.0);
            var usersArea = (width / 1000.0) * (height / 1000.0);
            // РЈСЃС‚Р°РЅР°РІР»РёРІР°РµРј РЅРёР¶РЅРёР№ Р»РёРјРёС‚ СЃС‚РѕРёРјРѕСЃС‚СЊ РїРѕ РјРёРЅРёРјР°Р»СЊРЅРѕР№ РґРѕСЃС‚СѓРїРЅРѕР№ РїР»РѕС‰Р°РґРё 0.13 Рј2
            // СЃС‚Р°СЂС‹Р№ РІР°СЂРёР°РЅС‚
            //var limitArea = usersArea &lt; 0.13 ? 0.13 : usersArea;
            // РЅРѕРІС‹Р№ РІР°СЂРёР°РЅС‚
            var limitArea = usersArea;
            var total = Math.round(limitArea * cost * count);
            var minPriceLimit = real_min_cost;
            if (total &lt; minPriceLimit)
            {
                total = minPriceLimit;
            }


            //Р”РѕР±Р°РІР»СЏРµРј РїРѕРґСЃС‡РµС‚ РјР°СЃСЃС‹ РїСЂРѕРґСѓРєС†РёРё
            var mass = ((density * usersArea * count + 500) / 1000).toFixed(2);
            $('.cDpdLen').text('');
            $('.cDpdWid').text('');
            $('.cDpdHgt').text('');
            $('.cDpdNum').text(1);
            $('.cDpdWgt').text(mass);
            $('.cDpdWgtAll').text(mass);

            return total;
        }

        /**
         * РџРѕР»СѓС‡Р°РµРј СЃСѓРјРјСѓ СЃС‚РѕРёРјРѕСЃС‚РµР№ РїРѕСЃС‚ СЂР°Р±РѕС‚
         */
        const getPostWorkSum = function () {
            var width = $('#largeFormatWidth').val();
            var height = $('#largeFormatHeight').val();
            var count = $('#largeFormatCount').val();
            var sum = 0;
            // СЃС‚РѕРёРјРѕСЃС‚СЊ Р»СЋРІРµСЂСЃРѕРІ
            switch ($('#cEyeletType').val().toLowerCase())
            {
                case 'РїРѕ СѓРіР»Р°Рј':
                    sum += 4.0 * $('#largeFormatCount').val() * $('#eyeletCost').html();
                    $('#СЃEyeletTurn').val('РќРµС‚');
                    $('#cPruningType').attr('disabled', 'disabled');
                    $('#cPruningType').val(0);
                    break;
                case 'РїРѕ РїРµСЂРёРјРµС‚СЂСѓ':
                    sum += ((($('#largeFormatWidth').val() / 1000.0) + ($('#largeFormatHeight').val() / 1000.0)) * 2.0) / ($('#СЃEyeletStep').val() / 1000) * $('#largeFormatCount').val() * $('#eyeletCost').html();
                    $('#СЃEyeletTurn').val('РµСЃС‚СЊ');
                    $('#cPruningType').attr('disabled', 'disabled');
                    $('#cPruningType').val(0);
                    break;
                case 'РІРµСЂС…':
                    sum += ($('#largeFormatWidth').val() / 1000.0) / ($('#СЃEyeletStep').val() / 1000) * $('#largeFormatCount').val() * $('#eyeletCost').html();
                    $('#СЃEyeletTurn').val('РµСЃС‚СЊ');
                    $('#cPruningType').attr('disabled', 'disabled');
                    $('#cPruningType').val(0);
                    break;
                case 'РІРµСЂС… Рё РІРЅРёР·':
                case 'Р»РµРІРѕ Рё РїСЂР°РІРѕ':
                    sum += ($('#largeFormatWidth').val() / 1000.0 * 2.0) / ($('#СЃEyeletStep').val() / 1000) * $('#largeFormatCount').val() * $('#eyeletCost').html();
                    $('#СЃEyeletTurn').val('РµСЃС‚СЊ');
                    $('#cPruningType').attr('disabled', 'disabled');
                    $('#cPruningType').val(0);
                    break;
                case 'РїРѕ СѓРіР»Р°Рј Рё СЃРµСЂРµРґРёРЅРµ':
                    sum += 8.0 * $('#largeFormatCount').val() * $('#eyeletCost').html();
                    $('#СЃEyeletTurn').val('РќРµС‚');
                    $('#cPruningType').attr('disabled', 'disabled');
                    $('#cPruningType').val(0);
                    break;
                case 'РЅРµС‚':
                    $('#cPruningType').removeAttr('disabled');
                    break;
            }
            // Р’СЂРµРјРµРЅРЅС‹Р№ РІР°СЂРёР°РЅС‚
            $('.cTotalCostEyelet').html(Math.round(sum));
            // СЃС‚РѕРёРјРѕСЃС‚СЊ РєР°СЂРјР°РЅР° РїРѕРґ С‚СЂСѓР±Сѓ
            switch ($('#cPocketType').val().toLowerCase())
            {
                case 'С‚РѕР»СЊРєРѕ СЃРІРµСЂС…Сѓ':
                case 'С‚РѕР»СЊРєРѕ СЃРЅРёР·Сѓ':
                case 'С‚РѕР»СЊРєРѕ СЃРїСЂР°РІР°':
                case 'С‚РѕР»СЊРєРѕ СЃР»РµРІР°':
                    sum += $('#cPocketCost').html() * 1.0 * $('#largeFormatCount').val();
                    break;
                case 'СЃРІРµСЂС…Сѓ Рё СЃРЅРёР·Сѓ':
                case 'СЃРїСЂР°РІР° Рё СЃР»РµРІР°':
                    sum += $('#cPocketCost').html() * 2.0 * $('#largeFormatCount').val();
                    break;
                case 'РїРѕ РїРµСЂРёРјРµС‚СЂСѓ':
                    sum += $('#cPocketCost').html() * 4.0 * $('#largeFormatCount').val();
                    break;
            }
            // СЃС‚РѕРёРјРѕСЃС‚СЊ СЃРїР°Р№РєРё
            if (solderFlag)
            {
                if (cost.widthLimit &gt; cost.maxPrintHeight &amp;&amp; cost.maxPrintHeight &gt; 0)
                {
                    widthLimit = cost.maxPrintHeight;
                }
                else
                {
                    widthLimit = cost.widthLimit;
                }
                if ($('#cEyeletType').val().toLowerCase() != 'РЅРµС‚')
                {
                    widthLimit = widthLimit - 80;
                }
                else
                {
                    if (Number.parseInt(width) &gt; Number.parseInt(widthLimit))
                    {
                        widthLimit = widthLimit - 80;
                    }
                }
                num_solder = 0;
                if (Number.parseInt(width) &gt; Number.parseInt(widthLimit) &amp;&amp; Number.parseInt(height) &gt; Number.parseInt(widthLimit))
                {
                    num_solder = Math.ceil(width / widthLimit) - 1;
                    if (num_solder == 1)
                    {
                        $('.cFullParts').html('РѕРґРЅРѕР№ С‡Р°СЃС‚Рё');
                    }
                    else
                    {
                        $('.cFullParts').html('"' + num_solder + '" С‡Р°СЃС‚РµР№');
                    }
                    $('.cWidthFullParts').html(widthLimit);
                    $('.cWidthLastPart').html(width - (widthLimit * num_solder));
                    $('.cNumSolder').html(num_solder);
                    $('.cSolderLenght').html(height);
                }
                solder_sum = Math.round((height / 1000) * num_solder * solderCost * count);
                $('.cTotalCostSolder').html(solder_sum);
                if (solder_sum &gt; 0)
                {
                    $('.cSolder').css({'display': 'block'});
                }
                else
                {
                    $('.cSolder').css({'display': 'none'});
                }
                sum += solder_sum;
            }
            else
            {
                $('.cSolder').css({'display': 'none'});
            }
            if ($('.cGluing #cGluingType').val() != 0)
            {
                gluing_sum = Math.round(((width * 2 / 1000) + (height * 2 / 1000)) * gluingCost * count);
                $('.cTotalCostGluing').html(gluing_sum);
                sum += gluing_sum;
            }
            else
            {
                gluing_sum = 0;
                $('.cTotalCostGluing').html(gluing_sum);
                sum += gluing_sum;
            }
            if ($('.cStrenghtGluing #cStrenghtGluingType').val() != 0)
            {
                gluing_sum = Math.round(((width * 2 / 1000) + (height * 2 / 1000)) * strenghtGluingCost * count);
                $('.cTotalCostStrenghtGluing').html(gluing_sum);
                sum += gluing_sum;
            }
            else
            {
                gluing_sum = 0;
                $('.cTotalCostStrenghtGluing').html(gluing_sum);
                sum += gluing_sum;
            }
            if ($('.cPruning #cPruningType').val() != 0)
            {
                pruning_sum = Math.round(((width * 2 / 1000) + (height * 2 / 1000)) * pruningCost * count);
                $('.cTotalCostPruning').html(pruning_sum);
                sum += pruning_sum;
            }
            else
            {
                pruning_sum = 0;
                $('.cTotalCostPruning').html(pruning_sum);
                sum += pruning_sum;
            }
            if ($('.cBannerRail #cBannerRailType').val() != 0)
            {
                BannerRail_sum = Math.round((width * 2 / 1000) * bannerRailCost * count);
                $('.cTotalCostBannerRail').html(Math.round(BannerRail_sum));
                sum += BannerRail_sum;
            }
            else
            {
                BannerRail_sum = 0;
                $('.cTotalCostBannerRail').html(BannerRail_sum);
                sum += BannerRail_sum;
            }
            if ($('.cLamination #cLaminationType').val() != 0)
            {
                Lamination_sum = Math.round((width / 1000) * (height / 1000) * laminationCost * count);
                $('.cTotalCostLamination').html(Math.round(Lamination_sum));
                sum += Lamination_sum;
            }
            else
            {
                Lamination_sum = 0;
                $('.cTotalCostLamination').html(Lamination_sum);
                sum += Lamination_sum;
            }
            // РЎС‚РѕРёРјРѕСЃС‚СЊ РЅР°С‚СЏР¶РєРё
            var stretch_sum = 0;
            stretch_sum += Math.round(((width - ($('.cStretch input:checked').attr('turn') * 2)) * 2 / 1000 + (height - ($('.cStretch input:checked').attr('turn') * 2)) * 2 / 1000) * $('.cStretch input:checked').val() * count);
            sum += stretch_sum;
            // Р’СЂРµРјРµРЅРЅС‹Р№ РІР°СЂРёР°РЅС‚
            $('.cTotalCostStretch').html(Math.round(stretch_sum));
            return Math.round(sum);
        };

        /**
         * РЎРєСЂС‹РІР°РµРј РґРѕРїРѕР»РЅРёС‚РµР»СЊРЅСѓСЋ РёРЅС„РѕСЂРјР°С†РёСЋ
         */
        const hideLargeFormatInfo = function () {
            largeFormatFlag = true;

            $('.large-format-info').hide();
            $('.cWrongSize').hide().empty();
            $('.large-format-title').empty(); // Р—Р°РіРѕР»РѕРІРѕРє С‚Р°Р±Р»РёС†С‹
            $('.large-format-table table').empty(); // РўРµР»Рѕ С‚Р°Р±Р»РёС†С‹

            if (instanceForLarge.isPartnerHost())
            {
                $('.title-container').empty(); // Р—Р°РіРѕР»РѕРІРѕРє С‚Р°Р±Р»РёС†С‹ (РґРѕРї.)
                $('.product_btn_save').empty();
            }
        };

        const sizeForStretch = function () {
            const turn = $('.cStretch input:checked').attr('turn');
            const width = $('#largeFormatWidth').val() - (turn * 2);
            const height = $('#largeFormatHeight').val() - (turn * 2);
            $('.cStretchWidth').html(width &gt; 0 ? width : 0);
            $('.cStretchHeight').html(height &gt; 0 ? height : 0);
        };

        const citySelectionLarge = function (city) {

            dpd_ready = false;
            dpd_flag = true;
            dpd_country = '';
            dpd_city = '';
            dpd_region = '';
            dpd_region2 = '';
            dpd_adress = '';

            $('.large_delivery .cDPD_terminal_selection .dpd_terminal_block').css('width', '1050px');
            $('.large_delivery .cDPD_terminal_selection .dpd_terminal_block div').css('width', '1050px');

            //РћС‚РєСЂС‹РІР°РµРј РІС‹Р±РёСЂР°Р»РєСѓ РїСѓРЅРєС‚С‹ РёР»Рё РєР°СЂС‚Р°
            $('.large_delivery .cDPD_terminal_selection').css('display', 'block');

            //РћС‚РєСЂС‹РІР°РµРј РёРЅС„Сѓ Рѕ РїРѕР»СѓС‡Р°С‚РµР»Рµ
            $('.large_delivery .cInfo_addressee').css('display', 'block'); // fix

            //РћС‚С‡РёС‰Р°РµРј СЃРїРёСЃР°РѕРє С‚РµСЂРјРёРЅР°Р»РѕРІ
            $('.large_delivery .cTerminal_list').html('');

            //Р—Р°РїСѓСЃРєР°РµРј РєСЂСѓС‚РёР»РєСѓ
            $('.large_delivery .city_update').css('display', 'block');

            //РљРёРґР°РµРј Р·Р°РїСЂРѕСЃ РЅР° РїРѕР»СѓС‡РµРЅРёРµ С‚РµСЂРјРёРЅР°Р»РѕРІ

            const coef = Math.cbrt(Number($('.cDpdNum').html()) + Number($('.cDpdNumDop').html()));
            const city_t = $('.large_delivery .dpd_city').val().split(', ');

            if (instanceForLarge.isPartnerHost())
            {
                $.ajax({
                    type: 'POST',
                    data: {otype: "large"},
                    url: "/CMS/AJAX/get_server_time_by_region.php",
                    async: false,
                    success: function (data) {
                        let result = JSON.parse(data);
                        own_region = result.own
                    }
                });
            }
            else
            {
                ph_id = $('.cPrintTerm input:checked').data('ph_id');
            }

            $.ajax({
                type: 'POST',
                data: {
                    own_region: own_region,
                    mark: 1,
                    otype: otype,
                    product_id: p_id,
                    country: 'Р&nbsp;РѕСЃСЃРёСЏ',
                    city: city_t[0],
                    region: city_t[1],
                    region2: city_t[1],
                    length: Number($('.cDpdLen').html()) * coef,
                    width: Number($('.cDpdWid').html()) * coef,
                    height: Number($('.cDpdHgt').html()) * coef,
                    weight: Number(Number($('.cDpdWgtAll').html()) + Number($('.cDpdWgtAllDop').html())).toFixed(2),
                    product: 'РїРµС‡Р°С‚РЅР°СЏ РїСЂРѕРґСѓРєС†РёСЏ',
                    cost: $('.printCost').html()
                },
                url: "/AJAX/get_dpd_price_terminal.php",
                async: true,
                success: function (data) {
                    try
                    {
                        const result = JSON.parse(data);
                        if (!result['DPD'])
                        {
                            $('.large_delivery .ldpd_del_period').html('0 Рґ.');
                            $('.large_delivery .ldpd_del_cost').html('0 СЂСѓР±.');
                        }
                        else
                        {
                            $('.large_delivery .ldpd_del_period').html(result['DPD'].DAYS + ' Рґ.');
                            $('.large_delivery .ldpd_del_cost').html(Math.ceil(Number(result['USER'].COST)) + ' СЂСѓР±.');
                        }
                    } catch (e)
                    {
                        $('.large_delivery .ldpd_del_period').html('0 Рґ.');
                        $('.large_delivery .ldpd_del_cost').html('0 СЂСѓР±.');
                    }
                }
            });

            let shipment_weight = $('.cLargeFormatDelivery .cDpdWgtAll').text();

            $.ajax({
                type: 'POST',
                data: {
                    'mark': 1,
                    'city': city,
                    'weight': shipment_weight
                },
                url: "/AJAX/get_dpd_terminals_new.php",
                async: true,
                success: function (data) {
                    let resp = JSON.parse(data);
                    let terminals = resp.term;
                    var str = '';
                    var x = "", y = "", k = 0;
                    for (var i = 0; i &lt; terminals.length; i++)
                    {
                        if (terminals[i]['ADDRESS_FULL'] !== "404105, Р’РѕР»РіРѕРіСЂР°РґСЃРєР°СЏ, Р’РѕР»Р¶СЃРєРёР№, РњРёСЂР° СѓР», Рґ. 74, РєРѕСЂРї. Рђ")
                        {
                            str += "&lt;tr id='td-is-" + i + "' location_id='" + terminals[i]['LOCATION_ID'] + "' data-address='" + terminals[i]['ADDRESS_SHORT'] + "'&gt;&lt;td class='del1' &gt;" + terminals[i]['PARCEL_SHOP_TYPE'] + "&lt;/td&gt;&lt;td class='del2'&gt;" + terminals[i]['ADDRESS_FULL'] + "&lt;/td&gt;&lt;/tr&gt;";
                        }
                    }
                    if (!str.length)
                    {
                        str = '&lt;tr&gt;&lt;td class="td-id-error"&gt;РЈС‡РёС‚С‹РІР°СЏ РЅРµСЃС‚Р°РЅРґР°СЂС‚РЅС‹Рµ РіР°Р±Р°СЂРёС‚С‹ С€РёСЂРѕРєРѕС„РѕСЂРјР°С‚РЅРѕР№ РїСЂРѕРґСѓРєС†РёРё РґРѕСЃС‚СѓРїРЅР° С‚РѕР»СЊРєРѕ Р°РґСЂРµСЃРЅР°СЏ РґРѕСЃС‚Р°РІРєР° РїРѕ Р»СЋР±РѕРјСѓ РіРѕСЂРѕРґСѓ  Р&nbsp;РѕСЃСЃРёР№СЃРєРѕР№ Р¤РµРґРµСЂР°С†РёРё&lt;/td&gt;&lt;/tr&gt;';
                        $('.large_delivery .del_addk').html('');
                        $('.large_delivery .del_addr').html('');
                    }
                    $(".large_delivery .city_update").css('display', 'none');
                    $('.large_delivery .cTerminal_list').html(str);
                }
            });
        };

        const largeSetDefaultDelivery = function () {
            const pickUp = 0;
            const targetedRegion = document.getElementsByClassName('radioLargeTargetedRostov').length;

            if (pickUp)
            {
                $('.radioPickUp').trigger('click');
            }
            else if (targetedRegion)
            {
                $('.radioLargeTargetedRostov').trigger('click');
                if (instanceForLarge.isPartnerHost())
                {
                    // old variant
                    $('.deliveryDate').text([newDate['d'], newDate['m'], newDate['y']].join('.'));
                }
                else
                {
                    setDeliveryDate(redyTimeDelivery(1));
                }
            }
            else
            {
                $('.radioPickUpDpdLarge').trigger('click');
            }
        };

        // universal large
        new (function () {

            let instance = this;

            instance.orderData = {};

            this.showLoader = function () {
                $('.download_out').css('display', 'block');
            };

            this.hideLoader = function () {
                $('.download_out').css('display', 'none');
            };

            this.showAlertModal = function (html) {
                let $alert = $('#alertModal');
                $alert.find('.modal-body p').html(html);
                $alert.modal('show');
            }

            this.disableSaveBtn = function () {
                let $btn = $('#largeFormatSave');
                $btn.prop('disabled', true);
                $btn.css('opacity', '0.4');
            }

            this.enableSaveBtn = function () {
                let $btn = $('#largeFormatSave');
                $btn.prop('disabled', false);
                $btn.css('opacity', '1');
            }

            this.decimalValue = function (value) {
                return +(parseInt(value) + '').replace(/[^\d]/gi, '');
            };

            this.orderError = function (message) {
                instance.showAlertModal(message);
                instance.hideLoader();
                instance.enableSaveBtn();
            };

            this.verificationOrderData = function () {
                if (instance.decimalValue(instance.orderData.totalCost) &lt;= 0)
                {
                    instance.orderError('РћС€РёР±РєР° СЃС‚РѕРёРјРѕСЃС‚Рё Р·Р°РєР°Р·Р°.');
                    return false;
                }

                if (instance.decimalValue(instance.orderData.printCost) &lt;= 0)
                {
                    instance.orderError('РћС€РёР±РєР° СЃС‚РѕРёРјРѕСЃС‚Рё РїРµС‡Р°С‚Рё.');
                    return false;
                }

                return true;
            };

            this.orderCreate = function () {

                if (!instance.verificationOrderData()) return;

                instance.showLoader();
                $.ajax({
                    type: 'POST',
                    data: instance.orderData,
                    url: "/AJAX/makeOrderRostov.php",
                    async: true,
                    dataType: 'json',
                    success: function (response) {

                        instance.hideLoader();
                        myDropzone['largeFormatTemplate'].removeAllFiles();

                        switch (response.type)
                        {
                            case 'done':
                                location.href = '/payment?order_id=' + response.info.id;
                                break;
                            case 'time':
                                instance.orderError("Р’Рѕ РІСЂРµРјСЏ СЃРѕР·РґР°РЅРёСЏ Р·Р°РєР°Р·Р° РІРѕР·РЅРёРєР»Рё РЅРµРёСЃРїСЂР°РІРЅРѕСЃС‚Рё. РџСЂРёРЅРѕСЃРёРј СЃРІРѕРё РёР·РІРёРЅРµРЅРёСЏ.");
                                break;
                            case 'guest':
                                instance.orderError("Р”Р»СЏ РѕС„РѕСЂРјР»РµРЅРёСЏ Р·Р°РєР°Р·Р° РЅРµРѕР±С…РѕРґРёРјРѕ РїСЂРѕР№С‚Рё СЂРµРіРёСЃС‚СЂР°С†РёСЋ Р»РёР±Рѕ РІРѕР№С‚Рё РІ Р»РёС‡РЅС‹Р№ РєР°Р±РёРЅРµС‚!");
                                break;

                            default:
                                location.href = '/order';
                        }
                    },
                    error: function () {
                        instance.orderError("Р’Рѕ РІСЂРµРјСЏ СЃРѕР·РґР°РЅРёСЏ Р·Р°РєР°Р·Р° РІРѕР·РЅРёРєР»Рё РЅРµРёСЃРїСЂР°РІРЅРѕСЃС‚Рё. РџСЂРёРЅРѕСЃРёРј СЃРІРѕРё РёР·РІРёРЅРµРЅРёСЏ.");
                    }
                });
            };

            this.handler__orderCreateBtn = function () {

                instance.disableSaveBtn();

                GetOwn();

                cost['noBonus'] = true;
                if ($('.cPrintTerm input:checked').attr('data-nobonus') === 'true')
                {
                    cost['noBonus'] = true;
                }

                if (myDropzone['largeFormatTemplate'].getUploadingFiles().length &gt; 0)
                {
                    instance.orderError("РќРµРѕР±С…РѕРґРёРјРѕ РґРѕР¶РґР°С‚СЊСЃСЏ РїРѕР»РЅРѕР№ Р·Р°РіСЂСѓР·РєРё С„Р°Р№Р»РѕРІ");
                }
                else
                {
                    if (largeFormatFlag)
                    {
                        //Р”Р°С‚Р° РіРѕС‚РѕРІРЅРѕСЃС‚Рё
                        var date = $('#largeFormatReady').html().split('.');
                        var readyTime = date[2] + "-" + date[1] + "-" + date[0];

                        if (instanceForLarge.isPartnerHost())
                        {
                            // old variant
                            date = $('#date_dpd_ready_lf').html().split('.');
                        }
                        else
                        {
                            let dateAssoc = getDeliveryDateFirst('assoc');
                            date = [dateAssoc['y'], dateAssoc['m'], dateAssoc['d']];
                        }

                        var delTime = date[2] + "-" + date[1] + "-" + date[0];

                        var postPrint = '';

                        //РЎРѕР±СЂР°С‚СЊ РїРѕСЃС‚ СЂР°Р±РѕС‚С‹
                        var eyeletTurn = '';
                        if ($('#СЃEyeletTurn').val().toLowerCase() !== "РЅРµС‚")
                        {
                            eyeletTurn = "СЃ РїРѕРґРІРѕСЂРѕС‚РѕРј";
                        }

                        switch ($('#cEyeletType').val().toLowerCase())
                        {
                            case 'РїРѕ СѓРіР»Р°Рј':
                                postPrint += 'Р›СЋРІРµСЂСЃС‹ (РїРѕ СѓРіР»Р°Рј); ';
                                break;
                            case 'РїРѕ РїРµСЂРёРјРµС‚СЂСѓ':
                                postPrint += 'Р›СЋРІРµСЂСЃС‹ (РїРѕ РїРµСЂРёРјРµС‚СЂСѓ, С‡РµСЂРµР· ' + $('#СЃEyeletStep').val() + ' РјРј, ' + eyeletTurn + '); ';
                                break;
                            case 'РІРµСЂС…':
                                postPrint += 'Р›СЋРІРµСЂСЃС‹ (РїРѕ РІРµСЂС…Сѓ, С‡РµСЂРµР· ' + $('#СЃEyeletStep').val() + ' РјРј, ' + eyeletTurn + '); ';
                                break;
                            case 'РІРµСЂС… Рё РІРЅРёР·':
                                postPrint += 'Р›СЋРІРµСЂСЃС‹ (РїРѕ РІРµСЂС…Сѓ Рё РЅРёР·Сѓ, С‡РµСЂРµР· ' + $('#СЃEyeletStep').val() + ' РјРј, ' + eyeletTurn + '); ';
                                break;
                            case 'Р»РµРІРѕ Рё РїСЂР°РІРѕ':
                                postPrint += 'Р›СЋРІРµСЂСЃС‹ (СЃР»РµРІР° Рё СЃРїСЂР°РІР°, С‡РµСЂРµР· ' + $('#СЃEyeletStep').val() + ' РјРј, ' + eyeletTurn + '); ';
                                break;
                            case 'РїРѕ СѓРіР»Р°Рј Рё СЃРµСЂРµРґРёРЅРµ':
                                postPrint += 'Р›СЋРІРµСЂСЃС‹ (РїРѕ СѓРіР»Р°Рј Рё СЃРµСЂРµРґРёРЅРµ); ';
                                break;
                        }

                        // РџСЂРѕР±Р° СЃРѕР±РёСЂР°РµРј РЅР°С‚СЏР¶РєСѓ
                        if ($('.cStretch').is(':visible'))
                        {
                            let $cStretch = $('.cStretch input:checked');
                            postPrint += $cStretch.attr('data-name') + '; ';
                            cost['name'] = $cStretch.attr('data-productName');
                        }

                        // РЎРѕР±РёСЂР°РµРј РїСЂРѕРєР»РµР№РєСѓ
                        if ($('.cGluing #cGluingType').val() != 0)
                        {
                            postPrint += 'РџСЂРѕРєР»РµР№РєР° РєСЂР°РµРІ; ';
                        }
                        // РЎРѕР±РёСЂР°РµРј РїСЂРѕРєР»РµР№РєСѓ СЃ СѓСЃРёР»РµРЅРёРµРј РІРµСЂРµРІРєРѕР№
                        if ($('.cStrenghtGluing #cStrenghtGluingType').val() != 0)
                        {
                            postPrint += 'РџСЂРѕРєР»РµР№РєР° РєСЂР°РµРІ СЃ СѓСЃРёР»РµРЅРёРµРј РІРµСЂРµРІРєРѕР№; ';
                        }
                        // РЎРѕР±РёСЂР°РµРј РѕР±СЂРµР·РєР°
                        if ($('.cPruning #cPruningType').val() != 0)
                        {
                            postPrint += $('.cPruning #cPruningType option:selected').text() + '; ';
                        }
                        // РЎРѕР±РёСЂР°РµРј Р‘Р°РЅРЅРµСЂ-СЂСЌР№Р»
                        if ($('.cBannerRail #cBannerRailType').val() != 0)
                        {
                            postPrint += ' Р‘Р°РЅРЅРµСЂ-СЂСЌР№Р»; ';
                        }
                        // РЎРѕР±РёСЂР°РµРј Р›Р°РјРёРЅР°С†РёСЏ
                        if ($('.cLamination #cLaminationType').val() != 0)
                        {
                            postPrint += 'Р›Р°РјРёРЅР°С†РёСЏ; ';
                        }

                        if (num_solder != 0)
                        {
                            postPrint += ' РЎРєР»РµР№РєР°: ' + num_solder + ' С€С‚.; ';
                        }

                        /**
                         *  РЎРѕР±РёСЂР°РµРј РґР°РЅРЅС‹Рµ РїРѕ РґРѕСЃС‚Р°РІРєРµ РќРђР§РђР›Рћ
                         */
                            // Р·Р°РґР°С‘Рј Р·РЅР°С‡РµРЅРёСЏ РґРѕСЃС‚Р°РІРєРё РїРѕ СѓРјРѕР»С‡Р°РЅРёСЋ "РЎР°РјРѕРІС‹РІРѕР·"
                        var dpd = 0;
                        var deliveryText = 'РЎР°РјРѕРІС‹РІРѕР· СЃРѕ СЃРєР»Р°РґР° РІ Рі. Р&nbsp;РѕСЃС‚РѕРІРµ-РЅР°-Р”РѕРЅСѓ (СѓР». РЎРµСЂР°С„РёРјРѕРІРёС‡Р°, Рґ.45)';
                        // РќРµ РѕС‡РµРЅСЊ СЂР°Р·РѕР±СЂР°Р»СЃСЏ РґР»СЏ С‡РµРіРѕ РЅСѓР¶РµРЅ СЌС‚РѕС‚ РїР°СЂР°РјРµС‚СЂ РІ Р·Р°РєР°Р·Рµ
                        var del_us = '';
                        // РџРµСЂРµРјРµРЅРЅР°СЏ РґР»СЏ РѕР±РѕР·РЅР°С‡РµРЅРёСЏ РёСЃРїРѕР»СЊР·РѕРІР°РЅРёСЏ DPD С‚РµСЂРјРёРЅР°Р»Р°
                        var terminalDpd = 0;

                        var sdek = 0;
                        var ems = 0;

                        var dpd_FIO = $('.cLargeFormatDelivery .dpdTerminalBlock .del_fio').val();
                        var dpd_name = getDeliveryName('.cLargeFormatDelivery .dpdTerminalBlock .del_user', dpd_FIO);
                        var dpd_phone = $('.cLargeFormatDelivery .dpdTerminalBlock .del_phone').val();

                        var dpd_courier = $('.cLargeFormatDelivery .dpdTerminalBlock .del_cour').val();

                        dpd_courier = $('.cLargeFormatDelivery .targeted_delivery_rostov .del_other').val();

                        switch ($('.tab input[name=deliveryLargeFormat]:checked').val())
                        {
                            case 'pickUp':
                            {
                                if (!instanceForLarge.isPartnerHost())
                                {
                                    instance.orderError("Р’РЅРёРјР°РЅРёРµ! Р’ СЃРІСЏР·Рё СЃРѕ СЃР»РѕР¶РёРІС€РµР№СЃСЏ СЃРёС‚СѓР°С†РёРµР№, СЃР°РјРѕРІС‹РІРѕР· РІ Р&nbsp;РѕСЃС‚РѕРІРµ-РЅР°-Р”РѕРЅСѓ РІСЂРµРјРµРЅРЅРѕ РЅРµ РґРѕСЃС‚СѓРїРµРЅ.");
                                }
                                break;
                            }
                            case 'targetedRostov':
                            {
                                if ($('#large_rostov_to_city').val() !== 'Р&nbsp;РѕСЃС‚РѕРІ-РЅР°-Р”РѕРЅСѓ')
                                {
                                    instance.orderError("Р”Р°РЅРЅС‹Р№ С‚РёРї РґРѕСЃС‚Р°РІРєРё РґРѕСЃС‚СѓРїРµРЅ С‚РѕР»СЊРєРѕ РґР»СЏ Рі. Р&nbsp;РѕСЃС‚РѕРІ-РЅР°-Р”РѕРЅСѓ");
                                    return;
                                }


                                let $cLargeFormatDeliveryHd = $('.cLargeFormatDelivery .delivery_block .del_addr_hd');

                                if ($cLargeFormatDeliveryHd.val() == '')
                                {
                                    $cLargeFormatDeliveryHd.css('border-color', 'red');

                                    instance.orderError("РќРµ РІСЃРµ РїРѕР»СЏ Р·Р°РїРѕР»РЅРµРЅС‹");
                                    return;
                                }

                                let $cLargeFormatDelivery = $('.cLargeFormatDelivery .delivery_block .del_addr');
                                let $cLargeFormatDeliveryOther = $('.cLargeFormatDelivery .delivery_block .del_other');

                                deliveryText = 'РђРґСЂРµСЃРЅР°СЏ РґРѕСЃС‚Р°РІРєР° РїРѕ Рі. Р&nbsp;РѕСЃС‚РѕРІРµ-РЅР°-Р”РѕРЅСѓ; РђРґСЂРµСЃ: ' +
                                    $cLargeFormatDelivery.val() +
                                    ', ' +
                                    $cLargeFormatDeliveryHd.val() +
                                    '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                    $('.cLargeFormatDelivery .delivery_block .del_user').val() +
                                    '; РўРµР»РµС„РѕРЅ: ' +
                                    $('.cLargeFormatDelivery .delivery_block .del_phone').val() +
                                    '; Р”РѕРїРѕР»РЅРёС‚РµР»СЊРЅРѕ: ' +
                                    $cLargeFormatDeliveryOther.val();
                                del_us = $cLargeFormatDelivery.val() + ', ' + $cLargeFormatDeliveryHd.val();
                                sdek = 1;
                                dpd_courier = $cLargeFormatDeliveryOther.val();
                                dpd_adress = del_us;
                                break;
                            }
                            case 'targetedRegion':
                            {
                                let $targetRegion = $(".cLargeFormatDelivery .radioTargetedRegion");
                                if ($('#large_kazan_to_city').val() !== $targetRegion.attr("data-city"))
                                {
                                    instance.orderError("Р”Р°РЅРЅС‹Р№ С‚РёРї РґРѕСЃС‚Р°РІРєРё РґРѕСЃС‚СѓРїРµРЅ С‚РѕР»СЊРєРѕ РґР»СЏ Рі. " + $targetRegion.attr("data-city"));
                                    return;
                                }

                                let $recipient_addr_hd = $('.cLargeFormatDelivery  .kazan_delivery .del_addr_hd');
                                if ($recipient_addr_hd.val() == '')
                                {
                                    $recipient_addr_hd.css('border-color', 'red');
                                    instance.orderError("РќРµ РІСЃРµ РїРѕР»СЏ Р·Р°РїРѕР»РЅРµРЅС‹");
                                    return;
                                }

                                deliveryText = 'РђРґСЂРµСЃРЅР°СЏ РґРѕСЃС‚Р°РІРєР° РїРѕ Рі. ' +
                                    $targetRegion.attr("data-city") +
                                    '; РђРґСЂРµСЃ: ' +
                                    $('.cLargeFormatDelivery .kazan_delivery .del_addr').val() +
                                    ', ' +
                                    $('.cLargeFormatDelivery .kazan_delivery .del_addr_hd').val() +
                                    '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                    $('.cLargeFormatDelivery .kazan_delivery .del_user').val() +
                                    '; РўРµР»РµС„РѕРЅ: ' +
                                    $('.cLargeFormatDelivery .kazan_delivery .del_phone').val() +
                                    '; Р”РѕРїРѕР»РЅРёС‚РµР»СЊРЅРѕ: ' +
                                    $('.cLargeFormatDelivery .kazan_delivery .del_other').val();
                                del_us = $('.cLargeFormatDelivery  .kazan_delivery .del_addr').val() + ', ' + $recipient_addr_hd.val();

                                // РґРѕР±Р°РІР»СЏРµРј РёРЅС„Сѓ РґР»СЏ РїСЂРµРІСЂР°С‰РµРЅРёСЏ РђРґСЂРµСЃРЅРѕР№ РґРѕСЃС‚Р°РІРєРё РІ DPD
                                dpd_country = 'Р&nbsp;РѕСЃСЃРёСЏ';
                                dpd_region = $targetRegion.attr("data-region");
                                dpd_city = $targetRegion.attr("data-city");
                                dpd_adress = del_us;
                                dpd = 1;
                                service_code = 'PCL';
                                terminalDpd = 0;

                                dpd_FIO = $('.cLargeFormatDelivery  .kazan_delivery .del_fio').val();
                                dpd_name = getDeliveryName('.cLargeFormatDelivery  .kazan_delivery .del_user', dpd_FIO);
                                dpd_phone = $('.cLargeFormatDelivery  .kazan_delivery .del_phone').val();
                                dpd_courier = $('.cLargeFormatDelivery  .kazan_delivery .del_other').val();
                                break;
                            }

                            case 'pickUpDpd':
                            {
                                if (!dpd_ready)
                                {
                                    instance.orderError('РќРµРѕР±С…РѕРґРёРјРѕ СЂР°СЃСЃС‡РёС‚Р°С‚СЊ СЃС‚РѕРёРјРѕСЃС‚СЊ Рё СЃСЂРѕРє РґРѕСЃС‚Р°РІРєРё. Р’С‹Р±РµСЂРёС‚Рµ РїСѓРЅРєС‚ "Р&nbsp;Р°СЃСЃС‡РёС‚Р°С‚СЊ СЃС‚РѕРёРјРѕСЃС‚СЊ"');
                                    return false;
                                }
                                dpd = 1;
                                terminalDpd = 1;
                                dpd_adress = dpd_terminal;
                                const deliveryFIO = $('.cLargeFormatDelivery .dpdTerminalBlock .del_fio').val();
                                deliveryText = 'DPD Р”РѕСЃС‚Р°РІРєР° РІ С‚РµСЂРјРёРЅР°Р» РђРґСЂРµСЃ: ' +
                                    dpd_country +
                                    "," +
                                    dpd_region +
                                    ',' +
                                    dpd_city +
                                    ',' +
                                    dpd_adress +
                                    '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                    deliveryFIO +
                                    '; РќР°РёРјРµРЅРѕРІР°РЅРёРµ: ' +
                                    getDeliveryName('.cLargeFormatDelivery .dpdTerminalBlock .del_user', deliveryFIO) +
                                    '; РўРµР»РµС„РѕРЅ: ' +
                                    $('.cLargeFormatDelivery .dpdTerminalBlock .del_phone').val();
                                del_us = $('.cLargeFormatDelivery .dpdTerminalBlock .del_addr').val();
                                break;
                            }


                            case 'targetedDpd':
                            {
                                if (!dpd_ready)
                                {
                                    instance.orderError("РќРµРѕР±С…РѕРґРёРјРѕ СЂР°СЃСЃС‡РёС‚Р°С‚СЊ СЃС‚РѕРёРјРѕСЃС‚СЊ Рё СЃСЂРѕРє РґРѕСЃС‚Р°РІРєРё. Р’С‹Р±РµСЂРёС‚Рµ РїСѓРЅРєС‚ \"Р&nbsp;Р°СЃСЃС‡РёС‚Р°С‚СЊ СЃС‚РѕРёРјРѕСЃС‚СЊ\"");
                                    return false;
                                }

                                let $recipient_address_hd = $('.cLargeFormatDelivery .dpdTargetedBlock .del_addr_hd');
                                if (!$recipient_address_hd.val())
                                {
                                    $recipient_address_hd.css('border-color', 'red');
                                    instance.orderError("РќРµ РІСЃРµ РїРѕР»СЏ Р·Р°РїРѕР»РЅРµРЅС‹");
                                    return;
                                }

                                dpd = 1;
                                //del_us = $('.cLargeFormatDelivery .dpdTargetedBlock .del_addr').val();
                                del_us = $('.cLargeFormatDelivery .dpdTargetedBlock .del_addr').val() + ', ' + $recipient_address_hd.val();
                                dpd_adress = del_us;
                                let $targetedDpd_recipient_phone = $('.cLargeFormatDelivery .dpdTargetedBlock .del_phone');
                                let $targetedDpd_recipient_cour = $('.cLargeFormatDelivery .dpdTargetedBlock .del_cour');

                                const deliveryFIO = $('.cLargeFormatDelivery .dpdTargetedBlock .del_fio').val();
                                const deliveryName = getDeliveryName('.cLargeFormatDelivery .dpdTargetedBlock .del_user', deliveryFIO);

                                deliveryText = 'DPD РђРґСЂРµСЃРЅР°СЏ РґРѕСЃС‚Р°РІРєР° РђРґСЂРµСЃ: ' +
                                    dpd_country +
                                    "," +
                                    dpd_region +
                                    ',' +
                                    dpd_city +
                                    ',' +
                                    dpd_adress +
                                    '; РџРѕР»СѓС‡Р°С‚РµР»СЊ: ' +
                                    deliveryFIO +
                                    '; РќР°РёРјРµРЅРѕРІР°РЅРёРµ: ' +
                                    deliveryName +
                                    '; РўРµР»РµС„РѕРЅ: ' +
                                    $targetedDpd_recipient_phone.val() +
                                    '; Р”РѕРїРѕР»РЅРёС‚РµР»СЊРЅРѕ: ' +
                                    $targetedDpd_recipient_cour.val();

                                dpd_FIO = deliveryFIO;
                                dpd_name = deliveryName;
                                dpd_phone = $targetedDpd_recipient_phone.val();
                                dpd_courier = $targetedDpd_recipient_cour.val();
                                break;
                            }

                            default :
                                instance.orderError("РџРѕР¶Р°Р»СѓР№СЃС‚Р°, РІС‹Р±РµСЂРёС‚Рµ СЃРїРѕСЃРѕР± РґРѕСЃС‚Р°РІРєРё");
                                return;
                        }
                        /**
                         *  РЎРѕР±РёСЂР°РµРј РґР°РЅРЅС‹Рµ РїРѕ РґРѕСЃС‚Р°РІРєРµ РљРћРќР•Р¦
                         */


                        let _comment = $('.cComment textarea').val();


                        if (_comment.match(/http/gi) === null &amp;&amp; myDropzone['largeFormatTemplate'].files.length === 0)
                        {
                            instance.orderError("Р—Р°РіСЂСѓР·РёС‚Рµ РјР°РєРµС‚ РёР»Рё СѓРєР°Р¶РёС‚Рµ РІ РєРѕРјРјРµРЅС‚Р°СЂРёРё СЃСЃС‹Р»РєСѓ РЅР° С„Р°Р№Р»!");
                        }
                        else
                        {
                            if (((Number($('#largeFormatPrintCost').text()) - getPostWorkSum()) /*  *0.9 */) &lt;= min_cost)
                            {
                                cost['noBonus'] = true;
                            }


                            if (instanceForLarge.isPartnerHost())
                            {
                                bonus.modalPay(() =&gt; {

                                    $('.download_out').css('display', 'block');
                                    $.ajax({
                                        type: 'POST',
                                        data: {
                                            'ph_id': '0',
                                            'own_region': own_region,
                                            'name': $('.cLFOrderDetails .title_order input').val(),
                                            'product': cost['name'],
                                            'size': $('#largeFormatWidth').val() + ' x ' + $('#largeFormatHeight').val() + ' РјРј',
                                            'material': cost['text'],
                                            'plot': '',
                                            'print': $('#largeFormatCount').val() + ' С€С‚.',
                                            'side': 'РћРґРЅРѕСЃС‚РѕСЂРѕРЅРЅСЏСЏ 4+0',
                                            'postPrint': postPrint,
                                            'readyDate': readyTime,
                                            'leadTime': $('#largeFormatLeadTime').val(),
                                            'actualDate': $('#largeFormatActualDate').val(),
                                            'printCost': $('#largeFormatPrintCost').text(),
                                            'postPrintCost': getPostWorkSum(),
                                            'deliverCost': $('#largeFormatCostOfDelivery').text(),
                                            'actualDeliverCost': $('#largeFormatActualDelivery').val(),
                                            'totalCost': Math.ceil( $('#largeFormatRealTotal').text() ),
                                            'userTotalCost': Math.ceil( $('#largeFormatTotal').text() ),
                                            'delivery': deliveryText,
                                            'del_user': del_us,
                                            'mass': '',
                                            'comment': _comment,
                                            'user_link': '',
                                            'kabinet': 'offset',
                                            'pay': $('.cLFOrderDetails .pay-block input:checked').val(),
                                            'print_name': 'РЁРёСЂРѕРєРѕС„РѕСЂРјР°С‚РЅР°СЏ РїРµС‡Р°С‚СЊ',
                                            'dpd_country': dpd_country,
                                            'dpd_region': dpd_region.replace(/вЂ”/g, "-"),
                                            'dpd_city': dpd_city,
                                            'dpd_adress': dpd_adress,
                                            'dpd_is_terminal': terminalDpd,
                                            'dpd_FIO': dpd_FIO,
                                            //'dpd_name': dpd_FIO,
                                            'dpd_name': dpd_name,
                                            'dpd_phone': dpd_phone,
                                            'dpd_courier': dpd_courier,
                                            'dpd_length': Number($('.cDpdLen').html()),
                                            'dpd_width': Number($('.cDpdWid').html()),
                                            'dpd_height': Number($('.cDpdHgt').html()),
                                            'dpd_weight': Number($('.cDpdWgtAll').html()),
                                            'dpd_service_code': service_code,
                                            'dpd': dpd,
                                            'deliveryDate': delTime,
                                            'sdek': sdek,
                                            'ems': ems,
                                            'goods': cost['goods'],
                                            'noBonus': cost['noBonus'],
                                            'payBonus': $('#bonus_amount').val(),
                                            'upload_ids': !!FileLoader ? FileLoader.getUploads() : {},
                                        },
                                        url: "/AJAX/makeOrderVtorge.php",
                                        async: true,
                                        success: function (data) {
                                            $('.download_out').css('display', 'none');
                                            myDropzone['largeFormatTemplate'].removeAllFiles();

                                            if (data) {
                                                var response = JSON.parse(data);
                                                switch (response.type) {
                                                    case 'done':
                                                        if (!!response['payment_page'])
                                                        {
                                                            location.href = response['payment_page'];
                                                        }
                                                        else
                                                        {
                                                            location.href = '/order';
                                                        }
                                                        break;
                                                    case 'time':
                                                        //alert("Р’Рѕ РІСЂРµРјСЏ СЃРѕР·РґР°РЅРёСЏ Р·Р°РєР°Р·Р° РІРѕР·РЅРёРєР»Рё РЅРµРёСЃРїСЂР°РІРЅРѕСЃС‚Рё. РџСЂРёРЅРѕСЃРёРј СЃРІРѕРё РёР·РІРёРЅРµРЅРёСЏ.");
                                                        $('#alertModal').find('.modal-body p').text("Р’Рѕ РІСЂРµРјСЏ СЃРѕР·РґР°РЅРёСЏ Р·Р°РєР°Р·Р° РІРѕР·РЅРёРєР»Рё РЅРµРёСЃРїСЂР°РІРЅРѕСЃС‚Рё. РџСЂРёРЅРѕСЃРёРј СЃРІРѕРё РёР·РІРёРЅРµРЅРёСЏ.");
                                                        $('#alertModal').modal('toggle');
                                                        break;
                                                    case 'guest':
                                                        $('#alertModal').find('.modal-body p').text("Р”Р»СЏ РѕС„РѕСЂРјР»РµРЅРёСЏ Р·Р°РєР°Р·Р° РЅРµРѕР±С…РѕРґРёРјРѕ РїСЂРѕР№С‚Рё СЂРµРіРёСЃС‚СЂР°С†РёСЋ Р»РёР±Рѕ РІРѕР№С‚Рё РІ Р»РёС‡РЅС‹Р№ РєР°Р±РёРЅРµС‚!");
                                                        $('#alertModal').modal('toggle');
                                                        break;
                                                    case 'CARD':
                                                        var info = response.info;
                                                        let _data = {
                                                            'service': 'card',
                                                            'orderNumber': info.id,
                                                            'amount': info.totalCost,
                                                            'partner': info.partner,
                                                            'clientId': info.user_id,
                                                            'description': info.name,
                                                            'email': info.email
                                                        };

                                                        $.ajax({
                                                            type: 'POST',
                                                            data: _data,
                                                            url: "/AJAX/partner_user_doPayment.php",
                                                            async: true,
                                                            success: function (data) {
                                                                var response = JSON.parse(data);
                                                                if (response['orderId'] &amp;&amp; response['formUrl']) {
                                                                    location.href = response['formUrl'];
                                                                } else {
                                                                    if (response['errorMessage']) {
                                                                        location.href = '/order';
                                                                    }
                                                                    // РґРѕР±Р°РІРёС‚СЊ РІС‹РІРѕРґ РѕС€РёР±РєРё
                                                                }

                                                            }
                                                        });
                                                        break;

                                                }
                                            } else {
                                                $('#alertModal').find('.modal-body p').text("Р’Рѕ РІСЂРµРјСЏ СЃРѕР·РґР°РЅРёСЏ Р·Р°РєР°Р·Р° РІРѕР·РЅРёРєР»Рё РЅРµРёСЃРїСЂР°РІРЅРѕСЃС‚Рё. РџСЂРёРЅРѕСЃРёРј СЃРІРѕРё РёР·РІРёРЅРµРЅРёСЏ.");
                                                $('#alertModal').modal('toggle');
                                            }
                                        }
                                    });
                                });
                            }
                            else
                            {
                                if ($('#large_print').is(':checked'))
                                {
                                    postPrint += 'РџРµС‡Р°С‚СЊ РїРѕРґ РјРѕСЋ РѕС‚РІРµС‚СЃС‚РІРµРЅРЅРѕСЃС‚СЊ (РњР°РєРµС‚ Р±СѓРґРµС‚ РЅР°РїРµС‡Р°С‚Р°РЅ РІ РёСЃС…РѕРґРЅРѕРј РІРёРґРµ. Рљ РјР°РєРµС‚Р°Рј,\n' +
                                        'РЅРµ СЃРѕРѕС‚РІРµС‚СЃС‚РІСѓСЋС‰РёРј С‚СЂРµР±РѕРІР°РЅРёСЏРј, СѓРєР°Р·Р°РЅРЅС‹Рј РЅР° СЃР°Р№С‚Рµ, РїСЂРµС‚РµРЅР·РёРё РЅРµ РїСЂРёРЅРёРјР°СЋС‚СЃСЏ.)';
                                }

                                instance.orderData = {
                                    'ph_id': $('.cPrintTerm input:checked').data('ph_id'),
                                    'own_region': own_region,
                                    'name': $('.cLFOrderDetails .title_order input').val(),
                                    'product': cost['name'],
                                    'size': $('#largeFormatWidth').val() + ' x ' + $('#largeFormatHeight').val() + ' РјРј',
                                    'material': cost['text'],
                                    'plot': '',
                                    'print': $('#largeFormatCount').val() + ' С€С‚.',
                                    'side': 'РћРґРЅРѕСЃС‚РѕСЂРѕРЅРЅСЏСЏ 4+0',
                                    'postPrint': postPrint,
                                    'readyDate': readyTime,
                                    'leadTime': $('#largeFormatLeadTime').val(),
                                    'actualDate': $('#largeFormatActualDate').val(),
                                    'printCost': $('#largeFormatPrintCost').text(),
                                    'postPrintCost': getPostWorkSum(),
                                    'deliverCost': $('#largeFormatCostOfDelivery').text(),
                                    'actualDeliverCost': $('#largeFormatActualDelivery').val(),
                                    'totalCost': $('#largeFormatTotal').html(),
                                    'delivery': deliveryText,
                                    'del_user': del_us,
                                    'mass': '',
                                    'comment': _comment,
                                    'user_link': '',
                                    'kabinet': 'offset',
                                    'pay': $('.cPayment input:checked').val(),
                                    'print_name': 'РЁРёСЂРѕРєРѕС„РѕСЂРјР°С‚РЅР°СЏ РїРµС‡Р°С‚СЊ',
                                    'dpd_country': dpd_country,
                                    'dpd_region': dpd_region.replace(/вЂ”/g, "-"),
                                    'dpd_city': dpd_city,
                                    'dpd_adress': dpd_adress,
                                    'dpd_is_terminal': terminalDpd,
                                    'dpd_FIO': dpd_FIO,
                                    'dpd_name': dpd_name,
                                    'dpd_phone': dpd_phone,
                                    'dpd_courier': dpd_courier,
                                    'dpd_length': Number($('.cDpdLen').html()),
                                    'dpd_width': Number($('.cDpdWid').html()),
                                    'dpd_height': Number($('.cDpdHgt').html()),
                                    'dpd_weight': Number($('.cDpdWgtAll').html()),
                                    'dpd_service_code': service_code,
                                    'dpd': dpd,
                                    'deliveryDate': delTime,
                                    'sdek': sdek,
                                    'ems': ems,
                                    'goods': cost['goods'],
                                    'noBonus': cost['noBonus'],
                                    'payBonus': $('#bonus_amount').val(),
                                    'upload_ids': FileLoader.getUploads(),
                                };
                                bonus.modalPay(() =&gt; instance.orderCreate());
                            }
                        }

                    }
                    else
                    {
                        $('html,body').animate({scrollTop: $('.cPrintTerm').offset().top}, 1100);
                        instance.enableSaveBtn();
                    }
                }
            };

            const __initialize = function () {

                const __initFancybox = function () {
                    $('.fancybox').fancybox({
                        helpers: {
                            title: {
                                type: 'inside'
                            }
                        }
                    });
                };

                const __initListenerProductClick = function () {

                    //Р’С‹РІРѕРґРёРј Р·Р°РіРѕР»РѕРІРѕРє Рё СЃРїРёСЃРѕРє РјР°С‚РµСЂРёР°Р»РѕРІ
                    $('div[table=productClick]').click(function (e) {
                        otype = 'large';
                        p_id = $(this).attr('productId');
                        hideLargeFormatInfo();

                        if (!instanceForLarge.isPartnerHost()) FileLoader.deleteAll(['kabinet_largeFormat_rostov', 'get_largeFormat_title']);

                        let url = "/AJAX/get_largeFormat_title.php";
                        if (instanceForLarge.isPartnerHost() &amp;&amp; $('#group_id').val() === "9")
                        {
                            url = "/AJAX/get_Partner_largeFormat_title.php";
                        }

                        $.ajax({
                            type: 'POST',
                            data: {
                                'productId': $(this).attr('productId')
                            },
                            url: url,
                            async: true,
                            success: function (data) {
                                var result = JSON.parse(data);

                                if (instanceForLarge.isPartnerHost())
                                {
                                    // Р—Р°РіРѕР»РѕРІРѕРє С‚Р°Р±Р»РёС†С‹
                                    $('.title-container').html(result.title).append(result.switch);
                                    // РўРµР»Рѕ С‚Р°Р±Р»РёС†С‹
                                    $('.large-format-table table').html(result.block);
                                    $('.product_btn_save').html(result.btn_save);
                                }
                                else
                                {
                                    // Р—Р°РіРѕР»РѕРІРѕРє С‚Р°Р±Р»РёС†С‹
                                    $('.large-format-title').html(result.title);
                                    // РўРµР»Рѕ С‚Р°Р±Р»РёС†С‹
                                    $('.large-format-table table').html(result.block);
                                }

                                // Scroll РЅР° С‚Р°Р±Р»РёС†Сѓ
                                $('html,body').animate({scrollTop: $('.large-format-content').offset().top}, 1100);

                                // РЎР±СЂР°СЃС‹РІР°РµРј СЂР°Р·РјРµСЂС‹
                                // Р’РѕР·РјРѕР¶РЅРѕ РїРµСЂРµРјРµСЃС‚РёС‚СЊ Рє РІС‹Р±РѕСЂСѓ СЃС‚РѕРёРјРѕСЃС‚Рё
                                $('#largeFormatWidth').val(1000);
                                $('#largeFormatHeight').val(1000);
                                $('#largeFormatCount').val(1);
                            }
                        });
                    });
                };

                const __initCityAutocomplete = function () {
                    $(".cCityForDPD").autocomplete({
                        source: availableTags,
                        minLength: 3
                    });
                };

                const __initPartnerListenerSaveProduct = function () {
                    $('.product_btn_save').on('click', '.save_product_properties', function() {

                        let product_id = $(this).attr('product_id');
                        let product_on = ($('.large-format-content .product_onoff #enable_product').prop('checked')) ? 1:0;

                        let materials = [];
                        $('.large-format-content input.print_extra_charge').each(function () {
                            let cup_tir = [$(this).attr('data-material'), $(this).attr('data-quality'), $(this).val()];
                            materials.push(cup_tir);
                        });

                        let product_image_button = btnImagePng.getDataForSave();
                        $.ajax({
                            type: 'POST',
                            data: {
                                product_id: product_id,
                                product_type: 'wildy',
                                product_on: product_on,
                                materials: materials,
                                product_image_button: product_image_button,
                            },
                            url: "/AJAX/save_product_partner_property.php",
                            async: true,
                            success: function (data) {
                                if(data === "DONE")
                                {
                                    let $img = $(`.first_block_product div[table="productClick"][productid="${product_id}"] img`);
                                    $img.attr('src', product_image_button.image);

                                    if(product_on === 1)
                                    {
                                        $img.removeClass('off');
                                    }
                                    else
                                    {
                                        $img.addClass('off');
                                    }

                                    $('.title-container').empty();
                                    $('.large-format-table table').empty();
                                    $('.product_btn_save').empty();
                                    $('html, body').animate({scrollTop: 0}, 600);

                                    $('#noticeModal').find('.modal-body p').text("Р”Р°РЅРЅС‹Рµ СЃРѕС…СЂР°РЅРµРЅС‹");
                                    $('#noticeModal').modal('toggle');
                                }
                                else
                                {
                                    $('#alertModal').find('.modal-body p').text("РћС€РёР±РєР° СЃРѕС…СЂР°РЅРµРЅРёСЏ");
                                    $('#alertModal').modal('toggle');
                                }
                            }
                        });
                    });
                };

                const __initListenerSelectPrice = function () {
                    //Р’С‹Р±РѕСЂ СЃС‚РѕРёРјРѕСЃС‚Рё РІ С‚Р°Р±Р»РёС†Рµ
                    $('.large-format-table').on('click', '.clickable', function (e) {

                        if (!instanceForLarge.isPartnerHost()) FileLoader.deleteAll(['kabinet_largeFormat_rostov', 'get_largeFormat_cost']);

                        // РїРѕСЃР»Рµ РІС‹Р±РѕСЂР° СЃС‚РѕРёРјРѕСЃС‚Рё РІ С‚Р°Р±Р»РёС†Рµ РѕС‚РїСЂР°РІР»СЏРµРјСЃСЏ РёСЃРєР°С‚СЊ СЌРіРѕ Р±СЂР°С‚РёС€РµРє СЃ РґСЂСѓРіРёРј РІСЂРµРјРµРЅРµРј
                        product_manager = '';
                        num_solder = 0;
                        self_pickup = 0;
                        solderCost = 0;
                        gluingCost = 0;
                        pruningCost = 0;
                        bannerRailCost = 0;
                        strenghtGluingCost = 0;
                        min_cost = Number($(this).attr('data-min_cost'));

                        if (instanceForLarge.isPartnerHost())
                        {
                            real_min_cost = Number($(this).attr('data-real_min_cost'));
                        }

                        $('.cOffsetDelivery .check_delivery').empty();
                        initAutocompleteD();
                        var id = $(this).attr('data-id');

                        $.ajax({
                            type: 'POST',
                            data: {
                                id: $(this).attr('data-id'),
                                id_material: $(this).attr('data-material'),
                                id_quality: $(this).attr('data-quality')
                            },
                            url: "/AJAX/get_largeFormat_cost.php",
                            async: true,
                            success: function (data) {
                                var result = JSON.parse(data);

                                solderFlag = result.solderFlag;
                                solderCost = result.solderCost;
                                laminationFlag = result.laminationFlag;
                                laminationCost = result.laminationCost;
                                gluingCost = result.gluingCost;
                                pruningCost = result.pruningCost;
                                bannerRailCost = result.BannerRailCost;
                                bannerRailFlag = result.BannerRailFlag;
                                strenghtGluingCost = result.strenghtGluingCost;
                                strenghtGluingFlag = result.strenghtGluingFlag;

                                if (result.dimension_limit)
                                {
                                    $('.dimension_limit_hide').hide();
                                    $('.cOrderSize label[for=largeFormatCount]').html('РљРѕР»РёС‡РµСЃС‚РІРѕ РєРѕРјРїР».');
                                }
                                else
                                {
                                    $('.dimension_limit_hide').css({'display': 'block'});
                                    $('.cOrderSize label[for=largeFormatCount]').html('РљРѕР»РёС‡РµСЃС‚РІРѕ, С€С‚')
                                }

                                if (bannerRailFlag &amp;&amp; bannerRailCost &gt; 0)
                                {
                                    $('.cBannerRail').css({'display': 'block'});
                                }
                                else
                                {
                                    $('#cBannerRailType').val(0);
                                    $('.cTotalCostBannerRail').html(0);
                                    $('.cBannerRail').css({'display': 'none'});
                                }

                                if (laminationFlag &amp;&amp; laminationCost &gt; 0)
                                {
                                    $('.cLamination').css({'display': 'block'});
                                }
                                else
                                {
                                    $('#cLaminationType').val(0);
                                    $('.cTotalCostLamination').html(0);
                                    $('.cLamination').css({'display': 'none'});
                                }

                                if (strenghtGluingFlag &amp;&amp; strenghtGluingCost &gt; 0)
                                {
                                    $('.cStrenghtGluing').css({'display': 'block'});
                                }
                                else
                                {
                                    $('#cStrenghtGluingType').val(0);
                                    $('.cTotalCostStrenghtGluing').html(0);
                                    $('.cStrenghtGluing').css({'display': 'none'});
                                }

                                $('.large-format-info').css({'display': 'block'});
                                $('html,body').animate({scrollTop: $('.large-format-info').offset().top}, 1100);

                                //Р—Р°РїРёСЃС‹РІР°РµРј РґР°РЅРЅС‹Рµ Рѕ РјР°С‚РµСЂРёР°Р»Рµ
                                cost['maxPrintHeight'] = result['maxPrintHeight'];
                                cost['widthLimit'] = result['widthLimit'];
                                cost['name'] = result['productName'];
                                cost['goods'] = result['goods'];
                                cost['density'] = result['density'];
                                cost['text'] = result['material'] + ' &lt;br&gt; Р’РёРґ РїРµС‡Р°С‚Рё: ' + result['quality'];
                                largeFormatFlag = true;
                                $('.cWrongSize').css('display: none');
                                $('.cWrongSize').html('');

                                var radioItems = '';
                                result['cost'].forEach(function (item) {
                                    //Р’СЂРµРјСЏ РґР»СЏ РјРµРЅРµРґР¶РµСЂР°
                                    var managerTime = TimeControl.parseReadyTime(item.time, false);
                                    //Р’СЂРµРјСЏ РґР»СЏ РєР»РёРµРЅС‚Р°
                                    var readyTime = TimeControl.parseReadyTime(item.time, true);
                                    var time = readyTime.split('-');
                                    if (time[1].length == 1)
                                    {
                                        time[1] = "0" + time[1];
                                    }
                                    if (time[2].length == 1)
                                    {
                                        time[2] = "0" + time[2];
                                    }
                                    radioItems += '&lt;div&gt;&lt;label&gt;&lt;input class="m-2" type="radio" name="options" autocomplete="off" data-ph_id="' + item.ph_id + '"data-nobonus="' + item.noBonus + '" data-preldate="' + managerTime + '" data-leadTime = "' + item.time + '" data-id="' + item.id + '" data-value="' + item.value + '" data-date="' + time[2] + '.' + time[1] + '.' + time[0] + '"&gt;Р“РѕС‚РѕРІРЅРѕСЃС‚СЊ РЅР° ' + time[2] + '.' + time[1] + ' вЂ” ' + item.value + ' СЂСѓР±. Р·Р° Рј.РєРІ.&lt;/label&gt;&lt;/div&gt;';
                                });
                                // Р”РѕР±Р°РІР»СЏРµРј РіСЂСѓРїРїСѓ СЂР°РґРёРѕР±Р°С‚Р°РЅРѕРІ Рё РІС‹Р±РёСЂР°РµРј РЅСѓР¶РЅС‹Р№ РїРѕ id
                                $('.cPrintTerm').html(radioItems);
                                $('.cPrintTerm input[data-id=' + id + '][type=radio]').prop("checked", true);

                                //РЎР±СЂР°СЃС‹РІР°РµРј СЃРµР»РµРєС‚С‹ Р»СЋРІРµСЂСЃРѕРІ
                                $('#cEyeletType').val('РќРµС‚');
                                $('#СЃEyeletStep').prop("disabled", true).val('300');
                                $('#СЃEyeletTurn').prop("disabled", true).val('РќРµС‚');

                                // РЎС‚РѕРёРјРѕСЃС‚СЊ Р»СЋРІРµСЂСЃР°
                                if (result['eyeletCost'] &gt; 0)
                                {
                                    $('#eyeletCost').html(result['eyeletCost']);
                                    $('.cEyelets').css({'display': 'block'});
                                }
                                else
                                {
                                    $('.cEyelets').css({'display': 'none'});
                                    $('#eyeletCost').html();
                                }

                                $('.cStretch #studioStretch')
                                    .val(result['cost_studio'])
                                    .attr('turn', result['turn_studio']);

                                $('.cStretch #galleryStretch')
                                    .val(result['cost_gallery'])
                                    .attr('turn', result['turn_gallery']);

                                // РџРѕСЃС‚СЂР°Р±РѕС‚Р° "РќР°С‚СЏР¶РєР°"
                                $('#noStretch').prop("checked", true);
                                if (result['stretch'])
                                {
                                    $('.cStretch').show();
                                }
                                else
                                {
                                    $('.cStretch').hide();
                                }

                                // РџРѕСЃС‚СЂР°Р±РѕС‚Р° "РџСЂРѕРєР»РµР№РєР° РєСЂР°СЏ"
                                $('#cGluingType').val(0);
                                if (result['gluingFlag'])
                                {
                                    $('.cGluing').show();
                                }
                                else
                                {
                                    $('.cGluing').hide();
                                }

                                // РџРѕСЃС‚СЂР°Р±РѕС‚Р° "РћР±СЂРµР·РєР°"
                                $('#cPruningType').val(0);
                                if (result['pruningFlag'])
                                {
                                    $('.cPruning').show();
                                    PruningFlag = true;
                                }
                                else
                                {
                                    $('.cPruning').hide();
                                    PruningFlag = false
                                }

                                // РџРѕР»СЏ РґР»СЏ Р·Р°РїРѕР»РЅРµРЅРёСЏ РІ РїСѓРЅРєС‚Рµ СЃС‚РѕРёРјРѕСЃС‚СЊ
                                settingDefaults();
                                largeSetDefaultDelivery();
                            }
                        });
                    });
                };

                const __initPartnerListenerInputExtraCharge = function () {
                    $('.large-format-table')
                        .on('change', 'input.print_extra_charge', function() {
                            let $input = $(this),
                                $parent = $input.parents('.extra-cost-calc');

                            let real_cost = +$parent.find('.__real_cost').text().replace(/\s+/g, '');
                            let percent = +$input.val().replace(/\s+/g, '');
                            let new_cost = Math.ceil(real_cost * (1 + percent /100));
                            $parent.find('.__new_cost').text(new_cost);
                        });
                };

                const __initPartnerListenersForCost = function () {
                    $('.large-format-content')
                        .on('change', '.product_onoff input[type=checkbox]', function () {
                            let $el = $(this),
                                $left = $el.siblings('.left'),
                                $right = $el.siblings('.right');

                            if ($el.prop('checked'))
                            {
                                $left.css('color', '#cdc5bf');
                                $right.css('color', '#482e1b');
                            }
                            else
                            {
                                $right.css('color', '#cdc5bf');
                                $left.css('color', '#482e1b');
                            }
                        })
                        .on('change', '#product_img_button', function() {
                            btnImagePng.useChangeListener(this);
                        })
                        .on('click', '#use-default-image', function() {
                            let $btn = $(this),
                                $parent = $btn.parents('.product-image-upload');

                            $parent.find('img.product-image-button').attr('src', $btn.attr('data-default-image'));
                            $parent.find('input[type="file"]').val('');
                        });
                };

                const __intiListenerChangeTime = function () {
                    // РР·РјРµРЅРµРЅРёРµ РІСЂРµРјРµРЅРё РІС‹РїРѕР»РЅРµРЅРёСЏ
                    $('.cPrintTerm').change(function (e) {
                        sizeForStretch();
                        settingDefaults();
                    });
                }

                const __initListenerChangeStretch = function () {
                    // РР·РјРµРЅРµРЅРёСЏ РїРѕСЃС‚СЂР°Р±РѕС‚С‹ "РќР°С‚СЏР¶РєР°"
                    $('.cStretch').change(function () {
                        sizeForStretch();
                        if ($('.cStretch input:checked').attr('id') == 'noStretch')
                        {
                            $('.cAlertStretch').css({'display': 'none'});
                            if (PruningFlag)
                            {
                                $('.cPruning').css({'display': 'block'});
                            }
                            else
                            {
                                $('.cPruning').css({'display': 'none'});
                                $('#cPruningType').val(0);
                                $('.cTotalCostPruning').html(0);
                            }

                        }
                        else
                        {
                            $('.cAlertStretch').css({'display': 'block'});
                            $('.cStretchTurn').html($('.cStretch input:checked').attr('turn'));
                            $('.cPruning').css({'display': 'none'});
                            $('#cPruningType').val(0);
                            $('.cTotalCostPruning').html(0);
                        }
                        settingDefaults();
                    });
                };

                const __initListenerChangeBannerRail = function () {
                    // РР·РјРµРЅРµРЅРёСЏ РїРѕСЃС‚СЂР°Р±РѕС‚С‹ "Р‘Р°РЅРЅРµСЂ-СЂСЌР№Р»"
                    $('.cBannerRail').change(function () {
                        settingDefaults();
                    });
                };

                const __initListenerChangeLamination = function () {
                    // РР·РјРµРЅРµРЅРёСЏ РїРѕСЃС‚СЂР°Р±РѕС‚С‹ "Р›Р°РјРёРЅР°С†РёСЏ"
                    $('.cLamination').change(function () {
                        settingDefaults();
                    });
                };

                const __initListenerChangePostWork = function () {
                    // РР·РјРµРЅРµРЅРёРµ РІ РїРѕСЃС‚ СЂР°Р±РѕС‚Р°С…
                    $('.post-work select').change(function () {
                        const id = $(this).attr('id');
                        if (id === 'cEyeletType' &amp;&amp; id !== 'СЃEyeletStep' &amp;&amp; id !== 'СЃEyeletTurn')
                        {
                            const cases = ["РїРѕ РїРµСЂРёРјРµС‚СЂСѓ", "РІРµСЂС…", "РІРµСЂС… Рё РІРЅРёР·", "Р›РµРІРѕ Рё РїСЂР°РІРѕ"];
                            const disabled = cases.includes($(this).val().toLowerCase());
                            $('#СЃEyeletStep').prop("disabled", disabled);
                            $('#СЃEyeletTurn').prop("disabled", disabled);
                        }

                        // Р”РѕР±Р°РІРёС‚СЊ РёР·РјРµРЅРµРЅРёРµ СЃС‚РѕРёРјРѕСЃС‚Рё
                        // РџРѕР»СЏ РґР»СЏ Р·Р°РїРѕР»РЅРµРЅРёСЏ РІ РїСѓРЅРєС‚Рµ СЃС‚РѕРёРјРѕСЃС‚СЊ
                        settingDefaults();

                        if (!instanceForLarge.isPartnerHost())
                        {
                            let $self = $(this)
                            if ($self.find('option').length &gt; 0)
                            {
                                let selectIndex = $self.find('option').context.selectedIndex
                                if (selectIndex &gt; 0)
                                {
                                    $("#alertPostWork").show()
                                }
                                else
                                {
                                    $("#alertPostWork").hide()
                                }
                            }
                        }
                    });
                };

                const __initListenerChangeOrderSize = function () {
                    // РР·РјРµРЅРµРЅРёСЏ РІ "СЂР°Р·РјРµСЂ Рё РєРѕР»-РІРѕ"
                    $('.cOrderSize input').change(function (e) {

                        if ($('#largeFormatWidth').val() &gt; 2900)
                        {
                            $('#cBannerRailType').val(0);
                            $('.cTotalCostBannerRail').html(0);
                            $('.cBannerRail').css({'display': 'none'});
                        }
                        else
                        {
                            if ($('#largeFormatHeight').val() &gt; 3000)
                            {
                                $('#cBannerRailType').val(0);
                                $('.cTotalCostBannerRail').html(0);
                                $('.cBannerRail').css({'display': 'none'});
                            }
                            else
                            {
                                if (bannerRailFlag &amp;&amp; bannerRailCost &gt; 0)
                                {
                                    $('.cBannerRail').css({'display': 'block'});
                                }
                                else
                                {
                                    $('#cBannerRailType').val(0);
                                    $('.cTotalCostBannerRail').html(0);
                                    $('.cBannerRail').css({'display': 'none'});
                                }
                            }
                        }

                        sizeForStretch();
                        settingDefaults();
                    });
                };

                const __initListenerSelectDelivery = function () {
                    // Р’С‹Р±РѕСЂ РґРѕСЃС‚Р°РІРєРё (РЅРµРѕР±С…РѕРґРёРјР° РѕС‡РёСЃС‚РєР° РґР°РЅРЅС‹С…)
                    $('.large_delivery .tab input').change(function () {

                        getUserCityName();
                        dpd_ready = false;
                        dpd_flag = true;
                        dpd_country = '';
                        dpd_city = '';
                        dpd_region = '';
                        dpd_region2 = '';
                        dpd_adress = '';

                        //РќРѕРІРѕРµ С‡РёСЃС‚РёРј РїРѕСЃР»Рµ DPD РќР°С‡Р°Р»Рѕ
                        $('.totalCost').text($('.printCost').html());
                        $('.deliveryCost').text(0);
                        $('.actualDeliveryCost').text(0);
                        if (instanceForLarge.isPartnerHost())
                        {
                            // old variant
                            $('.deliveryDate').text($('.dateReady').html());
                        }
                        else
                        {
                            let dateReadySplit = $('.dateReady').html().split('.');
                            setDeliveryDate({d: dateReadySplit[0], m: dateReadySplit[1], y: dateReadySplit[2]});
                        }
                        $('.del_addr_hd').val('').css('border-color','');
                        //РќРѕРІРѕРµ С‡РёСЃС‚РёРј РїРѕСЃР»Рµ DPD РљРћРќР•Р¦

                        var total_cost = Number($('.printCost').html());
                        var newDate = '';
                        if ($(this).hasClass("radioLargeTargetedRostov"))
                        {
                            total_cost += 100;
                            $('.totalCost').text(total_cost);
                            $('.deliveryCost').text(100);
                            newDate = redyTimeDelivery(1);

                            if (instanceForLarge.isPartnerHost())
                            {
                                // old variant
                                $('.deliveryDate').text(newDate['d'] + '.' + newDate['m'] + "." + newDate['y']);
                            }
                            else
                            {
                                setDeliveryDate(newDate);
                            }
                        }

                        // РђРґСЂРµСЃРЅР°СЏ РљР°Р·Р°РЅСЊ
                        if ($(this).hasClass("radioTargetedRegion"))
                        {
                            total_cost += 0;
                            $('.totalCost').text(total_cost);
                            $('.deliveryCost').text(0);
                            newDate = redyTimeDelivery(1);
                            if (instanceForLarge.isPartnerHost())
                            {
                                // old variant
                                $('.deliveryDate').text(newDate['d'] + '.' + newDate['m'] + "." + newDate['y']);
                            }
                            else
                            {
                                setDeliveryDate(newDate);
                            }
                        }

                        if ($(this).hasClass("radioPickUpDpdLarge"))
                        {
                            $('.dpd_delivery .del_addr, .dpd_delivery .del_addk').html('');
                        }
                    });
                };

                const __initListenerSelectCityForTerminal = function () {
                    // РІС‹Р±РѕСЂ РіРѕСЂРѕРґР° РґР»СЏ С‚РµСЂРјРёРЅР°Р»Р° DPD
                    $('.cLFOrderDetails .dpd_but_city').on('click', function () {
                        citySelectionLarge($('.cLFOrderDetails .dpd_city').val().toLowerCase());
                    });
                };

                const __initListenerSelectTerminal = function () {
                    //РІС‹Р±РѕСЂ С‚РµСЂРјРёРЅР°Р»Р° РґР»СЏ РґРѕСЃС‚Р°РІРєРё
                    $('.large_delivery .cTerminal_list').on('click', 'tr', function () {

                        if (!instanceForLarge.isPartnerHost()) DeliveryInstance.setMethod('large_dpd_delivery');

                        if ($(this).find('td').attr("class") !== "td-id-error")
                        {
                            $(".tr_act").removeClass();
                            $(this).removeClass().addClass("tr_act");
                            dpd_terminal = $(this).attr('data-address');
                            full_terminal = $(this).find(".del2").html();

                            //Р’Р°СЂРёР°РЅС‚ Р±РµР· РЇРЅРґРµРєСЃ РєР°СЂС‚С‹ РќРђР§РђР›Рћ
                            $('#large_dpd_delivery .block_is_ik .del_addk').html(dpd_terminal);
                            $('#large_dpd_delivery .block_is_ik .del_addr').html(full_terminal);

                            var arr = full_terminal.split(', ');
                            var city = $('.large_delivery .dpd_city').val().split(', ');
                            dpd_country = 'Р&nbsp;РѕСЃСЃРёСЏ';
                            dpd_region = arr[1];
                            dpd_region2 = arr[1];
                            dpd_city = city[0];
                            dpd_adress = dpd_terminal;
                            //Р’Р°СЂРёР°РЅС‚ Р±РµР· РЇРЅРґРµРєСЃ РєР°СЂС‚С‹ РљРћРќР•Р¦

                            $('.large_delivery .delivery_block_dpd_dpdp').css('display', 'block');
                            dpd_ready = false;
                            dpd_flag = true;
                            $('.totalCost').text($('.printCost').html());
                            $('.deliveryCost').text(0);

                            if (instanceForLarge.isPartnerHost())
                            {
                                // old variant
                                $('.deliveryDate').text($('.dateReady').html());
                            }
                            else
                            {
                                let dateReadySplit = $('.dateReady').html().split('.');
                                setDeliveryDate({d: dateReadySplit[0], m: dateReadySplit[1], y: dateReadySplit[2]});
                            }
                        }
                    });
                };

                const __initListenerTerminalCost = function () {
                    //РћР±СЂР°Р±Р°С‚С‹РІР°РµРј СЃС‚РѕРёРјРѕСЃС‚СЊ "РўРµСЂРјРёРЅР°Р»СЊРЅРѕР№ РґРѕСЃС‚Р°РІРєРё DPD"
                    $('.large_delivery .cInfo_addressee button.terminalButton').on('click', function () {
                        if ($('.large_delivery .dpd_terminal .del_addr').html().length &gt; 0)
                        {
                            $('.download_out').css('display', 'block');

                            var coef = Math.cbrt(Number($('.check_delivery table .cDpdNum').html()) + Number($('.check_delivery table .cDpdNumDop').html()));
                            $.ajax({
                                type: 'POST',
                                data: {
                                    'mark': $(this).data('mark'),
                                    'otype': otype,
                                    'product_id': p_id,
                                    'own_region': instanceForLarge.isPartnerHost() ? own_region : ph_id,
                                    'country': dpd_country,
                                    'city': dpd_city,
                                    'region': dpd_region,
                                    'region2': dpd_region2,
                                    'length': Number($('.cDpdLen').html()) * coef,
                                    'width': Number($('.cDpdWid').html()) * coef,
                                    'height': Number($('.cDpdHgt').html()) * coef,
                                    'weight': Number(Number($('.cDpdWgtAll').html()) + Number($('.cDpdWgtAllDop').html())).toFixed(2),
                                    'product': cost['name'],
                                    'cost': $('.printCost').html()
                                },
                                url: "/AJAX/get_dpd_price_terminal.php",
                                async: true,
                                success: function (data) {
                                    try
                                    {
                                        var result = JSON.parse(data);
                                        if (result['DPD'] == false)
                                        {
                                            dpd_ready = false;

                                            $('#alertModal').find('.modal-body p').text("РќРµРѕР±С…РѕРґРёРјРѕ РІС‹Р±СЂР°С‚СЊ РїСѓРЅРєС‚ РЅР°Р·РЅР°С‡РµРЅРёСЏ");
                                            $('#alertModal').modal('toggle');

                                            $('.totalCost').text($('.printCost').html());
                                            $('.deliveryCost').text(0);

                                            if (instanceForLarge.isPartnerHost())
                                            {
                                                $('.RealtotalCost').text($('.RealprintCost').html());

                                                // old variant
                                                $('.deliveryDate').text($('.dateReady').html());
                                            }
                                            else
                                            {
                                                let dateReadySplit = $('.dateReady').html().split('.');
                                                setDeliveryDate({d: dateReadySplit[0], m: dateReadySplit[1], y: dateReadySplit[2]});
                                            }
                                        }
                                        else
                                        {
                                            dpd_ready = true;
                                            service_code = result['DPD'].SERVICE_CODE;
                                            dpd_flag = result['CONFIRM'];
                                            if (result['USER_DAY'])
                                            {
                                                /**
                                                 * Р&nbsp;Р°Р±РѕС‚Р° СЃ РґР°С‚РѕР№ РґРѕСЃС‚Р°РІРєРё РћРў Р‘РђР›Р”Р«
                                                 */
                                                var new_date = redyTimeDelivery(Math.ceil(result['USER'].DAYS));
                                                if (instanceForLarge.isPartnerHost())
                                                {
                                                    // old variant
                                                    $('.deliveryDate').text(new_date['d'] + '.' + new_date['m'] + "." + new_date['y']);
                                                }
                                                else
                                                {
                                                    setDeliveryDate(new_date);
                                                }
                                                /**
                                                 * Р&nbsp;Р°Р±РѕС‚Р° СЃ РґР°С‚РѕР№ РґРѕСЃС‚Р°РІРєРё РћРў Р‘РђР›Р”Р«
                                                 */
                                            }
                                            else
                                            {
                                                /**
                                                 * Р&nbsp;Р°Р±РѕС‚Р° СЃ РґР°С‚РѕР№ РґРѕСЃС‚Р°РІРєРё DPD
                                                 */
                                                var date = $('.actualDateReady').val().split('-');
                                                var dpd_date = new Date(date[1] + "/" + date[2] + "/" + date[0]);

                                                dpd_date.setDate(dpd_date.getDate() + result['DPD'].DAYS);
                                                /******РџСЂРѕРІРµСЂРєР° Р±РѕР»СЊС€Рµ РјРµР»СЊРјРµ Р»Рё СЃРєСЂС‹С‚РѕР№ (СЂРµР°Р»СЊРЅРѕР№) РґР°С‚С‹ РќРђР§РђР›Рћ ******/
                                                date = $('.dateReady').html().split('.');
                                                var control_date = new Date(date[1] + "/" + date[0] + "/" + date[2]);

                                                if (dpd_date &lt; control_date)
                                                {
                                                    dpd_date = control_date;
                                                }
                                                /******РџСЂРѕРІРµСЂРєР° Р±РѕР»СЊС€Рµ РјРµР»СЊРјРµ Р»Рё СЃРєСЂС‹С‚РѕР№ (СЂРµР°Р»СЊРЅРѕР№) РґР°С‚С‹ РќРђР§РђР›Рћ ******/
                                                var day = dpd_date.getDate();
                                                if (day &lt; 10)
                                                {
                                                    day = "0" + day;
                                                }
                                                var month = dpd_date.getMonth() + 1;
                                                if (month &lt; 10)
                                                {
                                                    month = "0" + month;
                                                }

                                                if (instanceForLarge.isPartnerHost())
                                                {
                                                    // old variant
                                                    $('.deliveryDate').text(day + '.' + month + "." + dpd_date.getFullYear());
                                                }
                                                else
                                                {
                                                    setDeliveryDate({d: day, m: month, y: dpd_date.getFullYear()});
                                                }


                                                /**
                                                 * Р&nbsp;Р°Р±РѕС‚Р° СЃ РґР°С‚РѕР№ РґРѕСЃС‚Р°РІРєРё DPD
                                                 */
                                            }
                                            //РЎС‚РѕРёРјРѕСЃС‚СЊ РґРѕСЃС‚Р°РІРєРё
                                            var user_cost = Math.ceil(Number(result['USER'].COST));
                                            var dpd_cost = Math.ceil(Number(result['DPD'].COST));
                                            //Р”Р»СЏ РєР»РёРµРЅС‚Р°
                                            $('.deliveryCost').text(user_cost);
                                            //Р”Р»СЏ РјРµРЅРµРґР¶РµСЂР°
                                            $('.actualDeliveryCost').val(dpd_cost);
                                            //РЎСѓРјР°СЂРЅР°СЏ СЃС‚РѕРёРјРѕСЃС‚СЊ
                                            var total_cost = user_cost + Number($('.printCost').html());
                                            $('.totalCost').text(total_cost);
                                            if (instanceForLarge.isPartnerHost())
                                            {
                                                var real_total_cost = user_cost + Number($('.RealprintCost').html());
                                                $('.RealtotalCost').text(real_total_cost);
                                            }
                                        }
                                    } catch (e)
                                    {
                                        $('#alertModal').find('.modal-body p').text("Р’Рѕ РІСЂРµРјСЏ СЂР°СЃС‡РµС‚Р° СЃС‚РѕРёРјРѕСЃС‚Рё РґРѕСЃС‚Р°РІРєРё РІРѕР·РЅРёРєР»Рё РЅРµРїСЂРµРґРІРёРґРµРЅРЅС‹Рµ С‚СЂСѓРґРЅРѕСЃС‚Рё. РџРѕР¶Р°Р»СѓР№СЃС‚Р°, СЃРІСЏР¶РёС‚РµСЃСЊ СЃ РЅР°С€РёРј РјРµРЅРµРґР¶РµСЂРѕРј.");
                                        $('#alertModal').modal('toggle');
                                    }
                                    $('.download_out').css('display', 'none');
                                }
                            });
                        }
                        else
                        {
                            $('#alertModal').find('.modal-body p').text("РџРѕР¶Р°Р»СѓР№СЃС‚Р°, РІС‹Р±РµСЂРёС‚Рµ РїСѓРЅРєС‚ РІС‹РґР°С‡Рё РёР· СЃРїРёСЃРєР°.");
                            $('#alertModal').modal('toggle');
                        }
                    });
                };

                $(document).ready(function () {
                    __initFancybox();

                    if (instanceForLarge.isPartnerHost())
                    {
                        $('.large-format-title').addClass('title-container').removeClass('large-format-title');
                        $('.large-format-table').append('&lt;div class="product_btn_save mt-3"&gt;&lt;/div&gt;');
                    }

                    __initListenerProductClick();
                    __initCityAutocomplete();

                    if (instanceForLarge.isPartnerHost())  __initPartnerListenerSaveProduct();

                    __initListenerSelectPrice();

                    if (instanceForLarge.isPartnerHost())
                    {
                        __initPartnerListenerInputExtraCharge();
                        __initPartnerListenersForCost();
                    }

                    __intiListenerChangeTime();
                    __initListenerChangeStretch();
                    __initListenerChangeBannerRail();
                    __initListenerChangeLamination();
                    __initListenerChangePostWork();
                    __initListenerChangeOrderSize();

                    __initListenerSelectDelivery();
                    __initListenerSelectCityForTerminal();
                    __initListenerSelectTerminal();
                    __initListenerTerminalCost();

                    // РїРµСЂРµС…РѕРґ
                    $('#tabs li a').click(function () {
                        hideLargeFormatInfo()
                    });

                    $(".large_delivery ").on("click", ".dpd_delivery,  label", function () {
                        // РћСЃС‚Р°С‚РєРё С„СѓРЅРєС†РёРѕРЅР°Р»Р° РѕС‚ РѕС‡РµРЅСЊ СЃС‚Р°СЂРѕР№ РІРµСЂСЃС‚РєРё, РїРµСЂРµРґРµР»Р°С‚СЊ РїСЂРё РЅР°Р»РёС‡РёРё СЃРІРѕР±РѕРґРЅРѕРіРѕ РІСЂРµРјРµРЅРё
                        if ($(this).attr("class") === "dpd_act3none")
                        {
                            $(".large_delivery .dpd_act3none").removeClass().addClass("dpd_act");
                            $(".large_delivery .dpd_act3").removeClass().addClass("dpd_act3none");
                            $(".large_delivery .dpd_act").removeClass().addClass("dpd_act3");
                        }
                    });

                    $('#largeFormatSave').click(() =&gt; {
                        instance.handler__orderCreateBtn();
                    });
                });
            };

            __initialize();
        })();
    })();

    // for bonus
    window.cost = {
        noBonus: true
    };

    window.initialized_large = true;
}





</pre></body></html>