-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsepet.php
327 lines (225 loc) · 9.89 KB
/
sepet.php
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<!DOCTYPE html>
<html lang="en">
<head>
<?php
session_start();
// URL'den masa numarasını al
$masa_no = $_GET['id'] ?? '';
// Masa numarasını session'a ata
$_SESSION['masa_no'] = $masa_no;
?>
<!-- Baglanti deneme baslangic -->
<!-- kahvalti baglanti -->
<?php
include "baglanti.php";
$sorgu = $db->prepare("select * from menu");
$sorgu->execute();
?>
<!-- Baglanti deneme bitis -->
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>Meydan Park Gölhisar</title>
<meta content="" name="description">
<meta content="" name="keywords">
<!-- font -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">
<!-- CSS -->
<link href="assets/vendor/animate.css/animate.min.css" rel="stylesheet">
<link href="assets/vendor/aos/aos.css" rel="stylesheet">
<link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
<link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
<link href="assets/vendor/glightbox/css/glightbox.min.css" rel="stylesheet">
<link href="assets/vendor/swiper/swiper-bundle.min.css" rel="stylesheet">
<link href="assets/css/style.css" rel="stylesheet">
</head>
<body>
<div id="topbar" class="d-flex align-items-center fixed-top">
<div class="container d-flex justify-content-center justify-content-md-between">
<div class="contact-info d-flex align-items-center">
<i class="bi bi-phone d-flex align-items-center"><span>telefon numarası</span></i>
<i class="bi bi-clock d-flex align-items-center ms-4"><span>çalışma saatleri</span></i>
</div>
</div>
</div>
<header id="header" class="fixed-top d-flex align-items-cente">
<div class="container-fluid container-xl d-flex align-items-center justify-content-lg-between">
<h1 class="logo me-auto me-lg-0"><a href="/cafenew/index.php?id=<?php echo $masa_no; ?>">Meydan Park Cafe</a></h1>
<nav id="navbar" class="navbar order-last order-lg-0">
<ul>
<li><a class="nav-link scrollto active" href="/cafenew/index.php?id=<?php echo $masa_no; ?>">Anasayfa</a></li>
<li><a class="nav-link scrollto" href="#menu">Menü</a></li>
</ul>
<i class="bi bi-list mobile-nav-toggle"></i>
</nav>
<a href="/cafenew/index.php?id=<?php echo $masa_no; ?>" class="book-a-table-btn scrollto d-none d-lg-flex">Menüye Dön</a>
</div>
</header>
<!-- ======= Menu ======= -->
<section id="menu" class="menu section-bg">
<div class="container" data-aos="fade-up">
<div class="section-title">
<h2>Sepet</h2>
<p>Ürünler</p>
</div>
<?php
echo "<span>Masa Numaranız: {$masa_no}";
?>
<div class="row" data-aos="fade-up" data-aos-delay="100">
<div class="col-lg-12 d-flex justify-content-center">
<ul id="menu-flters">
<li data-filter="*" class="filter-active">Hepsi</li>
<li data-filter=".filter-kahvalti">Kahvaltılar</li>
<li data-filter=".filter-pizza">Pizzalar</li>
</ul>
</div>
</div>
<div class="row menu-container" data-aos="fade-up" data-aos-delay="200">
<?php
if(isset($_POST['remove_from_cart'])) {
$urun_id = $_POST['urun_id'];
$sepet_adi = 'sepet_' . $_SESSION['masa_no'];
if(isset($_SESSION[$sepet_adi][$urun_id])) {
unset($_SESSION[$sepet_adi][$urun_id]);
}
}
$sepet_adi = 'sepet_' . $_SESSION['masa_no'];
if (!isset($_SESSION[$sepet_adi]) || empty($_SESSION[$sepet_adi])) {
echo "<h1>Sepetiniz Boş</h1>";
} else {
echo "<div class='row'>";
foreach ($_SESSION[$sepet_adi] as $urun_id => $adet) {
$sorgu = $db->prepare("SELECT * FROM menu WHERE id = :urun_id");
$sorgu->bindParam(':urun_id', $urun_id);
$sorgu->execute();
$urun = $sorgu->fetch(PDO::FETCH_ASSOC);
$filter_class = '';
if ($urun['kategori'] == 'kahvalti') {
$filter_class = 'filter-kahvalti';
} elseif ($urun['kategori'] == 'pizza') {
$filter_class = 'filter-pizza';
}
echo "<div class='col-lg-6 menu-item $filter_class'>";
echo "<img src='verifoto/kahvaltifoto/{$urun['id']}.jpg' class='menu-img' alt=''>";
echo "<div class='menu-content'>";
echo "<span>{$urun['menu_name']}</span><span>{$urun['menu_price']} ₺</span>";
echo "<div id='hero.btn-menu'>";
echo "<form method='post' action='/cafenew/sepet.php?id={$masa_no}'>";
echo "<input type='hidden' name='urun_id' value='{$urun['id']}'>";
echo "<a>";
echo "<button style='background-color: #CDA45E' type='submit' class='butonekle'>Sepetten kaldır</button>";
echo "</a>";
echo "<input type='hidden' name='remove_from_cart' value='1'>";
echo "</form>";
echo "</div>";
echo "</div>";
echo "<div class='menu-ingredients'>{$urun['menu_ex']}</div>";
echo "</div>";
}
echo "</div>";
}
?>
<!-- menu php bitis .................................................................................... -->
</div>
</div>
<?php
$total_price = 0; // Toplam fiyatı saklamak için değişken
if (isset($_POST['remove_from_cart'])) {
$urun_id = $_POST['urun_id'];
$sepet_adi = 'sepet_' . $_SESSION['masa_no'];
if (isset($_SESSION[$sepet_adi][$urun_id])) {
unset($_SESSION[$sepet_adi][$urun_id]);
}
}
if (!isset($_SESSION[$sepet_adi]) || empty($_SESSION[$sepet_adi])) {
echo "<h1></h1>";
} else {
echo "<div style='text-align: center; margin-top: 100px;'>";
echo "<div style='margin: 0 auto; display: inline-block; '>";
echo "<table style='margin-bottom: 10px;'>";
echo "<thead><tr><th>Ürün Adı</th><th>Adet</th><th>Birim Fiyat</th><th>Toplam Fiyat</th></tr></thead>";
echo "<tbody>";
foreach ($_SESSION[$sepet_adi] as $urun_id => $adet) {
$sorgu = $db->prepare("SELECT * FROM menu WHERE id = :urun_id");
$sorgu->bindParam(':urun_id', $urun_id);
$sorgu->execute();
$urun = $sorgu->fetch(PDO::FETCH_ASSOC);
// Toplam fiyatı güncelle
$toplam_fiyat = $urun['menu_price'] * $adet;
$total_price += $toplam_fiyat;
echo "<tr>";
echo "<td>{$urun['menu_name']}</td>";
echo "<td>{$adet}</td>";
echo "<td>{$urun['menu_price']} ₺</td>";
echo "<td>{$toplam_fiyat} ₺</td>";
echo "<td>";
echo "<form method='post' action='/cafenew/sepet.php?id={$masa_no}'>";
echo "<input type='hidden' name='urun_id' value='{$urun['id']}'>";
echo "<button style='background-color: #CDA45E' type='submit' class='butonekle'>Sepetten Kaldır</button>";
echo "<input type='hidden' name='remove_from_cart' value='1'>";
echo "</form>";
echo "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "</div>"; // div kapanışı
echo "</div>"; // div kapanışı
// Toplam fiyatı göster
echo "<p style='text-align: center; color:#CDA45E; font-size: 25px;'>Toplam Fiyat: {$total_price} ₺</p>";
}
?>
<div style='text-align: center; margin-top: 30px;'>
<a href="/cafenew/sepet2.php?id=<?php echo $masa_no; ?>" style='background-color: #CDA45E; color: black; padding: 10px;' class='butonekle'>Sepeti Onayla</a>
</div>
</section><!-- menu bitiş -->
<!-- ======= Footer ======= -->
<footer id="footer">
<div class="footer-top">
<div class="container">
<div class="row justify-content-md-center">
<div class="col-lg-3 col-md-6">
<div class="footer-info">
<h3>Meydan Park Cafe</h3>
<p>
Çeşme, Cumhuriyet Myd. <br>
Gölhisar/Burdur<br><br>
<strong>Telefon</strong> +4948948<br>
<strong>Email:</strong> [email protected]<br>
</p>
<div class="social-links mt-3">
<a href="#" class="twitter"><i class="bx bxl-twitter"></i></a>
<a href="#" class="facebook"><i class="bx bxl-facebook"></i></a>
<a href="#" class="instagram"><i class="bx bxl-instagram"></i></a>
</div>
</div>
</div>
<div class="col-lg-2 col-md-6 footer-links">
<h4>Hızlı Linkler</h4>
<ul>
<li><i class="bx bx-chevron-right"></i> <a href="#">Anasayfa</a></li>
<li><i class="bx bx-chevron-right"></i> <a href="#">Menü</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<div class="copyright">
© Copyright <strong><span>Meydan Park Cafe</span></strong>. All Rights Reserved
</div>
</div>
</footer><!-- End Footer -->
<div id="preloader"></div>
<a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>
<!-- js bootstrap -->
<script src="assets/vendor/aos/aos.js"></script>
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="assets/vendor/glightbox/js/glightbox.min.js"></script>
<script src="assets/vendor/isotope-layout/isotope.pkgd.min.js"></script>
<script src="assets/vendor/swiper/swiper-bundle.min.js"></script>
<script src="assets/vendor/php-email-form/validate.js"></script>
<!-- Template Main JS File -->
<script src="assets/js/main.js"></script>
</body>
</html>