# Multi-Tenant Attendance

This module supports separate records per counsel by storing `tenant_id` and optional `branch_id` on all attendance tables. Administrators can tailor clocking forms and approval screens using the Form Builder so each organisation collects the fields relevant to their processes. Workflow events and document uploads integrate with the DMS just like other modules.

## Schema Changes

The following tables include the tenant and branch identifiers:

- `time_clocks`
- `timesheets`
- `time_clock_locations`
- `time_clock_documents`

`time_clock_documents` links clock entries with files managed by the [Document Management System](DocumentManagementSystem.md). New migrations add the columns and create indexes for filtering by tenant or branch.

## Form Definitions

Two default forms are provided:

1. **Time Clock Entry** – form `id` 13 defines the fields used when creating clock records from the UI. Tenants may override this form or create department-specific versions following the hierarchy in [HierarchicalConfiguration.md](HierarchicalConfiguration.md).
2. **Timesheet Approval** – previously relied on table view `id` 14. Table views are deprecated so the approval list is generated via model logic and rendered with `DataLoader`.

## Workflow Triggers

Attendance actions emit events consumed by the Workflow Engine:

- `timeclock.created` – fired when a new clock entry is saved.
- `timesheet.approved` – fired after a supervisor approves a sheet.

Workflows configured with these trigger names can notify managers or create follow-up tasks.

## DMS Integration

Clock entries support uploading attachments such as photos or signed slips. Files are stored using `DocumentService` and versioned via `DocumentVersioning`. The association is recorded in `time_clock_documents` so documents remain scoped to the current tenant.

## Upgrade Notes

Existing installations should apply the migrations outlined in [Multi-Tenant Migration](MultiTenantMigration.md) to add the `tenant_id` and `branch_id` columns before enabling these attendance features.
