aboutsummaryrefslogtreecommitdiff
path: root/public/products.php
blob: da337ad2c6d5d3ff0c2b20f66b14bae8d3c0789d (plain)
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
<!DOCTYPE html>
<?php require "../lib/db.php"; ?>
<?php require "../lib/login.php"; ?>
<?php 
function product_template($product) {
	$image_path = $product->image ? "/img/product/$product->id-thumb.jpg" : "/img/placeholder.png";
	echo <<<"EOF"
	<a href="/product.php?id=$product->id" class="product nolinkstyle">
		<img src="$image_path" alt="">
		<span class="price">$product->price</span>
		<span class="name">$product->name</span>
	</a>
EOF;
}
?>
<html>
<head>
	<?php include 'head.php' ?>
	<title>producten</title>
	<link rel='stylesheet' type='text/css' media='screen' href='products.css'>
</head>
<body>
	<?php include 'navbar.php' ?>
	<div class="main limwidth">
		<h2>lijst met producten:</h2>
		<?php do {
			if (($user_privileges & PRIVILEGE_ADMIN) == 0) break;
			echo <<<"EOF"
				<div class="center">
					<form action="/admin-product.php" method="get" class="d-ib">
						<input type="submit" value="Nieuw product toevoegen" class="button filled">
					</form>
					<form action="/admin-category.php" method="get" class="d-ib">
						<input type="submit" value="Nieuwe categorie toevoegen" class="button filled">
					</form>
				</div>
			EOF;
		} while (false); ?>
		<div class="products">
			<?php
				$res = $cursor->query("select id, image, price, name from webs.product");
				while ($product = $res->fetch_object()) product_template($product);
			?>
		</div>
	</div>
	<?php include 'footer.php' ?>
</body>
</html>