<?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';
//users withdrawals
$stmt = $actionParam->runQuery("SELECT * FROM tbl_withdrawal WHERE email=:email ORDER BY userID DESC");
$stmt->execute(array(":email"=>$uemail));
$withdrawRow=$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);
?>

<!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 | Withdrawals</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>
                                <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">
                            
                            <li class="active"><a href="#">Withdrawal History</a></li>
                        </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="deposits" class="nav-link">
                                            <i class="mdi mdi-database-plus"></i>
                                            <span>Deposits</span>
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a href="withdrawals" class="nav-link">
                                            <i class="mdi mdi-book"></i>
                                            <span>Withdrawals</span>
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a href="investments" class="nav-link">
                                            <i class="mdi mdi-book-multiple"></i>
                                            <span>Investments</span>
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a href="earnings" class="nav-link">
                                            <i class="mdi mdi-file-export"></i>
                                            <span>Earnings</span>
                                        </a>
                                        <div class="dropdown-menu dropdown-menu-right">
                                            <a class="dropdown-item" href="data-last-price.html">Last Price</a>
                                            <a class="dropdown-item" href="data-index-price.html">Index Price</a>
                                            <a class="dropdown-item" href="data-mark-price.html">Mark Price</a>
                                            <!-- <a class="dropdown-item" href="#">Founding Rate</a> -->
                                        </div>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <div class="col-xl-12">
                        <div class="card">
                            <div class="card-header">
                                <h4 class="card-title">Withdrawal History</h4>
                            </div>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table class="table table-striped">
                                        <thead>
                                            <tr>
                                                <th>S/N</th>
                                                <th>Order</th>
                                                <th>USD</th>
                                                <th>BTC</th>
                                                <th>Status</th>
                                                <th>Date</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php $count = 1; ?>
                            <?php foreach($withdrawRow as $row){ ?>
                            <?php
                            $price_in_btc = file_get_contents("https://blockchain.info/tobtc?currency=USD&value=" . $row['amount']);
                            ?>
                                                <tr>
                                                    <td><?php echo $count; ?></td>
                                                    <td><?php echo $row['orderID']; ?></td>
                                                    <td>$<?php echo number_format($row['amount'],2); ?></td>
                                                    <td><?php echo round($price_in_btc, 4); ?> BTC</td>
                                                    <td>   <?php if($row['status']==0){ ?>
                                                        Pending
                                                        <?php }else{ ?>
                                                        Success
                                                        <?php } ?></td>
                                                    <td><?php echo $row['date']; ?></td>
                                                </tr>
                                                <?php $count++; ?>
                                         <?php } ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </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>



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

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

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