<?php require_once(THEME_ROOT . '/blocks/head.php'); ?>
<?php require_once(THEME_ROOT . '/blocks/top.php'); ?>

    <br><br>
    <div class="container">
        <div class="row">
            <div class="main" style="text-align:center;">
                <h3><?php echo T('Вывод средств'); ?></h3>
            </div>
            <div class="row">
                <div class="col-sm-12 col-md-12">

                    <?php $is_payment = is_open("payment");
                    if ($is_payment["error"]) {
                        echo flash_show();
                    } else { ?>

                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">
                                    <?php echo T('Вывести средства'); ?>
                                </h3>
                            </div>

                            <div class="panel-body text-center">
                                <div class="row">
                                    <?php echo flash_show('payment'); ?>
                                    <form method="post" action="/handlers/user/payment.php">
                                        <?php echo form_init(); ?>

                                        <div class="col-lg-4 col-sm-6">
                                            <select name="system" class="form-control" style="width: 100%;" required>
                                                <option>- <?php echo T('Выберите Систему'); ?> -</option>

                                                <?php foreach (get_payment_system('payment') as $item) { ?>
                                                    <?php if (login_get_wallet($login, $item['value'])) { ?>
                                                        <option
                                                                value="<?php echo escape($item['value']); ?>"
                                                                <?php if (escape(post('system')) == $item['value']) { echo 'selected'; } ?>>

                                                            <?php echo escape($item['value']); ?>
                                                            (<?php echo login_get_wallet($login, $item['value']); ?>)
                                                            <?php echo T('доступно:'); ?>
                                                            <?php echo format_currency(login_summa_balans_system($login, $item['value']), $val).' '.escape($val); ?>
                                                        </option>
                                                    <?php } ?>
                                                <?php } ?>
                                            </select>
                                        </div>


                                        <div class="col-lg-4 col-sm-6">
                                            <div class="input-group" style="width: 100%;">
                                                <span class="input-group-addon">
                                                    <?php echo html($valu); ?>
                                                </span>
                                                <input
                                                        type="text" name="amount"
                                                        value="<?php echo escape(post('amount')); ?>"
                                                        placeholder="- <?php echo T("Введите сумму"); ?> -"
                                                        class="form-control"
                                                        required>
                                            </div>
                                        </div>

                                        <div class="col-lg-4 col-sm-6">
                                            <input
                                                    type="submit"
                                                    value="<?php echo T('Вывести'); ?>"
                                                    class="btn btn-default"
                                                    style="width: 100%;">
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    <?php } ?>
                </div>


                <div class="col-sm-12 col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title">
                                <?php echo T('История выплат'); ?>
                            </h3>
                        </div>

                        <div class="table-responsive">
                            <table class="table table-bordered table-hover" style="margin-bottom: 0px; text-align: center;">
                                <thead>
                                <tr>
                                    <td><?php echo T('Сумма').' ('.html($valu).')'; ?></td>
                                    <td><?php echo T('Дата'); ?></td>
                                    <td><?php echo T('Система'); ?></td>
                                    <td><?php echo T('Кошелек'); ?></td>
                                    <td><?php echo T('Статус'); ?></td>
                                </tr>
                                </thead>
                                <tbody>
                                <?php
                                $list = login_list_payment($login);
                                if ($list) {
                                    foreach ($list as $item) { ?>
                                        <tr style="text-align: center;">
                                            <td><?php echo format_currency($item['summa'], $val); ?></td>
                                            <td><?php echo format_date($item['date']); ?></td>
                                            <td>
                                                <svg width="57" height="20" role="img"> <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#bm_icon_payment_colored_<?php echo strtolower(escape($item['system'])); ?>"></use> </svg>
                                            </td>
                                            <td><?php echo escape($item['wallet']); ?></td>
                                            <td><?php echo $item['status'] ? T('Успешно') : T('Ожидает'); ?></td>
                                        </tr>
                                    <?php }
                                } else { ?>
                                    <tr>
                                        <td colspan="5" class="danger" align="center"><?php echo T('Записей не обнаружено'); ?></td>
                                    </tr>
                                <?php } ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


<?php require_once(THEME_ROOT . "/blocks/footer.php"); ?>