THE LABS GADGET CRM — MANDATORY QC ENFORCEMENT & QC QUEUE ALIGNMENT
Date: 19 Oct 2026

FEATURES
1) QC Job toolbar: 'Back to Repair' on the left, 'QC Queue' + repair status grouped at upper right; mobile stacking.
2) Server-enforced Intake QC: Start Repair, Complete Inspection (No Repair), and Reopen for Repair require a confirmed Intake stage and complete checklist.
3) Server-enforced Final QC: Confirm Device Collection requires approved Final QC, fully completed checklist, no failed or untested final tests, and at least one Pass.
4) Both QC steps show their actual state in the Repair Details Actions panel. Locked action links route staff to the relevant QC stage.
5) Completing repair still redirects to Final QC. Approving either Intake or Final QC now returns staff to Repair Details to continue their workflow.
6) Reopening a repair invalidates any previous Final QC approval (with QC audit). Reopening a cancelled registration invalidates previous Intake + Final QC approvals.
7) QC Queue shows Intake QC and Final QC columns, prioritising work awaiting confirmation.

IMPORTANT COMPATIBILITY
Built using the most recent Auto Intake/Final QC Redirect Repair Details page, which itself incorporated Premium Repair Details and the Owner Delete Repair function. The new package does NOT overwrite crm3.php, dashboard.php, app.php, crm-workflow.php, crm-qc.php, finance, POS, HR, inventory, or database schema.

INSTALL — AFTER A VERIFIED BACKUP
A) Download full CRM file backup and SQL backup via cPanel / phpMyAdmin, ideally keep backup outside public_html.
B) Make a separate copy of these LIVE files: repair-view.php, qc-job.php, qc-queue.php, assets/qc.css.
C) Verify your live repair-view.php still corresponds to the most recent Premium + Owner Delete + Auto QC Redirect version. If you or another developer modified any of the above files later, MERGE CHANGES rather than blindly overwriting.
D) Upload this ZIP to the CRM web root (where repair-view.php exists) and Extract. Replace only the 4 existing files named in B, add 2 new files named below.
E) Clear Mac browser cache: Cmd + Shift + R. Test using a separate staging copy / disposable test repair before trusting it for real customers.
F) No SQL upgrade, installer, or activation URL is required. Enforcement takes effect immediately upon Extract.

FILES IN THIS ZIP
- repair-view.php (REPLACE)
- qc-job.php (REPLACE)
- qc-queue.php (REPLACE)
- assets/qc.css (REPLACE)
- crm-qc-enforcement.php (NEW — private server-side QC gate helpers)
- assets/qc-enforcement.css (NEW)
- README_QC_ENFORCEMENT.txt

EXPECTED FLOW
Register Device -> Intake Inspection -> Save Checklist -> Confirm Intake -> Repair Details -> Start Inspection (if Pending) -> Start Repair -> Complete Repair -> Final QC -> Save Checklist -> Approve Final QC -> Repair Details -> Confirm Device Collection.

IMPORTANT NOTES
- Clock/timer logic, payments, stock movements, notification, warranty, and Owner Delete Repair are unchanged.
- 'Intake QC' may record failed checks with an explanation (documents pre-existing defects); the Final QC stage cannot be approved with any failures, any 'Not Tested', or fewer than one 'Pass'.
- For OLD jobs already in Repairing, the pre-existing repair can still be completed; new collection will require Final QC. Already Collected records are not retroactively modified.
- For OLD Completed jobs with no Intake QC, Reopen for Repair is intentionally blocked. Reconciliation of historical jobs needs Owner review; do not fabricate backdated Intake QC.
- Revising either QC checklist resets that stage to Draft; re-confirm or re-approve it to unlock its step again.
- The reset on reopening uses a DB transaction and adds an audit record; manual file rollback cannot restore a past approval automatically.
- This is tested by syntax and mocked logic, NOT an end-to-end run on the live hosting/production database. Test before operational use.

SAFE ROLLBACK
Restore the four files from B and remove crm-qc-enforcement.php and assets/qc-enforcement.css if they were new. No database rollback is needed. Note that QC audit changes caused by legitimate reopen actions cannot be rolled back with file replacement.
