<?php 
error_reporting(0); 
session_start();
$success=$failed="";
if(isset($_SESSION['SESS_LOGGEDIN']) == FALSE) {
    header("Location: " . $config_basedir."access-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`) VALUES ('$seller','$product_name',now(), '$email', '$user', '$wallet_id')");
            header('location: withdraw.php?success=requestSent');
        }
        else{
          header('location: withdraw.php?error=fundAccount');
        }
    }
    else{
      header('location: withdraw.php?error=notVerified');
    }
}
?>
<?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'];
$userImage = $numrow['user_image'];
$ver_b=$numrow['ver_badge'];

?>



<!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/myfavicon.png" type="image/x-icon">
  <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/styles.css">
  
  <script src='https://kit.fontawesome.com/a076d05399.js' crossorigin='anonymous'></script>
  <link rel="stylesheet" href="assets1/css/style.css">
  <title>Alpha Chequers™ - Withdrawal</title>

  <style>
@media (max-width: 800px) {
  .wtw{
   float: left !important;
  }
  
  .wtw1{
   float: left !important;
  }
  .balnce{
	  margin-right: 30px !important;
  }
}
.fw-semibold{
  color: #007bff !important;
}
@media (max-width: 800px) {
  .img-fluid{
   border: 1px solid #333 !important;
   margin-right: 6px !important;
  }
}
@media screen and (max-width:800px ){
     .text-center{
      font-size: 12px !important;
  }
  .primary{
    font-size: 12px !important;  
  }
}
</style>
</head>

<body style="background: var(--bg-body) !important">
  <div class="d-flex wrapper" id="wrapper">
    <!-- Sidebar -->
    <div id="sidebar-wrapper" class="sidebar-wrapper" style="padding-top: 0px !important">
      <div class="sidebar-heading" style="padding-top: 0px !important">
        <a href="../index.html" style="margin-top: 8px !important">
          <img id="logo" src="assets/img/crypto/logo.png" style="height: 25px; width: 25px" alt="">
          <span style="font-weight: bold; color: #007bff; font-size: 14px !important"> ALPHA <span style="color: orange !important; font-size: 14px !important">CHEQUERS</span>
</span></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 active 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 d-flex gap-2 align-items-center" href="verify.php">
              <span class="material-symbols-outlined fw-lighter">
                insights
              </span>
              <span class="fw-semibold">Verify</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="logout.php">
              <span class="material-symbols-outlined fw-lighter">
                logout
              </span>
              <span class="fw-semibold">Logout</span>
            </a>
          </li>
        
        </ul>
        
      </nav>
    </div>

    <!-- Page Content -->
    <div id="page-content-wrapper" class="page-content-wrapper" style="background: var(--bg-body) !important">
            



			<nav class="navbar navbar-expand-lg py-lg-3 px-2 px-lg-4 d-flex fixed-top justify-content-between" style="padding-top: 0px !important; padding-bottom: 0px !important; height: 60px !important">
       
	   <div class="d-flex align-items-center" style="margin-top: 0px !important">
          <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="#" style="color: #fff !important ">
                  <span class="material-symbols-outlined fw-light" style="color: orange !important ">
                    email
                  </span>
                  info@alphachequers.com</a>
               
          </div>
		  
		  
        </div>

        <div class="d-flex gap-3 p-lg-2 p-lg-0 align-items-center justify-content-end" style=" ">           
          <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">
              <?php if(!empty($userImage)) {
                             ?>                            
              <img height="35" width="35" class="img-fluid" src="userImages/<?php echo $userImage; ?>" alt="" style="border-radius: 50%">
              <?php
              }else{
                ?>
                <img src="assets/img/avatarnow.png" alt="" height="35" width="35" style="border-radius: 50%">
                <?php
              }
        
            ?>
              <div class="d-flex flex-column d-none d-xl-block">
           <script src="https://code.iconify.design/iconify-icon/1.0.7/iconify-icon.min.js"></script>
           
           <p class="mb-0 text-white fw-semibold" style="font-size: 15px">
		   <?php echo $forename; ?> <?php echo $surname; if($ver_b == 2){
                  echo "<iconify-icon icon='material-symbols:verified' style='color: #ccc; font-size: 12px'></iconify-icon>";
                 } ?>		  		      
		   </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="account-details.php">
                  <span class="material-symbols-outlined fw-light">
                    account_circle
                  </span>
                  Profile Settings</a>
              </li>
             
            
            
              <li>
                <a class="dropdown-item d-flex align-items-center gap-2" href="deposit.php">
                  <span class="material-symbols-outlined fw-light"> sync </span>
                  Deposit</a>
              </li>
              <li>
                <a class="dropdown-item d-flex align-items-center gap-1" href="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: 0px !important">

    <div class="row my-2 g-3 g-lg-4 pb-3" style="margin-top: 19px !important; padding: 0px !important">
          <div class="col-12" style="border: 2px solid # !important; height: auto !important; margin-top: 10px !important">
		   <span class="balnce" style="float: right !important">Balance:<span style='color: green !important; font-weight: bold !important; text-decoration: underline !important'> <?php display_currency($currency); echo' '. $balc ?>.00</span></span>
		  </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">

                 <div class="card" style="background-color: var(--bg-card)">
                <div class="card-body">
                  <h5 class="card-title" style="color: #fff; text-align: center !important">Withdrawal Request Form</h5>
				  
				  <p style="font-size: 13px">Please do not input amount that is higher than your current Account Balance: <span style='color: #fff !important; font-weight: bold !important;'> <?php display_currency($currency); echo' '. $balc ?>.00</span>.<br>
                   Fill the form below correctly and click the 'Request Now' button. We process your withdrawal request as soon as the request is received.</p>
				   <br/>
				  

           <br/>
				  
          <?php 
            if($_GET['success']){
            
            if($_GET['success'] == 'requestSent'){
              ?>
           <div class='alertme' style='color: green; height: 40px; width: auto; padding: 10px; border: 1px color: #777; background: #999;' align='center'>
           Request successfully sent!  Your request will be processed within 24 hours. Thank you for using ALPHA CHEQUERS. 
           </div>
           <br/>
           <?php
              
            }
            
          }
      


            




if(isset($_GET['error'])){
				  
          if($_GET['error'] == 'notVerified'){
          ?>
          <div class='alertme' style='color: red; height: 40px; width: auto; padding: 10px; border: 1px color: #777; background: pink;' align='center'>
          Please verify your account!
          </div>
          <br/>
          <?php						
        }else if($_GET['error'] == 'fundAccount'){
          ?>
          <div class='alertme' style='color: red; height: 40px; width: auto; padding: 10px; border: 1px color: #777; background: pink;' align='center'>
          Please fund your account!
          </div>
          <br/>
          <?php
        
        }
        
        }
        ?>
























                  <div class="settings-profile">
                    <form action="" enctype="multipart/form-data" name="myForm" id="myform" method="post">
                          
                      <div class="form-row mt-4">
                        <div class="col-md-6">
                          <label for="formFirst" style="float:left !important">Withdraw Amount</label>
                          <input id="details" type="number" name="details" min="2" class="form-control" placeholder="Amount" style="background-color: var(--bg-body); !important; border: 1px solid #1e222d; color: #ccc">
                        </div>
                        <div class="col-md-6">
                          <label for="formLast" style="float:left !important">Wallet ID<span style="font-size: 12px">(Personal Wallet Address)</span></label>
                          <input id="details" type="text" name="wallet_id" min="10" class="form-control" placeholder="Wallet address" style="background-color: var(--bg-body); !important; border: 1px solid #1e222d; color: #ccc">
                        </div>
						
						<div class="col-md-12">
						
                          <input type="submit" value="Request Now" id="btn-mlogin" name="button" style="border: 1px solid #1e222d">
                        </div>
						
						
						<div class="col-md-12" style=" margin-top: 40px !important;">
						<p style="font-size: 13px !important; text-align: center">If you have any question(s) or need any asistance, kindly contact our Support <br>Team via <span style="color: orange !important; font-size:13px">support@alphachequers.com.</span> You will get a response within the hour.</p>
                          </div>
                     
						
						
						</div>
					</form>
						</div>
						</div>
						</div>
						









</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">©2024. All Rights Reserved By <a href="#" class="primary" style="color: orange !important">Alpha Chequers.</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>