-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
113 lines (100 loc) · 4.17 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
<?php require_once "site.php" ?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>MedSmart</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./assets/css/main.css">
<link rel="stylesheet" href="./assets/css/home.css">
<link rel="stylesheet" href="./assets/css/carousel.css">
<link rel="shortcut icon" href="./assets/images/favicon.ico" type="image/x-icon">
</head>
<body>
<?php renderMainMenu() ?>
<div id="site-banner">
<div id="banner-title">
<h3>Redefining the role <br>of a pharmacy...</h3>
<p>Getting your medication delivered<br> got a whole lot simpler!</p>
</div>
</div>
<div id="search-bar">
<div class="content">
<img src="./assets/images/icons/search.svg" width="30px" alt="">
<input type="search" name="search" placeholder="Enter Product Name">
</div>
</div>
<main>
<?php
/** displays a product in the promo carousel
* @param array $product product details
*/
function displayProduct($product)
{
$discounted_price = $product["price"] - $product["discount"];
echo "<div class='item'>
<a class='promo-card' href='./productview.php?proviewid={$product['id']}'>
<div class='product-image' style='background-image: url(\"./uploads/products/{$product['image']}\");'>
</div>
<span class='product-name'>{$product["name"]}</span>
<span class='product-price'>
<span class='old-price'>
Rs. {$product["price"]}
</span>
<span class='new-price'>
Rs. $discounted_price
</span>
</span>
<span class='product-buy button' data-product-id='{$product['id']}'>Add To Cart</span>
</a>
</div>";
}
$con = connectDB();
$sql = "SELECT id, name, price, discount, image FROM `product` WHERE discount != 0";
$result = $con->query($sql);
if ($result->num_rows > 0) {
echo '<h2 id="promo-title">Promotions</h2>
<div class="carousel" id="promo-carousel">
<ul class="carousel-contents">';
while ($row = $result->fetch_assoc()) {
displayProduct($row);
}
echo '</ul></div>';
}
$con->close();
?>
<div id="site-about">
<h2>About Us<h2>
<p>MedSmart (Pvt) Ltd., (established in 2020) provides a platform
to make it easier for customers to find necessary medical
products. We provide a range of quality medications,
medical devices and instruments which we deliver
to your doorstep. We have a friendly experienced
staff to serve you at all times. Our aim is to deliver
the best customer service & healthcare products
because we value our customers and their essential
health needs as our first priority.</p>
</div>
</main>
<?php renderFooter() ?>
<script src="./assets/js/main.js"></script>
<script src="./assets/js/carousel.js"></script>
<script>
const promoCarousel = document.querySelector("#promo-carousel");
if (promoCarousel !== null) {
initCarousel(promoCarousel, 4, {
hasControls: true,
center: true,
speed: 2500
});
}
const search = document.querySelector("input[name='search']");
if (search) {
search.addEventListener("keypress", (e) => {
if (e.key.toLocaleLowerCase() === 'enter' && search.value !== "") {
window.location = "./store.php?submit=&search=" + encodeURIComponent(search.value);
}
})
}
</script>
</body>
</html>