{% extends "base.html" %} {% block content %}

Monthly Attendance Summary

Select employees for bulk update, or click a day to edit (if payroll not frozen).
Reset
Bulk Month Update
Applies to selected employees (left checkbox). Skips payroll-frozen employees.
Tip: leave From/To Date blank for full month. For one day, select same From and To Date.
Present Half Day Leave RH Holiday Weekend LWP Half-day Leave (split) WFH Green outline = Manual/Bulk.
{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} {% for c, m in messages %} {% endfor %} {% endif %} {% endwith %} {% set has_rows = summary_data and summary_data|length > 0 %} {% if has_rows %} {% set days = summary_data[0].days %}
{% for cell in days %} {% endfor %} {% for row in summary_data %} {% set emp = row.employee %} {% set frozen = row.payroll_frozen %} {% for cell in row.days %} {% set a = cell.record %} {% set remark = a.remarks if a else '' %} {% set is_manual = (a and (a.source in ['Manual','Bulk'])) %} {% set hl = cell.half_leave %} {% set is_rh_leave = cell.is_rh_leave|default(false) %} {% set is_wfh = cell.is_wfh|default(false) %} {# second-half derived from Attendance.note if present: "SH:Present" etc #} {% set sh = '' %} {% if a and a.note %} {% if 'SH:' in a.note %} {% set sh = (a.note.split('SH:')[1].split('|')[0]).strip() %} {% endif %} {% endif %} {# ✅ UI override for Holiday/Weekend if stored as blank/LWP or no row #} {% set is_holiday_day = holiday_dates and (cell.date in holiday_dates) %} {% set is_weekend_day = weekend_dates and (cell.date in weekend_dates) %} {% set display_remark = remark %} {% if is_rh_leave %} {% set display_remark = 'RH' %} {% elif (not hl) and (not is_manual) and is_holiday_day and ((not a) or (remark in ['', 'LWP'])) %} {% set display_remark = 'Holiday' %} {% elif (not hl) and (not is_manual) and is_weekend_day and ((not a) or (remark in ['', 'LWP'])) %} {% set display_remark = 'Weekend' %} {% endif %} {% endfor %} {% endfor %}
{{ cell.date.day }}
{{ cell.date.strftime('%a') }}
{{ emp.full_name }}
{{ emp.employee_code }} {% if frozen %} · Payroll Frozen {% endif %}
{% else %}
No employees found for this filter.
{% endif %}
{% endblock %}