-
Notifications
You must be signed in to change notification settings - Fork 0
/
order_ad.php
186 lines (158 loc) · 7.43 KB
/
order_ad.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
<?php clearstatcache(); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN"
crossorigin="anonymous"
/>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<link rel="stylesheet" href="assets/css/styles.css" />
<link rel="stylesheet" href="assets/css/styles.css?v=2" />
<title>Admin Dashboard</title>
<style>
html{
font-size:0.8750em;
}
</style>
</head>
<body id="body">
<div class="container-fluid">
<?php require_once 'nav_admin.php' ?>
<main style="height:100vh">
<div class="main__container">
<div class="main__title">
<img src="assets/hello.svg" alt="" />
<div class="main__greeting">
<h1>Hello Caffeteria</h1>
<p>Welcome to your admin dashboard</p>
</div>
</div>
</div>
<section class="content">
<div class="box-body">
<div class="table-responsive rounded card-table">
<div id="example1_wrapper" class="dataTables_wrapper container-fluid dt-bootstrap4 no-footer"><div class="row"><div class="col-sm-12 col-md-6"></div><div class="col-sm-12 col-md-6"></div></div>
<div class="row" style="background-color:white;padding-top:30px">
<div class="col-sm-12" style="padding-bottom:30px;"><table class="table border-no dataTable no-footer" id="example1" role="grid" aria-describedby="example1_info">
<thead>
<tr role="row">
<th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-label="Order ID: activate to sort column ascending">Order ID</th><th class="sorting_asc" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-label="Date: activate to sort column descending" aria-sort="ascending">Date</th><th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-label="Customer Name: activate to sort column ascending">Customer Name</th><th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-label="Location: activate to sort column ascending">Location</th><th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-label="Amount: activate to sort column ascending">Amount</th><th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-label="Status Order: activate to sort column ascending">Status Order</th><th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" aria-label=": activate to sort column ascending"></th></tr>
</thead>
<tbody>
<?php
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}
$no_of_records_per_page = 10;
$offset = ($pageno-1) * $no_of_records_per_page;
require_once "config.php";
// Check connection
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
die();
}
$total_pages_sql = "SELECT COUNT(*) FROM orders";
$result = mysqli_query($conn,$total_pages_sql);
$total_rows = mysqli_fetch_array($result)[0];
$total_pages = ceil($total_rows / $no_of_records_per_page);
$sql = "SELECT * FROM orders order by order_id desc LIMIT $offset, $no_of_records_per_page";
$res_data = mysqli_query($conn,$sql);
while($row = mysqli_fetch_array($res_data)){
//here goes the data
echo '<tr class="hover-primary even" role="row">';
echo '<td class="">#' . $row['order_id'] . '</td>';
echo '<td class="sorting_1">' . $row['date'] . '</td>';
echo '<td>' . $row['name'] . '</td>';
echo '<td>' . $row['address'] . '</td>';
echo '<td> $' . $row['amount'] . '</td>';
if($row['status']=='in_progress') {
echo '<td id="'. $row['order_id'] .'span"> <span class="badge badge-pill badge-warning">In Progress...</span> </td>';
echo '<td> <div id="'. $row['order_id'] .'" class="btn-group"> <a class="hover-primary dropdown-toggle no-caret" data-bs-toggle="dropdown" aria-expanded="false"><i class="fa fa-ellipsis-h"></i></a> <div class="dropdown-menu" style="margin: 0px;">';
echo '<a class="dropdown-item" onclick="deliver(' . $row['order_id'] . ')">Delivered</a>';
echo '<a class="dropdown-item" onclick="cancel(' . $row['order_id'] . ')">Cancel</a>';
echo '</div></div></td>';
}
else if($row['status']=='delivered')
echo '<td> <span class="badge badge-pill badge-success">Delivered</span> </td> <td></td>';
else
echo '<td> <span class="badge badge-pill badge-danger">Cancelled</span> </td> <td></td>';
echo '</tr>';
}
mysqli_close($conn);
?>
<tr>
<td>
<ul class="pagination">
<li><a href="?pageno=1">First</a></li>
<li class="<?php if($pageno <= 1){ echo 'disabled'; } ?>">
<a href="<?php if($pageno <= 1){ echo '#'; } else { echo "?pageno=".($pageno - 1); } ?>">Prev</a>
</li>
<li class="<?php if($pageno >= $total_pages){ echo 'disabled'; } ?>">
<a href="<?php if($pageno >= $total_pages){ echo '#'; } else { echo "?pageno=".($pageno + 1); } ?>">Next</a>
</li>
<li><a href="?pageno=<?php echo $total_pages; ?>">Last</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</section>
</main>
<!-- <div id="sidebar">
<div class="sidebar__title">
<div class="sidebar__img">
<img src="assets/logo.png" alt="logo" />
<h1>Cafeteria</h1>
</div>
<i
onclick="closeSidebar()"
class="fa fa-times"
id="sidebarIcon"
aria-hidden="true"
></i>
</div>
<div class="sidebar__menu">
<div class="sidebar__link active_menu_link">
<i class="fa fa-home"></i>
<a href="#">Dashboard</a>
</div>
</div>
</div> -->
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
<script src="assets/js/script.js"></script>
<script>
function send_post(value,status)
{
$.ajax({
type:"POST",
url:"update_status.php",
data: "order_id=" + value + "&status=" + status,
success:function(html)
{
if(html=='true')
console.log('updated');
else
console.log(html);
}
});
}
</script>
</body>
</html>