This repository has been archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
achievements.php
331 lines (285 loc) · 13.1 KB
/
achievements.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
328
329
330
331
<?php
session_start();
$email = $_SESSION['email'];
include 'connect_mysql/connect.php';
$conn = OpenCon();
$sql = "SELECT * FROM Customer WHERE EMail='$email'";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$id = $row['CustomerID'];
$sqlimage = "SELECT name FROM images WHERE CustomerID='$id'";
$resultimage = mysqli_query($conn,$sqlimage);
$rowimage = mysqli_fetch_array($resultimage);
$image = $rowimage['name'];
$image_src = "upload/".$image;
$sqlachievementcount = mysqli_query($conn, "SELECT count(CustomerID) AS count FROM userachievement WHERE CustomerID = '$id'");
$achcount = $sqlachievementcount->fetch_assoc();
$sqlachievement6=mysqli_query($conn, "SELECT * FROM userachievement WHERE CustomerID = '$id' AND AchievementID = '6'");
if(mysqli_num_rows($sqlachievement6) > 0) {
//ingenting
}
elseif ($achcount['count'] >= 5) {
$achivement6=mysqli_query($conn, "INSERT INTO userachievement(AchievementID, CustomerID) VALUES('6','$id')");
echo '<script>alert("Gratulere, du har oppnådd 5 achievements!👍🎉")</script>';
}
//legger inn tellingene på nytt, slik at det blir oppdatert etter achievement 6
$sqlachievementcount1 = mysqli_query($conn, "SELECT count(CustomerID) AS count FROM userachievement WHERE CustomerID = '$id'");
$achcount1 = $sqlachievementcount1->fetch_assoc();
$totalPerc = $achcount1['count'] / 6 * 100;
$totalPercentage = round($totalPerc,0);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="main.css" />
<title>Achievements</title>
</head>
<body>
<header class="block" style="justify-content: left;">
<div id="sideMenu">
<div style="align-self: flex-start;">
<a href="home.php"
><div class="block sideMenuItem">
<img
src="https://www.svgrepo.com/show/14443/home.svg"
class="sideMenuIcon"
/>Home
</div></a
>
<a href="budget.php"
><div class="block sideMenuItem">
<img
src="https://www.svgrepo.com/show/17167/pie-chart.svg"
class="sideMenuIcon"
/>Budget
</div></a
>
<a href="budget-planner/budget-planner.php"
><div class="block sideMenuItem">
<img
src="https://www.svgrepo.com/show/11983/from-a-to-z.svg"
class="sideMenuIcon"
/>Budget planner
</div></a
>
<a href="achievements.php"
><div class="block sideMenuItem">
<img
src="https://www.svgrepo.com/show/84275/trophy.svg"
class="sideMenuIcon"
/>Achievements
</div></a
>
</div>
<div style="align-self: flex-end; margin-bottom: 40px;">
<a href="profile.php"
><div class="block sideMenuItem">
<img
src="https://www.svgrepo.com/show/7025/user.svg"
class="sideMenuIcon"
/>Profile
</div></a
>
<a href="faq.php"
><div class="block sideMenuItem">
<img
src="https://www.svgrepo.com/show/348371/help.svg"
class="sideMenuIcon"
/>Help
</div></a
>
<a href="login/logout.php"
><div class="block sideMenuItem">
<img
src="https://www.svgrepo.com/show/334066/log-out-circle.svg"
class="sideMenuIcon"
/>Log out
</div></a
>
</div>
</div>
<img
id="menuClosed"
alt="menuLogo"
class="headerLogo"
src="https://www.svgrepo.com/show/336031/hamburger-button.svg"
style="position: fixed;"
/>
<img
src="Pictures/logo_header.png"
alt="logo_header"
class="finance-logo"
/>
<a href="profile.php" style="margin-top: 2%; margin-right: 1%;position: fixed; right: 0">
<img
src="<?php echo $image_src; ?>"
alt="profile_photo"
class="profile-logo"
/>
</a>
</header>
<main>
<h1 style="text-align: center;">Achievements</h1>
<div class="block">
<div class="contentBoxAchievements">
<h2>Overview</h2>
<label id="contentBox-achievements" style="width: 200px; padding-left: 20px; margin: 10px;">Total Achievements</label>
<!-- Legger inn som input for å visualisere hva som skal inn -->
<!--<input style="" type="text" /> -->
<output> <?php echo $achcount1['count'] ?></output>
<label style="width: 200px; padding-left: 20px; margin: 10px; padding-bottom: 20px;">Totale Percentage</label>
<!-- Legger inn som input for å visualisere hva som skal inn -->
<output> <?php echo $totalPercentage ?>%</output> <br>
<label style="margin: 10px; padding-left: 20px; padding-bottom: 20px;">Achievement Rank</label>
<?php if ($totalPercentage < 34)
{?>
<img
src="Pictures/bronze-medal.png"
alt="member rank"
style="width: 40px; height: 40; margin-left: 10%; margin-top: 5%;"
/>
<label style="margin: 10px; padding-left: 5px; padding-bottom: 20px;">Bronze</label>
<?php }
elseif ($totalPercentage > 34 && $totalPercentage < 68)
{ ?>
<img
src="Pictures/silver-medal.png"
alt="member rank"
style="width: 40px; height: 40; margin-left: 10%; margin-top: 5%;"
/>
<label style="margin: 10px; padding-left: 5px; padding-bottom: 20px;">Silver</label>
<?php }
elseif ($totalPercentage > 68)
{ ?>
<img
src="Pictures/gold-medal.png"
alt="member rank"
style="width: 40px; height: 40; margin-left: 10%; margin-top: 5%;"
/>
<label style="margin: 10px; padding-left: 5px; padding-bottom: 20px;">Gold</label>
<?php } else {
} ?>
</div>
<div class="contentBoxAchievements" style="max-width: 500px; width: 100%; padding: 10px;">
<h2>Unlocked</h2>
<?php
// sjekker databasen på 2 kriterier og henter ut rowsa om kriterien er møtt
$rowsql1 = mysqli_query( $conn, "SELECT * FROM userachievement WHERE CustomerID = '$id' AND AchievementID = '1'");
$rowsql2 = mysqli_query( $conn, "SELECT * FROM userachievement WHERE CustomerID = '$id' AND AchievementID = '2'");
$rowsql3 = mysqli_query( $conn, "SELECT * FROM userachievement WHERE CustomerID = '$id' AND AchievementID = '3'");
$rowsql4 = mysqli_query( $conn, "SELECT * FROM userachievement WHERE CustomerID = '$id' AND AchievementID = '4'");
$rowsql5 = mysqli_query( $conn, "SELECT * FROM userachievement WHERE CustomerID = '$id' AND AchievementID = '5'");
$rowsql6 = mysqli_query( $conn, "SELECT * FROM userachievement WHERE CustomerID = '$id' AND AchievementID = '6'");
?>
<!-- Sjekker om $rowsql1 inneholder data, om det er innhold i spørringen sender den ut html koden -->
<?php
if (mysqli_num_rows($rowsql1) > 0)
{ ?>
<section style="display:flex">
<img
src="Pictures/graph.png"
alt="graph"
class="achievementspicture"
style="width: 40px; height: 50; margin-left: 2%; margin: 1.4% 1%; position: absolute;"
/>
<h3 style = "margin-left: 14%">Net positive</h3>
</section>
<under style="margin-left: 14%; font-style: italic;">Earn more than you spend</under>
<!-- Sjekker om $rowsql2 inneholder data, om det er innhold i spørringen sender den ut html koden -->
<?php }
if (mysqli_num_rows($rowsql2) > 0)
{ ?>
<section style="display:flex; margin-top: 20px">
<img
src="Pictures/bigspenderss.png"
alt="big spender"
class="achievementspicture"
style="width: 40px; height: 50; margin-left: 2%; margin: 1% 1%; position: absolute;"
/>
<h3 style = "margin-left: 14%">Big spender</h3>
</section>
<under style="margin-left: 14%; font-style: italic;">Spend more than 10 000$ one month</under>
<!-- Sjekker om $rowsql3 inneholder data, om det er innhold i spørringen sender den ut html koden -->
<?php }
if (mysqli_num_rows($rowsql3) > 0)
{ ?>
<section style="display:flex; margin-top: 20px">
<img
src="Pictures/smile.ico"
alt="welcome"
class="achievemntspicture"
style="width: 40px; height: 50; margin-left: 2%; margin: 1.5% 1%; position: absolute;"
/>
<h3 style = "margin-left: 14%">Welcome!</h3>
</section>
<under style="margin-left: 14%; font-style: italic;">Made an account</under>
<!-- Sjekker om $rowsql4 inneholder data, om det er innhold i spørringen sender den ut html koden -->
<?php }
if (mysqli_num_rows($rowsql4) > 0)
{ ?>
<section style="display:flex ; margin-top: 20px">
<img
src="Pictures/smart.jpg"
alt="smart investor"
class="achievementspicture"
style="width: 40px; height: 50; margin-left: 2%; margin: 1.4% 1%; position: absolute;"
/>
<h3 style = "margin-left: 14%">Smart investor</h3>
</section>
<under style="margin-left: 14%; font-style: italic;">Have an additional source of income</under>
<!-- Sjekker om $rowsql5 inneholder data, om det er innhold i spørringen sender den ut html koden -->
<?php }
if (mysqli_num_rows($rowsql5) > 0)
{ ?>
<section style="display:flex; margin-top: 20px">
<img
src="Pictures/investor.png"
alt="first budget"
class="achievemntspicture"
style="width: 40px; height: 50; margin-left: 2%; margin: 1.5% 1%; position: absolute;"
/>
<h3 style = "margin-left: 14%">First budget</h3>
</section>
<under style="margin-left: 14%; font-style: italic;">Create your first budget</under>
<!-- Sjekker om $rowsql6 inneholder data, om det er innhold i spørringen sender den ut html koden -->
<?php }
if (mysqli_num_rows($rowsql6) > 0)
{ ?>
<section style="display:flex; margin-top: 20px">
<img
src="Pictures/person.png"
alt="accomplished"
class="achievementspicture"
style="width: 40px; height: 50; margin-left: 2%; margin: 1.4% 1%; position: absolute;"
/>
<h3 style = "margin-left: 14%">Accomplished</h3>
</section>
<under style="margin-left: 14%; font-style: italic;">Complete 5 achievements</under>
<?php } else {
} ?>
</div>
</div>
</main>
<footer>
<ul>
<li>
<a href="home.php">Home</a>
</li>
<li>
<a href="faq.php">FAQ</a>
</li>
<li>
<a href="about.php">About</a>
</li>
<li>
<a href="contactForm/index.php">Contact</a>
</li>
</ul>
<p>© 2021 Finance Budget App AS</p>
</footer>
<script src="main.js"></script>
</body>
</html>