<?php require_once(THEME_ROOT . '/blocks/user_head.php'); ?>
<?php require_once(THEME_ROOT . '/blocks/user_top.php'); ?>
<div id="page-content-wrapper">
    <div class="row">
        <div class="col-md-3">
            <div class="cab_block shadow bounceIn wow">
                <h2><?php echo T('Баланс'); ?></h2>
                <table class="with_icon">
                    <td>
                        <p class="amount"><?php echo format_currency(login_sum_balans($login), $val) . ' ' . html($valu); ?></p>
                    </td>
                    <td align="right">
                        <div class="icon_circle">
                            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"
                                 fill="none" stroke="#000" stroke-width="2" stroke-linecap="round"
                                 stroke-linejoin="round">
                                <polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline>
                            </svg>
                        </div>
                    </td>
                </table>
            </div>
        </div>
        <div class="col-md-3">
            <div data-wow-delay="0.05s" class="bounceIn wow cab_block shadow">
                <h2><?php echo T('Мои депозиты'); ?></h2>
                <table class="with_icon">
                    <td>
                        <p class="amount"><?php echo format_currency(login_activ_depozit($login), $val) . ' ' . html($valu); ?></p>
                    </td>
                    <td align="right">
                        <div class="icon_circle">
                            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"
                                 fill="none" stroke="#000" stroke-width="2" stroke-linecap="round"
                                 stroke-linejoin="round">
                                <rect x="2" y="7" width="20" height="14" rx="2" ry="2"></rect>
                                <path d="M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"></path>
                            </svg>
                        </div>
                    </td>
                </table>
            </div>
        </div>
        <div class="col-md-3">
            <div data-wow-delay="0.2s" class="bounceIn wow cab_block shadow">
                <h2><?php echo T('Выведено средств'); ?></h2>
                <table class="with_icon">
                    <td>
                        <p class="amount"><?php echo format_currency(login_payment($login), $val) . ' ' . html($valu); ?></p>
                    </td>
                    <td align="right">
                        <div class="icon_circle">
                            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"
                                 fill="none" stroke="#000" stroke-width="2" stroke-linecap="round"
                                 stroke-linejoin="round">
                                <circle cx="12" cy="12" r="10"></circle>
                                <line x1="8" y1="12" x2="16" y2="12"></line>
                            </svg>
                        </div>
                    </td>
                </table>
            </div>
        </div>
        <div class="col-md-3">
            <div data-wow-delay="0.25s" class="bounceIn wow cab_block shadow">
                <h2><?php echo T('Партнеры ('); ?><?php echo (int)login_refer_count($login); ?>)</h2>
                <table class="with_icon">
                    <td>
                        <p class="amount"><?php echo format_currency(login_refer($login), $val) . ' ' . html($valu); ?></p>
                    </td>
                    <td align="right">
                        <div class="icon_circle">
                            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24">
                                <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" fill="none" stroke="#000"
                                      stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></path>
                                <circle cx="9" cy="7" r="4" fill="none" stroke="#000" stroke-linecap="round"
                                        stroke-linejoin="round" stroke-width="2"></circle>
                                <path d="M23 21v-2a4 4 0 0 0-3-3.87" fill="none" stroke="#000"
                                      stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></path>
                                <path d="M16 3.13a4 4 0 0 1 0 7.75" fill="none" stroke="#000" stroke-linecap="round"
                                      stroke-linejoin="round" stroke-width="2"></path>
                            </svg>
                        </div>
                    </td>
                </table>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-9">
            <div data-wow-delay="0.1s" class="bounceIn wow cab_block shadow cabinet_graph" style="padding: 10px;">
                <div class="graph_currency active_graph"
                     data-val="<?php echo escape($val); ?>"><?php echo escape($val); ?></div>
                <div id="graph<?php echo strtoupper(escape($val)); ?>" class="chart_visible"
                     style="height: 500px"></div>
            </div>
        </div>
        <div class="col-md-3">
            <div data-wow-delay="0.15s" class="bounceIn wow cab_block shadow">

                <div class="icon_profit">
                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24">
                        <rect x="18" y="3" width="4" height="18" fill="none" stroke="#000" stroke-linecap="round"
                              stroke-linejoin="round" stroke-width="2"></rect>
                        <rect x="10" y="8" width="4" height="13" fill="none" stroke="#000" stroke-linecap="round"
                              stroke-linejoin="round" stroke-width="2"></rect>
                        <rect x="2" y="13" width="4" height="8" fill="none" stroke="#000" stroke-linecap="round"
                              stroke-linejoin="round" stroke-width="2"></rect>
                    </svg>
                </div>

                <p class="amount text-center" style="color: #dd2027; font-size: 30px">
                    + <?php echo format_currency(login_profit($login) + login_refer($login), $val) . ' ' . html($valu); ?></p>
            </div>
        </div>
    </div>
</div>
</div>

<?php

?>

<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
    });

    function number_format(number, decimals, dec_point, thousands_sep) {
        var i, j, kw, kd, km;
        if (isNaN(decimals = Math.abs(decimals))) {
            decimals = 2;
        }
        if (dec_point == undefined) {
            dec_point = ",";
        }
        if (thousands_sep == undefined) {
            thousands_sep = ".";
        }

        i = parseInt(number = (+number || 0).toFixed(decimals)) + "";

        if ((j = i.length) > 3) {
            j = j % 3;
        } else {
            j = 0;
        }
        km = (j ? i.substr(0, j) + thousands_sep : "");
        kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep);
        kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : "");
        return km + kw + kd;
    }

    Morris.Area({
        element: 'graph<?php echo strtoupper(escape($val)); ?>',
        behaveLikeLine: true,
        data: [

            <?php for ($i = 6; $i >= 0; $i--) {
            $profit_table = get_list('profit', '`login`=' . escape_db($login) . ' AND `status`=' . escape_db(1) . ' AND `date_end`>=' . strtotime(date('d-m-Y', time() - 86400 * $i)) . ' AND `date_end` <=' . strtotime(date('d-m-Y', time() - 86400 * ($i - 1))));
            $day_sum = 0;
            foreach ($profit_table as $item) {
                $day_sum = $day_sum + $item['summa'];
            }
            echo "{x: '" . date('d.m', time() - 86400 * $i) . "', y: '" . $day_sum . "'},";
        } ?>

        ],
        xkey: 'x',
        ykeys: 'y',
        labels: 'x',
        resize: true,
        parseTime: false,
        smooth: true,
        lineColors: ['#3ab44c'],
        lineWidth: 1,
        pointStrokeWidths: [1],
        shown: true,
        pointFillColors: ['#3ab44c'],
        pointStrokeColors: ['#fff'],
        gridLineColor: 'rgba(0,0,0, .1)',
        gridStrokeWidth: 1,
        numLines: 9,
        pointSize: 4,
        yLabelFormat: function (y) {
            return number_format(y.toString(), 2, ',', ' ');
        },
        hideHover: 'auto',
        gridTextColor: '#000',
        gridTextSize: 16,
        grid: true,
        axes: true,
        continuousLine: 'undefined',
        fillOpacity: 100,
        hoverCallback: function (index, options, content, row) {
            return "+" + number_format(row.y, 2, ',', ' ');
        }
    });

    $(".graph_currency").on("click", function () {

        $(".graph_currency").removeClass("active_graph");
        $(this).addClass("active_graph");
        val = $(this).data("val");
        $(".chart_visible").css("display", "none");
        $("#graph" + val).fadeIn(1500).css("display", "block");
        ion.sound.play("wuf-3");
        //$(".graph"+val).css("display", "block");

    });

    function Values(val) {
        $(".chart_visible").css("display", "none");
        $("#graph" + val).css("display", "block");
    }


    $(document).ready(function () {
        Values('<?php echo strtoupper(escape($val)); ?>');

    });


    $(".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>
