# 109 Chrono

Compact Windows/macOS timer for employees. It shows **only the briefs assigned to the logged-in employee** and lets them start/stop the same chronometer as the CRM.

## What employees see

- Login with their CRM email and password
- Their briefs (title, client, project, status, time already tracked)
- Brief details (description, deadline)
- Start / stop the timer (one running timer per person, same as the web chrono)
- Manual time when they forgot to start the timer
- Always-on-top and a system tray icon

Time is saved on the CRM (`brief_time_entries`) and updates brief cost the same way as the website widget.

## Run locally (development)

1. Start the CRM (`php artisan serve` or your usual host).
2. Run the Sanctum migration if it is not applied yet:

```bash
php artisan migrate
```

3. Install and launch the desktop app:

```bash
cd desktop-timer
npm install
npm start
```

On the login screen, open **Serveur CRM** and set:

- local: `http://127.0.0.1:8000`
- production: `https://crm.109worldwide.com` (or your real `APP_URL` with `https://`)

Only users with an employee profile and the `view_my_briefs` permission can sign in.

## Build installers

Windows (on a Windows machine):

```bash
cd desktop-timer
npm install
npm run dist:win
```

The installer is written to `desktop-timer/release/`.

macOS (must be built on a Mac):

```bash
cd desktop-timer
npm install
npm run dist:mac
```

First-time install: send employees the `.exe` / `.dmg`. They do not need the CRM source, only the installer and the CRM server URL.

## Automatic updates

Installed copies of **109 Chrono** check the CRM for a newer version a few seconds after launch, then every 4 hours. If an update exists, a popup asks the employee to download it; after the download they restart to install. They can also right-click the tray icon → **Verifier les mises a jour**.

This only works on the **installed** app (`npm start` does not auto-update).

To publish an update:

1. Bump `"version"` in `desktop-timer/package.json` (example: `1.1.0` → `1.1.1`).
2. Build the installer (`npm run dist:win` and/or `npm run dist:mac`).
3. Copy these files from `desktop-timer/release/` into `public/desktop-chrono/updates/` on the CRM server:
   - Windows: `latest.yml`, `109-Chrono-x.y.z.exe`, `109-Chrono-x.y.z.exe.blockmap`
   - macOS: `latest-mac.yml`, `109-Chrono-x.y.z.zip` (and the `.blockmap` if present)
4. Deploy / upload those files so they are reachable at:
   `https://crm.109worldwide.com/desktop-chrono/updates/latest.yml`

Employees already on a version **with** auto-update (1.1.0+) will get the popup. Anyone still on an older installer without this feature needs the new installer once.
