HAQQANIA CLASS/DAY ATTENDANCE RULE Back up the existing files and database before upload: admin/finalize.php student/dashboard.php student/attendance.php Extract this ZIP inside public_html, retaining the admin/ and student/ paths. Also upload the new student/includes/attendance_rules.php helper. Refresh both student pages with Ctrl+F5 or close/reopen the installed portal. No SQL migration or record deletion is needed. RULE A class/day counts only if at least one member of that class has a Present entry. An Absent-only class/day does not count, even if finalize wrote those Absent rows in the past. Matching is by trimmed current students_master.darja. - Held day + student's Present => Present. - Held day + approved/null-status student_leaves entry => Leave. - Held day + no Present/no approved leave => Absent. - No class Present => Attendance not recorded; excluded from all three counts and the attendance percentage denominator. Future days are not included. Zero eligible days display a dash, not 0%. Present wins over duplicate/old Absent rows. A leave outside a held day does not inflate leave totals. Pending/rejected leave does not count as approved leave. The existing percentage rule present/held-days is retained; approved leave is shown separately and does not silently become Present. FILES CHANGED - admin/finalize.php: writes Absent only for active students in classes with a Present entry today; counts only those classes in absent/leave totals. - student/attendance.php: shared class/day rule for calendar and monthly summary. - student/dashboard.php: same denominator and today's status as the calendar. - student/includes/attendance_rules.php: shared read-only calculation helper. FIRST LIVE CHECK 1. Pick a past day when an entire class had no Present entry but had Absent entries from finalize. Calendar should show Attendance not recorded, and that day should not lower the monthly percentage. 2. Pick a day when one member of that class was Present. Unscanned classmates without approved leave should be Absent; approved leave stays Leave. 3. Verify another class with no Present that day remains unrecorded. 4. Compare dashboard monthly percentage against the calendar. 5. On a test date/system, finalize should not create Absent for an untouched class. LIMITS / SCOPE No attendance rows are deleted or rewritten by the student pages. Finalize changes future finalization behavior only. Existing Absent-only rows remain in DB but are ignored by these updated portal calculations. Other admin reports, cron scripts and includes/activity_center.php were not supplied in this request and have not been changed; raw-log views or old activity-feed items can still display the old stored Absent rows. Their current files are needed if those displays also need this same rule. No scanner code, time windows or offline behavior is changed. Class matching uses current roster membership, as did the old code. A student moved to another class has no dated class history available in these files. A Present row is the available evidence of attendance being held, whether it came from a scan or an authorized manual entry. No scan_logs schema was supplied. VERIFICATION PHP 8.2-compatible syntax parser passed all four files. Executed the actual SELECT queries against SQLite fixtures covering class isolation, Absent-only days, duplicate status rows, date/datetime bounds, and approved/rejected leave. This is not a live MySQL/PHP integration test; verify the above cases on hosting. ROLLBACK Restore the three backed-up PHP files. The helper can remain unused. No database restore is required. Rolling back does not delete/undo new finalized records.