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

Appraisal Dashboard

{% if is_hr_admin %} Budgets Question Master Score Rules Initiate {% endif %}
{# ----------------------- Filters ----------------------- #} {% set filter_action = (request.args.get('action') or 'all')|lower %}
{% if is_hr_admin %}
Tip: For pending items even if effective month is different, choose Show = Action Required.
{% endif %}
{# Preserve tab on filter submit #} {% if request.args.get('tab') %} {% endif %}
{# ----------------------- Build lists for non-HR users ----------------------- #} {% set my_pending = [] %} {% set my_history = [] %} {% set my_team_pending = [] %} {% if not is_hr_admin %} {% for a in appraisals %} {% set s = (a.status or '')|lower %} {% set is_mine_emp = (a.employee_id == current_user.id) %} {% set is_mine_mgr = (a.manager_id == current_user.id) %} {# my pending #} {% if (s == 'awaiting_employee' and is_mine_emp) or (s == 'awaiting_manager' and is_mine_mgr) %} {% set _ = my_pending.append(a) %} {% endif %} {# my history (anything mine but not pending) #} {% if is_mine_emp or is_mine_mgr %} {% if not ((s == 'awaiting_employee' and is_mine_emp) or (s == 'awaiting_manager' and is_mine_mgr)) %} {% set _ = my_history.append(a) %} {% endif %} {% endif %} {# my team pending (manager stage only) #} {% if is_mine_mgr and s == 'awaiting_manager' %} {% set _ = my_team_pending.append(a) %} {% endif %} {% endfor %} {% endif %} {# ----------------------- Pending alert (non-HR) ----------------------- #} {% if not is_hr_admin and my_pending|length > 0 %} {% set first = my_pending[0] %} {% set first_status = (first.status or '')|lower %}
You have {{ my_pending|length }} appraisal(s) requiring your action.
{% if first_status == 'awaiting_employee' %} Fill Now {% elif first_status == 'awaiting_manager' %} Review Now {% else %} Open {% endif %}
{% endif %} {# ----------------------- Due This Month (HR only) ----------------------- #} {% if is_hr_admin %}
Appraisal Due This Month
{% for r in due_rows %} {% else %} {% endfor %}
Employee Code Department Due Date Action
{{ r.emp.full_name }} {{ r.emp.employee_code }} {{ r.dept.name if r.dept else '-' }} {{ r.due_date.strftime('%d-%b-%Y') }} Initiate
No employees due this month.
{% endif %} {# ----------------------- Tabs (non-HR) ----------------------- #} {% if not is_hr_admin %} {% set active_tab = (request.args.get('tab') or 'pending')|lower %} {% endif %} {# ----------------------- Select list rows ----------------------- #} {% if is_hr_admin %} {% set list_rows = appraisals %} {% else %} {% set active_tab = (request.args.get('tab') or 'pending')|lower %} {% if active_tab == 'team' %} {% set list_rows = my_team_pending %} {% elif active_tab == 'history' %} {% set list_rows = my_history %} {% else %} {% set list_rows = my_pending %} {% endif %} {% endif %} {# ----------------------- Main Table ----------------------- #}
{% if is_hr_admin %} {% if filter_action == 'action' %} Appraisals Needing Action (All Months) {% elif filter_action == 'completed' %} Completed Appraisals (All Months) {% else %} Appraisals Effective This Month {% endif %} {% else %} {% set active_tab = (request.args.get('tab') or 'pending')|lower %} {% if active_tab == 'team' %} My Team Pending Appraisals {% elif active_tab == 'history' %} My Appraisal History {% else %} My Pending Appraisals {% endif %} {% endif %}
Showing {{ list_rows|length }} record(s)
{% if list_rows|length == 0 %} {% endif %} {% for a in list_rows %} {% set e = emp_map.get(a.employee_id) %} {% set s = ((a.status or '')|string|lower|trim)|replace(' ', '_')|replace('-', '_') %} {% endfor %}
Employee Process Status Effective Month Action
No records found.
{{ e.full_name if e else a.employee_id }} {% if e %}
{{ e.employee_code }}
{% endif %}
{% if a.process_type == 'P1' %}P1 (Emp + Mgr) {% elif a.process_type == 'P2' %}P2 (Mgr) {% else %}P3 (Direct){% endif %} {% if s == 'awaiting_employee' %} Pending for Employee {% elif s == 'awaiting_manager' %} Pending for Manager {% elif s == 'scored' %} Scored (HR Pending) {% elif s == 'hr_finalized' %} HR Finalized {% elif s == 'applied' %} Applied {% elif s == 'cancelled' %} Cancelled {% else %} {{ a.status }} {% endif %} {{ a.effective_month.strftime('%b-%Y') }} {% if s == 'awaiting_employee' and a.employee_id == current_user.id %} Fill Appraisal {% elif s == 'awaiting_manager' and a.manager_id == current_user.id %} Fill Review {% elif is_hr_admin and (s in ['scored','initiated','hr_finalized']) %} HR Finalize {% else %} View {% endif %}
{% endblock %}