-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsadaqa_tracker.php
More file actions
108 lines (94 loc) · 3.83 KB
/
Copy pathsadaqa_tracker.php
File metadata and controls
108 lines (94 loc) · 3.83 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
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
$page_title = "Sadaqa Tracker";
require_once __DIR__ . '/autoload.php';
use App\Core\Bootstrap;
use App\Helpers\Layout;
Bootstrap::init();
Layout::header();
Layout::sidebar();
// 1. Auto-Healing: Create sadaqa_tracker Table (Handled by install.php)
$year = filter_input(INPUT_GET, 'year', FILTER_VALIDATE_INT) ?? date('Y');
// Get total sadaqa per month for the selected year
$stmt = $pdo->prepare("
SELECT MONTH(sadaqa_date) as month, SUM(amount) as total
FROM sadaqa_tracker
WHERE tenant_id = :tenant_id AND YEAR(sadaqa_date) = :year
GROUP BY MONTH(sadaqa_date)
");
$stmt->execute(['tenant_id' => $_SESSION['tenant_id'], 'year' => $year]);
$monthly_totals = $stmt->fetchAll(PDO::FETCH_KEY_PAIR);
$months = [
1 => 'January',
2 => 'February',
3 => 'March',
4 => 'April',
5 => 'May',
6 => 'June',
7 => 'July',
8 => 'August',
9 => 'September',
10 => 'October',
11 => 'November',
12 => 'December'
];
$current_month = date('n');
$current_year = date('Y');
?>
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="h3 fw-bold mb-0">Sadaqa <span class="text-success fw-light">|</span> Tracker <?php echo $year; ?></h1>
<div class="btn-group">
<a href="?year=<?php echo $year - 1; ?>" class="btn btn-outline-light text-dark"><i
class="fa-solid fa-chevron-left"></i></a>
<button type="button" class="btn btn-light fw-bold px-4"><?php echo $year; ?></button>
<a href="?year=<?php echo $year + 1; ?>" class="btn btn-outline-light text-dark"><i
class="fa-solid fa-chevron-right"></i></a>
</div>
</div>
<div class="row g-4">
<?php foreach ($months as $num => $name): ?>
<?php
$total = $monthly_totals[$num] ?? 0;
$is_current = ($year == $current_year && $num == $current_month);
$has_data = $total > 0;
// Card Style
$bg_style = $is_current
? "background: linear-gradient(135deg, #20c997, #198754); color: white;"
: "background: white;";
$text_muted = $is_current ? "text-white-50" : "text-muted";
$text_primary = $is_current ? "text-white" : "text-success";
?>
<div class="col-6 col-md-4 col-lg-3">
<a href="monthly_sadaqa.php?month=<?php echo $num; ?>&year=<?php echo $year; ?>" class="text-decoration-none">
<div class="card shadow-sm border-0 h-100 <?php echo $is_current ? 'shadow-lg transform-scale' : ''; ?>"
style="<?php echo $bg_style; ?> transition: transform 0.2s;">
<div class="card-body p-4 d-flex flex-column justify-content-between text-center">
<div>
<h5 class="fw-bold mb-1 <?php echo $is_current ? 'text-white' : 'text-dark'; ?>">
<?php echo $name; ?>
</h5>
<small class="<?php echo $text_muted; ?>"><?php echo $year; ?></small>
</div>
<div class="mt-4">
<?php if ($has_data): ?>
<h4 class="fw-bold mb-0 <?php echo $text_primary; ?>">
<small style="font-size: 0.6em">AED</small>
<span class="blur-sensitive"><?php echo number_format($total, 2); ?></span>
</h4>
<?php else: ?>
<div class="<?php echo $text_muted; ?> small py-1">- No Entry -</div>
<?php endif; ?>
</div>
</div>
</div>
</a>
</div>
<?php endforeach; ?>
</div>
<style>
.transform-scale:hover {
transform: translateY(-5px);
}
</style>
<?php
Layout::footer();
?>