THE LABS GADGET CRM — PHASE 12 / DEVICE INSPECTION & QUALITY CONTROL
========================================================================
English UI • Futuristic Dark Blue • Official The Labs Gadget Logo
PHP 8.1+ • MySQL/MariaDB • Adds tables, preserves existing CRM records

CONTENTS
- Intake Inspection before repair (Pending/Checking), with 16 function/condition checks.
- Final Quality Check after repair is Completed and before Collected.
- Status per item: Pass, Fail, Not Applicable, Not Tested, with notes for failures.
- Private evidence photos for each stage (max 3, up to 2 MiB each; JPEG/PNG/WebP).
- Frontdesk / Owner / Manager signoff after checks completed. Failed Final QC cannot be approved.
- Staff/time activity audit for checklist saves, signoff, uploads and deletions.
- QC Queue and direct links from Repair Job screen.
- Images served only by authenticated and authorised qc-photo.php; stored inside MariaDB.
- No public photo paths or directory under public_html.
- Only assigned staff, Owner or Manager can record Final QC; Frontdesk can record intake.
- Owner/Manager/Frontdesk can confirm QC after completing and reviewing the checklist.

ACCESS & RESPONSIBILITY
- Owner / Manager / Accounts/HR / Frontdesk: may view QC records for all jobs.
- Assigned staff: can view and record their assigned repair job. Registering staff may view.
- Pending/Checking: intake may be edited by Owner, Manager, Frontdesk or assigned staff.
- Completed: final QC may be edited by Owner, Manager or assigned staff.
- QC confirmation: Owner, Manager or Frontdesk; cannot approve with untested tests.
- Frontdesk and staff cannot simply change QC records for completed/collected jobs.
- Staff Permissions > Repair Jobs applies to QC pages as well.
- Existing Repairs, POS, Inventory, WhatsApp and Warranty access stays unchanged.

SAFE DEPLOYMENT
1. POS Phase 11 is installed but not yet live-tested: do NOT treat POS as production-ready.
2. Backup entire CRM folder outside public_html and export SQL via phpMyAdmin.
3. The ZIP replaces ONLY crm3.php and repair-view.php. Verify their SHA/contents if manually changed.
4. Upload this ZIP to actual Document Root alongside login.php, crm3.php and repair-view.php.
5. Extract the ZIP into the SAME folder; overwrite the two existing files only.
6. Confirm new files qc-job.php, qc-queue.php, qc-photo.php, crm-qc.php,
   upgrade-fasa12.php, assets/qc.css appear next to the originals.
7. Login as Owner and open https://crm.thelabsgadget.com/upgrade-fasa12.php
8. Click Activate Phase 12 ONCE. It creates four additive QC tables.
9. After success DELETE upgrade-fasa12.php from cPanel File Manager.
10. Open a TEST repair job, use Device Inspection & QC, save and confirm intake.
11. On a TEST job Completed but NOT Collected, save all final tests and approve.
12. Confirm staff access rules and that private qc-photo.php rejects unauthorised accounts.
13. Test photo upload from mobile with JPEG/PNG/WebP under 2MB (phone HEIC not supported).

ROLL-OUT LIMITATION IMPORTANT
- This patch is QC ADVISORY: the Complete Repair and Confirm Device Collection
  buttons stay unchanged, so there is no chance of blocking live jobs by accident.
- The mandatory QC-before-collection server gate can be enabled in a later, TESTED
  patch if requested. This package DOES NOT claim to enforce it.
- Tests are completed by staff; the software cannot automatically evaluate hardware.
- The system uses a finite fixed inspection checklist, not customizable in Settings yet.
- Photos use MariaDB MEDIUMBLOB and INCREASE database backup size; observe hosting quotas.
- JPEG/PNG/WebP only; <=2 MiB per image, <=3 images per stage, <=12 MP.
- When PHP GD is available uploaded photos are reencoded to JPEG to remove EXIF.
  Without GD the original image is stored privately; avoid including sensitive metadata.
- This package does not take photos without staff selecting/capturing them.
- QC approvals do not alter invoice totals, payment status or warranty periods.
- Do not upload SQL backups or customer's photos to public_html.

TABLES (additive)
repair_qc_inspections, repair_qc_results, repair_qc_photos, repair_qc_audit

ROLLBACK
- Restore original crm3.php and repair-view.php from before Fasa 12.
- Remove new qc pages if rolling back completely; don't delete newly added QC
  database tables if staff have begun recording real inspections.
- Backups cannot restore later live repairs or payments without careful reconciliation.

LOCAL VALIDATION
- PHP static syntax check, ZIP test and exact file-name checks.
- Live hosting database/schema permissions, phone camera upload and workflow
  compatibility have NOT yet been verified. Test before production rollout.
