Spaces:
Sleeping
Sleeping
Update templates/order_history.html
Browse files- templates/order_history.html +101 -119
templates/order_history.html
CHANGED
@@ -4,156 +4,138 @@
|
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>Order History</title>
|
|
|
|
|
7 |
<style>
|
8 |
body {
|
9 |
-
font-family: Arial, sans-serif;
|
10 |
-
background-color: #
|
|
|
11 |
margin: 0;
|
12 |
padding: 0;
|
13 |
-
text-align: center;
|
14 |
}
|
15 |
-
|
16 |
-
|
17 |
-
max-width: 600px;
|
18 |
margin: 40px auto;
|
19 |
-
background: white;
|
20 |
padding: 20px;
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
h2 {
|
26 |
-
color: #007bff;
|
27 |
-
margin-bottom: 15px;
|
28 |
-
}
|
29 |
-
|
30 |
-
.back-button {
|
31 |
-
display: block;
|
32 |
-
margin: 10px auto 20px;
|
33 |
-
background-color: #007bff;
|
34 |
-
color: white;
|
35 |
-
padding: 10px 15px;
|
36 |
-
border: none;
|
37 |
-
border-radius: 5px;
|
38 |
-
font-size: 16px;
|
39 |
-
cursor: pointer;
|
40 |
-
text-decoration: none;
|
41 |
-
width: 50%;
|
42 |
}
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
.order-card {
|
49 |
-
background: #fff;
|
50 |
-
padding: 15px;
|
51 |
-
margin: 10px 0;
|
52 |
border-radius: 8px;
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
.order-card p {
|
58 |
-
margin: 5px 0;
|
59 |
-
font-size: 14px;
|
60 |
}
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
border-radius: 5px;
|
66 |
-
display: inline-block;
|
67 |
}
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
color: #fff;
|
72 |
}
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
color: #
|
77 |
}
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
color: #
|
82 |
}
|
83 |
-
|
84 |
-
.show-more-btn {
|
85 |
-
background-color: #007bff;
|
86 |
-
color: white;
|
87 |
padding: 8px 15px;
|
|
|
|
|
88 |
border: none;
|
89 |
-
border-radius:
|
90 |
-
font-size:
|
|
|
91 |
cursor: pointer;
|
92 |
-
|
93 |
-
display: block;
|
94 |
-
width: 50%;
|
95 |
-
margin-left: auto;
|
96 |
-
margin-right: auto;
|
97 |
}
|
98 |
-
|
99 |
-
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
102 |
-
|
103 |
</style>
|
104 |
</head>
|
105 |
<body>
|
106 |
|
107 |
<div class="container">
|
108 |
-
<
|
109 |
-
|
110 |
-
<!-- Back to Menu Button -->
|
111 |
-
<a href="{{ url_for('menu') }}" class="back-button">Back to Menu</a>
|
112 |
-
|
113 |
-
{% if orders %}
|
114 |
-
{% for order in orders %}
|
115 |
-
<div class="order-card {% if loop.index > 3 %}hidden{% endif %}">
|
116 |
-
<p><strong>Date:</strong> {{ order['CreatedDate'][:10] }}</p>
|
117 |
-
<p><strong>Order:</strong> {{ order['Order_Details__c'] }}</p>
|
118 |
-
<p><strong>Total Amount:</strong> ${{ order['Total_Amount__c'] }}</p>
|
119 |
-
<p><strong>Discount:</strong> ${{ order['Discount__c'] }}</p>
|
120 |
-
<p><strong>Total Bill:</strong> ${{ order['Total_Bill__c'] }}</p>
|
121 |
-
<p class="order-status
|
122 |
-
{% if order['Order_Status__c'] == 'Pending' %}status-pending
|
123 |
-
{% elif order['Order_Status__c'] == 'Completed' %}status-completed
|
124 |
-
{% elif order['Order_Status__c'] == 'Cancelled' %}status-cancelled{% endif %}">
|
125 |
-
{{ order['Order_Status__c'] }}
|
126 |
-
</p>
|
127 |
-
</div>
|
128 |
-
{% endfor %}
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
{% endif %}
|
134 |
-
|
135 |
-
|
136 |
-
{% endif %}
|
137 |
</div>
|
138 |
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
}
|
152 |
-
|
153 |
-
// Initially hide extra orders
|
154 |
-
document.addEventListener("DOMContentLoaded", () => {
|
155 |
-
document.querySelectorAll(".order-card.hidden").forEach(order => order.style.display = "none");
|
156 |
-
});
|
157 |
</script>
|
158 |
|
159 |
</body>
|
|
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>Order History</title>
|
7 |
+
<!-- Bootstrap CSS -->
|
8 |
+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
|
9 |
<style>
|
10 |
body {
|
11 |
+
font-family: 'Arial', sans-serif;
|
12 |
+
background-color: #fdf4e3; /* Light cream background */
|
13 |
+
color: #333333; /* Dark gray text */
|
14 |
margin: 0;
|
15 |
padding: 0;
|
|
|
16 |
}
|
17 |
+
.order-history-container {
|
18 |
+
max-width: 900px;
|
|
|
19 |
margin: 40px auto;
|
|
|
20 |
padding: 20px;
|
21 |
+
background-color: #ffffff; /* White card background */
|
22 |
+
border-radius: 15px;
|
23 |
+
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
|
24 |
+
border: 1px solid #ffe5b4; /* Light orange border */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
+
.order-item {
|
27 |
+
display: flex;
|
28 |
+
justify-content: space-between;
|
29 |
+
background-color: #fffcf5; /* Light beige background for items */
|
|
|
|
|
|
|
|
|
|
|
30 |
border-radius: 8px;
|
31 |
+
padding: 10px;
|
32 |
+
margin-bottom: 10px;
|
33 |
+
border: 1px solid #ffe5b4; /* Light orange border */
|
|
|
|
|
|
|
|
|
34 |
}
|
35 |
+
.order-item img {
|
36 |
+
width: 70px;
|
37 |
+
height: 70px;
|
38 |
+
object-fit: cover;
|
39 |
border-radius: 5px;
|
|
|
40 |
}
|
41 |
+
.order-item-details {
|
42 |
+
flex: 1;
|
43 |
+
margin-left: 15px;
|
|
|
44 |
}
|
45 |
+
.order-item-title {
|
46 |
+
font-size: 1.2rem;
|
47 |
+
font-weight: bold;
|
48 |
+
color: #c04e01; /* Warm orange color for the title */
|
49 |
}
|
50 |
+
.order-item-price {
|
51 |
+
font-size: 1.1rem;
|
52 |
+
font-weight: bold;
|
53 |
+
color: #2b9348; /* Green for the price */
|
54 |
}
|
55 |
+
.reorder-button {
|
|
|
|
|
|
|
56 |
padding: 8px 15px;
|
57 |
+
background-color: #ff5722;
|
58 |
+
color: #ffffff;
|
59 |
border: none;
|
60 |
+
border-radius: 25px;
|
61 |
+
font-size: 1rem;
|
62 |
+
font-weight: bold;
|
63 |
cursor: pointer;
|
64 |
+
transition: background-color 0.3s ease;
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
+
.reorder-button:hover {
|
67 |
+
background-color: #e64a19;
|
68 |
+
}
|
69 |
+
footer {
|
70 |
+
background-color: #333333;
|
71 |
+
color: #ffffff;
|
72 |
+
text-align: center;
|
73 |
+
padding: 15px 10px;
|
74 |
+
margin-top: 20px;
|
75 |
}
|
|
|
76 |
</style>
|
77 |
</head>
|
78 |
<body>
|
79 |
|
80 |
<div class="container">
|
81 |
+
<div class="order-history-container">
|
82 |
+
<h4 class="mb-4 text-center">Your Order History</h4>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
+
{% if orders %}
|
85 |
+
{% for order in orders %}
|
86 |
+
<h5>Order on: {{ order.CreatedDate }}</h5>
|
87 |
+
{% for line in order.Order_Details__c.split('\n') %}
|
88 |
+
{% set item_parts = line.split('|') %}
|
89 |
+
<div class="order-item">
|
90 |
+
<img src="{{ item_parts[4].strip().replace('Image:', '') }}"
|
91 |
+
alt="{{ item_parts[0].strip() }}"
|
92 |
+
onerror="this.src='/static/placeholder.jpg';">
|
93 |
+
<div class="order-item-details">
|
94 |
+
<div class="order-item-title">{{ item_parts[0].strip() }}</div>
|
95 |
+
<div><small class="text-muted">Quantity: {{ item_parts[1].strip() }}</small></div>
|
96 |
+
</div>
|
97 |
+
<div class="order-item-price">${{ item_parts[3].strip().replace('Price:', '') }}</div>
|
98 |
+
<button class="reorder-button" onclick="addToCart('{{ item_parts[0].strip() }}')">Reorder</button>
|
99 |
+
</div>
|
100 |
+
{% endfor %}
|
101 |
+
{% endfor %}
|
102 |
+
{% else %}
|
103 |
+
<p class="text-center">No orders found in your history.</p>
|
104 |
{% endif %}
|
105 |
+
|
106 |
+
</div>
|
|
|
107 |
</div>
|
108 |
|
109 |
+
<!-- Footer -->
|
110 |
+
<footer>
|
111 |
+
<p>Thank you for dining with us! <span>We look forward to serving you again.</span></p>
|
112 |
+
</footer>
|
113 |
|
114 |
+
<script>
|
115 |
+
// Function to handle reordering an item
|
116 |
+
function addToCart(itemName) {
|
117 |
+
// You can send a request to the backend to add the item to the cart
|
118 |
+
fetch('/cart/add', {
|
119 |
+
method: 'POST',
|
120 |
+
headers: {
|
121 |
+
'Content-Type': 'application/json',
|
122 |
+
},
|
123 |
+
body: JSON.stringify({
|
124 |
+
itemName: itemName, // Item to be reordered
|
125 |
+
}),
|
126 |
+
})
|
127 |
+
.then(response => response.json())
|
128 |
+
.then(data => {
|
129 |
+
if (data.success) {
|
130 |
+
alert('Item added to cart successfully!');
|
131 |
+
} else {
|
132 |
+
alert('Error: ' + data.error);
|
133 |
+
}
|
134 |
+
})
|
135 |
+
.catch(error => {
|
136 |
+
alert('An error occurred: ' + error);
|
137 |
+
});
|
138 |
}
|
|
|
|
|
|
|
|
|
|
|
139 |
</script>
|
140 |
|
141 |
</body>
|