-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheditadmin.php
More file actions
255 lines (219 loc) · 14.2 KB
/
Copy patheditadmin.php
File metadata and controls
255 lines (219 loc) · 14.2 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
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<?php
session_start();
if (!isset($_SESSION['userId'])) {
header("Location: login.php");
}
?>
<html lang="en">
<head>
<title>Kueh Menu</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name ="KUUUEEEH website where you find the best kuehs" content="" property="">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/editadmin.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src='https://kit.fontawesome.com/a076d05399.js'></script>
<script src="js/editadmin.js"></script>
<script src="js/process_editadmin.js"></script>
</head>
<body>
<?php include "adminheader.php" ?>
<div class="container">
<!--The animated kueh images for the banner are taken and credited by ladyironchef: Beginner’s Guide to Kuehs – 9 Traditional Kuehs You Must Try https://www.ladyironchef.com/2015/08/guide-traditional-kueh/-->
<img src="img/BannerWhite.png" alt="Kueh Banner" class="responsive" id="bannerresize">
</div>
<!--Admin header and search by category or food name and add food item function-->
<section class="container standardfont">
<h1 class="fontheader" id="editadmin_header">Kueh Panel</h1>
<section class="card">
<section class="card-header">
<span class="fas fa-search searchIcon"></span><strong> Search by</strong>
<a href="#" class="btn btn-dark addItem btn-sm" data-toggle="modal" data-target="#addModal" aria-label="Add New Item"><span class="fa fa-plus-circle"></span> Add New Item</a>
</section>
<section class="card-body">
<form name = "searchform" action="process_search.php" onsubmit="return validateSearch()" method="post">
<div class="row">
<div class="col-2">
<section class="form-group">
<label for="scategory" class="formtitle">Category</label>
<input type="text" name="scategory" id="scategory" class="form-control" placeholder="Enter Category" required pattern="^[a-zA-Z](?!.* {2})[ \w.-]{2,}$">
</section>
</div>
<div class="col-2">
<section class="form-group">
<label for="sname">Name</label>
<input type="text" name="sname" id="sname" class="form-control" placeholder="Enter Name" required pattern="^[a-zA-Z](?!.* {2,})[ \w.-]{2,}$">
</section>
</div>
<div class="col-4">
<button type="submit" name="submit" value="search" id="search" class="btn btn-primary" aria-label="Submit Search"><span class="fas fa-search"></span> Search</button>
</div>
</div>
</form>
</section>
</section>
</section>
<!--add new item modal-->
<aside class="modal fade standardfont" id="addModal">
<section class="modal-dialog modal-dialog-centered">
<section class="modal-content">
<form name = "addform" action="process_admin_addnew.php" onsubmit="return validateAdd()" method="post" enctype="multipart/form-data">
<section class="modal-header">
<h4 class="modal-title">Add New Item</h4>
<button type="button" class="close" data-dismiss="modal" role="button" aria-label="Close Add New Item">×</button>
</section>
<section class="modal-body">
<section class="form-group">
<label for="addCategory">Select Category:</label>
<select class="form-control" name="addCategory" id="addCategory" required>
<option value="" disabled selected>Please select an category</option>
<option value="Kueh with Character">Kueh with Character</option>
<option value ="The Basic Kuehs">The Basic Kuehs</option>
<option value ="The Heavyweight Kuehs">The Heavyweight Kuehs</option>
</select>
</section>
<section class="form-group">
<label for="addName">Name</label>
<input type="text" name="addName" id="addName" class="form-control" placeholder="Enter Name" required maxLength="15" pattern="/^[a-zA-Z ](?!.*{2,})[ \w.-]{2,}$/">
</section>
<section class="form-group">
<label for="addDescription">Description</label>
<textarea name="addDescription" id="addDescription" class="form-control" rows="5" placeholder="Enter Description" required maxLength="200"></textarea>
</section>
<section class="form-group">
<label for="addPrice">Price</label>
<input type="text" name="addPrice" id="addPrice" class="form-control" placeholder="Enter Price" required pattern="^(?=.*[1-9])\d{0,2}(?:\.\d{0,2})?$">
</section>
<p>Insert Image</p>
<section class="custom-file">
<label class="custom-file-label" for="insertImg">Choose file</label>
<input type="file" class="custom-file-input" name="insertImg" id="insertImg" required accept=".jpg, .jpeg">
</section>
</section>
<section class="modal-footer">
<button type="submit" class="btn btn-success" name="submit" id="submit">Submit</button>
</section>
</form>
</section>
</section>
</aside>
<!--Edit/update & display food items in the menu table-->
<section class="container standardfont">
<section class="card">
<table class="table table-hover table-responsive">
<thead>
<tr class="d-flex">
<th class="col-1">Prod No.</th>
<th class="col-2">Category</th>
<th class="col-2">Name</th>
<th class="col-2">Description</th>
<th class="col-1">Price</th>
<th class="col-2">Image</th>
<th class="col-1">Status</th>
<th class="col-1">Action</th>
</tr>
</thead>
<tbody>
<?php
include "dbConfig.php";
$conn = connectToDB();
$sql = "SELECT * FROM product";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
?>
<tr class="table-light d-flex">
<td class="col-1 data"><?php echo $row['prodId']; ?></td>
<td class="col-2 data"><?php echo $row['category']; ?></td>
<td class="col-2 data"><?php echo $row['name']; ?></td>
<td class="col-2 data"><?php echo $row['description'];?></td>
<td class="col-1 data"><?php echo $row['price']; ?></td>
<td class="col-2"><img src="<?php echo $row['image']; ?>" class="img-fluid img-thumbnail" alt="<?php echo $row['name']; ?>"></td>
<td class="col-1 data"><?php echo $row['status']; ?></td>
<td class="col-1"><button type="button" class="btn editbtn" aria-label="Edit Item"><span class="fa fa-edit"> Edit</span></button>
</tr>
<?php
}
} else {
echo "0 results found";
}
$result->free_result();
?>
</tbody>
</table>
</section>
</section>
<!--Edit modal-->
<!-- https://www.youtube.com/watch?v=mh4MVFiMZTM to retrieve and display in the fields-->
<aside>
<section class="modal fade standardfont" id="editModal">
<section class="modal-dialog modal-dialog-centered">
<section class="modal-content">
<form name = "editform" action="process_admin_edit.php" onsubmit="return validateEdit()" method="post" enctype="multipart/form-data">
<section class="modal-header">
<h4 class="modal-title">Edit Item</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</section>
<section class="modal-body">
<section class="form-group">
<label for="updateProdId">Product Id</label>
<input type="text" name="updateProdId" id="updateProdId" class="form-control" placeholder="Product ID" readonly>
</section>
<section class="form-group">
<label for="editCategory">Select Category:</label>
<select class="form-control" name="editCategory" id="editCategory" required>
<option value="" disabled>Please select a category</option>
<option value ="Kueh with Character">Kueh with Character</option>
<option value ="The Basic Kuehs">The Basic Kuehs</option>
<option value ="The Heavyweight Kuehs">The Heavyweight Kuehs</option>
</select>
</section>
<section class="form-group">
<label for="editName">Name</label>
<input type="text" name="editName" id="editName" class="form-control" placeholder="Enter Name" required maxLength="15" pattern="/^[a-zA-Z ](?!.*{2,})[ \w.-]{2,}$/">
</section>
<section class="form-group">
<label for="editDescription">Description</label>
<textarea name="editDescription" id="editDescription" class="form-control" rows="5" placeholder="" required maxLength="200"></textarea>
</section>
<section class="form-group">
<label for="editPrice">Price</label>
<input type="text" name="editPrice" id="editPrice" class="form-control" required pattern="^(?=.*[1-9])\d{0,2}(?:\.\d{0,2})?$">
</section>
<section class="form-group">
<label for="editStatus">Select Status:</label>
<select class="form-control" name="editStatus" id="editStatus" required>
<option value="" disabled>Please select a status</option>
<option>Active</option>
<option>Inactive</option>
</select>
</section>
<p>Update Image</p>
<section class="custom-file">
<label class="custom-file-label" for="updateImg">Choose file</label>
<input type="file" class="custom-file-input" id="updateImg" name="updateImg" accept=".jpg, .jpeg">
</section>
</section>
<section class="modal-footer">
<button type="submit" class="btn btn-success" id="update" name="update" aria-label="Update Item">Update</button>
</section>
</form>
</section>
</section>
</section>
</aside>
</body>
</html>