# Phase 30 - Document Management & Electronic Agreements

Phase 30 adds a central controlled document repository to the PHP/MySQLi microfinance platform.

## Professional workspace

Route: `/document-management`

Tabs:
- Control Centre
- Repository
- Approvals
- e-Signatures
- Expiry Monitor

The module is positioned under **System Administration -> Administration Suite -> Document Management** because repository governance, confidentiality, retention, approval evidence and integrity controls are institution-wide administration responsibilities. Operational customer and loan records can still link directly to customers and loans.

## Controls

- PDF, JPG and PNG uploads only
- 10 MB maximum file size
- files stored outside `public/`
- random stored file names
- SHA-256 integrity hash per version
- immutable version numbering
- maker-checker approval
- document creator cannot approve/reject the same record
- restricted-document download requires Administrator, CEO, Manager or Auditor role
- complete audit trail for create, version, submit, approve/reject, download and signature evidence
- expiry monitoring

## Electronic signatures

The module records signing requests and evidence for customer, guarantor, employee, director or other signers. Supported evidence methods are OTP, drawn signature, digital certificate, and wet-signature record. The current phase records controlled evidence; live OTP/certificate execution can be connected later through the API & Integrations hub.

## Upgrade

Import `sql/migration_030_document_management.sql` after backing up the database.

Ensure the PHP process can write to `storage/document-repository/`. This directory must remain outside the public web root.
