MDR Report Summary
Report code: mdr_report_summary, labelled "MDR Report Sumary" in the menu (a seed typo). Opens the documents_master print mode with type=mdr_report_summary; the handler is documents_mater_handler_print_mdr_report_summary.php (note mater in the file name), 1,011 lines, fully on $pdo. One row per discipline with counts: how many MDR documents exist, how many have been issued under each status, how many are still under review, and how many carry each return code. Where the MDR Report sums weighted progress, this one counts documents.
How this page was verified
Traced in master on 2026-09-06 and compared with the big five and KTP. Screenshots from inact-ktp.eris.place on the KTP production snapshot, project SNS. KTP's copy differs by 311 lines; see the instance differences.
The filter form

Project, an Actual Date window (actual_date_from, actual_date_to, d/m/Y), and Preview or Excel (mdr_report_summary_download_as). No field filters. Unlike the MDR Report, the date window here filters the library rows that are counted: it becomes d.doc_send_received BETWEEN ... (or >= / <= when one side is empty) in both document queries. The title line "Actual Date from ... to ..." shows the window, or the earliest and latest doc_send_received of the project when the window is empty.
The four queries
- Reference lists: disciplines (
ts_docdiscipline, keyed bydocdisc_id), return codes (ts_doc_resultcode, ordered bydoc_res_sort), issued statuses (ts_issued_statusordered byts_progress_gate.sequence, keyed byissued_id). - The MDR: every
ts_documents_masterrow of the project, joined to its discipline bydm_discipline_identifier = docdisc_code, and grouped bydocdisc_id. A document whose discipline code is not in the discipline list is not in any group, so it is counted nowhere except in QTY (QTY matches on the code, not on the join). - Issued rows:
ts_documentsof the project joined tots_issued_statusonissued_code, for the issued statuses in use, inside the date window. Stored by document number andissued_id._R(return) and_C(comment) revisions are not excluded here, unlike in the MDR Report. - The latest library row per document:
ts_map_documents_libraryjoined tots_documents, inside the date window, one row perdoc_number. On MySQL that is aGROUP BY doc_numberover a subquery ordered bydoc_send_received DESC, doc_rev DESC, which relies on MySQL returning the first row of each group; on SQL Server and PostgreSQL it isROW_NUMBER() OVER (PARTITION BY doc_number ORDER BY doc_due_date DESC, doc_send_received DESC, doc_rev DESC). The two orderings differ: SQL Server and PostgreSQL pick the latest due date first, MySQL the latest received date.
No routing table is read. This report does not care whether a revision was routed.
The columns

One row per discipline of the project, in whatever order ts_docdiscipline returns them (the query has no ORDER BY), then a Total row and a Percentage row. The columns come in two halves that use two different definitions of a document's state, which is the thing to keep in mind when the halves disagree: Latest Issuance looks at every library row of the document inside the window, Status looks at one row, the latest.
QTY and the discipline rows

| Column | Value |
|---|---|
| Discipline | docdisc_code - docdisc_name, one row per discipline row of the project, even when it has no documents |
| QTY | MDR rows whose dm_discipline_identifier equals the discipline code. Counted from the flat MDR list, so a document whose code matches no discipline row is in nobody's QTY and in no other column either |
The Latest Issuance half
| Column | Value |
|---|---|
| one column per issued status, in gate order | the number of the discipline's documents that have at least one library row with that issued status inside the window (query 3). The name is misleading: this is not the latest issue. A document that went IFR, then IFA, then AFC counts once in each of the three columns |
| Not Yet Submitted | the discipline's documents with no library row under any issued status inside the window |
Two things follow. The columns are not a funnel, so IFA can be larger than IFR when documents enter at IFA. And the _R and _C revisions are counted like any other row, which changes nothing while the return twin carries the same status as its original, but does let a document whose original revision sits before the window start count through its return row inside the window.
The Status half
| Column | Value |
|---|---|
| Under Review | the discipline's documents whose latest library row (query 4) has an empty doc_appdate, the approver's sign-off date |
one column per return code, in doc_res_sort order | documents whose latest row has a doc_appdate and that doc_res_id |
A document is counted once at most, and can be counted nowhere: a latest row with a sign-off date but a result code that is not in the project's list falls through, and a document with no library row inside the window has no latest row at all. So Under Review plus the return-code columns do not add up to QTY, and the gap is not the same set as Not Yet Submitted.
The latest row is usually the _R return twin, because its doc_send_received is the return date. The twin carries the same result code and sign-off date as its original, so the count is the same; it only matters for the window, as noted above.
Total and Percentage rows

| Row | Value |
|---|---|
| Total | the column sums over all disciplines |
| Percentage | each total divided by the QTY total, as a whole percent in HTML and as a 0.00% cell in Excel. QTY itself always reads 100%. The Latest Issuance percentages can add up to far more than 100, the Status ones to less |
Worked example, one Civil document on KTP
SNS-C-CC-10-002 (discipline C - Civil) has ten library rows: revisions A (IFR), B and B1 (IFA), 0 and 0R (AFC), each with its _R return twin, all inside the window of the screenshot (2024-03-06 to 2026-02-04).
| Half | What the handler looks at | Where the document is counted |
|---|---|---|
| Latest Issuance | all ten rows: IFR, IFA and AFC each appear at least once; ASB and FI never | IFR 1, IFA 1, AFC 1, ASB 0, FI 0, Not Yet Submitted 0 |
| Status | the latest row only: 0R_R, received 2025-02-05, doc_appdate 2025-02-05, doc_res_id 1 (AP, APPROVED) | APPROVED 1; nothing in Under Review or the other codes |
Add up the 73 Civil documents the same way and you get the row below.
The Civil row on KTP
Project SNS on the snapshot, window 2024-03-06 to 2026-02-04, QTY 805. The C - Civil row reads:
| QTY | IFR | IFA | AFC | ASB | FI | Not Yet Submitted | Under Review | AP | AC | NA | RC | FI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 73 | 51 | 64 | 47 | 2 | 0 | 6 | 5 | 14 + 43 + 2 | 4 | 5 | 0 | 0 |
- IFA (64) is higher than IFR (51): documents can enter at IFA, and a document counts in every status it has rows for.
- The Status half adds up to QTY here: 5 + 59 + 4 + 5 = 73, so every Civil document has a library row in the window. The 6 "Not Yet Submitted" are therefore documents whose rows carry an issued status outside the list, or none at all. The two halves use different definitions and only reconcile by accident.
- At project level they do not: the Status columns sum to 764 of 805. The other 41 documents have no library row in the window and sit inside the 100 "Not Yet Submitted".
- The APPROVED column is split three ways (14 / 43 / 2) because KTP groups each return code by the issued status of the latest row: IFR/IFA, AFC/FI, ASB. Master prints one column per return code.
The total row is 805 / 577 / 582 / 553 / 18 / 92 / 100 / 64 / 505 (21 + 505 + 2 in KTP's split) / 38 / 54 / 79 / 1, and the percentage row divides each by 805.
Known issues
- Division by zero when the project has no MDR rows: the percentage row divides by QTY.
- MySQL relies on non-standard
GROUP BYin query 4. Whether it picks the intended row depends on the server'ssql_mode; this handler does not set it, the Routing Overdue one does. - Different "latest row" on different drivers, see query 4: SQL Server and PostgreSQL sort by due date first, MySQL by received date.
- Return and comment revisions count as issuances in the Latest Issuance columns, because query 3 does not exclude
_Rand_Crevisions. - A document can vanish from the Status half: a latest row whose result code is not in the project's list, or a document with no row inside the window, is counted nowhere, so the Status columns and QTY disagree without any visible reason.
- "Latest Issuance" is a misnomer. The columns count every status a document ever had rows under, not its latest one.
- A project with no MDR rows skips query 3 (
ist.issued_id in (%s)would be empty), so every issuance column prints 0 and Not Yet Submitted equals QTY, which is also 0.
Instance differences
Checked on 2026-09-06 by diffing the handler.
| Instance | Difference |
|---|---|
| KTP (311 lines) | Adds $approved_by_issued_codes groups (IFR, IFA; AFC, FI; ASB) and a third header row that splits every return-code column by those groups. MySQL-only queries (the driver branch is absent). A timer around the run. |
| Timas (181 lines) | An older layout of the same counts; MySQL only. |
| Prima Energy (181 lines) | The version before query 3 was rewritten: one issuance query per document and per status (sprintf with the document number and issued_id inside the loops), so the run time grows with MDR rows times statuses. Checked by diff on 2026-09-08, not traced. |
| Medco (98 lines) | SQL Server specifics in the two document queries. |
| Jadestone (8 lines) | Cosmetic; identical logic. |
| JOTRE | Identical to master. |
Related
- MDR Report: the weighted version.
- DMS reports.
- DMS settings: where disciplines, issued statuses and return codes are maintained.