Nation Statistics & Prize Money Report
1. Overview
This tool produces a two-page PDF report for a given show week, combining participation statistics by nation with a complete prize money breakdown. It is designed for FEI reporting, organiser summaries, and post-show accounting.
The report is generated server-side with HTML2PDF and downloads directly to the operator's machine — no intermediate preview step.
2. Report contents
Page 1 — Nations Statistics
For each competition selected from the master list, a table showing:
| Row | Meaning |
|---|---|
| Host Nation (XXX) | Unique riders and horses from the selected host country |
| Other Nations | Unique riders and horses from all remaining countries |
| Total | Combined totals across both rows |
Counts are unique: a rider entered twice in the same competition is counted once, and the same applies to horses. The host nation row is shaded so it reads at a glance.
Page 2 — Prize Money Distribution
One row per CSI competition of the selected week:
- Competition number (
clabb) - Competition name with the subtitle underneath
- Number of ranked entries
- Prize money in euros
Below the detail rows, subtotals are printed per CSI category, followed by a grand total.
Both pages carry the Equipe logo, the show ID, the selected week, and a footer with contact details.
3. Access and authentication
Launched from Equipe with a JWT token:
nation_statistics.php?token=<JWT>
- Signing algorithm: HS256
- Leeway: 60 seconds
- Payload fields used:
meeting_url,url,style_url, andapi_key
The show ID is extracted from the 5th segment of payload->url (index 4 after splitting on /) and printed in the report headers.
4. Data sources
| Endpoint | Purpose |
|---|---|
<meeting_url>/competitions.json |
Competition list, class names, FEI IDs |
<meeting_url>/economies.json |
Prize money totals, ranked quantities, fee types |
<meeting_url>/competitions/<id>/starts.json |
Entry lists for nation statistics |
Competitions and economies are matched on the clabb field. A competition is included in the prize money table only if:
clabbdoes not containDNCz == "H"(a real competition)klasscontainsCSI
5. Week detection
Weeks are derived from the FEI ID. The first 12 characters of feiid identify the show week, so competitions sharing that prefix are grouped together and offered as a single option in the week dropdown.
Example:
2026_CI_0799_S_S_02_05→ week key2026_CI_0799
Only weeks that actually have prize money data appear in the list.
6. Category detection
Prize money is aggregated into FEI categories. Category detection is deliberately tolerant, because class names are entered by hand and vary between organisers.
Recognised categories
CSI1 CSI2 CSI3 CSI4 CSI5 CSIO CSIYH CSIAm-A CSIAm-B CSIP CSIV CSIU25
Detection order
- Prefix stripping — if the name contains
-, everything before it is discarded (18 - CSIO5* Grand Prix→CSIO5* Grand Prix) - Normalisation — uppercased, whitespace and hyphens removed
- CSIO first — checked before numeric matching, since
CSIO5*would otherwise matchCSI5 - Star counting —
CSI***resolves toCSI3 - Numeric match —
CSI 3*,CSI3*,CSI-3all resolve toCSI3 - Named categories —
YH,Am-A,Am-B,U25,P,V, each tested against both the spaced and the compacted form
A class that matches nothing returns null and is excluded from the category subtotals and from the grand total. If a class you expect is missing from the totals, its name almost certainly does not match any pattern above.
7. Interface
Week / Show Selection
Dropdown listing every detected week. One report covers one week.
Competition Selection
Multi-select listing entries where z == "L", allow_many == false, and a FEI ID is present — these are the master lists used for nation statistics. Hold Ctrl (Cmd on macOS) to select several.
This selection drives page 1 only. Page 2 always covers the entire selected week.
Host Nation
Dropdown of IOC three-letter codes with full country names. Required. The selected nation is the one broken out separately on page 1.
Generate PDF Report
Submits the form and streams the PDF back as a download.
8. Output
Filename format:
<showid>-prize-distribution-<week>.pdf
Example:
12345-prize-distribution-2026_CI_0799.pdf
Page setup: A4 portrait, UTF-8, margins 5/5/5/8 mm.
9. Text sanitisation
Two helpers clean text before it reaches the PDF renderer:
removeEmojis()— strips emoji ranges (U+1F600–1F6FF,U+1F300–1F5FF,U+1F1E0–1F1FF,U+2600–26FF,U+2700–27BF). Applied to class names and subtitles, since HTML2PDF cannot render emoji glyphs and would otherwise output boxes or fail.cleanText()— normalises UTF-8 and removes control characters. Available as a secondary safeguard.
10. Troubleshooting
No weeks in the dropdown
No competition matched the inclusion filter. Check that classes contain CSI in the class name and that economies exist for them.
Prize money total lower than expected One or more class names failed category detection. Compare the class names in Equipe against the patterns in section 6 — a stray character or an unusual abbreviation is the usual cause.
Nation statistics page is empty
No master list was selected, or the selected lists returned no entries with rider_country, rider_name, and horse_name all present. Entries missing any of these three fields are skipped.
Blank or corrupted PDF
Usually stray output before the PDF stream. The script uses ob_start()/ob_end_clean() to suppress it, but a PHP warning emitted earlier can still break the file. Check the error log.
Host nation row shows zero
The IOC code selected does not match the rider_country values in the data. Equipe must be using the same three-letter codes.
12. Operational notes
- Page 1 reflects entries, not results — it counts who was entered in the selected lists, regardless of whether they competed.
- Page 2 reflects economies, which are only accurate once prize money has been finalised in Equipe. Running the report mid-show will show provisional figures.
- Selecting many master lists produces one statistics table per list, which can push page 1 across several pages. Table rows are set to avoid breaking mid-row.