Repository navigation
Expand file tree
/
Copy pathorders.html
More file actions
64 lines (57 loc) · 2.03 KB
/
Copy pathorders.html
File metadata and controls
64 lines (57 loc) · 2.03 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
<!DOCTYPE html>
<html lang="fa">
<script src="auth.js"></script>
<script>checkAuth();</script>
<head>
<meta charset="UTF-8">
<title>پیگیری سفارشات زنده</title>
<link rel="stylesheet" href="style.css">
<style>
.order-box {
border: 1px solid #ccc;
padding: 10px;
margin-bottom: 15px;
border-radius: 10px;
background: #fdfdfd;
}
.order-box h3 { margin: 5px 0; }
.status-btn { margin-top: 10px; }
</style>
</head>
<body>
<div class="container" style="max-width: 700px;">
<h2>📦 سفارشات در حال پیگیری</h2>
<div id="orders-container"></div>
</div>
<script>
const ordersContainer = document.getElementById("orders-container");
const orders = JSON.parse(localStorage.getItem("orders")) || [];
const statuses = ["در انتظار", "در حال آمادهسازی", "تحویلشده"];
function renderOrders() {
ordersContainer.innerHTML = "";
orders.forEach((order, index) => {
const box = document.createElement("div");
box.className = "order-box";
let items = order.items.map(item => `🍽 ${item.name} × ${item.count}`).join("<br>");
box.innerHTML = `
<h3>🧾 سفارش #${index + 1}</h3>
<p><strong>مشتری:</strong> ${order.customer || "ناشناس"}</p>
<p><strong>غذاها:</strong><br>${items}</p>
<p><strong>مبلغ:</strong> ${order.total} تومان</p>
<p><strong>وضعیت:</strong> ${order.status}</p>
<button class="status-btn" onclick="nextStatus(${index})">📤 تغییر وضعیت</button>
`;
ordersContainer.appendChild(box);
});
}
function nextStatus(index) {
let current = orders[index].status || statuses[0];
let nextIndex = (statuses.indexOf(current) + 1) % statuses.length;
orders[index].status = statuses[nextIndex];
localStorage.setItem("orders", JSON.stringify(orders));
renderOrders();
}
renderOrders();
</script>
</body>
</html>