Impact Life Executive Dashboard - API Sync Scheduler (v17)
===========================================================

1. Import install.sql for a fresh installation.
   Existing installations are upgraded automatically by api_sync_lib.php when
   the DB user has ALTER privileges. If ALTER is blocked, run upgrade_sync_v15.sql once.

2. Open sync_settings.php and configure:
   - Base URL and endpoints
   - Bearer token
   - Payments / Claims configured ranges
   - Sync interval (default 10 minutes)
   - API Batch Size (recommended 1 day)
   - Automatic Rolling Window (recommended 24 hours)
   - Enable automatic sync
   - Keep "Use current date/time ... for automatic sync" checked when the
     automatic scheduler should always sync up to the current time.

3. Use Endpoint Tests with an exact known-good one-day range first. Test fields
   are independent of the automatic "to now" setting.

4. Use Manual / Backfill Sync for historical data. Long ranges are automatically
   split into smaller calendar-day API requests according to API Batch Size.

5. Add this cron entry on Linux/cPanel:

   * * * * * /usr/bin/php /FULL/PATH/Impact_Executive_Dashboard_final/cron_sync.php >> /FULL/PATH/Impact_Executive_Dashboard_final/api_sync_cron.log 2>&1

The launcher runs every minute, but cron_sync.php checks api_sync_settings and
only contacts the upstream APIs when the configured interval is due. With a
10-minute interval it runs every 10 minutes. Automatic sync uses the rolling
window instead of requesting the entire historical range repeatedly.

To force a one-off configured-range sync from command line:

   /usr/bin/php /FULL/PATH/Impact_Executive_Dashboard_final/cron_sync.php --force

Security recommendation
-----------------------
Prefer setting the upstream token as a server environment variable:

   UPSTREAM_BEARER_TOKEN="your-generated-token"

When this variable exists, it overrides the token stored in the database.
Never paste live Bearer tokens into emails, chats, screenshots or diagnostics.
