<?php require_once(THEME_ROOT . '/blocks/user_head.php'); ?>
<?php require_once(THEME_ROOT . '/blocks/user_top.php'); ?>

<div id="page-content-wrapper">
    <?php
    $is_payment = is_open("payment");
    if ($is_payment["error"]) {
        echo flash_show();
    } else {
        ?>
        <div class="avatar-body shadow border_20 withdrawal_block wow bounceIn">
            <div class="row">
                <div class="col-sm-12 col-xs-12 col-md-12 col-lg-3">
                    <p class="hidden-xs wow bounceIn" data-wow-delay="0.05s"><?php echo T('Сумма'); ?></p>
                    <div class="row">
                        <div class="col-md-12 wow bounceIn" data-wow-delay="0.4s">
                            <div class="wallet_block" data-value="1">
                                <input
                                        type="text"
                                        id="amount"
                                        placeholder="- <?php echo T("Введите сумму"); ?> -"
                                        class="inpts" value="">
                                <span><?php echo html($valu); ?></span>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12 col-xs-12 col-md-12 col-lg-9">
                    <p class="hidden-xs wow bounceIn" data-wow-delay="0.1s"><?php echo T('Платежная система'); ?></p>

                    <div class="row">
                        <?php $delay = 0.20;
                        $list = get_payment_system('payment');
                        $count_list = 0;
                        foreach ($list as $item) {
                            if (login_get_wallet($login, $item['value'])) {
                                $count_list++;
                            }
                        }
                        if ($count_list <= 3) {
                            $count_list = 4;
                        } elseif ($count_list == 4) {
                            $count_list = 3;
                        } else {
                            $count_list = 2;
                        }

                        $wallet = false;

                        foreach ($list as $item) {
                            if (login_get_wallet($login, $item['value'])) {
                                $wallet = true; ?>
                                <div class="col-md-<?php echo (int)$count_list; ?> col-xs-6 wow bounceIn"
                                     data-wow-delay="0.<?php echo (float)$delay; ?>s" style="margin-bottom: 15px;">
                                    <div class="wallet_block systems" data-value="<?php echo escape($item['value']); ?>"
                                         style="padding-bottom: 0 !important;">
                                        <svg width="60" height="60" role="img"> <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#bm_icon_mini_logos_colored_<?php echo strtolower(escape($item['value'])); ?>"></use> </svg>
                                        <hr style="margin: 0; margin-top: 2px;">
                                        <span>
                                            <?php echo format_currency(login_summa_balans_system($login, $item['value']), $val) . ' ' . html($valu); ?>
                                        </span>
                                    </div>
                                </div>
                            <?php }
                            $delay = $delay + 0.05;
                        }
                        if (!$wallet) { ?>
                            <h4 style="text-align: center;"><?php echo T('Укажите реквизиты в настройках кошельков'); ?></h4>
                        <?php } ?>
                    </div>
                </div>
            </div>

            <?php echo(flash_show('payment')); ?>
            <form action="/handlers/user/payment.php" method="POST" class="text-center" style="margin-top: 10px;">
                <?php echo form_init(); ?>
                <input type="hidden" name="system" value="<?php echo escape(post('system')); ?>">
                <input type="hidden" name="amount" value="<?php echo escape(post('amount')); ?>">
                <button type="submit" class="btn btn-success btn-lg wow fadeInUp" data-wow-delay="0.2s"
                        style="margin-top: 10px;">
                    <?php echo T('Вывести'); ?>
                </button>
            </form>
        </div>
    <?php } ?>

</div>


</div>
<script src="//cdn.jsdelivr.net/jquery/2.1.4/jquery.min.js" type="text/javascript"></script>
<script src="/theme/demo108/assets/common/Assets/js/sidebar_menu.js" type="text/javascript"></script>
<script src="/theme/demo108/assets/common/Assets/sound/ion.sound.min.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.min.js"></script>
<script>

    ion.sound({
        sounds: [
            {
                name: "bip-2"
            },
            {
                name: "wuf-3"
            },
            {
                name: "wuf-1"
            },
            {
                name: "wuf-4"
            },
            {
                name: "bip-1"
            },
            {
                name: "welcome_ru"
            },
            {
                name: "withdrawal_ru"
            },
        ],
        path: "/theme/demo108/assets/common/Assets/sound/sounds/",
        preload: true,
        volume: 1.0,
        multiplay: true
    });

    $(document).ready(function () {
        if ($('input[name="amount"]').val() != '') {
            $('#amount').val($('input[name="amount"]').val());
            $('#amount').parent('.wallet_block').addClass('shadow');
            $('#amount').parent('.wallet_block').css('opacity', '1');
        }

        if ($('input[name="system"]').val() != '') {
            $('.systems').css('opacity', '0.6');
            $('.systems').removeClass('shadow');
            $('.systems[data-value="' + $('input[name="system"]').val() + '"]').addClass('shadow');
            $('.systems[data-value="' + $('input[name="system"]').val() + '"]').css('opacity', '1');
        }
    });

    $('#amount').on('keyup', function () {
        $('input[name="amount"]').val($(this).val());
    });

    $('#amount').parent('.wallet_block').on('click', function () {
        $(this).addClass('shadow');
        $(this).css('opacity', '1');
    });

    $(".systems").on("click", function () {
        $(".systems").css("opacity", "0.6");
        $(".systems").removeClass("shadow");
        if ($('#amount').val() == '') {
            $('#amount').parent('.wallet_block').removeClass('shadow');
            $('#amount').parent('.wallet_block').css('opacity', '0.6');
        }
        $(this).addClass("shadow");
        $(this).css("opacity", "1");
        $('input[name="system"]').val($(this).data('value'));
        ion.sound.play("wuf-1");
    });

    $(".sidebar-nav li, .btn").on("mouseenter", function () {
        ion.sound.play("bip-2");
    });

    $(".sidebar-nav li, .btn").on("click", function () {
        ion.sound.play("bip-1");
    });

    $(".form-control").on("click", function () {
        ion.sound.play("wuf-1");
    });
    if ($(".wow").is(':visible')) {
        ion.sound.play("wuf-1");
    }
</script>
</body>
</html>
