-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathadmin.php
241 lines (234 loc) · 13.5 KB
/
admin.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<?php
include "header.php";
include_once "dbconnect.php";
if(!isset($_SESSION['admin']))
header("Location: adminlogin.php");
$admin_id = $_SESSION['admin'];
?>
<body class="adminpb">
<?php include "adminbar.php"; ?>
<div class="admin-content" id="adorder">
<h1>Orders Panel</h1><br><br>
<ul class="nav nav-tabs nav-justified">
<li class="active"><a data-toggle="tab" href="#neworders">New Orders</a></li>
<li><a data-toggle="tab" href="#seenorders">Accepted Orders</a></li>
</ul>
<div class="tab-content admintabs">
<div id="neworders" class="tab-pane fade in active adminpane">
<h3>New Orders</h3><br>
<center>
<div id="a-new-bills">
<?php
$query1 = mysqli_query($bd,"SELECT * FROM bill WHERE b_delivery='' ORDER BY b_id DESC");
if(mysqli_num_rows($query1)>0)
{
while ($row1 = mysqli_fetch_array($query1))
{
$bid = $row1['b_id'];
$uid = $row1['b_uid'];
?>
<table class="bigtable">
<tr>
<td class="bigtd">
<table class="i-flex-bill adtable">
<tr class="t-head1">
<th>Bill ID : <?php echo $bid ?></th>
<th colspan="2"><?php echo $row1['b_date']; ?></th>
</tr>
<tr class="t-head2">
<th>Menu Item</th>
<th>Qty</th>
<th>Price (Rs)</th>
</tr>
<?php
$query2 = mysqli_query($bd,"SELECT * FROM orders INNER JOIN menu ON o_mid=m_id WHERE o_bid='$bid'");
if(mysqli_num_rows($query2)>0)
{
while ($row2 = mysqli_fetch_array($query2))
{?>
<tr class="t-content">
<td><?php echo ucwords($row2['m_name']); ?></td>
<td><?php echo $row2['o_quantity']; ?></td>
<td><?php echo $row2['o_price'] ?></td>
</tr>
<?php
}
}?>
<tr class="t-foot1">
<td>Sum (Without taxes)</td>
<td></td>
<td><?php echo $row1['b_sum']; ?></td>
</tr>
<tr class="t-foot2">
<td colspan="3">Total (Inclusive of taxes) : Rs.<?php echo $row1['b_total']; ?></td>
</tr>
<tr class="t-foot2">
<td colspan="3">Status : <?php echo ucfirst($row1['b_status'])?><br></td>
</tr>
</table>
</td>
<td class="bigtd">
<table>
<?php
$query3 = mysqli_query($bd,"SELECT * FROM users WHERE u_id='$uid'");
$row3 = mysqli_fetch_array($query3);
?>
<tr class="t-foot2">
<td colspan="3">Name : <?php echo ucfirst($row3['u_fname']).' '.ucfirst($row3['u_lname']) ?><br></td>
</tr>
<tr class="t-foot2">
<td colspan="3">Phone No : <?php echo $row3['u_phone'] ?><br></td>
</tr>
<tr class="t-foot2">
<td colspan="3">Address :<br><?php echo ucfirst($row1['b_address'])?><br><br></td>
</tr>
<tr class="t-foot2">
<td colspan="3">
<button type="button" class="submit-btn" value="<?php echo $row1['b_id'] ?>" onclick="orderStatus1(this)">Accept</button><br>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
}
?>
</div>
</center>
</div>
<div id="seenorders" class="tab-pane fade adminpane">
<h3>Accepted Orders</h3><br>
<center>
<div id="a-seen-bills">
<?php
$query1 = mysqli_query($bd,"SELECT * FROM bill WHERE b_delivery='accepted' ORDER BY b_id DESC");
if(mysqli_num_rows($query1)>0)
{
while ($row1 = mysqli_fetch_array($query1))
{
$bid = $row1['b_id'];
$uid = $row1['b_uid'];
?>
<table class="bigtable">
<tr>
<td class="bigtd">
<table class="i-flex-bill adtable">
<tr class="t-head1">
<th>Bill ID : <?php echo $bid ?></th>
<th colspan="2"><?php echo $row1['b_date']; ?></th>
</tr>
<tr class="t-head2">
<th>Menu Item</th>
<th>Qty</th>
<th>Price (Rs)</th>
</tr>
<?php
$query2 = mysqli_query($bd,"SELECT * FROM orders INNER JOIN menu ON o_mid=m_id WHERE o_bid='$bid'");
if(mysqli_num_rows($query2)>0)
{
while ($row2 = mysqli_fetch_array($query2))
{?>
<tr class="t-content">
<td><?php echo ucwords($row2['m_name']); ?></td>
<td><?php echo $row2['o_quantity']; ?></td>
<td><?php echo $row2['o_price'] ?></td>
</tr>
<?php
}
}?>
<tr class="t-foot1">
<td>Sum (Without taxes)</td>
<td></td>
<td><?php echo $row1['b_sum']; ?></td>
</tr>
<tr class="t-foot2">
<td colspan="3">Total (Inclusive of taxes) : Rs.<?php echo $row1['b_total']; ?></td>
</tr>
<tr class="t-foot2">
<td colspan="3">Status : <?php echo ucfirst($row1['b_status'])?><br></td>
</tr>
</table>
</td>
<td class="bigtd">
<table>
<?php
$query3 = mysqli_query($bd,"SELECT * FROM users WHERE u_id='$uid'");
$row3 = mysqli_fetch_array($query3);
?>
<tr class="t-foot2">
<td colspan="3">Name : <?php echo ucfirst($row3['u_fname']).' '.ucfirst($row3['u_lname']) ?><br></td>
</tr>
<tr class="t-foot2">
<td colspan="3">Phone No : <?php echo $row3['u_phone'] ?><br></td>
</tr>
<tr class="t-foot2">
<td colspan="3">Address :<br><?php echo ucfirst($row1['b_address'])?><br><br></td>
</tr>
<tr class="t-foot2">
<td colspan="3">
<button type="button" class="submit-btn" value="<?php echo $row1['b_id'] ?>" onclick="orderStatus2(this)">Delivered</button><br>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
}
?>
</div>
</center>
</div>
</div>
</div>
<script>
$(document).ready(function(){
setInterval(function(){
$('#a-new-bills').load(document.URL + ' #a-new-bills');
}, 30000);
});
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
});
function orderStatus1(bill) {
var bid = $(bill).val();
$.ajax({
type: 'POST',
url: 'phpfunctions.php',
data: {
'abillid': bid
},
success: function(status) {
if(status=='success')
{
$(bill).closest(".bigtable").remove();
$('#a-seen-bills').load(document.URL + ' #a-seen-bills');
}
else
alert("Failed");
}
});
}
function orderStatus2(bill) {
var bid = $(bill).val();
$.ajax({
type: 'POST',
url: 'phpfunctions.php',
data: {
'dbillid': bid
},
success: function(status) {
if(status=='success')
{
$(bill).closest(".bigtable").remove();
}
else
alert("Failed");
}
});
}
</script>
<br><br>
</body>