-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpesanan_proses.html
221 lines (194 loc) · 9.77 KB
/
pesanan_proses.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pesanan di Proses</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
<style>
body {
font-family: Arial, sans-serif;
}
.footer {
background-color: #333;
color: white;
text-align: center;
padding: 20px 0;
}
.footer .social-icons {
margin-top: 10px;
}
.footer .social-icons a {
color: white;
margin: 0 10px;
font-size: 24px;
text-decoration: none;
transition: color 0.3s ease;
}
.footer .social-icons a:hover {
color: #FFD700; /* Warna hover */
}
</style>
</head>
<body class="bg-gray-200 min-h-screen">
<!-- Header -->
<header class="bg-gray-800 text-white p-4">
<div class="container mx-auto flex justify-between items-center">
<h1 class="text-2xl font-bold">Warung Mbah Karmi</h1>
<!-- Mobile Menu Button -->
<div class="md:hidden">
<button id="menu-btn" class="focus:outline-none" aria-label="Toggle menu">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
</svg>
</button>
</div>
<!-- Navbar -->
<nav id="menu" class="hidden md:flex space-x-4">
<a href="index.html" class="hover:text-gray-200">Penjualan</a>
<a href="pesanan_proses.html" class="hover:text-gray-200">Pesanan di Proses</a>
<a href="transaksi_total.html" class="hover:text-gray-200">Total Transaksi Berhasil</a>
</nav>
</div>
</header>
<!-- Mobile Menu -->
<div id="mobile-menu" class="hidden md:hidden bg-gray-800 text-white p-4 space-y-2">
<a href="index.html" class="block hover:text-gray-200">Penjualan</a>
<a href="pesanan_proses.html" class="block hover:text-gray-200">Pesanan di Proses</a>
<a href="transaksi_total.html" class="block hover:text-gray-200">Total Transaksi Berhasil</a>
</div>
<!-- Main Content -->
<div class="container mx-auto py-6">
<div id="order-list" class="bg-white p-6 shadow rounded">
<h2 class="text-xl font-bold mb-4">Daftar Pesanan</h2>
<!-- Pesanan akan ditampilkan di sini -->
</div>
<!-- Pagination -->
<div id="pagination" class="mt-6 flex justify-between">
<button id="prev-btn" aria-label="Previous page" class="bg-blue-500 text-white py-2 px-4 rounded" onclick="changePage(-1)">Sebelumnya</button>
<span id="page-info" class="font-semibold"></span>
<button id="next-btn" aria-label="Next page" class="bg-blue-500 text-white py-2 px-4 rounded" onclick="changePage(1)">Selanjutnya</button>
</div>
</div>
<footer class="bg-gray-800 text-white text-center py-6">
<p class="mb-4">© 2024 Your Company. All rights reserved.</p>
<div class="flex justify-center mb-4 space-x-4">
<a href="https://www.instagram.com/" target="_blank" class="text-white hover:text-yellow-400 text-2xl"><i class="fab fa-instagram"></i></a>
<a href="https://www.linkedin.com/" target="_blank" class="text-white hover:text-yellow-400 text-2xl"><i class="fab fa-linkedin"></i></a>
<a href="https://www.facebook.com/" target="_blank" class="text-white hover:text-yellow-400 text-2xl"><i class="fab fa-facebook"></i></a>
<a href="https://www.youtube.com/" target="_blank" class="text-white hover:text-yellow-400 text-2xl"><i class="fab fa-youtube"></i></a>
</div>
<div class="flex justify-center space-x-4">
<a href="#home" class="text-white hover:underline">Home</a>
<span>|</span>
<a href="#news" class="text-white hover:underline">News</a>
<span>|</span>
<a href="#about" class="text-white hover:underline">About</a>
<span>|</span>
<a href="#contact" class="text-white hover:underline">Contact Us</a>
<span>|</span>
<a href="#team" class="text-white hover:underline">Our Team</a>
</div>
</footer>
<!-- JavaScript -->
<script>
let currentPage = 1;
const itemsPerPage = 5;
document.addEventListener('DOMContentLoaded', function() {
loadOrders();
function loadOrders() {
const orderList = document.getElementById('order-list');
let orders = [];
try {
orders = JSON.parse(localStorage.getItem('orders')) || [];
} catch (e) {
console.error('Failed to load orders:', e);
}
// Sort orders by most recent first
orders.sort((a, b) => new Date(b.time) - new Date(a.time));
// Calculate pagination
const totalPages = Math.ceil(orders.length / itemsPerPage);
const startIndex = (currentPage - 1) * itemsPerPage;
const endIndex = Math.min(startIndex + itemsPerPage, orders.length);
// Clear existing orders
orderList.innerHTML = '';
// Display orders for the current page
if (orders.length === 0) {
orderList.innerHTML = '<p class="text-gray-600">Tidak ada pesanan yang sedang diproses.</p>';
return;
}
for (let i = startIndex; i < endIndex; i++) {
const order = orders[i];
const orderElement = document.createElement('div');
orderElement.classList.add('border', 'p-4', 'rounded', 'mb-4', 'shadow');
let itemsList = '';
order.items.forEach(item => {
itemsList += `<li>${item.name} - Qty: ${item.quantity} - Rp ${(item.price * item.quantity).toLocaleString()}</li>`;
});
orderElement.innerHTML = `
<div class="flex justify-between">
<div>
<p class="font-semibold">Order ID: ${order.id}</p>
<p class="text-sm text-gray-600">Waktu: ${order.time}</p>
<ul class="mt-2 list-disc list-inside">
${itemsList}
</ul>
<p class="mt-2 font-semibold">Total: Rp ${order.total.toLocaleString()}</p>
</div>
<div>
<button class="mt-4 bg-red-500 text-white py-2 px-4 rounded" onclick="deleteOrder(${order.id})">Hapus</button>
</div>
</div>
`;
orderList.appendChild(orderElement);
}
// Update pagination info
document.getElementById('page-info').innerText = `Halaman ${currentPage} dari ${totalPages}`;
document.getElementById('prev-btn').disabled = currentPage === 1;
document.getElementById('next-btn').disabled = currentPage === totalPages;
}
window.changePage = function(direction) {
const orders = JSON.parse(localStorage.getItem('orders')) || [];
const totalPages = Math.ceil(orders.length / itemsPerPage);
currentPage += direction;
currentPage = Math.max(1, Math.min(currentPage, totalPages));
loadOrders();
};
window.deleteOrder = function(orderId) {
Swal.fire({
title: 'Apakah Anda yakin?',
text: "Pesanan ini akan dihapus secara permanen.",
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Ya, hapus!',
cancelButtonText: 'Batal'
}).then((result) => {
if (result.isConfirmed) {
let orders = [];
try {
orders = JSON.parse(localStorage.getItem('orders')) || [];
} catch (e) {
console.error('Failed to load orders:', e);
}
orders = orders.filter(order => order.id !== orderId);
localStorage.setItem('orders', JSON.stringify(orders));
loadOrders();
Swal.fire(
'Dihapus!',
'Pesanan berhasil dihapus.',
'success'
);
}
});
};
});
const menuBtn = document.getElementById('menu-btn');
const mobileMenu = document.getElementById('mobile-menu');
menuBtn.addEventListener('click', () => {
mobileMenu.classList.toggle('hidden');
});
</script>
</body>
</html>