# Setup Guide — Ops Runway (Complete Edition)

Everything in one package: The Board, My Day (clock-in, compulsory tasks, evidence upload), unlimited staff per department, and full HR/CEO visibility (History, Manage Staff).

## What this app can do

- **The Board** — jobs split across 5 departments (Marketing, Operations, Communications, Accounting, Customer Experience), each with its own to-dos, deadlines, and proof-of-completion.
- **My Day** — every staff member clocks in (and out), completes 6 compulsory tasks (worth 70% of their day) plus 3 personal activity slots (worth 30%), and can upload one evidence document per day (max 150KB).
- **Unlimited staff per department** — HR and CEO can create as many staff accounts as needed, in any department, anytime, right from inside the app. No file editing required.
- **HR and CEO have identical, full oversight**:
  - See everyone's monthly completion %, weekend bonus, and deductions at a glance.
  - Click into any person's any day to see exactly what they did, plus download their evidence.
  - Close, reopen, or query any to-do on The Board.
  - **History tab** — browse everything, ever (from install-date onward): every My Day record, every Board action, filterable by date range, person, or department.

## Step 1: Create a MySQL database

1. Log into cPanel → **MySQL Databases**.
2. Under "Create New Database," type a name (e.g. `staffmgt`). Click Create.
   - cPanel will save it as `yourcpaneluser_staffmgt` — note the full name shown.
3. Under "MySQL Users" → "Add New User." Pick a username (e.g. `staffadmin`) and a strong password. Note both.
   - cPanel saves it as `yourcpaneluser_staffadmin`.
4. Under "Add User To Database," add that user to that database.
5. Tick **ALL PRIVILEGES** → click "Make Changes."

Write down: database name, database username, database password.

*(Tip: cPanel also has a "Database Wizard" that walks through all of this in one guided flow — either way works.)*

## Step 2: Create your folder and upload the files

1. In cPanel, go to **File Manager** → `public_html`.
2. Create a new folder (e.g. `staffmgt`) and open it.
3. Upload every file from this package into that folder, keeping the folder structure intact: `api/`, `css/`, `includes/`, `js/`, `uploads/`, plus `login.html`, `board.html`, `schema.sql`, `setup.php`.

## Step 3: Import the schema

1. In cPanel, go to **phpMyAdmin**.
2. Click your new database on the left.
3. Click the **Import** tab.
4. Choose `schema.sql` (included here) → click **Go**.
5. Confirm you now see these 7 tables: `users`, `jobs`, `job_todos`, `compulsory_tasks`, `myday_records`, `myday_compulsory_done`, `activity_log`.

## Step 4: Add your database details

1. In File Manager, open `includes/config.php` in the Code Editor.
2. Replace these three lines with your real values from Step 1:
   ```
   define('DB_NAME', 'yourcpaneluser_yourdbname');
   define('DB_USER', 'yourcpaneluser_yourdbuser');
   define('DB_PASS', 'your-database-password');
   ```
3. Save.

*(The timezone is already set to Nigeria time in this file, so clock-in times will be accurate from the start.)*

## Step 5: Create the first logins

1. Visit `yoursite.com/staffmgt/setup.php` (adjust the path to match your folder name) once.
2. This creates **7 starter accounts**: marketing, operations, communications, accounting, cx, hr, ceo — all with password `changeme123`.
3. It also adds **6 starter compulsory tasks** (placeholders — replace them with your real ones later via phpMyAdmin's `compulsory_tasks` table, keeping the weights summing to 70).
4. **Delete `setup.php` immediately after** — this is a one-time-use file and a security risk if left in place.

## Step 6: Log in and add your real staff

1. Visit `yoursite.com/staffmgt/login.html`.
2. Log in as `hr` or `ceo`.
3. Click the **👥 Manage Staff** tab.
4. For each real staff member: enter their name, pick a username, set a password, choose their department, click **Create Account**. Repeat as many times as needed — there's no limit per department.
5. Share each person's login with them directly.
6. Change the default passwords for `marketing`, `operations`, etc. (or better — stop using those shared accounts entirely once real individual staff accounts exist for everyone).

## What each account type can do

- **Individual staff** (created via Manage Staff): logs in with their own username, has their own personal My Day (clock-in, compulsory tasks, activity slots, evidence upload), and works within their department's shared to-do lane on The Board.
- **hr** and **ceo** — identical powers:
  - **The Board**: Close / Reopen / Query any to-do, any department.
  - **My Day tab**: instead of a personal day, shows everyone's monthly overview table, with drill-down into any person's any day.
  - **Manage Staff tab**: create or remove staff accounts, any department, unlimited.
  - **History tab**: two views — "My Day History" (browse any date range, any person, with evidence download links) and "Board History" (a full timeline of every action, filterable by department).

## Editing the compulsory task list

1. Go to phpMyAdmin → your database → `compulsory_tasks` table.
2. Edit the `text` and `weight` for each row, or add/remove rows entirely.
3. **All weights must add up to exactly 70** — the other 30% comes from each person's 3 daily activity slots (10% each).
4. Changes take effect immediately — no file uploads needed for this.

## About evidence uploads

- One document per person per day, max **150KB**, checked both by the browser and the server (so it can't be bypassed).
- Files are stored for real on your server in `uploads/evidence/` — not just a filename reference.
- HR and CEO can download anyone's evidence from either the My Day drilldown or the History tab.

## Troubleshooting

- **"Database connection failed"** → double-check `includes/config.php` — usually a typo in the database name, username, or password.
- **Evidence upload fails** → confirm `uploads/evidence/` exists and is writable (should work by default; if not, set its permissions to 755 in File Manager).
- **Blank page or missing tabs after visiting the site** → try a hard refresh (clear cache), since browsers sometimes hold onto an old copy of the page.
- **Login page can't reach the server** → double check the `api/` folder uploaded completely, and that your hosting's PHP version is 7.4 or newer (ideally 8.0+).
