-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
177 lines (164 loc) · 8.4 KB
/
admin.php
File metadata and controls
177 lines (164 loc) · 8.4 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
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
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dashboard</title>
<?php
include "./includes/header.php";?>
<style>
.wrapper{
min-width: 650px;
margin: 0 auto;
background: white;
}
.page-header h2{
margin-top: 0;
}
table tr td:last-child a{
margin-right: 15px;
}
.text-color {
color: white;
}
</style>
<script>
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
</script>
</head>
<body>
<span class ="text-color">
<?php
include "./includes/nav.php";
session_start();
if (!isset($_SESSION['memberid']) || !$_SESSION['isAdmin']) {
header('HTTP/1.0 403 Forbidden');
echo "<br>";
echo "<br>";
echo "<br>";
echo "<br>";
echo "<h1>Forbidden</h1>";
echo "You must have admin privileges to access this page.";
echo "<br>";
echo "<br>";
}
else {
?>
</span>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="clearfix">
<br>
<br>
<br>
<br>
<h2 class="pull-left">Car Details</h2>
<a href="create.php" class="btn btn-success pull-right" style="color:whitesmoke;">Add New Car</a>
</div>
<?php
require_once "conntodb.php";
// Attempt select query execution
$sql = "SELECT * FROM car";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table class='table table-bordered table-striped'>";
echo "<thead>";
echo "<tr>";
echo "<th>#</th>";
echo "<th>Brand</th>";
echo "<th>Model</th>";
echo "<th>Price</th>";
echo "<th>Stock</th>";
echo "<th>Status</th>";
echo "<th>Action</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['brand'] . "</td>";
echo "<td>" . $row['model'] . "</td>";
echo "<td>" . $row['price'] . "</td>";
echo "<td>" . $row['stock'] . "</td>";
echo "<td>" . $row['status'] . "</td>";
echo "<td>";
echo "<a href='read.php?id=". $row['id'] ."' title='View Record' data-toggle='tooltip'><span class='fa fa-eye'></span></a>";
echo "<a href='update.php?id=". $row['id'] ."' title='Update Record' data-toggle='tooltip'><span class='fa fa-pencil'></span></a>";
echo "<a href='delete.php?id=". $row['id'] ."' title='Delete Record' data-toggle='tooltip'><span class='fa fa-trash'></span></a>";
echo "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
// Free result set
mysqli_free_result($result);
} else{
echo "<p class='lead'><em>No records were found.</em></p>";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
?>
</div>
</div>
</div>
</div>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="clearfix">
<br>
<h2 class="pull-left">Order Details</h2>
</div>
<?php
//for ORDERS and ORDER_DETAIL
$stmt = $link->prepare("SELECT os.id, charge_id, transaction_date, saleStatus, count(car_id) cars FROM orders os, order_detail od where os.id = od.order_id group by os.id");
$stmt->execute();
$result = $stmt->get_result();
?>
<table class='table table-bordered table-striped'>
<thead>
<tr>
<th>#</th>
<th>Transaction Date</th>
<th>Charge ID</th>
<th>Sale Status</th>
<th>Count of Cars</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
while($row = $result->fetch_assoc()) {
?>
<tr>
<td><?php echo $row["id"]?></td>
<td><?php echo $row["transaction_date"]?></td>
<td><?php echo $row["charge_id"]?></td>
<td><?php echo $row["saleStatus"]?></td>
<td><?php echo $row["cars"]?></td>
<td>
<a href='orderMod.php?mod=upd&id=<?php echo $row["id"]?>&status=1' title='Update Status: Processed' data-toggle='tooltip'><span class='fa fa-pencil'></span></a>
<a href='orderMod.php?mod=upd&id=<?php echo $row["id"]?>&status=2' title='Update Status: Completed' data-toggle='tooltip'><span class='fa fa-pencil'></span></a>
<a href='orderMod.php?mod=del&id=<?php echo $row["id"]?>' title='Delete Order' data-toggle='tooltip'><span class='fa fa-trash'></span></a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php
}
include "./includes/footer.php";
?>
</body>
</html>