# Features — bi_tool_php

Evidence date: 2026-10-19. Revision: `master` `b440d76` (2023-11-18, "total litres calculation fix").

No feature list existed in the source repository or in Silicon Ark. Status below is from `master`. There is no other remote branch.

Planned features written as a roadmap: **none found**.

## Current features (master)

| Feature | What it does | Evidence | Status |
|---|---|---|---|
| Folder import | Scans `...\SAWIS\2023_data_file\`, skips `.` and `..`, skips the first line of each file, splits the rest on `\|` | `import.php` | Implemented |
| Insert into `mapper_data` | Writes source columns plus lookup columns. `processed` is stored as `0` | `import.php` insert | Implemented |
| Litre parse | Comma becomes a decimal point. Dots are left in place. `floatval` converts the string | `import.php`, commit `b440d76` | Implemented |
| Return negation on import | When raw column 21 is `R`, litres are rounded to 0 decimals and multiplied by `-1` | `import.php` | Implemented. Meaning of `R` is inferred |
| Country enrichment on import | `country_group_lookup` by cleaned column 4. Copies English name, Afrikaans name, `BO`, `BU`, `BB` | `import.php` | Implemented |
| Product enrichment on import | `product_type_lookup` by column 39 with spaces removed. Copies report description, white/red, and type | `import.php` | Implemented. Afrikaans report description is not selected, so it is stored empty |
| String cleanup | Trim, `9:00 am` → `9A`, `3:00 am` → `3A`, strip quotes and a short punctuation set, backslash to space | `import.php` `cleanString` | Implemented |
| Per-file error dump | Appends failed insert errors and `var_dump`s them after each file. Does not stop the folder loop | `import.php` | Implemented |
| Long run limits | `memory_limit` `16G`. Import `max_execution_time` `12000`. Notices suppressed | `import.php` | Implemented |
| Unprocessed-row updater | Selects `mapper_data` where `processed = 0` in growing batches and sets `processed = 1` | `index.php` | Implemented. Unchanged since the 2023-10-25 dump |
| Older lookups on the updater | `country_groups` by `kde`, `produk_kodes` by `kd` (`prd_kde`) | `index.php` | Implemented |
| Second litre negation | Updater multiplies stored litres by `-1` when `rk` is `R`, without rounding | `index.php` | Implemented. Conflicts with the import if both run |
| Date parts on the updater | Rewrites `year`, `month`, and `datumtyd` from `datum` | `index.php` | Implemented |
| Test-folder probe | Dumps the first path under the Phase 1 test folder and exits | `math.php` | Implemented. Does not import |
| Column dictionary | 43 semicolon-separated titles | `header.csv` | Present. Not read by any script |
| Student-question pseudocode | Next question, lesson, and level | `bt_getquestion.pseudo` | Text only. Not implemented |

## Completed features

Git history does not mark a feature "done" in a tracker. The behaviours above are the snapshot at `b440d76`. The November commits replaced an earlier import, listed under recently changed and deprecated.

## In development

Nothing on `master` is marked in progress. `math.php` contains a `die` before the import attempt, which is a debug stop left in the committed file, not a named in-progress feature. Provenance: **Implemented**.

No branch other than `master` exists on the remote that was cloned.

## Recently changed

| Date | Commit | What changed in behaviour |
|---|---|---|
| 2023-11-01 | `90cccc9` | Import stopped resuming from `uploaded_file` and stopped logging each row there. It scans a folder. Lookups switched to `country_group_lookup` and `product_type_lookup`. Inserts targeted `imported_mapper_data`. Returns became `round` then negate. `math.php` gained the test-folder probe |
| 2023-11-18 | `b440d76` | Execution limit 3600 → 12000. Litre formula no longer strips `.`. Product lookup key moved from column 11 to column 39, and `TYPE` is selected. English and Afrikaans country fields are assigned separately. Insert target returned to `mapper_data` with that table's column names (`prod_kode`, `bottleweight`, `bottledescription`, `closuretype`, `foreignvalue`, `eurvalue`, `gbpvalue`, `usdvalue`, `classname`). A commented connection to `10.0.0.145` / `sawis_bi` was added. The password in that comment is not recorded in this file |

## Deprecated or removed

These behaviours are in Git history and are not what `import.php` does at `b440d76`.

| Behaviour | Where it last ran | Evidence |
|---|---|---|
| Resume from `uploaded_file.last_row` for the same filename | `import.php` before `90cccc9` | Diff of `90cccc9`. The same query remains only in unreachable lines of `math.php` |
| Insert a progress row into `uploaded_file` for every source line | `import.php` before `90cccc9` | Diff of `90cccc9` |
| Insert into `imported_mapper_data` using underscored column names (`prod_kde`, `bottle_weight`, `class_name`, …) | `import.php` at `90cccc9`, replaced in `b440d76` | Diff of `b440d76` |
| Product lookup on column 11 (`PRD_KDE`) without `TYPE` | `import.php` at `90cccc9` | Diff of `b440d76` |
| Litre formula that deletes `.` then converts `,` | `import.php` before `b440d76`. Still the formula in the unreachable block of `math.php` | Diff of `b440d76`, `math.php` |
| Negate returns without rounding | `import.php` before `90cccc9`. Still the rule in `index.php` | Dump-era import and current `index.php` |
| Country lookup on `country_groups` and product lookup on `produk_kodes` during import | `import.php` before `90cccc9` | Diff of `90cccc9`. `index.php` still uses those tables |
| Commented sample inserts into `mapper_data_20230416` | Removed from `import.php` in `90cccc9` | Diff of `90cccc9`. Sample rows are not reproduced here |

`index.php` was not deleted when the import was rewritten. It is still a current file. Calling it deprecated is **Inferred** from the fact that later commits edited `import.php` only. **Requires confirmation** before treating it as retired.

## Not in the repository

| Item | Evidence |
|---|---|
| Reporting screens, charts, or exports | No such files on `master` |
| Schema for the six table names used in SQL | No `.sql` file |
| Tests, Composer, Docker, CI config | No such files |
| `sonar-project.properties`, `sonarqube_scan.bat` | Named by the 2026-09-28 task-creation scan. Absent from `b440d76` |
| A scheduler that starts the PHP files | No cron or task-scheduler file |
| An implementation of `getQuestion` | Only `bt_getquestion.pseudo` |
