-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapproval.php
More file actions
150 lines (138 loc) · 5.75 KB
/
approval.php
File metadata and controls
150 lines (138 loc) · 5.75 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
include 'db_connection.php';
session_start();
if(isset($_POST['accept'])){
$sql = "UPDATE Users
SET approval = 1
WHERE user_ID=$_POST[accept]";
//will eventually send message about accept
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}elseif(isset($_POST['decline'])){
$sql = "UPDATE Users
SET role = 'buyer'
WHERE user_ID=$_POST[decline]";
//Will eventually send message about decline
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
?>
<?php
//TEMPLATES
include 'templates/head.html';
include 'templates/nav-admin.php';
?>
<main class="flex w-full">
<?php
include 'templates/admin-side-bar.php';
?>
<section class="w-full p-4">
<div class="w-full text-md">
<div class="bg-white shadow sm:rounded">
<div class="mt-5 md:mt-0 md:col-span-2">
<div class="bg-white p-8 rounded-md w-full">
<div class=" flex items-center justify-between pb-6">
<div>
<h2 class="text-gray-600 font-semibold">Account Approval</h2>
</div>
<div class="flex items-center justify-between"></div>
</div>
<!--Table-->
<?php
$sql = "SELECT * FROM Users WHERE role='seller' && approval=0";
$result = $conn->query($sql);
?>
<form action="approval.php" id="form1" method="POST">
<div class="-mx-4 sm:-mx-8 px-4 sm:px-8 py-4 overflow-x-auto">
<div class="inline-block min-w-full shadow rounded-lg overflow-hidden">
<!--Table Header-->
<table class="min-w-full leading-normal">
<thead>
<tr>
<th
class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Name
</th>
<th
class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
ID Number
</th>
<th
class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Email
</th>
<th
class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Select
</th>
</tr>
</thead>
<!--Table Body-->
<tbody>
<?php
while($res = mysqli_fetch_array($result)) {
?>
<tr>
<!--Qustion-->
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<p class="text-gray-900 whitespace-no-wrap">
<input type="text" name="name" readonly value=" <?php echo $res['first_name'] . " " . $res['last_name'] ?> ">
</p>
</td>
<!--Answer-->
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<p class="text-gray-900 whitespace-no-wrap">
<input type="text" name="name" readonly value=" <?php echo $res['user_ID'] ?> ">
</p>
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<p class="text-gray-900 whitespace-no-wrap">
<input type="text" name="name" readonly value=" <?php echo $res['email'] ?> ">
</p>
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white flex justify-evenly">
<button type="submit" name="accept" form="form1" id="accept" value="<?php echo $res['user_ID']?>">✅</button>
<button type="submit" name="decline" form="form1" id="decline" value="<?php echo $res['user_ID']?>">❌</button>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</form>
<!------>
</div>
</div>
</div>
</div>
</section>
</main>
<!--This needs to be merged with the table above-->
<div>
<table>
<?php
$sql = "SELECT * FROM Users WHERE role='seller' && approval=0";
$result = $conn->query($sql);
while($res = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $res['first_name'] . " " . $res['last_name'] . "</td>";
echo "<td>" . $res['user_ID'] . "</td>";
echo "<td>" . $res['email'] . "</td>";
?>
<?php
}
?>
</table>
</div>
<?php
include 'templates/footer.html';
?>