Attendance Management
Comprehensive attendance tracking for students and staff with reports, shortage alerts, and regularisation
Overview
OptiCRM provides a complete attendance management system covering students, teaching staff, and operational staff. It includes daily/period-wise marking, automated shortage alerts, holiday management, staff self-service, and regularisation workflows.
Student Attendance
Daily Marking
- Navigate to Attendance from the sidebar
- Select the class/section and date
- System loads all enrolled students
- Mark each student: Present, Absent, Late, Half Day, Excused, Leave
- Click Save -records saved to database
- Students marked Absent automatically trigger SMS/Email notification to their primary guardian
Period-Wise Attendance
For subject-level tracking, teachers can mark attendance per period:
- Select the period number in addition to class and date
- System uses the timetable to identify which subject/teacher is scheduled
- Allows tracking: "Present for Maths (Period 1) but absent for Science (Period 3)"
Attendance Statuses
| Status | Code | Description |
|---|---|---|
| Present | P | Student was present |
| Absent | A | Absent (unexcused) -triggers parent notification |
| Late | L | Arrived late (counts as present for percentage) |
| Half Day | HD | Present for half the day (counts as 0.5) |
| Excused | E | Absent with valid reason |
| Leave | LV | On approved leave |
| Holiday | H | Institutional holiday |
| Weekend | W | Non-working day |
Attendance Corrections
HOD or Principal can correct wrongly-marked records:
- Navigate to the student's attendance record
- Change the status with a mandatory reason
- Reason is appended to the record's notes for audit trail
Staff Attendance
Admin Marking
- Navigate to HR & Staff →Staff Attendance (admin view)
- Select department and date
- Mark each staff member: Present, Absent, Half Day, On Leave, Work From Home, On Duty
- Optionally enter check-in/check-out times
- Overtime auto-calculated if working hours exceed 8
Self-Service View
Staff members can view their own attendance at Self Service →My Attendance:
- Monthly calendar grid with color-coded status badges
- Summary cards: Present, Absent, Leave, Half Day, Holidays, Overtime hours, Attendance %
- Navigate between months
Staff Attendance Statuses
| Status | Description |
|---|---|
| STAFF_PRESENT | Present at work |
| STAFF_ABSENT | Absent |
| STAFF_HALF_DAY | Present for half day |
| STAFF_ON_LEAVE | On approved leave |
| STAFF_HOLIDAY | Institutional holiday |
| WORK_FROM_HOME | Working remotely |
| ON_DUTY | On official duty outside campus |
Attendance Regularisation
When a staff member notices an incorrect attendance record:
- Go to Self Service →My Attendance
- Click the day with wrong status
- Submit a regularisation request with:
- Current (wrong) status
- Requested (correct) status
- Reason for correction
- HOD or Admin reviews the request
- On approval: attendance record is automatically corrected
API: POST /api/staff-attendance/regularisation (submit), PATCH (approve/reject)
Holiday Management
Setting Up Holidays
Navigate to Administration →Holiday Calendar:
- Click Add Holiday
- Enter: name, date, type, and options
- Holidays automatically affect:
- Student attendance (students auto-marked as HOLIDAY)
- Staff attendance (excluded from working day count)
- Working days calculation
- Calendar display
Holiday Types
| Type | Description | Example |
|---|---|---|
| Gazetted | Government-declared holidays | Republic Day, Independence Day |
| Restricted | Optional holidays | Regional festivals |
| Vacation | Extended breaks | Summer vacation, Winter break |
| Custom | Institution-specific | Annual Day, Foundation Day |
Options
- Applies to Staff -Include in staff working days calculation
- Applies to Students -Include in student attendance calculation
- Recurring -Repeats every year (e.g., Republic Day)
Attendance Reports
Daily Register
API: GET /api/attendance/report?type=daily§ionId=xxx&date=2026-04-13
Shows all students in a section for one date with:
- Student name, code, status, notes
- Summary: total present/absent/late/half-day/excused
- Who marked the attendance and when
Monthly Summary
API: GET /api/attendance/report?type=monthly§ionId=xxx&month=4&year=2026
Full month grid showing:
- One row per student, one column per day (1-31)
- Status codes: P (Present), A (Absent), L (Late), HD (Half Day), E (Excused), LV (Leave), H (Holiday), W (Weekend)
- Right column: attendance percentage per student
- Color coding: Green (above 90%), Amber (75-90%), Red (below 75%)
- Working days count (excludes holidays and weekends)
Shortage Report
API: GET /api/attendance/report?type=shortage§ionId=xxx
Lists students below 75% attendance:
- Student name, code, class/section
- Present days / working days, percentage
- Guardian name and phone number
- Sorted by percentage (lowest first)
Automated Shortage Alerts
A daily cron job (POST /api/cron/attendance-shortage) runs automatically:
- For each institution, calculates every student's attendance percentage
- Students below 75% trigger an email to their primary guardian
- Email includes: student name, attendance percentage, present/working days
- Deduplication: Each student is notified at most once per week (Redis-based)
- Requires:
CRON_SECRETenv variable for security
Sample notification:
"Alert: Your child Aarav Sharma (STU-2026-0042, Grade 8-A) has 68% attendance this term, which is below the required 75%. Please ensure regular attendance."
Role-Based Access
| Role | Student Attendance | Staff Attendance | Holidays | Regularisation |
|---|---|---|---|---|
| Super Admin | Full manage | Full manage | Manage | Approve all |
| Institution Admin | Full manage | Full manage | Manage | Approve all |
| Principal | View all, correct | View all | Manage | Approve |
| HOD | View dept, correct | View dept | View | Approve dept |
| Teacher | Mark own classes | View own | View | - |
| Staff | - | View own | View | Submit own |
| Parent | View child (portal) | - | View | - |
| Student | View own (portal) | - | View | - |
API Reference
| Method | Route | Description |
|---|---|---|
| GET | /api/staff-attendance?month=X&year=Y | Staff attendance (self or by staffId) |
| POST | /api/staff-attendance | Mark staff attendance (admin) |
| GET | /api/staff-attendance/regularisation | List regularisation requests |
| POST | /api/staff-attendance/regularisation | Submit regularisation request |
| PATCH | /api/staff-attendance/regularisation | Approve/reject regularisation |
| GET | /api/attendance/report?type=monthly | Attendance reports (monthly, daily, shortage) |
| GET | /api/holidays?year=2026 | List holidays |
| POST | /api/holidays | Create holiday |
| DELETE | /api/holidays?id=xxx | Delete holiday |
| POST | /api/cron/attendance-shortage | Run shortage alert cron |
Technical Architecture (Developer Reference)
Storage Model
Attendance uses dedicated Prisma tables (not JSONB DynamicRecord) for performance reasons. With millions of rows (every student x every day), dedicated tables with proper indexes are essential for aggregations, date-range queries, and cross-entity joins.
However, all attendance entities are fully integrated into the entity system:
- Object Manager - Visible as standard objects (StaffAttendance, Holiday, Attendance)
- Report Builder - Custom reports with filters, grouping, computed columns
- Cross-Object Reports - Student+Attendance join for combined student-attendance analysis
- Entity List - CRUD views at
/o/StaffAttendance,/o/Holiday - Dashboard KPIs - todayAttendanceRate, attendanceBySection
- Export - CSV, Excel, PDF via the report builder
Database Models
Attendance (student) - prisma/schema.prisma
- Unique:
[studentId, date, period] - Indexes:
[sectionId, date],[studentId, date] - 7 statuses: PRESENT, ABSENT, LATE, HALF_DAY, EXCUSED, HOLIDAY, LEAVE
- Source tracking: MANUAL, BIOMETRIC, IMPORTED
StaffAttendance - prisma/schema.prisma
- Unique:
[staffId, date] - 7 statuses: STAFF_PRESENT, STAFF_ABSENT, STAFF_HALF_DAY, STAFF_ON_LEAVE, STAFF_HOLIDAY, WORK_FROM_HOME, ON_DUTY
- Check-in/out with overtime auto-calculation
Holiday - prisma/schema.prisma
- Unique:
[institutionId, date] - Types: GAZETTED, RESTRICTED, VACATION, CUSTOM
- Affects: attendance calculations, calendar, working days
AttendanceRegularisation - prisma/schema.prisma
- Status: REG_PENDING, REG_APPROVED, REG_REJECTED
- On approval: auto-updates StaffAttendance record
PersonalEvent - prisma/schema.prisma
- User-scoped calendar events
- Indexed:
[userId, startDate]
Key Implementation Files
| File | Purpose |
|---|---|
src/actions/attendance.ts | Student attendance server actions (mark, get, correct, shortage) |
src/actions/staffAttendance.ts | Staff attendance server actions (mark, summary, monthly sheet) |
src/actions/holidays.ts | Holiday CRUD + working days calculator |
src/lib/query/static-queries.ts | Report builder query handlers for Attendance, StaffAttendance, Holiday |
src/lib/entity-registry.ts | Field definitions for report builder and layout system |
src/lib/entity-actions.ts | PRISMA_MODEL_MAP entries for generic CRUD |
src/lib/kpi/engine.ts | KPI calculations (todayAttendanceRate, attendanceBySection) |
src/app/api/staff-attendance/route.ts | Staff attendance REST API |
src/app/api/attendance/report/route.ts | Attendance reports (daily, monthly, shortage) |
src/app/api/cron/attendance-shortage/route.ts | Daily shortage alert cron |
src/app/api/calendar/route.ts | Unified calendar aggregation |
Integration Points
Report Builder - An admin can create custom reports like:
- "Staff Attendance by Department" - source: StaffAttendance, group by: department
- "Student Shortage List" - source: Attendance, filter: percentage below 75
- "Holiday Summary by Type" - source: Holiday, group by: type
Cross-Object Reports - Student+Attendance join enabled in cross-object.ts:
- Shows student details alongside their attendance summary
- Columns: studentName, className, presentDays, absentDays, percentage
Dashboard KPIs - Real-time metrics from kpi/engine.ts:
todayAttendanceRate(institutionId)- today's present percentageattendanceByClass(institutionId)- per-section rates for chart
Calendar - Holiday model feeds into the unified calendar API:
- Red blocks for holidays
- Working days excluded from attendance calculations