-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadmin_addNewMenu.html
283 lines (269 loc) · 18.3 KB
/
admin_addNewMenu.html
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add New Menu</title>
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/adminmain.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="container-fluid">
<div class="row">
<div class="col-md-2">
<div class="sidebar" style="width: 350px; ">
<div class="row">
<div class="col">
<div class="d-flex flex-column flex-shrink-0 p-3 sidebar custom-bg">
<a href="/"
class="d-flex align-items-center mb-3 mb-md-0 me-md-auto link-body-emphasis text-decoration-none">
<svg class="bi pe-none me-2" width="40" height="32">
<use xlink:href="#bootstrap" />
</svg>
<span class="fs-4">Big Bang Fried Chicken</span>
</a>
<hr>
<ul class="nav nav-pills flex-column mb-auto">
<li>
<a href="admin_MenuUpdate_Promotion.html" class="nav-link active">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" class="bi bi-pencil"
viewBox="0 0 16 16">
<path
d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325" />
</svg>
<svg class="bi pe-none me-2" width="16" height="16">
<use xlink:href="#speedometer2" />
</svg>
Menu View
</a>
</li>
<li>
<a href="admin_foodManagement.html"
class="nav-link link-body-emphasis">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" class="bi bi-pencil"
viewBox="0 0 16 16">
<path
d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325" />
</svg>
<svg class="bi pe-none me-2" width="16" height="16">
<use xlink:href="#speedometer2" />
</svg>
Food Management
</a>
</li>
<li>
<a href="admin_orderHistory.html"
class="nav-link link-body-emphasis">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" class="bi bi-clock-history"
viewBox="0 0 16 16">
<path
d="M8.515 1.019A7 7 0 0 0 8 1V0a8 8 0 0 1 .589.022zm2.004.45a7 7 0 0 0-.985-.299l.219-.976q.576.129 1.126.342zm1.37.71a7 7 0 0 0-.439-.27l.493-.87a8 8 0 0 1 .979.654l-.615.789a7 7 0 0 0-.418-.302zm1.834 1.79a7 7 0 0 0-.653-.796l.724-.69q.406.429.747.91zm.744 1.352a7 7 0 0 0-.214-.468l.893-.45a8 8 0 0 1 .45 1.088l-.95.313a7 7 0 0 0-.179-.483m.53 2.507a7 7 0 0 0-.1-1.025l.985-.17q.1.58.116 1.17zm-.131 1.538q.05-.254.081-.51l.993.123a8 8 0 0 1-.23 1.155l-.964-.267q.069-.247.12-.501m-.952 2.379q.276-.436.486-.908l.914.405q-.24.54-.555 1.038zm-.964 1.205q.183-.183.35-.378l.758.653a8 8 0 0 1-.401.432z" />
<path
d="M8 1a7 7 0 1 0 4.95 11.95l.707.707A8.001 8.001 0 1 1 8 0z" />
<path
d="M7.5 3a.5.5 0 0 1 .5.5v5.21l3.248 1.856a.5.5 0 0 1-.496.868l-3.5-2A.5.5 0 0 1 7 9V3.5a.5.5 0 0 1 .5-.5" />
</svg>
<svg class="bi pe-none me-2" width="16" height="16">
<use xlink:href="#table" />
</svg>
Order History
</a>
</li>
<li>
<a href="admin_feedback.html" class="nav-link link-body-emphasis">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" class="bi bi-clock-history"
viewBox="0 0 16 16">
<path
d="M8.515 1.019A7 7 0 0 0 8 1V0a8 8 0 0 1 .589.022zm2.004.45a7 7 0 0 0-.985-.299l.219-.976q.576.129 1.126.342zm1.37.71a7 7 0 0 0-.439-.27l.493-.87a8 8 0 0 1 .979.654l-.615.789a7 7 0 0 0-.418-.302zm1.834 1.79a7 7 0 0 0-.653-.796l.724-.69q.406.429.747.91zm.744 1.352a7 7 0 0 0-.214-.468l.893-.45a8 8 0 0 1 .45 1.088l-.95.313a7 7 0 0 0-.179-.483m.53 2.507a7 7 0 0 0-.1-1.025l.985-.17q.1.58.116 1.17zm-.131 1.538q.05-.254.081-.51l.993.123a8 8 0 0 1-.23 1.155l-.964-.267q.069-.247.12-.501m-.952 2.379q.276-.436.486-.908l.914.405q-.24.54-.555 1.038zm-.964 1.205q.183-.183.35-.378l.758.653a8 8 0 0 1-.401.432z" />
<path
d="M8 1a7 7 0 1 0 4.95 11.95l.707.707A8.001 8.001 0 1 1 8 0z" />
<path
d="M7.5 3a.5.5 0 0 1 .5.5v5.21l3.248 1.856a.5.5 0 0 1-.496.868l-3.5-2A.5.5 0 0 1 7 9V3.5a.5.5 0 0 1 .5-.5" />
</svg>
<svg class="bi pe-none me-2" width="16" height="16">
<use xlink:href="#table" />
</svg>
Feedback
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div>
<h2>Hi <span class="user-name"></span> </h2>
</div>
<!--Admin personal infomation add function-->
<div class="col-md-8">
<div>
<h4>Add New Menu Item</h4>
</div>
<hr>
<div class="row">
<!-- One-third width column -->
<div class="col-md-4">
<img src="images/Beverages_Mineral_Water.jpg" alt="Cart Image" class="img-fluid img-food">
</div>
<!-- Two-thirds width column -->
<div class="col-md-8">
<div class="item-details">
<form id="add-food-form" class="needs-validation" novalidate>
<div class="row">
<label for="foodTitle" class="form-label">Food Title: </label>
<input type="text" class="form-control" id="food-name" name="foodName"
placeholder="Enter the food title" value="" required>
<div class="invalid-feedback">
Valid food title is required.
</div>
</div>
<div class="row">
<label for="price" class="form-label">Price (RM): </label>
<input type="number" class="form-control" id="food-price" name="price"
placeholder="Enter the price" value="" required>
<div class="invalid-feedback">
Valid price is required.
</div>
</div>
<div class="row">
<label for="foodDes" class="form-label">Description: </label>
<input type="text" class="form-control" id="food-info" name="info"
placeholder="Add the description for this menu" value="" required>
<div class="invalid-feedback">
Valid description is required.
</div>
</div>
<div class="row">
<label for="current-categories">Categories</label>
<select class="custom-select d-block w-100" id="current-categories"
name="category-id" required>
<option value="">-Choose type of category-</option>
<option>Beverages</option>
<option>Fried Chicken</option>
<option>Combo</option>
<option>Sides</option>
</select>
<div class="invalid-feedback">
Please select a type of feedback.
</div>
</div>
<br>
<div class="row">
Promotion
</div>
<div class="row">
<div class="row mb-3">
<div class="col-6 promotionRadio">
<label class="list-group-item d-flex gap-2 mb-2">
<input class="form-check-input flex-shrink-0" type="radio"
name="Promotion" id="Promotion" value="yes">
<span>Yes</span>
</label>
</div>
<div class="col-6 promotionRadio">
<label class="list-group-item d-flex gap-2 mb-0">
<input class="form-check-input flex-shrink-0" type="radio"
name="Promotion" id="noPromotion" value="no" checked>
<span>No</span>
</label>
</div>
</div>
</div>
<div class="row">
<div id="extraForm" style="display: none;">
<form>
<!-- Additional form fields go here -->
<div class="form-group">
<label for="Promotion Price">Promotion Price:</label>
<input type="text" class="form-control" id="Promotion Price"
placeholder="New Price">
</div>
</form>
</div>
</div>
<div class="row">
<div
class="col-12 d-flex flex-row-reverse justify-content-between align-items-center py-3">
<button type="submit" class="btn btn-primary">Update</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="./js/jquery-3.7.1.js"></script>
<script src="js/admin.js"></script>
<script src="./js/bootstrap.js"></script>
<script src="./js/axios.js"></script>
<script src="./js/AjaxHelper.js"></script>
<script>
$(document).ready(function () {
// Function to fetch categories and populate dropdowns
function fetchCategories() {
$.ajax({
url: 'http://bugcreator.org.cn:5000/foodCategory/list',
type: 'GET',
success: function (response) {
var categories = response.message.items; // Access the items array within the message object
$('#current-categories').empty();
$('#delete-category-id').empty();
categories.forEach(function (category) {
$('#current-categories').append('<option value="' + category.id + '">' + category.categoryName + '</option>');
$('#delete-category-id').append('<option value="' + category.id + '">' + category.categoryName + '</option>');
});
},
error: function (xhr, status, error) {
alert('Error fetching categories: ' + xhr.responseText);
}
});
}
// Fetch categories when the page loads
fetchCategories();
// Event listener for form submission
$('#add-food-form').on('submit', function (e) {
e.preventDefault(); // Prevent default form submission
// Collect form data
var foodData = {
foodName: $('#food-name').val(),
src: $('#food-src').val(),
foodCategoryId: parseInt($('#current-categories').val()), // Assuming category ID is a number
price: parseFloat($('#food-price').val()), // Assuming price is a float
info: $('#food-info').val()
};
// Send POST request using AJAX
$.ajax({
url: 'http://bugcreator.org.cn:5000/food/add', // Replace with your actual endpoint
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(foodData), // Convert data to JSON string
success: function (response) {
console.log('Food item added successfully:', response);
alert(response.message);
// Clear form fields or reset form as needed
$('#add-food-form')[0].reset();
},
error: function (error) {
console.error('Error adding food item:', error);
// Handle error case, show error message, etc.
alert('Error adding food item. Please try again.');
}
});
});
});
</script>
</body>
</html>