<div class="switch-btn {if $one_module.status eq "0"}switch-on{/if}" data-id="#yandex_payment_module-1" id="yandex_payment__switch-btn"><div></div></div>
<input type="checkbox" hidden="hidden" name="yandex_payment_module_status" id="yandex_payment_module_status" value="{if $one_module.status eq "0"}1{else}0{/if}"/>
<script>
    $(function () {
        var OneCsyncCheckStatus = $('#yandex_payment_module_status');
        var OneCsyncModuleLink = $('#module__yandex_payment');
        $('#yandex_payment__switch-btn').click(function () {
            var $this = $(this);
            if ($this.hasClass('switch-on')) {
                jconfirm('{$lang.disabled_module_alert}', function () {
                    $this.toggleClass('switch-on');
                    $this.trigger('off.switch');

                });
            } else {
                $this.toggleClass('switch-on');
                $this.trigger('on.switch');
            }
        });
        $('#yandex_payment__switch-btn').on('on.switch', function () {
            // Посылаем запрос на включение модуля
            $.ajax({
                url: '{$config.site_url}/edit_modules.php?module=yandex_payment',
                type: 'POST',
                data: {
                    csrf: '{$csrf}',
                    activate: 0
                },
                beforeSend: function() {
                    makePreloader();
                },
                success: function (resp) {
                    destroyPreloader();
                    OneCsyncCheckStatus.val('1');
                    OneCsyncModuleLink.removeClass('disabled');
                    location.href = OneCsyncModuleLink.attr('href');
                }
            });
        });
        $('#yandex_payment__switch-btn').on('off.switch', function () {
            // Посылаем запрос на выключение модуля
            $.ajax({
                url: '{$config.site_url}/edit_modules.php?module=yandex_payment',
                type: 'post',
                data: {
                    csrf: '{$csrf}',
                    activate: 1
                },
                beforeSend: function() {
                    makePreloader();
                },
                success: function (resp) {
                    destroyPreloader();
                    OneCsyncCheckStatus.val('0');
                    OneCsyncModuleLink.addClass('disabled');
                }
            });
        });
    });
</script>
