# Daily login attendance and monthly receipts

## Install on XAMPP
1. Back up the database and application.
2. In phpMyAdmin select the SLPS database and import database/migrations/20261016_login_attendance.sql once. It creates three new tables and sets the tracking start to the installation date in Zambia time. Do not import the entire schema over an existing database.
3. Apply the updated application files, preserving existing database/OpenRouter settings and uploads. Refresh with Ctrl+F5.

Students open Attendance History for their monthly receipt. Staff, administrators and HODs open Login Attendance. Management sees student receipt cards with monthly totals; click a card for the full-page receipt, select another month or print. Management lists are paginated (30 students per page). HOD access stays within their assigned department and campus; staff and administrators have global access.

A successful student sign-in records the first activity of that Zambia calendar day. An authenticated request from an already signed-in session also records daily activity. One database row per user and day prevents duplicate attendance. No student login is created by an administrator viewing a receipt. Attendance records system participation, not classroom presence or proof that a specific resource was read. Weekends and public holidays count because the requirement is every day.

The current day without activity is Awaiting login. After midnight it becomes No login recorded and displays red. Future dates show Upcoming. Dates before installation tracking or student enrollment show Not tracked. Existing records are not fabricated from last_login, which cannot establish a complete historical record.

A month closes at 00:00 on the first of the next month in Africa/Lusaka (UTC+02). Closure is calculated from the calendar, so it does not depend on a user being online or a scheduled task. On first access to a closed month's receipts, the system stores immutable monthly snapshots using a unique student/month key. Later logins cannot modify these closed receipts. Open receipts are computed from current daily records. Snapshots contain the student details at finalisation. This is automatic calendar closure with on-access snapshot storage, not a background midnight batch job.

Login continues if the attendance tables have not yet been installed; the receipt page reports the missing migration. Apply the migration before using attendance. Retain the new tables and include them in database backups.

Automated verification covers month/day generation, pending versus absence, future days, tracking/enrollment boundaries, leap years, Zambia timezone boundaries, student isolation and staff/HOD access rules. A live XAMPP/MySQL database and browser print rendering were not available for end-to-end verification.
