This repository has been archived by the owner on Nov 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequests.php
195 lines (157 loc) · 6.24 KB
/
requests.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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?php
include_once "header.php";
$rt = true;
if(!$lg && !$vp){
$rt = false;
}
if($lg && $lg != $id){
$rt = false;
}
if($vp && $vp != $id){
$rt = false;
}
?>
<style>
.wrapper {
border : 0px dotted #ccc; padding: 0px;
}
#sidebar { }
#tree { background-color: white;
background-size: cover;
background-image: url(https://i.imgur.com/dEqI5GG.png);
height: 100vh;
}
@media screen and (min-width: 600px) {
.wrapper {
height: auto; overflow: hidden; // clearing
}
#sidebar { padding: 20px;width: 400px; float: left;height: 100vh; }
#tree { margin-left: 400px; }
}
.input-color {
position: relative;
}
.input-color input {
padding-left: 20px;
margin-bottom: 10px;
}
.input-color .color-box {
width: 30px;
height: 30px;
background-color: #ccc;
left: 5px;
top: 5px;
}
.button {
background-color: #4CAF50; /* Green */
border: none;
color: white;
width: 100%;
padding: 8px 14px;
text-align: left;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
</style>
<style>
th, td {
padding: 10px;
text-align: left;
}
#tree {
background-color: white;
background-size: cover;
background-image: url(https://i.imgur.com/dEqI5GG.png);
height: 100vh;
}
#requests_table th, #requests_table td {
border-bottom: 1px solid #ddd;
}
</style>
<div class="wrapper">
<?php include_once "sidebar.php"; ?>
<div id="tree">
<div class="pt-box" style=" width: 574px;
border-radius: 3px;
margin: 20px 0px 0px 50px; background: #fff0;box-shadow: 0 0px 0px rgba(0, 0, 0, 0.13);">
<form class="pt-form" style="background-color: #ffffffba;">
<h4><b>What are requests?</b></h4><br>
<p>If someone you've impacted makes an account here, you can add them to your tree by username (by sending a request). If they accept your request, their tree will automatically be added to your tree, and their impact statistics will be added to yours - <i>live!</i>
<br>
<br>
<h4 style="background-color: #4caf50;color: white;padding: 8px 0px 8px 10px;margin: 0px 100px 10px 0px;border-radius: 5px;"><i class="fas fa-bell"></i> Recieved Requests</h4>
<?php
$get_requests = "
SELECT r.idrequests, r.accepted, a.username
FROM ".prefix."requests r
JOIN ".prefix."accounts a ON r.from_id = a.id
JOIN ".prefix."bubbles b ON a.id = b.account_id
WHERE r.to_id=$lg";
$requests = $db->query($get_requests);
if ( $requests->num_rows > 0 ) {
echo '<table id="requests_received_table">';
echo '<tr><th>User</th><th>Status</th><th></th><th></th></tr>';
while ( $req = $requests->fetch_assoc() ) {
$accept = ( $req['accepted'] )
? '<em>Accepted</em>'
: '<button class="btn btn-primary request-action" data-action="accept" data-id="'.$req['idrequests'].'">Accept</button>';
$revoke = ( $req['accepted'] )
? '<button class="btn btn-danger request-action" data-action="revoke" data-id="'.$req['idrequests'].'">Revoke</button>'
: '';
echo '<tr>';
echo "<td>{$req['username']}</td>";
echo "<td>$accept</td>";
echo "<td>$revoke</td>";
echo '</tr>';
}
echo '</table><br>';
}
else {
echo '<p>No requests to review. Invite friends to <a href="/">myvegantree.org</a>!</p><br>';
}
$requests->close();
?>
<?php
$get_sent_requests = "
SELECT r.idrequests, r.accepted, a.username
FROM ".prefix."requests r
JOIN ".prefix."accounts a ON r.to_id = a.id
WHERE r.from_id=$lg";
$requests_sent = $db->query($get_sent_requests);
if ( $requests_sent->num_rows > 0 ) {
echo '<hr><h4 style="background-color: #da6161;color: white;padding: 8px 0px 8px 10px;margin: 0px 100px 10px 0px;border-radius: 5px;"><i class="fas fa-paper-plane"></i> Sent Requests</h4>';
echo '<table id="requests_sent_table">';
echo '<tr><th>User</th><th>Status</th><th></th><th></th></tr>';
while ( $req = $requests_sent->fetch_assoc() ) {
$accept = ( $req['accepted'] ) ? '<em>Accepted</em>' : '<em>Not Yet Accepted</em>';
$cancel = '<button class="btn btn-warn request-action" data-action="cancel" data-id="'.$req['idrequests'].'">Cancel</button>';
echo '<tr>';
echo "<td>{$req['username']}</td>";
echo "<td>$accept</td>";
echo "<td>$cancel</td>";
echo '</tr>';
}
echo '</table><br>';
}
$requests_sent->close();
?>
<span></span>
<table id="make_request_table" style="margin: 0px 0px -0px -9px;">
<tr><td><h4 style="background-color: #337ab7;color: white;padding: 8px 0px 8px 10px;margin: 0px 77px 5px 0px;border-radius: 5px;"><i class="fas fa-users"></i> Make A Request</h4></td><td></td></tr>
<tr>
<td><input type="text" id="request_username" placeholder="Username" size="30"></td>
<td><button id="request_send_btn" class="btn btn-primary">Send Request</button></td>
</tr>
</table>
</form>
</div>
</div>
</div>
<!-- Latest compiled and minified JavaScript -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="js/jquery.livequery.js"></script>
<script src="js/custom.js"></script>