Repository navigation
Expand file tree
/
Copy pathindex.php
More file actions
95 lines (87 loc) · 4.04 KB
/
Copy pathindex.php
File metadata and controls
95 lines (87 loc) · 4.04 KB
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
<?php
require_once 'includes/database.php';
require_once 'includes/functions.php';
require_once 'includes/header.php';
$total_teas = getTeaCount($mysqli);
$recent = $mysqli->query("SELECT * FROM teas ORDER BY drink_date DESC LIMIT 5");
$stats_result = $mysqli->query("SELECT COUNT(DISTINCT drink_date) as tea_days, MAX(drink_date) as last_tea FROM teas");
$stats = $stats_result->fetch_assoc();
$brand_result = $mysqli->query("SELECT brand, COUNT(*) as cnt FROM teas GROUP BY brand ORDER BY cnt DESC LIMIT 1");
$top_brand = $brand_result ? $brand_result->fetch_assoc() : null;
?>
<div class="home-hero">
<h1>Welcome to TeaKeeper</h1>
<p class="home-subtitle">Your personal tea journal — track every cup, every day.</p>
</div>
<div class="home-stats-grid">
<div class="home-stat-card">
<div class="home-stat-num"><?php echo $total_teas; ?></div>
<div class="home-stat-label">Total Teas</div>
</div>
<div class="home-stat-card">
<div class="home-stat-num"><?php echo $stats['tea_days'] ?? 0; ?></div>
<div class="home-stat-label">Tea Days</div>
</div>
<div class="home-stat-card">
<div class="home-stat-num"><?php echo $top_brand ? htmlspecialchars($top_brand['brand']) : '—'; ?></div>
<div class="home-stat-label">Favourite Brand</div>
</div>
<div class="home-stat-card">
<div class="home-stat-num">
<?php echo $stats['last_tea'] ? date('j M', strtotime($stats['last_tea'])) : '—'; ?>
</div>
<div class="home-stat-label">Last Tea</div>
</div>
</div>
<div class="home-sections">
<div class="home-section">
<h2>Recent Teas</h2>
<?php if ($recent && $recent->num_rows > 0): ?>
<table>
<tr>
<th>Date</th>
<th>Brand</th>
<th>Name</th>
<th>Flavor</th>
</tr>
<?php while ($tea = $recent->fetch_assoc()): ?>
<tr>
<td><?php echo htmlspecialchars($tea['drink_date']); ?></td>
<td><?php echo htmlspecialchars($tea['brand']); ?></td>
<td><?php echo htmlspecialchars($tea['tea_name']); ?></td>
<td><?php echo htmlspecialchars($tea['flavor']); ?></td>
</tr>
<?php endwhile; ?>
</table>
<a href="teas.php" class="home-link-btn">View all teas →</a>
<?php else: ?>
<?php echo showMessage("No teas yet! Import a CSV to get started.", 'info'); ?>
<a href="iexport.php" class="home-link-btn">Import CSV →</a>
<?php endif; ?>
</div>
<div class="home-section">
<h2> How to Use</h2>
<ul class="home-howto">
<li><strong><a href="teas.php">Teas</a></strong> — Browse, edit, add, or delete individual entries.
</li>
<li><strong><a href="calendar.php">Calendar</a></strong> — See your tea days colour-coded by month.
Click a date to see details.</li>
<li><strong><a href="statistics.php">Statistics</a></strong> — Explore brand rankings, monthly trends,
and flavour breakdowns.</li>
<li><strong><a href="iexport.php">Import / Export</a></strong> — Load a CSV file, download your data,
or reset to defaults.</li>
</ul>
<h3>CSV Format</h3>
<pre class="home-pre">drink_date,brand,tea_name,flavor
2025-01-15,Fructus,Earl Grey,Bergamot
2025-01-16,dmBio,Peppermint,Mint</pre>
<h3>About This Project</h3>
<p>TeaKeeper was created by <strong>Gloomcaller</strong> as a pre-exam project.</p>
<p>
<a href="https://github.com/Gloomcaller" target="_blank">GitHub</a> ·
<a href="https://linkedin.com/in/vojislav-beli-14a47b302" target="_blank">LinkedIn</a> ·
<a href="mailto:belivojislavit10923@gmail.com">Email</a>
</p>
</div>
</div>
<?php require_once 'includes/footer.php'; ?>