-
Notifications
You must be signed in to change notification settings - Fork 0
/
withdrawal.php
123 lines (115 loc) · 6.12 KB
/
withdrawal.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php include "includes/head.php"; ?>
<?php
$error = 0;
$row = [];
$table = "payouts";
if(isset($_GET['id']) && !empty($_GET['id'])){
$id = trim($_GET['id']);
$getData = $conn->prepare("SELECT * FROM `${table}` WHERE id = ?");
$getData->execute([$id]);
if($getData->rowCount() > 0){
$row = $getData->fetch(PDO::FETCH_OBJ);
}
}
else{
$error = 1;
}
if($error == 1 && empty($row)){
echo '<h3>Access Forbidden</h3>';
}
else{
if(isset($_POST['submit'])){
$status = $_POST['status'];
$editData = $conn->prepare("UPDATE payouts SET wstatus=?, approved_by = ? WHERE id=?");
$editData->execute([
$status, $_SESSION['admin'], $id
]);
if($editData->rowCount() > 0){
echo "<div class='alert alert-success'>Updated.</div>";
if($status == "approved"){
$getWallet = $conn->query("SELECT * FROM wallets WHERE user_id = '$row->user_id'");
$wallet = $getWallet->fetch(PDO::FETCH_OBJ);
$newAmount = $wallet->balance - $row->amount;
if($newAmount > 0){
$editWallet = $conn->prepare("UPDATE wallets SET balance=? WHERE id=?");
$editWallet->execute([$newAmount, $wallet->id]);
}
else{
echo "<div class='alert alert-info'>Error! User amount less than requested withdrawal amount.</div>";
}
}
}
if($editData->rowCount() == 0){
echo "<div class='alert alert-danger'>Failed.</div>";
}
}
?>
<?php $getUser = $conn->query("SELECT * FROM users WHERE id = '$row->user_id'"); $user = $getUser->fetch(PDO::FETCH_OBJ); ?>
<!-- Start info box -->
<div class="row mt-5" style="display:flex;justify-content:center;">
<div class="col-md-6">
<div class="widget">
<div class="widget-header">
<h4><b>Manage Withdrawal</b></h4>
</div>
<div class="widget-content" style="padding:10px;">
<form method="post">
<div class="form-group">
<label>Email Address</label>
<input type="text" value="<?php echo $user->email; ?>" readonly class="form-control"/>
</div>
<div class="form-group">
<label>Amount(₦)</label>
<input type="text" value="<?php echo $row->amount; ?>" readonly class="form-control"/>
</div>
<div class="form-group">
<ul class="list-group">
<li class="list-group-item">
<b>Bank Name :</b>
<?php echo $user->bank; ?>
</li>
<li class="list-group-item">
<b>Account Name :</b>
<?php echo $user->accountname; ?>
</li>
<li class="list-group-item">
<b>Account Number :</b>
<?php echo $user->accountnumber; ?>
</li>
<li class="list-group-item">
<b>Momo Account Name :</b>
<?php echo $user->momoaccountname; ?>
</li>
<li class="list-group-item">
<b>Momo Account Number :</b>
<?php echo $user->momoaccountnumber; ?>
</li>
<li class="list-group-item">
<b>Paypal Email :</b>
<?php echo $user->paypalemail; ?>
</li>
<li class="list-group-item">
<b>Payoneer Email :</b>
<?php echo $user->payoneeremail; ?>
</li>
</ul>
</div>
<div class="form-group">
<label>Status</label>
<select name="status" class="form-control">
<option <?php if($row->status == "pending"){ echo "selected"; } ?> value="pending">pending</option>
<option <?php if($row->status == "approved"){ echo "selected"; } ?> value="approved">approved</option>
<option <?php if($row->status == "declined"){ echo "selected"; } ?> value="declined">declined</option>
<option <?php if($row->status == "cancelled"){ echo "selected"; } ?> value="cancelled">cancelled</option>
</select>
</div>
<hr>
<button type="submit" name="submit" class="btn btn-block btn-md btn-success">Update</button>
</form>
</div>
</div>
</div>
</div>
<!-- End of info box -->
<?php } ?>
<?php include "includes/foot.php"; ?>