-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
307 lines (278 loc) · 14.5 KB
/
index.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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>POS Penjualan</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">
<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 class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
<!-- Daftar Produk -->
<div class="bg-white p-6 shadow rounded col-span-1 sm:col-span-2 lg:col-span-2">
<h2 class="text-xl font-bold mb-4">Daftar Produk</h2>
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-4" id="product-list">
<!-- Produk Item -->
<div class="bg-gray-200 p-4 rounded">
<img src="foto_manakan/Ayampenyet.webp" alt="Product Image" class="w-full mb-2 rounded product-image">
<h3 class="text-lg font-semibold">Ayam Penyet</h3>
<p class="text-gray-600">Rp 18,000</p>
<button class="mt-2 bg-blue-500 text-white py-1 px-2 rounded text-xs" onclick="addToCart('Ayam Penyet', 18000)">Tambahkan</button>
</div>
<!-- Produk Item -->
<div class="bg-gray-200 p-4 rounded">
<img src="foto_manakan/soto.webp" alt="Product Image" class="w-full mb-2 rounded product-image">
<h3 class="text-lg font-semibold">Soto Madiun</h3>
<p class="text-gray-600">Rp 12,000</p>
<button class="mt-2 bg-blue-500 text-white py-1 px-2 rounded text-xs" onclick="addToCart('Soto Madiun', 12000)">Tambahkan</button>
</div>
<!-- Produk Item -->
<div class="bg-gray-200 p-4 rounded">
<img src="foto_manakan/Rawon.webp" alt="Product Image" class="w-full mb-2 rounded product-image">
<h3 class="text-lg font-semibold">Rawon Daging</h3>
<p class="text-gray-600">Rp 20,000</p>
<button class="mt-2 bg-blue-500 text-white py-1 px-2 rounded text-xs" onclick="addToCart('Rawon Daging', 20000)">Tambahkan</button>
</div>
<!-- Produk Item -->
<div class="bg-gray-200 p-4 rounded">
<img src="foto_manakan/pecelMadiun.webp" alt="Product Image" class="w-full mb-2 rounded product-image">
<h3 class="text-lg font-semibold">Pecel Madiun</h3>
<p class="text-gray-600">Rp 8,000</p>
<button class="mt-2 bg-blue-500 text-white py-1 px-2 rounded text-xs" onclick="addToCart('Pecel Madiun', 8000)">Tambahkan</button>
</div>
<!-- Produk Item -->
<div class="bg-gray-200 p-4 rounded">
<img src="foto_manakan/Ikan.webp" alt="Product Image" class="w-full mb-2 rounded product-image">
<h3 class="text-lg font-semibold">Ikan Gurame</h3>
<p class="text-gray-600">Rp 25,000</p>
<button class="mt-2 bg-blue-500 text-white py-1 px-2 rounded text-xs" onclick="addToCart('Ikan Gurame', 25000)">Tambahkan</button>
</div>
<!-- Produk Item -->
<div class="bg-gray-200 p-4 rounded">
<img src="foto_manakan/airputih.webp" alt="Product Image" class="w-full mb-2 rounded product-image">
<h3 class="text-lg font-semibold">Air Putih Es</h3>
<p class="text-gray-600">Rp 3,000</p>
<button class="mt-2 bg-blue-500 text-white py-1 px-2 rounded text-xs" onclick="addToCart('Air Putih Es', 3000)">Tambahkan</button>
</div>
<!-- Produk Item -->
<div class="bg-gray-200 p-4 rounded">
<img src="foto_manakan/esteh.webp" alt="Product Image" class="w-full mb-2 rounded product-image">
<h3 class="text-lg font-semibold">Es Teh Manis</h3>
<p class="text-gray-600">Rp 5,000</p>
<button class="mt-2 bg-blue-500 text-white py-1 px-2 rounded text-xs" onclick="addToCart('Es Teh Manis', 5000)">Tambahkan</button>
</div>
<!-- Produk Item -->
<div class="bg-gray-200 p-4 rounded">
<img src="foto_manakan/esjeruk.webp" alt="Product Image" class="w-full mb-2 rounded product-image">
<h3 class="text-lg font-semibold">Es Jeruk Manis</h3>
<p class="text-gray-600">Rp 7,000</p>
<button class="mt-2 bg-blue-500 text-white py-1 px-2 rounded text-xs" onclick="addToCart('Es Jeruk Manis', 7000)">Tambahkan</button>
</div>
<!-- Produk Item -->
<div class="bg-gray-200 p-4 rounded">
<img src="foto_manakan/pecelMadiun.webp" alt="Product Image" class="w-full mb-2 rounded product-image">
<h3 class="text-lg font-semibold">Pecel Madiun</h3>
<p class="text-gray-600">Rp 8,000</p>
<button class="mt-2 bg-blue-500 text-white py-1 px-2 rounded text-xs" onclick="addToCart('Pecel Madiun', 8000)">Tambahkan</button>
</div>
<!-- Tambahkan produk lain sesuai kebutuhan -->
</div>
</div>
<!-- Keranjang Belanja -->
<div class="bg-white p-6 shadow rounded col-span-1 lg:col-span-1">
<h2 class="text-xl font-bold mb-4">Keranjang Belanja</h2>
<ul class="space-y-2" id="cart-items">
<!-- Item Keranjang akan ditambahkan di sini -->
</ul>
<div class="mt-4">
<div class="flex justify-between">
<span class="font-semibold">Total:</span>
<span class="font-semibold" id="total-price">Rp 0</span>
</div>
<button class="mt-4 bg-green-500 text-white py-2 px-4 w-full rounded text-xs" onclick="processPayment()">Proses Pembayaran</button>
</div>
</div>
</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 totalPrice = 0;
let cart = [];
function addToCart(productName, productPrice) {
const existingItem = cart.find(item => item.name === productName);
if (existingItem) {
existingItem.quantity += 1;
updateCartItem(existingItem);
} else {
const newItem = {
id: cart.length,
name: productName,
price: productPrice,
quantity: 1
};
cart.push(newItem);
renderCartItem(newItem);
}
totalPrice += productPrice;
updateTotalPrice();
}
function updateCartItem(item) {
const cartItemElement = document.getElementById(`cart-item-${item.id}`);
cartItemElement.querySelector('.item-quantity').innerText = `Qty: ${item.quantity}`;
cartItemElement.querySelector('.item-total').innerText = `Rp ${(item.price * item.quantity).toLocaleString()}`;
}
function changeQuantity(itemId, change) {
const item = cart.find(item => item.id === itemId);
if (item) {
item.quantity += change;
if (item.quantity === 0) {
cart = cart.filter(item => item.id !== itemId);
document.getElementById(`cart-item-${item.id}`).remove();
} else {
updateCartItem(item);
}
totalPrice += item.price * change;
updateTotalPrice();
}
}
function renderCartItem(item) {
const cartItems = document.getElementById('cart-items');
const newItemElement = document.createElement('li');
newItemElement.classList.add('flex', 'justify-between', 'items-center', 'bg-gray-100', 'p-2', 'rounded');
newItemElement.setAttribute('id', `cart-item-${item.id}`);
newItemElement.innerHTML = `
<span>${item.name} - <span class="item-quantity">Qty: ${item.quantity}</span></span>
<span class="item-total">Rp ${(item.price * item.quantity).toLocaleString()}</span>
<div class="flex items-center space-x-2">
<button class="bg-red-500 text-white px-2 py-1 rounded text-xs" onclick="changeQuantity(${item.id}, -1)">-</button>
<button class="bg-green-500 text-white px-2 py-1 rounded text-xs" onclick="changeQuantity(${item.id}, 1)">+</button>
</div>
`;
cartItems.appendChild(newItemElement);
}
function updateTotalPrice() {
document.getElementById('total-price').innerText = `Rp ${totalPrice.toLocaleString()}`;
}
function processPayment() {
if (cart.length === 0) {
alert("Keranjang belanja kosong.");
return;
}
Swal.fire({
title: 'Konfirmasi Pembayaran',
text: 'Apakah Anda yakin ingin memproses pembayaran?',
icon: 'question',
showCancelButton: true,
confirmButtonText: 'Ya',
cancelButtonText: 'Tidak'
}).then((result) => {
if (result.isConfirmed) {
completePayment();
}
});
}
function completePayment() {
const order = {
id: Date.now(),
time: new Date().toLocaleString(),
items: cart,
total: totalPrice
};
let orders = JSON.parse(localStorage.getItem('orders')) || [];
orders.push(order);
localStorage.setItem('orders', JSON.stringify(orders));
Swal.fire({
title: 'Pembayaran Berhasil!',
text: 'Pesanan Anda sedang diproses.',
icon: 'success',
confirmButtonText: 'OK'
}).then(() => {
cart = [];
totalPrice = 0;
document.getElementById('cart-items').innerHTML = '';
updateTotalPrice();
});
}
<!-- Script for Mobile Menu Toggle -->
const menuBtn = document.getElementById('menu-btn');
const mobileMenu = document.getElementById('mobile-menu');
menuBtn.addEventListener('click', () => {
mobileMenu.classList.toggle('hidden');
});
</script>
</body>
</html>