-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
225 lines (203 loc) · 15.1 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<?php
include __DIR__ . "/partials/header.php";
include __DIR__ . "/model/Product.php";
$featProducts = Product::displayFeatured();
$latestProducts = Product::displayLatest();
?>
<body>
<main>
<!-- Hero -->
<div class="jumbotron mt-5 p-3 p-md-5 text-white bg-dark">
<div class="col-md-12 px-0">
<h1 class="display-4">Looking for some <i>games?</i> 😎</h1>
<p class="lead my-3">Welcome to the <b>best</b> place to find GAMES!</p>
</div>
</div>
<!-- Hero END -->
<div class="jumbotron jumbotron-fluid text-center bg-light d-flex align-items-center justify-content-center">
<div class="container">
<h1 class="mb-3 mt-3">No <i>seriously</i>, we've got games!</h1>
<p class="mb-3">I don't know why you'd look anywhere else - Kahjiit 😺 has <a href="./shop.php">wares if you have coin</a>. . .</p>
</div>
</div>
<!-- Featured GAMES Display -->
<h3 class="mb-3 mt-3 text-center display-6">Check out our <i>FEATURED</i> games!</h3>
<div class="row row-cols-1 row-cols-lg-3 g-5 m-0 justify-content-center">
<?php if ($featProducts) : ?>
<?php foreach ($featProducts as $id) : ?>
<?php $product = new Product($id['id']); ?>
<div class="col-xl-4 col-md-6 d-flex justify-content-center">
<div class="card border-dark bg-dark text-white shadow card-size">
<img src="./static/images/products/<?= $product->getImage() ?>" class="card-img-top product-image" alt="<?= $product->getName() ?>">
<div class="card-body">
<div class="text-center">
<h5 class="card-title text-center"><?= $product->getName() ?> </h5><span class="small mb-0 text-center"><?= $product->getRating() ?> <i class="fa-solid fa-star"></i></span>
<p class="gameGenre text-center"><?= $product->getGenre() ?></p>
</div>
<p class="display-5 mt-3 text-center">R <?= $product->getPrice() ?></p>
<div class="d-flex flex-column align-items-center flex-fill">
<span class="small"><?= $product->getStock() ?></span><p class="display-7 mb-1">left!</p>
</div>
<div class="container">
<div class="d-flex justify-content-evenly">
<div class="mt-3">
<form action="./processing/process-session.php" method="post">
<input type="hidden" name="productId" value="<?= $product->getId() ?>">
<button type="button" class="btn btn-light" data-bs-toggle="modal" data-bs-target="#productModal<?= $product->getId() ?>"><i>Details</i></button>
<?php if(isset($_SESSION['Cart']) === true) : ?>
<?php if (in_array($product->getId(), $_SESSION['Cart'])) : ?>
<button type="submit" name="Submit" class="btn btn-primary" disabled><i>Already in!</i></button>
<?php elseif ($product->getStock() == 0) : ?>
<button type="submit" name="Submit" class="btn btn-danger" disabled><i>Out of Stock</i></button>
<?php else : ?>
<button type="submit" name="Submit" class="btn btn-primary"><i>Add to Cart</i></button>
<?php endif ?>
<?php elseif (empty($_SESSION["Cart"])) : ?>
<button type="submit" name="Submit" class="btn btn-danger" disabled><i>Log in to add!</i></button>
<?php endif ?>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="productModal<?= $product->getId() ?>" tabindex="-1" aria-labelledby="modalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<form action="./processing/process-session.php" method="post">
<div class="modal-header">
<h1 class="modal-title fs-4"><?= $product->getName() ?></h1>
<p class="gameGenre"><?= $product->getGenre() ?></p>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<iframe width="100%" height="350" src=<?= $product->getTrailer_link() ?>></iframe>
<div>
<p class="fs-5 text-center">Description:</p>
<p><?= $product->getDescription() ?></p>
<p class="display-5 lh-1 mb-1">R <?= $product->getPrice() ?></p>
<p class="fs-5 text-center">Play <?= $product->getName() ?> <i>today!</i></p>
<!-- Hidden field for productID -->
<input type="hidden" name="productId" value="<?= $product->getId() ?>">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Nah, lemme see others...</button>
<?php if(isset($_SESSION['Cart']) === true) : ?>
<?php if (in_array($product->getId(), $_SESSION['Cart'])) : ?>
<button type="submit" name="Submit" class="btn btn-primary" disabled><i>Already in!</i></button>
<?php elseif ($product->getStock() == 0) : ?>
<button type="submit" name="Submit" class="btn btn-danger" disabled><i>Out of Stock</i></button>
<?php else : ?>
<button type="submit" name="Submit" class="btn btn-primary"><i>Add to Cart</i></button>
<?php endif ?>
<?php elseif (empty($_SESSION["Cart"])) : ?>
<button type="submit" name="Submit" class="btn btn-danger" disabled><i>Log in to add!</i></button>
<?php endif ?>
</div>
</form>
</div>
</div>
</div>
<?php endforeach ?>
<?php else : ?>
<h2>Sorry, the request could not be completed. Go back and refresh your browser</h2>
<?php endif ?>
</div>
<!-- Featured GAMES Display END -->
<!-- New Additions GAMES Display -->
<h4 class="mb-3 mt-5 text-center display-6">Our <i>LATEST</i> additions...</h4>
<div class="row row-cols-1 row-cols-lg-3 g-5 m-0 justify-content-center">
<?php if ($latestProducts) : ?>
<?php foreach ($latestProducts as $id) : ?>
<?php $product = new Product($id['id']); ?>
<div class="col-xl-4 col-md-6 d-flex justify-content-center">
<div class="card border-dark bg-dark text-white shadow card-size">
<img src="./static/images/products/<?= $product->getImage() ?>" class="card-img-top product-image" alt="<?= $product->getName() ?>">
<div class="card-body">
<div class="text-center">
<h5 class="card-title text-center"><?= $product->getName() ?> </h5><span class="small mb-0 text-center"><?= $product->getRating() ?> <i class="fa-solid fa-star"></i></span>
<p class="gameGenre text-center"><?= $product->getGenre() ?></p>
</div>
<p class="display-5 mt-3 text-center">R <?= $product->getPrice() ?></p>
<p class="small text-center">Added: <?= $product->getAdd_date() ?></p>
<div class="d-flex flex-column align-items-center flex-fill">
<span class="small"><?= $product->getStock() ?></span><p class="display-7 mb-1">left!</p>
</div>
<div class="container">
<div class="d-flex justify-content-evenly">
<div class="mt-3">
<form action="./processing/process-session.php" method="post">
<input type="hidden" name="productId" value="<?= $product->getId() ?>">
<button type="button" class="btn btn-light" data-bs-toggle="modal" data-bs-target="#productModal<?= $product->getId() ?>"><i>Details</i></button>
<?php if(isset($_SESSION['Cart']) === true) : ?>
<?php if (in_array($product->getId(), $_SESSION['Cart'])) : ?>
<button type="submit" name="Submit" class="btn btn-primary" disabled><i>Already in!</i></button>
<?php elseif ($product->getStock() == 0) : ?>
<button type="submit" name="Submit" class="btn btn-danger" disabled><i>Out of Stock</i></button>
<?php else : ?>
<button type="submit" name="Submit" class="btn btn-primary"><i>Add to Cart</i></button>
<?php endif ?>
<?php elseif (empty($_SESSION["Cart"])) : ?>
<button type="submit" name="Submit" class="btn btn-danger" disabled><i>Log in to add!</i></button>
<?php endif ?>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="productModal<?= $product->getId() ?>" tabindex="-1" aria-labelledby="modalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<form action="./processing/process-session.php" method="post">
<div class="modal-header">
<h1 class="modal-title fs-4"><?= $product->getName() ?></h1>
<p class="gameGenre"><?= $product->getGenre() ?></p>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<iframe width="100%" height="350" src=<?= $product->getTrailer_link() ?>></iframe>
<div>
<p class="fs-5 text-center">Description:</p>
<p><?= $product->getDescription() ?></p>
<p class="display-5 lh-1 mb-1">R <?= $product->getPrice() ?></p>
<p class="fs-5 text-center">Play <?= $product->getName() ?> <i>today!</i></p>
<!-- Hidden field for productID -->
<input type="hidden" name="productId" value="<?= $product->getId() ?>">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Nah, lemme see others...</button>
<?php if(isset($_SESSION['Cart']) === true) : ?>
<?php if (in_array($product->getId(), $_SESSION['Cart'])) : ?>
<button type="submit" name="Submit" class="btn btn-primary" disabled><i>Already in!</i></button>
<?php elseif ($product->getStock() == 0) : ?>
<button type="submit" name="Submit" class="btn btn-danger" disabled><i>Out of Stock</i></button>
<?php else : ?>
<button type="submit" name="Submit" class="btn btn-primary"><i>Add to Cart</i></button>
<?php endif ?>
<?php elseif (empty($_SESSION["Cart"])) : ?>
<button type="submit" name="Submit" class="btn btn-danger" disabled><i>Log in to add!</i></button>
<?php endif ?>
</div>
</form>
</div>
</div>
</div>
<?php endforeach ?>
<?php else : ?>
<h2>Sorry, the request could not be completed. Go back and refresh your browser</h2>
<?php endif ?>
</div>
<!-- New Additions GAMES Display END -->
</main>
<?php include __DIR__ . "/partials/footer.php"; ?>
</body>
</html>