-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.tpl.php
72 lines (66 loc) · 2.54 KB
/
common.tpl.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
<?php declare(strict_types = 1);
?>
<?php function drawHeader(Session $session) { ?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Meet & Eat</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href='../Css/style.css'>
<link rel="icon" type="image/ico" href="../Docs/logo.png" alt="logo">
<script src="../Javascript/script.js" defer></script>
<script src = "https://code.jquery.com/jquery-3.5.1.min.js" > </script>
</head>
<body>
<header>
<a href="../index.php"><img id="logo" src="../Docs/logo.png" alt="logo"></a>
<h1><a href="../index.php">Meet & Eat</a></h1>
<?php if ($session::login()) drawLogoutForm($session::getUsername(), '../Actions/action_logout.php');
else drawLoginForm('../Actions/action_login.php'); ?>
</header>
<section id="messages">
<?php foreach ($session->getMessages() as $message) { ?>
<article class="<?=$message['type']?>">
<?=$message['text']?>
</article>
<?php } ?>
</section>
<main>
<?php
require_once('../Database/connection.db.php');
require_once('../Classes/session.class.php');
require_once('../Classes/user.class.php');
$db = getDatabaseConnection('sqlite:../Database/database.db');
$admin = User::verifyAdmin($db, intval($session::getId()));
$orders = User::verifyOrders($db, intval($session::getId()));
$user = $session::getUsername();
if($user && $admin){ ?>
<a href="../Pages/admin.php"><img id="adminIcon" src="../Docs/admin.png"></a>
<?php }
if(isset($_SESSION['id'])){ ?>
<a href="../Pages/order.php"><img id="cartIcon" src="../Docs/cart.png"></a>
<?php }
} ?>
<?php function drawLoginForm(string $path) { ?>
<form action=<?php echo ($path); ?> method="post" class="login">
<input type="text" name="username" placeholder="username">
<input type="password" name="password" placeholder="password">
<a href="register.php">Register</a>
<button type="submit">Login</button>
</form>
<?php } ?>
<?php function drawLogoutForm(string $username, string $path) { ?>
<form action=<?php echo ($path); ?> method="post" class="logout">
<a href="../Pages/profile.php"><?=$username?></a>
<button type="submit">Logout</button>
</form>
<?php } ?>
<?php function drawFooter() { ?>
</main>
<footer>
LTW Project © 2022 By Daniela Tomás and Henrique Vicente
</footer>
</body>
</html>
<?php } ?>