{# === PAGE HEADER === #}
{# On desktop: title left, buttons right in a row #}
{# On mobile: title on top, buttons below in a 2x2 grid #}
Payroll Dashboard
{# === ANALYTICS SUMMARY BAR — compact row of key numbers === #}
{# Always visible. Clicking "Show Details" expands the full stat cards and charts below. #}
{# Key numbers in a compact row #}
Outstanding
R {{ outstanding_total|floatformat:2 }}
Paid (60d)
R {{ recent_payments_total|floatformat:2 }}
Loans ({{ active_loans_count }})
R {{ active_loans_balance|floatformat:2 }}
{# Toggle button to expand/collapse full analytics #}
{# === FULL ANALYTICS (hidden by default — toggled by button above) === #}
{# --- Stat cards row --- #}
{# --- Left column: stat cards --- #}
{# Outstanding Total — with breakdown of wages vs adjustments #}
Outstanding Payments
R {{ outstanding_total|floatformat:2 }}
{% if pending_adj_add_total or pending_adj_sub_total %}
{# === ADJUSTMENTS TAB LINK === #}
{# Task 4: flat table view of every payroll adjustment with filters, #}
{# bulk actions, and row edit/delete. See _adjustment_row.html. #}
{# =============================================== #}
{# === PENDING PAYMENTS TAB === #}
{# =============================================== #}
{% if active_tab == 'pending' %}
{# === PENDING PAYMENTS FILTER BAR === #}
{# Lets admin filter by team, show only overdue workers, or exclude workers with loans #}
{# On mobile: hide Days, Day Rate, Log Amount, Adjustments, Net Adj columns #}
{# Only show: Worker (with badges), Total, Adjust + Pay buttons #}
{# All details are accessible by tapping the worker name (opens lookup modal) #}
{% if loan.active %}
Active
{% else %}
Paid Off
{% endif %}
{% empty %}
{% if loan_filter == 'active' %}No active loans or advances.{% else %}No loan/advance history.{% endif %}
{% endfor %}
{% endif %}
{# =============================================== #}
{# === ADJUSTMENTS TAB === #}
{# =============================================== #}
{# Flat, filterable table of every PayrollAdjustment in the system. #}
{# Filters run server-side via GET params (type, worker, team, status, date range). #}
{# Row actions reuse the existing Edit / Delete / Preview modals so no new JS is needed. #}
{% if active_tab == 'adjustments' %}
{# --- Sticky filter bar (pill-popover checkbox filters for Type/Workers/Teams) --- #}
{# --- Stats row (scoped to the currently-filtered set) --- #}
{# --- PREVIEW PAYSLIP MODAL --- #}
{# === BATCH PAY MODAL === #}
{# Shows a preview of which workers will be paid (based on team pay schedules), #}
{# then lets the admin confirm to process all payments at once. #}
Batch Pay by Schedule
{# Content loaded via JavaScript #}
Loading preview...
Payslip Preview & Repayments
{# Content loaded via JavaScript #}
Loading preview...
{# === WORKER LOOKUP MODAL === #}
{# Shows a comprehensive financial report card for any active worker. #}
{# Triggered by clicking a worker name or the "Worker Lookup" button. #}
Worker Lookup
{# Worker selector dropdown #}
{# Report card content — populated dynamically by JavaScript #}
Select a worker to view their report card.
{# ================================================================== #}
{# === JAVASCRIPT === #}
{# ================================================================== #}
{# Django's json_script filter safely outputs JSON without XSS risk #}
{{ overtime_data_json|json_script:"otDataJson" }}
{{ team_workers_map_json|json_script:"teamWorkersJson" }}
{{ chart_labels_json|json_script:"chartLabelsJson" }}
{{ chart_totals_json|json_script:"chartTotalsJson" }}
{{ project_chart_json|json_script:"projectChartJson" }}
{{ worker_chart_json|json_script:"workerChartJson" }}
{# === CHOICES.JS CDN — loaded only when the Adjustments tab is active === #}
{# Used by the Type / Workers / Teams multi-select filters. If the CDN fails #}
{# the