-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdnevnik.php
97 lines (83 loc) · 3.77 KB
/
dnevnik.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
<?php
include_once("vanjske_biblioteke/sesija.class.php");
include("vanjske_biblioteke/baza.class.php");
Sesija::kreirajSesiju();
$uloga = $_SESSION['uloga'];
$korisnik = $_SESSION['korisnik'];
$korisnik_id = $_SESSION['id'];
$now = date("Y-m-d");
$baza = new Baza();
$baza->spojiDB();
if ($baza->pogreskaDB()) {
echo "Problem kod upita na bazu podataka!";
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Dječji vrtići</title>
<meta charset="UTF-8">
<meta name="author" content="LJ">
<link href="css/stil.css" rel="stylesheet" type="text/css"/>
<link href="https://fonts.googleapis.com/css2?family=Amatic+SC:wght@700&family=Architects+Daughter&display=swap" rel="stylesheet">
</head>
<body style="background-image: url(slike/index-slika.jpg)">
<header>
<h1><a href="index.php">Dječji vrtići</a></h1>
<?php
$putanja = dirname($_SERVER['REQUEST_URI']);
include './navigacija.php';
?>
</header>
<section>
<form novalidate method='GET' name='dnevnik_filter' action='dnevnik.php'>
<label>Pretražite po datumu:</label><br>
<input id='filter' name='filter' type='text'/>
<input name='button_filter' type='submit' value='Filtriraj' style='font-family: Amatic SC, cursive;'/><br>
</form>
<?php
if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) {
$startrow = 0;
} else {
$startrow = (int)$_GET['startrow'];
}
if (isset($_GET["filter"])) {
$now = date("Y-m-d H:i:s");
$sql = "insert into dnevnik (vrijeme, OIB_korisnik, tip_id) values ('$now', '$korisnik_id', 3)";
$rs = $baza->selectDB($sql);
$vrijeme = $_GET["filter"];
$sql = "select k.OIB_korisnik, tp.naziv_promjene, d.vrijeme from korisnik k, tip_promjene tp, dnevnik d where k.OIB_korisnik = d.OIB_korisnik and d.tip_id = tp.tip_promjene_id and d.vrijeme LIKE '%{$vrijeme}%' order by d.vrijeme desc LIMIT $startrow, 7";
}
else {
$sql = "select k.OIB_korisnik, tp.naziv_promjene, d.vrijeme from korisnik k, tip_promjene tp, dnevnik d where k.OIB_korisnik = d.OIB_korisnik and d.tip_id = tp.tip_promjene_id order by d.vrijeme desc LIMIT $startrow, 7";
}
$rs = $baza->selectDB($sql);
if ($baza->pogreskaDB()) {
echo "Problem kod upita na bazu podataka!";
exit;
}
echo "<table><tr><th>Šifra korisnika</th><th>Tip promjene</th><th>Vrijeme promjene</th></tr>\n";
while (list($oib, $tip, $vrijeme) = $rs->fetch_array()) {
echo "<tr>
<td>$oib</td>
<td>$tip</td>
<td>$vrijeme</td>
</tr>\n";
}
echo "</table>\n";
echo "<a style='text-decoration: none; color: #30323d;' href='".$_SERVER['PHP_SELF'].'?startrow='.($startrow+7)."'>Sljedeća</a><br>";
$prethodna = $startrow - 7;
if ($prethodna >= 0)
echo "<a style='text-decoration: none; color: #30323d;' href='".$_SERVER['PHP_SELF'].'?startrow='.$prethodna."'>Prethodna</a>";
$rs->close();
$baza->zatvoriDB();
?>
</section>
<footer>
<address>
<p><small>© 2020. Luka Jakovic</small></p><br>
</address>
</footer>
</body>
</html>