<?php
session_start();
require_once '../../../../classconn/class.user.php';
require_once '../../../../action/usercontrol/setup.php';
require_once '../../../../action/sessiontimer/intimer.php';
require_once '../../../../action/usercontrol/logout.php';
require_once '../../../../action/getIP/ip.php';
//retrieve users latest 5 referrals
$stmt = $actionParam->runQuery("SELECT * FROM tbl_user WHERE ref_email=:email ORDER BY userID DESC LIMIT 5");
$stmt->execute(array(":email"=>$uemail));
$refRow=$stmt->fetchAll(PDO::FETCH_ASSOC);

$stmt = $actionParam->runQuery("SELECT SUM(amount) as amount FROM tbl_earning WHERE email=:email");
$stmt->execute(array(":email"=>$uemail));
$profitRow=$stmt->fetch(PDO::FETCH_ASSOC);

//retrieve user's investment history
$stmt = $actionParam->runQuery("SELECT * FROM tbl_earning WHERE email=:email ORDER BY userID DESC LIMIT 7");
$stmt->execute(array(":email"=>$uemail));
$investRow=$stmt->fetchAll(PDO::FETCH_ASSOC);


if(isset($_POST['btn-withdraw'])){
    header("Location: withdraw");
    exit;
}
$price_in_btc = file_get_contents("https://blockchain.info/tobtc?currency=USD&value=" . ($userRow['balance']));
?>

<!DOCTYPE html>
<html lang="en">


<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Sescentigate | Member Dashboard </title>
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="images/favicon.png">
    <!-- Custom Stylesheet -->
    <link rel="stylesheet" href="vendor/nice-select/css/nice-select.css">
    <link rel="stylesheet" href="vendor/waves/waves.min.css">
    <link rel="stylesheet" href="css/style.css">
</head>

<body>

    <div id="preloader">
        <div class="sk-three-bounce">
            <div class="sk-child sk-bounce1"></div>
            <div class="sk-child sk-bounce2"></div>
            <div class="sk-child sk-bounce3"></div>
        </div>
    </div>

    <div id="main-wrapper">

        <div class="header dashboard">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-xl-12">
                        <nav class="navbar navbar-expand-lg navbar-light px-0 justify-content-between">
                            <a class="navbar-brand" href="index"><img src="images/logo.png" alt=""></a>

                            <div class="header-right d-flex my-2 align-items-center">
                                <div class="language">
                                    <div class="dropdown">
                                       
                                    </div>
                                </div>
                                <div class="dashboard_log">
                                    <div class="profile_log dropdown">
                                        <div class="user" data-toggle="dropdown">
                                            <span class="thumb"><i class="mdi mdi-account"></i></span>
                                            <span class="arrow"><i class="la la-angle-down"></i></span>
                                        </div>

                                        <div class="dropdown-menu dropdown-menu-right">
                                            <div class="user-email">
                                                <div class="user">
                                                    <i class="thumb"><i class="mdi mdi-account"></i></i>
                                                    <div class="user-info">
                                                        <h6><?php echo ucfirst($userRow['fullname']); ?></h6>
                                                        <span><?php echo ucfirst($userRow['email']); ?></span>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="user-balance">
                                                <div class="available">
                                                    <p>Available</p>
                                                    <span><?php echo number_format($userRow['balance'],2); ?> USD</span>
                                                </div>
                                                <div class="total">
                                                    <p>Total Profits</p>
                                                    <span><?php echo number_format($userRow['profit'],2); ?> USD</span>
                                                </div>
                                            </div>
                                            <a href="profilesettings" class="dropdown-item">
                                                <i class="mdi mdi-account"></i> Profile
                                            </a>
                                            <a href="deposits" class="dropdown-item">
                                                <i class="mdi mdi-history"></i> History
                                            </a>
                                            <a href="?logout" class="dropdown-item logout">
                                                <i class="mdi mdi-logout"></i> Logout
                                            </a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </nav>
                    </div>
                </div>
            </div>
        </div>

        <div class="sidebar">
            <div class="menu">
                <ul>
                    <li>
                        <a href="index" data-toggle="tooltip" data-placement="right" title="Dashboard">
                            <span><i class="mdi mdi-view-dashboard"></i></span>
                        </a>
                    </li>
                    <li>
                        <a href="depositfunds" data-toggle="tooltip" data-placement="right" title="Deposit">
                            <span><i class="mdi mdi-face-profile"></i></span>
                        </a>
                    </li>

                    <li>
                        <a href="crypto" data-toggle="tooltip" data-placement="right" title="Buy Crypto">
                            <span><i class="mdi mdi-tumblr-reblog"></i></span>
                        </a>
                    </li>
                    <li>
                        <a href="deposits" data-toggle="tooltip" data-placement="right" title="Transactions">
                            <span><i class="mdi mdi-database"></i></span>
                        </a>
                    </li>
                    <li>
                        <a href="profilesettings" data-toggle="tooltip" data-placement="right" title="Profile">
                            <span><i class="mdi mdi-account"></i></span>
                            
                        </a>
                    </li>
                    <li>
                        <a href="?logout" data-toggle="tooltip" data-placement="right" title="Logout">
                            <span><i class="mdi mdi-power"></i></span>
                        </a>
                    </li>
                </ul>
            </div>
        </div>

        <div class="page-title dashboard">
            <div class="container">
                <div class="row">
                    <div class="col-6">
                        <div class="page-title-content">
                            <p>Welcome Back,
                                <span> <?php echo ucfirst($userRow['fullname']); ?></span>
                            </p>
                        </div>
                    </div>
                    <div class="col-6">
                        <ul class="text-right breadcrumbs list-unstyle">
                            
                            
                        </ul>
                    </div>
                </div>
            </div>
        </div>

        <div class="content-body">
            <div class="container">
                <div class="row">
                    <div class="col-xl-12">
                        <div class="card sub-menu">
                            <div class="card-body">
                                <ul class="d-flex">
                                    
                                    <li class="nav-item">
                                        <a href="depositfunds" class="nav-link">
                                            <i class="mdi mdi-heart"></i>
                                            <span>Deposit</span>
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a href="withdraw" class="nav-link">
                                            <i class="mdi mdi-pentagon"></i>
                                            <span>Withdraw</span>
                                        </a>
                                    </li>
                                    
                                    <li class="nav-item">
                                        <a href="invest" class="nav-link">
                                            <i class="mdi mdi-diamond"></i>
                                            <span>Invest</span>
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>

                    <div class="col-xl-6 col-lg-6 col-md-6">
                        <div class="card profile_card">
                            <div class="card-body">
                                <div class="media">
                                    <img class="mr-3 rounded-circle mr-0 mr-sm-3" src="" width=""
                                        height="" alt="">
                                    <div class="media-body">
                                        <span>Hello</span>
                                        <h4 class="mb-2"><?php echo ucfirst($userRow['fullname']); ?></h4>
                                        <p class="mb-1"> <span><i class="fa fa-phone mr-2 text-primary"></i></span><?php echo ucfirst($userRow['phone']); ?></p>
                                        <p class="mb-1"> <span><i class="fa fa-envelope mr-2 text-primary"></i></span>
                                        <?php echo ucfirst($userRow['email']); ?>  
                                        </p>                                        
                                    </div>
                                </div>

                                <ul class="card-profile__info">
                                    <li>
                                        <h5 class="mr-4">Country</h5>
                                        <span class="text-muted"><?php echo ucfirst($userRow['country']); ?></span>
                                    </li>
                                   
                                    <li>
                                        <h5 class="mr-4">IP Address</h5>
                                        <span class="text-success"><?php echo $ip_address; ?>
                                        </span>
                                    </li>
                                </ul>
                                
                                <div class="social-icons">
                                   
                                   
                                </div>
                            </div>
                        </div>
                    </div>


                    <div class="col-xl-6 col-lg-6 col-md-6">
                        <div class="card acc_balance">
                            <div class="card-header">
                                <h4 class="card-title">Wallet</h4>
                            </div>
                            <div class="card-body">
                                <span>Available BTC</span>
                                <h3> <?php echo round($price_in_btc,4); ?> BTC</h3>

                                <div class="d-flex justify-content-between my-3">
                                    <div>
                                        <p class="mb-1">Minimum Deposit</p>
                                        <h4>1000 USD</h4>
                                    </div>
                                    <div>
                                        <p class="mb-1">Minimum Withdrawal</p>
                                        <h4>50 USD</h4>
                                    </div>
                                </div>

                               

                                <div class="btn-group mb-3">
                                    <button class="btn btn-success" onclick="location.href='depositfunds';">Deposit</button>
                                    <button class="btn btn-danger" onclick="location.href='withdraw';">Withdraw</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xl-12">
                    <!-- TradingView Widget BEGIN -->
                    <div class="tradingview-widget-container mb-4">
                                  <div class="tradingview-widget-container__widget"></div>
                                  <script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-ticker-tape.js" async>
                                  {
                                  "symbols": [
                                    {
                                      "proName": "FOREXCOM:SPXUSD",
                                      "title": "S&P 500"
                                    },
                                    {
                                      "proName": "FOREXCOM:NSXUSD",
                                      "title": "Nasdaq 100"
                                    },
                                    {
                                      "proName": "FX_IDC:EURUSD",
                                      "title": "EUR/USD"
                                    },
                                    {
                                      "proName": "BITSTAMP:BTCUSD",
                                      "title": "BTC/USD"
                                    },
                                    {
                                      "proName": "BITSTAMP:ETHUSD",
                                      "title": "ETH/USD"
                                    }
                                  ],
                                  "showSymbolLogo": true,
                                  "colorTheme": "light",
                                  "isTransparent": false,
                                  "displayMode": "regular",
                                  "locale": "en"
                                }
                        </script>
                                 </div>
                            </div><br><br>
                                <!-- TradingView Widget END -->

                    <div class="col-xl-12">
                        <div class="row">
                            <div class="col-xl-3 col-lg-3 col-md-3 col-sm-6">
                                <div class="card text-center pt-2">
                                    <div class="card-body">
                                        <p class="mb-1">BALANCE</p>
                                        <h4>$ <?php echo number_format($userRow['balance'],2); ?></h4>
                                    </div>
                                </div>
                            </div>
                            <div class="col-xl-3 col-lg-3 col-md-3 col-sm-6">
                                <div class="card text-center pt-2">
                                    <div class="card-body">
                                        <p class="mb-1">PROFITS</p>
                                        <h4>$ <?php echo number_format($userRow['profit'],2); ?></h4>
                                    </div>
                                </div>
                            </div>
                            <div class="col-xl-3 col-lg-3 col-md-3 col-sm-6">
                                <div class="card text-center pt-2">
                                    <div class="card-body">
                                        <p class="mb-1">LAST DEPOSIT</p>
                                        <h4>$ <?php echo number_format($userRow['last_deposite'],2); ?></h4>
                                    </div>
                                </div>
                            </div>
                            <div class="col-xl-3 col-lg-3 col-md-3 col-sm-6">
                                <div class="card text-center pt-2">
                                    <div class="card-body">
                                        <p class="mb-1">LAST WITHDRAWAL</p>
                                        <h4>$ <?php echo number_format($userRow['last_withdrawal'],2); ?></h4>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-xl-12">
                                <!-- TradingView Widget BEGIN -->
                                <div class="tradingview-widget-container">
                                <div class="tradingview-widget-container__widget"></div>
                                <div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/" rel="noopener nofollow" target="_blank"><span class="blue-text"></span></a></div>
                                <script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-market-overview.js" async>
                                {
                                "colorTheme": "light",
                                "dateRange": "12M",
                                "showChart": true,
                                "locale": "en",
                                "largeChartUrl": "",
                                "isTransparent": false,
                                "showSymbolLogo": true,
                                "showFloatingTooltip": false,
                                "width": "100%",
                                "height": "660",
                                "plotLineColorGrowing": "rgba(41, 98, 255, 1)",
                                "plotLineColorFalling": "rgba(41, 98, 255, 1)",
                                "gridLineColor": "rgba(240, 243, 250, 0)",
                                "scaleFontColor": "rgba(106, 109, 120, 1)",
                                "belowLineFillColorGrowing": "rgba(41, 98, 255, 0.12)",
                                "belowLineFillColorFalling": "rgba(41, 98, 255, 0.12)",
                                "belowLineFillColorGrowingBottom": "rgba(41, 98, 255, 0)",
                                "belowLineFillColorFallingBottom": "rgba(41, 98, 255, 0)",
                                "symbolActiveColor": "rgba(41, 98, 255, 0.12)",
                                "tabs": [
                                    {
                                    "title": "Indices",
                                    "symbols": [
                                        {
                                        "s": "FOREXCOM:SPXUSD",
                                        "d": "S&P 500"
                                        },
                                        {
                                        "s": "FOREXCOM:NSXUSD",
                                        "d": "US 100"
                                        },
                                        {
                                        "s": "FOREXCOM:DJI",
                                        "d": "Dow 30"
                                        },
                                        {
                                        "s": "INDEX:NKY",
                                        "d": "Nikkei 225"
                                        },
                                        {
                                        "s": "INDEX:DEU40",
                                        "d": "DAX Index"
                                        },
                                        {
                                        "s": "FOREXCOM:UKXGBP",
                                        "d": "UK 100"
                                        }
                                    ],
                                    "originalTitle": "Indices"
                                    },
                                    {
                                    "title": "Futures",
                                    "symbols": [
                                        {
                                        "s": "CME_MINI:ES1!",
                                        "d": "S&P 500"
                                        },
                                        {
                                        "s": "CME:6E1!",
                                        "d": "Euro"
                                        },
                                        {
                                        "s": "COMEX:GC1!",
                                        "d": "Gold"
                                        },
                                        {
                                        "s": "NYMEX:CL1!",
                                        "d": "WTI Crude Oil"
                                        },
                                        {
                                        "s": "NYMEX:NG1!",
                                        "d": "Gas"
                                        },
                                        {
                                        "s": "CBOT:ZC1!",
                                        "d": "Corn"
                                        }
                                    ],
                                    "originalTitle": "Futures"
                                    },
                                    {
                                    "title": "Bonds",
                                    "symbols": [
                                        {
                                        "s": "CBOT:ZB1!",
                                        "d": "T-Bond"
                                        },
                                        {
                                        "s": "CBOT:UB1!",
                                        "d": "Ultra T-Bond"
                                        },
                                        {
                                        "s": "EUREX:FGBL1!",
                                        "d": "Euro Bund"
                                        },
                                        {
                                        "s": "EUREX:FBTP1!",
                                        "d": "Euro BTP"
                                        },
                                        {
                                        "s": "EUREX:FGBM1!",
                                        "d": "Euro BOBL"
                                        }
                                    ],
                                    "originalTitle": "Bonds"
                                    },
                                    {
                                    "title": "Forex",
                                    "symbols": [
                                        {
                                        "s": "FX:EURUSD",
                                        "d": "EUR to USD"
                                        },
                                        {
                                        "s": "FX:GBPUSD",
                                        "d": "GBP to USD"
                                        },
                                        {
                                        "s": "FX:USDJPY",
                                        "d": "USD to JPY"
                                        },
                                        {
                                        "s": "FX:USDCHF",
                                        "d": "USD to CHF"
                                        },
                                        {
                                        "s": "FX:AUDUSD",
                                        "d": "AUD to USD"
                                        },
                                        {
                                        "s": "FX:USDCAD",
                                        "d": "USD to CAD"
                                        }
                                    ],
                                    "originalTitle": "Forex"
                                    }
                                ]
                                }
                  </script>
                         </div>
                               </div>
<!-- TradingView Widget END -->
     <!-- TradingView Widget BEGIN -->
<!-- <div class="tradingview-widget-container">
  <div class="tradingview-widget-container__widget"></div>
  <div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/markets/currencies/forex-cross-rates/" rel="noopener" target="_blank"><span class="blue-text"></span></a></div>
  <script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-forex-cross-rates.js" async>
  {
  "width": "100%",
  "height": 400,
  "currencies": [
    "EUR",
    "USD",
    "JPY",
    "GBP",
    "CHF",
    "AUD",
    "CAD",
    "NZD",
    "CNY"
  ],
  "isTransparent": false,
  "colorTheme": "white",
  "locale": "en"
}
  </script>
</div> -->
<!-- TradingView Widget END -->
                    <!-- <div class="col-xl-12">
                        <div class="card">
                            <div class="card-header">
                                <h4 class="card-title">Earnings History</h4>
                            </div>
                            <div class="card-body">
                                <div class="transaction-table">
                                    <div class="table-responsive">
                                        <table class="table table-striped mb-0 table-responsive-sm">
                                            <thead>
                                                <tr>
                                                    <th>ID</th>
                                                    <th>Amount</th>
                                                    <th>Type</th>
                                                    <th>Date</th>
                                                    <th>Status</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                            <?php $count = 1; ?>
                                     <?php foreach($investRow as $row){ ?>
                                                <tr>
                                                    <td><?php echo $count; ?></td>
                                                    <td>$<?php echo number_format($row['amount'],2); ?></td>
                                                    <td><?php echo $row['type']; ?></td>
                                                    <td><?php echo $row['date']; ?></td>
                                                    <td>Completed</td>
                                                </tr>
                                                <?php $count++; ?>
                                                  <?php } ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
  -->
        <br>

        <div class="col-xl-12">
                        <div class="card">
                            <div class="card-header">
                                <h4 class="card-title">Affiliate Program</h4>
                            </div>
                            <div class="card-body">
                                <div class="row justify-content-between">
                                    <div class="col-xl-6 col-lg-6">
                                        <h5>Affiliate Link</h5>
                                        <p>Copy and paste this link to send to friends or use in your articles. When
                                            users sign up using this link, your account will be credited with a 3% referral
                                            bonus.</p>
                                    </div>
                                    <div class="col-xl-5 col-lg-6">
                                        <h5>Share your link</h5>
                                        <form action="#">
                                            <div class="input-group">
                                                <input type="text" class="form-control"
                                                    value="https://<?php echo $_SERVER['HTTP_HOST']; ?>/register?referral=<?php echo $uemail; ?>">
                                                <div class="input-group-append">
                                                    <button type="button" class="input-group-text bg-primary text-white">Copy</button>
                                                </div>
                                            </div>
                                            <script>
                                        var copyTextareaBtn = document.querySelector('.input-group-text');

                                        copyTextareaBtn.addEventListener('click', function(event) {
                                          var copyTextarea = document.querySelector('.form-control');
                                          copyTextarea.select();

                                          try {
                                            var successful = document.execCommand('copy');
                                            var msg = successful ? 'successful' : 'unsuccessful';
                                            console.log('Copying text command was ' + msg);
                                          } catch (err) {
                                            console.log('Oops, unable to copy');
                                          }
                                        });
                                    </script>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>


        <div class="footer dashboard">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-sm-8 col-12">
                        <div class="copyright">
                            <p>© Copyright
                                <script>
                                    var CurrentYear = new Date().getFullYear()
                                    document.write(CurrentYear)
                                </script> <a href="https://sescentigate.com">Sescentigate</a> All Rights Reserved
                            </p>
                        </div>
                    </div>
                    <div class="col-sm-4 col-12">
                        <div class="footer-social">
                            <ul>
                            <div id="google_translate_element"></div>
                    <script type="text/javascript">
                    function googleTranslateElementInit() {
                      new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
                    }
                    </script>

                    <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>  
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    

<!--Start of Tawk.to Script-->
<script type="text/javascript">
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
(function(){
var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
s1.async=true;
s1.src='https://embed.tawk.to/69b3c9713a61e31c3587d370/1jjj4lpgk';
s1.charset='UTF-8';
s1.setAttribute('crossorigin','*');
s0.parentNode.insertBefore(s1,s0);
})();
</script>
<!--End of Tawk.to Script-->

    <script src="js/global.js"></script>

    <script src="vendor/waves/waves.min.js"></script>

    <script src="js/scripts.js"></script>
</body>


</html>