<?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">
                <?php foreach (get_plans() as $item) { ?>
                    <div class="col-sm-12 col-md-4">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">
                                    <?php echo T($item['description']); ?>
                                </h3>
                            </div>

                            <div class="panel-body">
                                <?php /* <?php if ($item['img'] !== '') { ?>
                                     <div style="text-align:center;">
                                         <img class="img-responsive" style="height: 250px;" src="<?php echo escape($item['img']); ?>">
                                     </div>
                                 <?php } ?> */ ?>
                                <div style="width: 200px;height: 200px;background: #666666;border-radius: 50%;margin: 0 auto;color: white;font-size: 56px;text-align: center;line-height: 200px;">
                                    <?php if ($item['count']) {
                                        echo (float)($item['percent']*$item['count'] - !$item['return']*100);
                                    } else {
                                        echo (float)$item['percent'];
                                    } ?>%
                                </div>
                                <br>
                                <ul class="list-group" style="margin-bottom: 0;">
                                    <li class="list-group-item">
                                        <?php echo T('Срок действия'); ?>
                                        <span class="badge">
                                            <?php if ($item['count']) {
                                                echo val_seconds($item['seconds']*$item['count']);
                                            } else {
                                                echo val_seconds($item['seconds']);
                                            } ?>
                                        </span>
                                    </li>
                                    <li class="list-group-item">
                                        <?php echo T('Ежедневная выплата'); ?>
                                        <span class="badge">
                                            <?php echo (float)$item['percent']; ?>%
                                        </span>
                                    </li>
                                    <li class="list-group-item">
                                        <?php echo T('Минимальная сумма'); ?>
                                        <span class="badge">
                                            <?php echo format_currency($item['min'], $val).' '.html($valu); ?>
                                        </span>
                                    </li>
                                    <li class="list-group-item">
                                        <?php echo T('Максимальная сумма'); ?>
                                        <span class="badge">
                                            <?php echo format_currency($item['max'], $val) . ' ' . html($valu); ?>
                                        </span>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                <?php } ?>


                <div class="col-sm-12 col-md-12">

                    <?php $is_invest = is_open("invest");
                    if ($is_invest["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('invest'); ?>
                                    <form method="post" action="/pay/index.php">
                                        <?php echo form_init(); ?>
                                        <?php if ($settings_define_show_get_plans) { ?>
                                            <div class="col-lg-3 col-sm-6">
                                                <select name="plan" class="form-control" style="width: 100%;" required>
                                                    <option>- <?php echo T('Выберите План'); ?> -</option>
                                                    <?php foreach (get_plans() as $item) { ?>
                                                        <option
                                                                value="<?php echo (int)$item["id"]; ?>"
                                                                <?php if (escape(post('plan')) === $item['id']) { echo 'selected'; } ?>>

                                                            <?php echo translate_dinamic(escape($item["description"])); ?>
                                                        </option>
                                                    <?php } ?>
                                                </select>
                                            </div>
                                        <?php } ?>


                                        <div class="col-lg-3 col-sm-6">
                                            <select name="system" class="form-control" style="width: 100%;" required>
                                                <option>- <?php echo T('Выберите Систему'); ?> -</option>
                                                <?php foreach (get_payment_system('invest') as $item) { ?>
                                                    <option
                                                            value="<?php echo escape($item['value']); ?>"
                                                            <?php if (escape(post('system')) === $item['value']) { echo 'selected'; } ?>>

                                                        <?php echo escape($item['value']); ?>
                                                    </option>
                                                <?php } ?>
                                            </select>
                                        </div>


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

                                        <div class="col-lg-3 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('Дата'); ?></td>
                                        <td><?php echo T('Сумма').' ('.html($valu).')'; ?></td>
                                        <td><?php echo T('Система'); ?></td>
                                        <td><?php echo T('Статус'); ?></td>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    $list = login_list_invest($login);
                                    if ($list) {
                                        foreach ($list as $item) { ?>
                                            <tr style="text-align: center;">
                                                <td><?php echo format_date($item['date']); ?></td>
                                                <td><?php echo format_currency($item['summa'], $val); ?></td>
                                                <td><?php echo escape($item['system']); ?></td>
                                                <td><?php echo $item['status'] ? T('Успешно') : T('Ожидает'); ?></td>
                                            </tr>
                                        <?php }
                                    } else { ?>
                                        <tr>
                                            <td colspan="4" 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"); ?>