THE LABS GADGET CRM — PHASE 7: WARRANTY & AFTER-SALES
=====================================================

THIS IS AN ADDITIVE PATCH FOR THE EXISTING PHASE 6.2 CRM INSTALLATION.
It does not include config.php, change existing passwords, or alter sales, inventory, repair status, invoices or job timer data.

NEW FILES:
- crm-warranty.php              Shared warranty/claim rules
- warranties.php                Warranty dashboard / customer search
- warranty-job.php              Issue warranty, register claims, decide status
- warranty-card.php             Print-friendly warranty certificate
- upgrade-fasa7.php             Owner-only one-time database setup (delete after setup)
- assets/warranty.css           Responsive dashboard styling
- assets/warranty-card.css      Printable certificate styling
- assets/warranty-print.js      Print button

EXISTING FILES UPDATED (BACK THESE UP FIRST):
- crm3.php                      Adds Warranty & Claims sidebar link
- repair-view.php               Adds Warranty & After-Sales shortcut to repair page

INSTALL STEPS
1) Back up the COMPLETE CRM folder and export the MariaDB database using phpMyAdmin -> Export.
2) Extract this ZIP into the ACTUAL Document Root of crm.thelabsgadget.com.
3) Only allow overwrite for: crm3.php and repair-view.php. These were based on the Phase 6.2 releases. If you customised either file since then, reconcile changes instead of blindly overwriting.
4) Open https://crm.thelabsgadget.com/upgrade-fasa7.php while logged in as Owner, then click Activate Phase 7 once.
5) When activation succeeds, immediately DELETE upgrade-fasa7.php from the hosting folder.
6) Open Warranty & Claims in the sidebar, locate an existing Collected repair, and issue a warranty for a legitimate eligible service.
7) Test a new claim (if appropriate), then have Owner/Manager review a status update and verify the audit log.
8) Open Print Warranty Card from the record, then Print / Save as PDF.

DATABASE TABLES CREATED (ADDITIVE, NO DESTRUCTIVE ALTERATIONS):
- repair_warranties
- warranty_claims
- warranty_claim_events

BUSINESS RULES
- Warranty is NEVER issued automatically. A Collected repair can have one warranty record, issued by Owner, Manager or Accounts/HR.
- Period choices: 7, 14, 30, 90, 180 or 365 DAYS. Start date is the collected date in Malaysia time; end date is inclusive.
- Only an ACTIVE warranty can receive a new claim; claims submitted during the valid period can still be reviewed later.
- Any active logged-in staff member may register a customer complaint. Owner/Manager control status changes: Open -> Inspecting -> Approved -> Resolved or Open/Inspecting -> Rejected.
- Unresolved claims prevent a new duplicate claim for the same warranty; submissions are protected with unique request tokens.
- Only Owner/Manager may void a warranty, only when it has no claims; void requires a reason and is retained in the database.
- Warranty claims and approvals do NOT automatically deduct parts, create payments/refunds, change repair status or start a timer. Continue using existing Repair Job, Inventory, and Payments modules for those actions.
- No WhatsApp/SMS notifications or public customer portal are included.
- The printed warranty card is for after-sales reference. It is not a tax invoice or payment receipt.

SECURITY & NOTES
- CSRF validation, server-side role checks and SQL parameter binding are used on all write actions.
- Source code and static syntax checks have been completed. Hosting-level database behaviour, actual permissions and customer-facing printing still need live testing by the Owner.
- Avoid registering sample warranty claims on a real customer repair: claim histories are auditable and cannot be silently deleted.
