-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelivery.html
More file actions
265 lines (232 loc) · 8.09 KB
/
delivery.html
File metadata and controls
265 lines (232 loc) · 8.09 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
256
257
258
259
260
261
262
263
264
265
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Panel - Order & Delivery Management</title>
<style>
body {
font-family: 'Arial', sans-serif;
background-color: #f9f4e6;
margin: 0;
padding: 0;
color: #4a3c31;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
h1 {
text-align: center;
color: #6b4f3a;
}
.tabs {
display: flex;
justify-content: center;
margin-top: 20px;
}
.tab {
background-color: #8c6a47;
color: #fff;
padding: 15px 30px;
cursor: pointer;
border-radius: 8px;
margin: 0 10px;
transition: background-color 0.3s ease;
}
.tab:hover, .active-tab {
background-color: #a07856;
}
.orders, .delivery-system {
display: none;
margin-top: 20px;
}
.orders.active-tab, .delivery-system.active-tab {
display: block;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th, td {
padding: 12px;
text-align: center;
border: 1px solid #ddd;
}
th {
background-color: #6b4f3a;
color: #fff;
}
td {
background-color: #f9f4e6;
color: #4a3c31;
}
.action-btn {
background-color: #8c6a47;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 8px;
cursor: pointer;
font-size: 16px;
}
.action-btn:hover {
background-color: #a07856;
}
.status-select {
padding: 5px 10px;
margin-right: 10px;
border-radius: 5px;
border: 1px solid #ddd;
}
</style>
</head>
<body>
<div class="container">
<h1>Admin Panel - Order & Delivery Management</h1>
<!-- Tab Navigation -->
<div class="tabs">
<div class="tab active-tab" id="customerOrdersTab">Order Management</div>
<div class="tab" id="deliverySystemTab">Delivery Management</div>
</div>
<!-- Order Management Section -->
<div class="orders active-tab" id="customerOrders">
<h2>Order Management</h2>
<table id="ordersTable">
<thead>
<tr>
<th>Order ID</th>
<th>Customer Name</th>
<th>Order Date</th>
<th>Items</th>
<th>Total Amount</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<!-- Orders will be dynamically inserted here -->
</tbody>
</table>
</div>
<!-- Delivery Management Section -->
<div class="delivery-system" id="deliverySystem">
<h2>Delivery Management</h2>
<table id="deliveryTable">
<thead>
<tr>
<th>Order ID</th>
<th>Customer Name</th>
<th>Delivery Date</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<!-- Delivery orders will be dynamically inserted here -->
</tbody>
</table>
</div>
</div>
<script>
// Initialize order and delivery data arrays
let customerOrders = [];
let deliveryOrders = [];
// Function to update the Customer Orders Table
function updateOrdersTable() {
const ordersTable = document.getElementById('ordersTable').getElementsByTagName('tbody')[0];
ordersTable.innerHTML = '';
customerOrders.forEach(order => {
const row = document.createElement('tr');
row.innerHTML = `
<td>${order.orderId}</td>
<td>${order.customerName}</td>
<td>${order.orderDate}</td>
<td>${order.items.map(item => item.name).join(', ')}</td>
<td>$${order.totalAmount.toFixed(2)}</td>
<td><button class="action-btn" onclick="moveToDelivery('${order.orderId}')">Add to Delivery</button></td>
`;
ordersTable.appendChild(row);
});
}
// Function to update the Delivery Table
function updateDeliveryTable() {
const deliveryTable = document.getElementById('deliveryTable').getElementsByTagName('tbody')[0];
deliveryTable.innerHTML = '';
deliveryOrders.forEach(order => {
const row = document.createElement('tr');
row.innerHTML = `
<td>${order.orderId}</td>
<td>${order.customerName}</td>
<td>${order.deliveryDate}</td>
<td>
<select class="status-select" onchange="updateDeliveryStatus('${order.orderId}', this.value)">
<option value="Pending" ${order.status === 'Pending' ? 'selected' : ''}>Pending</option>
<option value="In Progress" ${order.status === 'In Progress' ? 'selected' : ''}>In Progress</option>
<option value="Delivered" ${order.status === 'Delivered' ? 'selected' : ''}>Delivered</option>
</select>
</td>
<td><button class="action-btn" onclick="completeDelivery('${order.orderId}')">Complete Delivery</button></td>
`;
deliveryTable.appendChild(row);
});
}
// Function to move an order to the Delivery System
function moveToDelivery(orderId) {
const order = customerOrders.find(o => o.orderId === orderId);
if (order) {
// Add delivery date and status
order.deliveryDate = new Date().toLocaleDateString();
order.status = 'Pending';
// Move order from customerOrders to deliveryOrders
deliveryOrders.push(order);
customerOrders = customerOrders.filter(o => o.orderId !== orderId);
// Update both tables
updateOrdersTable();
updateDeliveryTable();
}
}
// Function to update the delivery status
function updateDeliveryStatus(orderId, newStatus) {
const order = deliveryOrders.find(o => o.orderId === orderId);
if (order) {
order.status = newStatus;
updateDeliveryTable();
}
}
// Function to mark a delivery as complete
function completeDelivery(orderId) {
const order = deliveryOrders.find(o => o.orderId === orderId);
if (order) {
order.status = 'Delivered';
updateDeliveryTable();
}
}
// Tab Navigation
document.getElementById('customerOrdersTab').addEventListener('click', () => {
document.getElementById('customerOrders').style.display = 'block';
document.getElementById('deliverySystem').style.display = 'none';
document.getElementById('customerOrdersTab').classList.add('active-tab');
document.getElementById('deliverySystemTab').classList.remove('active-tab');
});
document.getElementById('deliverySystemTab').addEventListener('click', () => {
document.getElementById('customerOrders').style.display = 'none';
document.getElementById('deliverySystem').style.display = 'block';
document.getElementById('deliverySystemTab').classList.add('active-tab');
document.getElementById('customerOrdersTab').classList.remove('active-tab');
});
// Simulate receiving orders from the customer side (using localStorage)
function loadCustomerOrder() {
const orderDetails = JSON.parse(localStorage.getItem('newOrder'));
if (orderDetails) {
customerOrders.push(orderDetails);
updateOrdersTable();
localStorage.removeItem('newOrder');
}
}
// Load customer orders when the page loads
window.onload = loadCustomerOrder;
</script>
</body>
</html>