<?php
    require_once 'check_security.php';
     $showpopup=false;
    if(isset($_GET['vvvv'])){
        $showpopup=true;
        $poptitle="Withdrawal Successfully";
        $subtitilepop="Withdrawal submit Successfully";
    }
    if(isset($_POST['sub'])){

              
    $amount=$_POST['amount'];
    $upiid=$_POST['upiid'];
 
    
    $date = date('d/m/Y_H:i:s');
    $amount=mysqli_real_escape_string($conn,$amount);
    $upiid=mysqli_real_escape_string($conn,$upiid);
    $totalmycg=$winmoney+$addmoney;
    $newqwithdrae=$withdrawal+$amount;
   if($winmoney>=$amount){
       $newwinmoney=$winmoney-$amount;
       $transquary=mysqli_query($conn,"INSERT INTO history_trans (type,title,time,amount,oldamount,status,visble,member_id) Values ('2','3','$date','$amount0','$totalmycg','0','0','$id')");
        $balquery=mysqli_query($conn,"UPDATE  userdataa Set winmoney='$newwinmoney', withdrawal='$newqwithdrae' WHERE id='$id'");
        $withdrawtgrthg=mysqli_query($conn,"INSERT INTO withdraw (upiid,amount,time,status,memer_id) Values ('$upiid','$amount','$date','0','$id')");
 header("Location: withdraw.php?vvvv=withdraw");
   }else{
    $showpopup=true;
    $poptitle="Insuficient Balance";
    $subtitilepop="Insuficient balance in your wallat";
   }

       
    }
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Withdraw Money</title>
</head>

<style>


body{
display: block;
background-color: aliceblue;
}
*{
padding: 0;
margin: 0;

box-sizing: border-box;
font-family: Poppins, "sans-serif";
text-decoration: none;


}
div.bodyconde{
    background-color: aliceblue;
    text-align: center;
    
}
div.bodyconde div.withlayoutd{
 text-align: center;
box-shadow: 10px;
margin-top: 11%;
width: max-content;
border-radius: 5px;
padding: 10px;
box-shadow: 0px 5px 10px cadetblue;
border: 1px solid #ccc;
background-color: white;
}
div.bodyconde div.withlayoutd h2{
    align-self: center;
    margin: 7px;
    margin-bottom: 10px;
}
div.bodyconde div.withlayoutd div.infutfildiv{
    margin: 7px;
    text-align: start;
    padding: 7px;
    display: block;
}
div.bodyconde div.withlayoutd div.infutfildiv input{
    padding: 10px;
    width: 100%;
    margin: 5px;
    background-color: #f2f4f6;
font-size: 17px;
    border: 1px solid #ccc;
    border-radius: 3px;
  
}
div.bodyconde div.withlayoutd div.infutfildiv label{
    margin: 2px;
}
div.bodyconde div.succesds{
    text-align: center;
box-shadow: 10px;
margin-top: 11%;
width: max-content;
border-radius: 5px;
padding: 10px;
box-shadow: 0px 5px 10px cadetblue;
border: 1px solid #ccc;
background-color: white;
}
div.bodyconde div.succesds img{
    width: 40px;
    margin: 5px;
    height: 40px;
}
div.bodyconde div.succesds h2{
    margin: 5px;
}
div.bodyconde div.succesds p{
    margin: 5px;
}
div.bodyconde div.succesds button{
    box-shadow: 0px 5px 10px cadetblue;
border: 1px solid #ccc;
border-radius: 5px;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 30px;
margin: 5px;
font-size: 18px;
color: white;
padding-right: 30px;
background-color: rgb(69, 29, 226);
}
div.bodyconde div.withlayoutd button{
    padding: 10px;
    width: 80%;
    color: white;
    background-color: #f2f4f6;
font-size: 18px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: rgb(69, 29, 226);
}
</style>

<body>
    <div class="bodyconde">
        <?php if($showpopup==true){
            ?>
        <center>
            <center>
        <div class="succesds">
            <img src="https://fairbattle.earnmoreapp.in/adminnh/assist/icon/cash.png" />
            <h2><?php echo $poptitle; ?></h2>
            <p><?php echo $subtitilepop; ?></p>
            <a href="/fairb/">
            <button>Ok</button>
        </a>
        </div>
    </center>
</center>
<?php }else{
    ?>
        <center>
            <center>
                <form method="POST" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>" >
<div class="withlayoutd">
<h2>Withdrawal Your Money</h2>
<div class="infutfildiv">
    <label for="amount"><b>Enter Amount</b></label>
    <input type="text" name="amount" class="inputfeld" placeholder="Enter Amount"  onkeypress='return event.charCode >= 48 && event.charCode <= 57' required>
    </div>
    <div class="infutfildiv">
<label for="upiid"><b>Enter UPI ID</b></label>
<input type="text" name="upiid"  class="inputfeld" placeholder="Enter UPI ID" required>
</div>
<button type="submit" name="sub">Withdraw</button>
</div>
</form>
            </center>

        </center>
        <?php } ?>

    </div>

</body>
</html>