-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDashboardController.php
More file actions
105 lines (84 loc) · 2.89 KB
/
Copy pathDashboardController.php
File metadata and controls
105 lines (84 loc) · 2.89 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
<?php
/*
=======================================================================
PHPPayroll — Open Source HR & Payroll Management Software
Version: 3.0
License: MIT Open Source License
Developed & Maintained By: PHPPayroll (https://www.phppayroll.com)
Description:
PHPPayroll is a Payroll and Human Resource Management platform
available in two deployment models: PHPPayroll Open-Source, a free,
self-hosted edition for essential HR and payroll operations, and
PHPPayroll Cloud, a fully managed, enterprise-grade payroll system.
PHPPayroll is designed to help organizations manage Employees,
Attendance, Leaves, Payroll, and core HR workflows with simplicity,
security, and speed.
Core Modules Included (Open-Source Edition):
- Employee Management
- Attendance Tracking
- Leave Management
- Payroll Management
- HR Dashboard
- Secure Login
This software is open for modification and extension.
You are free to customize, improve, and commercially use the
Open-Source edition without licensing fees, provided this
copyright notice remains preserved.
Website:
https://www.phppayroll.com
Live Demo:
https://www.phppayroll.com/demo/
Download:
https://www.phppayroll.com/download/
Community Contribution:
Developers are welcome to contribute improvements, bug fixes,
and enhancements to the Open-Source edition. Please visit our
website for documentation, updates, and community support.
Last Update: 14-12-2025
=======================================================================
*/
// app/controllers/DashboardController.php
class DashboardController
{
protected $conn;
public function __construct($conn)
{
$this->conn = $conn;
if (empty($_SESSION['user_id'])) {
header('Location: index.php');
exit;
}
}
protected function getSingleInt(string $sql): int
{
$result = $this->conn->query($sql);
if (!$result) return 0;
$row = $result->fetch_row();
return isset($row[0]) ? (int)$row[0] : 0;
}
public function index()
{
// =====================
// HR DASHBOARD STATS
// =====================
// Employees
$totalEmployees = $this->getSingleInt(
"SELECT COUNT(*) FROM phppayroll_employees"
);
$activeEmployees = $this->getSingleInt(
"SELECT COUNT(*) FROM phppayroll_employees WHERE status = 1"
);
// Today's attendance
$todayAttendance = $this->getSingleInt(
"SELECT COUNT(*) FROM phppayroll_attendance WHERE attendance_date = CURDATE()"
);
// Pending leave requests
$pendingLeaves = $this->getSingleInt(
"SELECT COUNT(*) FROM phppayroll_leaves WHERE status = 'pending'"
);
// =====================
// LOAD VIEW
// =====================
include __DIR__ . '/../views/dashboard/index.php';
}
}