<?php
session_start();
date_default_timezone_set("Africa/Lagos");
require_once '../include/Constants.php';
require_once "../vendor/autoload.php";
require_once "../include/DatabaseConn.php";
require_once "../models/User.php";
require_once '../models/USettings.php';
require_once '../include/GoogleAuthenticator.php';
require_once '../models/Settings.php';
require_once '../models/Investment.php';
require_once '../models/Invoice.php';

$db = new DatabaseConn();
$link = $db->connect();

$user = User::getCurrentUser($link);
if (is_null($user)) {
    $url = $_SERVER['REQUEST_URI'];
    header("location: ../login?" . RETURN_URL . "=" . $url);
    die();
}

$settings = USettings::getSystemSettings($link, $user->getEmail());
if ($settings->getTwofa() && is_null($user->getFa())) {
    header("location: add-2fa");
    die();
}
?>
<!DOCTYPE html>

<html>
    <head>
        <?php
        require_once './partials/head.php';
        ?>
        <link href="../css/form.css" rel="stylesheet" type="text/css"/>
        <link href="../css/component.css" rel="stylesheet" type="text/css"/>
        <style>
            #select2-list-container {
                background-color: #2a2e39;
                border: 1px solid #2a2e39;
                color: #fff !important;
                border-radius: 2px;
            }
        </style>
    </head>
    <body>
        <div id="app">
            <?php require_once './partials/header.php'; ?>
            <div class="settings mtb15">
                <div class="container-fluid mtb15 no-fluid main-container" id="container" style="padding: 0;">
                    <?php require_once './partials/side.php'; ?>
                    <div class="content main-content" id="content" style="padding: 10px;">
                        <div class="row">

                            <div class="tab-pane col-md-12 col-lg-12" id="settings-wallet" role="tabpanel" aria-labelledby="settings-wallet-tab">
                                <div class="wallet">
                                    <div class="">
                                        <div class="tab-content">
                                            <div class="tab-pane fade show active" id="coinBTC" role="tabpanel">
                                                <div class="card">
                                                    <div class="card-body">
                                                        <div class="row wallet-address">
                                                            <div class="col-md-12 settings-profile">
                                                                <form class="form-horizontal" id="fmm" action="payment-options?gae=<?php
                                                                if (isset($_GET['gae'])) {
                                                                    echo ($_GET['gae']);
                                                                }
                                                                ?>" method="POST">
                                                                    <div class="form-group">
                                                                        <label class="control-label col-md-5">Minimum Investment  ($)</label>
                                                                        <div class="col-md-7">
                                                                            <input class="form-control" type="text" value="<?php echo "{$setting->getMin()}"; ?>" disabled="">
                                                                        </div>
                                                                    </div>
                                                                    <div class="form-group">
                                                                        <label class="control-label col-md-5">Maximum Investment  ($)</label>
                                                                        <div class="col-md-7">
                                                                            <input class="form-control" type="text" value="<?php echo "{$setting->getMax()}"; ?>" disabled="">
                                                                        </div>
                                                                    </div>
                                                                    <div class="form-group">
                                                                        <label class="control-label col-md-5">Enter Amount to Invest  ($)</label>
                                                                        <div class="col-md-7">
                                                                            <input class="form-control" type="text" name="amount" required="">
                                                                        </div>
                                                                    </div>
                                                                    <input type="hidden" name="package_type" id="pt" value="" />
                                                                    <div class="form-group">
                                                                        <label class="control-label col-md-3">Pay Through</label>
                                                                        <div class="col-md-9">
                                                                            <div class="radio-inline">
                                                                                <label>
                                                                                    <input style="vertical-align: middle; " type="radio" name="account22" value="wallet" required=""> Use Balance on Wallet (USD <?php echo User::getWalletBalance($link, $user->getEmail()); ?>)
                                                                                </label>
                                                                            </div>
                                                                            <div class="radio-inline">
                                                                                <label>
                                                                                    <input style="vertical-align: middle;" type="radio" name="account22" value="md" required=""> Manual Deposit through other wallet (Blockchain, Coinbase, etc).
                                                                                </label>
                                                                            </div>
                                                                        </div>
                                                                        <div class="col-md-8 col-md-offset-3">
                                                                            <button class="btn btn-primary icon-btn" id="btt" type="submit" name="save_btn"><i class="fa fa-fw fa-lg fa-check-circle"></i>INVEST</button>

                                                                        </div>

                                                                    </div>
                                                                </form>
                                                            </div>

                                                        </div>

                                                    </div>
                                                </div>
                                            </div>
                                            <form id="fm" action="investment-plans?plan=<?php
                                            if (isset($_GET['plan'])) {
                                                echo ($_GET['plan']);
                                            }
                                            ?>" method="POST">
                                                <input type="hidden" name="package_type" id="pt" value="" />

                                            </form>
                                        </div>
                                        <footer style="position: fixed;bottom: 0;right: 0; margin-right: 10px">
                                            <p style="text-align: right; color: white; font-size: 12px;"><?php echo APP_NAME; ?> Copyright 2020. All right reserved.</p>
                                        </footer>
                                    </div>
                                </div>
                            </div>
                        </div
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php require_once './partials/scripts.php'; ?>

</body>
</html>
