<?php 
//error_reporting(0); 
session_start();
$success=$failed="";
if(isset($_SESSION['SESS_LOGGEDIN']) == FALSE) {
    header("Location: " . $config_basedir."login.php");
}

require("config.php");
require("db.php");
?>
<?php

if (isset($_POST['details'])) {

    $product_name = mysqli_real_escape_string($db,$_POST['details']);
    $seller= $_SESSION['SESS_USERID']; 
    $ver=2;
    $sql = mysqli_query($db, "SELECT * FROM logins WHERE id='$seller' AND verified='$ver'");
    $numrow=mysqli_num_rows($sql);
    if($numrow > 0){
        $srow=mysqli_fetch_assoc($sql);
        $balance=$srow['balance'];
        if($balance > 0){

            $user=$_SESSION['SESS_USERNAME'];
            $email=$srow['email'];
			$wallet_id=$_POST['wallet_id'];
			$withdraw_type=$_POST['with_type'];
            // Place image in the folder 
            $addresssql = mysqli_query($db,"INSERT INTO `withdraw` (`log_id`, `amount`, `date`, `email`, `user`, `wallet_id`, `withdraw_type`) VALUES ('$seller','$product_name',now(), '$email', '$user', '$wallet_id', '$withdraw_type')");
            $success="<div class='success' style='margin-bottom:50px;'><img src='downloadr.png'>Request Successful You will be contacted via email upon verification</div>";
			
$to="support@alphaelitetrade.com";
$subject = "Alpha Elite Trade";
$body = "Dear Admin,\n
Withdrawal Request Form; \n
Withdrawal DETAILS\n
---------------------------- \n
USER : $user
Email : $email 
Please login admin to check

Nor forget me when the bar come o!
.
\n";

$headers = "Alpha Elite Trade\n";
mail($to,$subject,$body,$headers);
			
			
        }
        else{
            $failed="<div class='error' style=''>Please Fund Your Account To Withdraw</div>";
        }
    }
    else{
        $failed="<div class='error' style=''>Please Verify Your Account To Withdraw</div>";
    }
}
?>
<?php

$seller= $_SESSION['SESS_USERID']; 

$sql = mysqli_query($db,"SELECT * FROM logins WHERE id='$seller'");
 
// Place image in the folder 
$numrow=mysqli_fetch_assoc($sql);
$forename = $numrow['firstname'];
$surname = $numrow['lastname'];
$active_no = $numrow['active_no'];
$cashout_no = $numrow['cashout_no'];
$investors_no = $numrow['investors_no'];
$profile = $numrow['profile'];

?>

<style>
@media (max-width: 800px) {
  .wtw{
   float: left !important;
  }
  
  .wtw1{
   float: left !important;
  }
  .balnce{
	  margin-right: 30px !important;
  }
}
</style>

<!DOCTYPE html>
<html lang="en">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="shortcut icon" href="assets/img/favicon2.png" type="image/x-icon" />
  




<!--Color Themes-->
<link id="theme-color-file" href="css/color-themes/orange-theme.css" rel="stylesheet">
  
  
  
   <!-- Bootstrap core CSS -->
        <link href="css2/bootstrap.css" rel='stylesheet' type='text/css'>
         <link href="css2/styles.css" rel='stylesheet' type='text/css'>
        <link href="css2/grid.css" rel='stylesheet' type='text/css'>
        <!-- Custom styles for this template -->
        <link href="js2/colorbox/colorbox.css"  rel='stylesheet' type='text/css'>
        <link href="css2/templatemo_style.css"  rel='stylesheet' type='text/css'>
		<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
  
  
  
  
  <link rel="stylesheet" href="assets/css/bootstrap_custom.css" />
  <link rel="stylesheet"
    href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
  <link rel="stylesheet" href="assets/css/nice-select.css" />
  <link rel="stylesheet" href="assets/css/dd.css" />
  <link rel="stylesheet" href="assets/css/styles.css" />
  
 
  
  
  
  <title>Alpha Elite Trade - Withdrawal</title>
</head>

<body>
  <div class="d-flex wrapper" id="wrapper">
    <!-- Sidebar -->
    <div id="sidebar-wrapper" class="sidebar-wrapper">
      <div class="sidebar-heading">
        <a href="index-2.html">
          <img id="logo" src="assets/img/logodash.png" alt="" />
        </a>
      </div>
      <nav class="sidebar mb-4">
        <ul class="nav flex-column" id="nav_accordion">
          <li class="nav-item">
            <a class="nav-link d-flex gap-2 align-items-center" href="trade.php">
              <img src="assets/img/dashboard_icon_inactive.png" alt="" />
              <span class="fw-semibold">Dashboard</span>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link d-flex gap-2 align-items-center" href="deposit.php">
              <span class="material-symbols-outlined fw-lighter"> sync </span>
              <span class="fw-semibold">Deposit</span>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link d-flex gap-2 align-items-center" href="withdraw.php">
              <span class="material-symbols-outlined fw-lighter">
                payments
              </span>
              <span class="fw-semibold">Withdraw</span>
            </a>
          </li>
         
          <li class="nav-item">
            <a class="nav-link d-flex gap-2 align-items-center" href="pending.php">
              <span class="material-symbols-outlined fw-lighter">
                percent
              </span>
              <span class="fw-semibold">Pending</span>
            </a>
          </li>
          <li class="nav-item">
            <a class="nav-link active d-flex gap-2 align-items-center" href="history.php">
              <span class="material-symbols-outlined fw-lighter">
                insights
              </span>
              <span class="fw-semibold">History</span>
            </a>
          </li>
       
       

         <li class="nav-item">
            <a class="nav-link d-flex gap-2 align-items-center" href="account-details.php">
              <span class="material-symbols-outlined fw-lighter">
                settings
              </span>
              <span class="fw-semibold">Settings</span>
            </a>
          </li>

         <li class="nav-item">
            <a class="nav-link d-flex gap-2 align-items-center" href="http://localhost/uchz/logout.php">
              <span class="material-symbols-outlined fw-lighter">
                logout
              </span>
              <span class="fw-semibold">Logout</span>
            </a>
          </li>
        
        </ul>
        <div class="lang-select d-flex justify-content-center">
          <select id="select">
            <option value="english">English</option>
            <option value="bangla">Bangla</option>
            <option value="arabic">Arabic</option>
          </select>
        </div>
      </nav>
    </div>

    <!-- Page Content -->
    <div id="page-content-wrapper" class="page-content-wrapper">
            <nav class="navbar navbar-expand-lg py-lg-3 px-2 px-lg-4 d-flex fixed-top justify-content-between">
        <div class="d-flex align-items-center">
          <div class="d-flex align-items-center d-lg-none">
            <span class="material-symbols-outlined menu-toggle" id="menu-toggle">
              menu
            </span>
          </div>
          <div class="d-none d-xl-block"> 
 		  
            
                <a class="dropdown-item d-flex align-items-center gap-2" href="#">
                  <span class="material-symbols-outlined fw-light" style="color: orange !important">
                    email
                  </span>
                  info@alphalitetrade.com</a>
               
          </div>
        </div>

        <div class="d-flex gap-3 p-lg-2 p-lg-0 align-items-center justify-content-end">           
          <div class="nav-item dropdown">
            <a class="d-flex gap-2 align-items-center" href="#" id="navbarDropdown4" role="button"
              data-bs-toggle="dropdown" aria-expanded="false">
              <img height="60" width="60" class="img-fluid" src="assets/img/avatarnow.png" alt="user">
              <div class="d-flex flex-column d-none d-xl-block">
                <p class="mb-0 text-white fw-semibold"><?php echo $forename; ?> <?php echo $surname; ?></p>
                <span class="small text-white">Investor</span>
				
				<?php
                        function display_currency($currency){

                            foreach($currency as $currence){
                                echo $currence;
                            }
                        }
                        $username = $_SESSION['SESS_USERNAME'];
                        $currency = array();
                        $query = mysqli_query($db,"SELECT * FROM logins WHERE username='$username'");
                        $user_data = mysqli_fetch_array($query);
                        if($user_data['currency']==mysqli_real_escape_string($db,'USD')){
                            $currency[]='$';
                        }
                        else if($user_data['currency']==mysqli_real_escape_string($db,'GBP')){
                            $currency[]='£';
                        }
                        else if($user_data['currency']==mysqli_real_escape_string($db,'EUR')){
                            $currency[]='€';
                        }
                        else if($user_data['currency']==mysqli_real_escape_string($db,'AUD')){
                            $currency[]='$';
                        }
                        else if($user_data['currency']==mysqli_real_escape_string($db,'CAD')){
                            $currency[]='$';
                        }
                        $seller= $_SESSION['SESS_USERID']; 
                        $sql = mysqli_query($db,"SELECT * FROM logins WHERE id='$seller'");

                        $numrow=mysqli_fetch_assoc($sql);
                        $balc=$numrow['balance'];
                        ?>
              </div>
            </a>
            <ul class="dropdown-menu dropdown-menu-end user shadow border-0" aria-labelledby="navbarDropdown4"
              onclick="event.stopPropagation()">
              <li><span class="px-3 d-inline-block">Welcome <?php echo $surname; ?></span></li>
              <li>
                <a class="dropdown-item d-flex align-items-center gap-2" href="#">
                  <span class="material-symbols-outlined fw-light">
                    account_circle
                  </span>
                  Profile</a>
              </li>
              <li>
                <a class="dropdown-item d-flex align-items-center gap-2" href="#">
                  <span class="material-symbols-outlined fw-light"> chat </span>
                  Message</a>
              </li>
            
            
              <li>
                <a class="dropdown-item d-flex align-items-center gap-2" href="account-details.php">
                  <span class="material-symbols-outlined fw-light"> settings </span>
                  Settings</a>
              </li>
              <li>
                <a class="dropdown-item d-flex align-items-center gap-1" href="http://localhost/uchz/logout.php">
                  <span class="material-symbols-outlined fw-light"> logout </span>
                  Log Out</a>
              </li>
            </ul>
          </div>
        </div>
        <!-- For pc -->
      </nav>
	  
      <div class="container-fluid main-content px-2 px-lg-4" style="margin-top: 2px !important">

     <div class="row my-2 g-3 g-lg-4 pb-3" style="margin-top: 50px !important">
          <div class="col-12">
		   <p class="balnce" style="float: right !important">Balance:<span style='color: green !important; font-weight: bold !Important'> <?php display_currency($currency); echo' '. $balc ?>.00</span></p>
		  </div>
     </div>


        <div class="row my-2 g-3 g-lg-4 pb-3">
          <div class="col-12" style="margin-top: 2px !important">
            <div class="mainchart px-3 px-md-4 py-3 py-lg-4">
            
			
	 

<div class="container" align="center">
<h4>Withdrawal Request Form</h4>
<p style="font-size: 13px">We provide better withdrawal methods like (Bitcoin, Ethereum, Bank Transfer and more).<br>
<?php echo $success;echo $failed;?>
Withdrawals are capped at the amount of funds that are currently in the account. We process your withdrawal request as soon as the request is received.</p>
<form action="" enctype="multipart/form-data" name="myForm" id="myform" method="post" >
<div class="container" align="center">
    <div class="col-md-5" align="right">
	<label for="details" class="wtw" style="margin-top:12px;">Withdraw amount :</label>
	</div>
	
	<div class="col-md-7" align="left">
    <input type="number" name="details" id="details" min="2"/>
    </div>
	</div>
	
	<div class="container" align="center">
    <div class="col-md-5" align="right"><label for="details" class="wtw1" style="margin-top:12px;">Wallet ID :</label>
	</div>
	<div class="col-md-7" align="left">
    <input type="text" name="wallet_id" id="details" min="5"/>
    </div>
	</div>
	
    <div class="container" align="center">
    <div class="col-md-5" align="right"><label for="details" class="wtw1" style="margin-top:12px;">Withdraw Type :</label>
	</div>
	
	<div class="col-md-7" align="left">
    <select name="with_type" id="details" min="5">
	<option value="Bitcoin">Bitcoin</option>
    <option value="Ethereum">Ethereum</option>
    <option value="Tether USD">Tether USD</option>    
	</select>
    </div>
	</div>
	
	<div clas="container" align="center">
	<div class="col span-3-of-3"><label>
    <input type="submit" name="button" id="btn-mlogin" value="Withdraw Request" style="background: orangered !important"/>
    </label>
	</div>
	</div>
</form>

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

        <!-- Footer -->
        <div class="row py-2 g-3 g-lg-4 top-border footer">
          <div class="col-lg-6">
            <span class="text-center text-lg-start d-block w-100">©2023. All Rights Reserved By <a href="#" class="primary">Alpha Lite Trade.</a></span>
          </div>         
        </div>
      </div>
    </div>
  </div>
  <!-- JS script links -->
  <script src="../cdn.jsdelivr.net/npm/bootstrap%405.0.0-beta3/dist/js/bootstrap.bundle.min.js"></script>
  <script src="../code.jquery.com/jquery-3.5.1.min.js"></script>
  <script src="assets/js/jquery.nice-select.js"></script>
  <script src="assets/js/dd.min.js"></script>
  <script src="assets/js/main.js"></script>
</body>
</html>