<?php
        session_start();
        require_once($_SERVER['DOCUMENT_ROOT'] . '/conf.php');

        if (!auth_is_user()) {
            redirect("/");
        }

        if (session("groups") !== "admin") {
            redirect('/');
        }

        require_once($_SERVER['DOCUMENT_ROOT'] . "/adg/framework_admin/forms.php");
        require_once($_SERVER['DOCUMENT_ROOT'] . "/adg/framework_admin/form_handlers.php");

        if (isset($_POST['data'])) {
            $list = $_POST['data'];
        }
        //обычный перебор
        foreach($list as $item) {
?>
    <tr style="<?php if($item['new']) { echo 'background-color: rgb(160, 255, 121);'; }?>">
        <td><?php echo (int)$item['id']; ?></td>
        <td><?php echo button_payment($item['id']); ?></td>
        <td>
            <form action="?page=<?php echo "item_users"; ?>" method="post">
                <?php echo form_init(); ?>
                <input type = "hidden" name = "id" value = "<?php echo (int)login_id($item['login']); ?>">
                <button type="submit" style="border:none;background:none;"><?php echo escape($item['login']); ?></button>
            </form>
        </td>
        <td>
            <form action="?page=<?php echo "item_users"; ?>" method="post">
                <?php echo form_init(); ?>
                <input type = "hidden" name = "id" value = "<?php echo (int)login_id(login_refer_login($item['login'])); ?>">
                <button type="submit" style="border:none;background:none;"><?php echo escape(login_refer_login($item['login'])); ?></button>
            </form>
        </td>
        <td style="min-width: 110px;">
            <?php
            if ($val === 'RUB') {
                echo '<i class="fa fa-rub"></i> '.format_currency($item['summa'], $val);
                if ($item['system'] === "PerfectMoney") {
                    echo '<br><i class="fa fa-usd"></i> '.format_currency(bm_convert_rub_2_usd($item['summa']), "usd");
                }
                if ($item['system'] === "BitCoin") {
                    echo '<br><i class="fa fa-btc"></i> '.format_currency(bm_convert_rub_2_btc($item['summa']), "btc");
                }
            }

            if ($val === 'USD') {
                echo '<i class="fa fa-usd"></i> '.format_currency($item['summa'], $val);
                if ($item['system'] === "Qiwi" || $item['system'] === 'YandexMoney') {
                    echo '<br><i class="fa fa-rub"></i> '.format_currency(bm_convert_usd_2_rub($item['summa']), "rub");
                }
                if ($item['system'] === "BitCoin") {
                    echo '<br><i class="fa fa-btc"></i> '.format_currency(bm_convert_usd_2_btc($item['summa']), "btc");
                }
            }
    //foreach(get_payment_adg(0) as $item) {

            if ($val === 'BTC') {
                echo '<i class="fa fa-btc"></i> '.format_currency($item['summa'], $val);
                /*
                if ($item['system'] === 'PerfectMoney') {
                    $summa = $item['summa'];
                    echo (float)$summa.'<br /><i class="fa fa-usd"></i>'.format_currency(bm_convert_btc_2_usd($summa), 'usd');
                } else if ($item['system'] === 'BitCoin') {
                    echo format_currency($item['summa'], 'btc');
                } else {
                    $summa = $item['summa'];
                    echo (float)$summa.'<br /><i class="fa fa-rub"></i>'.format_currency(bm_convert_btc_2_rub($summa), 'rub');
                }*/
            }
            ?>
        </td>
        <td><?php echo format_date($item['date']);?></td>
        <td><?php echo escape($item['system']); ?></td>
        <td><?php echo escape($item['wallet']); ?></td>
        <?php
        $color = login_check_chain_ip($item['login'], $item['ip']);
        ?>
        <td <?php echo $color;?>><?php echo escape($item['ip']); ?></td>
        <td <?php echo $color;?>><?php echo login_reg_ip(login_refer_login($item['login'])); ?></td>
        <td><?php echo button_delete(escape($item['id'])); ?></td>
    </tr>
<?php } ?>