THE LABS GADGET CRM — PHASE 8A+ (COMBINED RELEASE)
WhatsApp Notifications + 3-Day Follow-Ups + Save Customer Contacts
==================================================================

THIS ZIP REPLACES THE PREVIOUS PHASE 8A NOTIFICATION ZIP.
It works whether you have installed the old Phase 8A ZIP or not.
It requires Phase 7 CRM with the workflow / repair tables already active.

FEATURES
1. Existing Phase 8A WhatsApp status notifications (messages in Bahasa Melayu).
2. After-Sales Follow-Ups: records are due when a device has been Collected
   for 72 hours. The queue appears in the "3-Day Follow-Ups" sidebar menu.
3. Staff manually open WhatsApp, review and SEND the prepared follow-up
   message. WhatsApp API is NOT used. No automatic message sending takes place.
4. After sending, staff can click "Mark Followed Up" to keep the record
   out of the due queue. It is an internal staff acknowledgment, NOT a
   WhatsApp sent / delivery / read confirmation.
5. "Save Customer Contact (.vcf)" on Repair Job and Notification Preview
   downloads a VCF file (iPhone/Android can import it to phone Contacts).
   A browser website cannot save directly to iOS/Android Contacts without
   the user accepting the contact import.

CUSTOMER CONTACT NAME PATTERN
TLG-DDMM-YY-NN, e.g.:
  TLG-1310-26-01 = first DISTINCT customer registered for repair on 13 Oct 2026
  TLG-1310-26-02 = second distinct customer that local day
The registration date is taken from repair_jobs.created_at converted from
UTC to Malaysia time. It is NOT the warranty / completion / collection date.
If the same customer registers two phones on the same day, they get the
same contact label. Returning on another day produces that day's label.
Existing customer names and phone numbers stored in CRM are NOT renamed.
Only the exported phone Contact has the TLG-... label.
No new table is needed for contact codes: they are calculated from existing
repair registrations. Existing registrations should not be manually backdated
or imported out of chronology if labels have already been saved to Contacts.

UPGRADE / INSTALLATION
1. Back up your CRM directory and database using phpMyAdmin -> Export -> SQL.
2. Back up crm3.php, repair-view.php, warranty-job.php specifically.
3. Upload this ZIP into the actual Document Root of crm.thelabsgadget.com
   in cPanel File Manager, and EXTRACT there.
4. Replace the three existing PHP files above with the included versions.
   If any of these files were customised since Phase 7/8A, compare before
   replacing; this ZIP is based on the known Phase 8A versions.
5. All other included files are additions or upgrades to Phase 8A.
6. Sign in as Owner and visit:
   https://crm.thelabsgadget.com/upgrade-fasa8b.php
7. Press "Activate Phase 8B" ONCE to create the one new table
   crm_customer_followups. This does not erase existing repair records.
8. DELETE upgrade-fasa8b.php from File Manager once successful.
9. Open https://crm.thelabsgadget.com/followups.php
10. Test Save Customer Contact from one Repair Job and import the .vcf.

DATABASE CHANGES
One additive table crm_customer_followups:
 - repair_id primary key
 - followed_up_by staff user id
 - followed_up_at UTC
No changes to customer records, sales, repair statuses, inventory or payments.

WHATSAPP / PRIVACY
- Staff must check the recipient and confirm the message is appropriate.
- Standard WhatsApp deeplink opens a prepared message; SEND is manual.
- Do not mistake "Marked Followed Up" for actual WhatsApp delivery.
- Honor customer consent or objections to after-sales messages.
- Phone numbers are only accessible to logged-in staff who are allowed
  to handle that repair: Owner, Manager, Accounts/HR, Frontdesk or assigned staff.
- Never place your CRM backup SQL or config.php in a public directory.

TEST CHECKLIST
[ ] Normal WhatsApp notifications remain functional.
[ ] A job NOT yet collected doesn't appear as follow-up due.
[ ] A Collected job under 72 hours doesn't appear as follow-up due.
[ ] A Collected job >=72 hours appears as due.
[ ] Opening Follow-Up yields Bahasa Melayu message & correct customer number.
[ ] Clicking WhatsApp doesn't automatically send a message.
[ ] Mark Followed Up removes it from Due and shows it under Completed.
[ ] Save Customer Contact creates a .vcf named TLG-DDMM-YY-NN.
[ ] Daily first and second customers get 01 and 02.
[ ] Staff access to unassigned jobs is forbidden.
[ ] Payments, repair workflow, warranty and inventory still work.

ROLLBACK
- Replace crm3.php, repair-view.php, warranty-job.php from your backups.
- Remove the added Phase 8B PHP files and links. Leave the new follow-up
  database table in place unless you deliberately plan a separate rollback
  with an appropriate database backup. Do NOT delete the table blindly.
- If Phase 8A was installed already, retain its files as required by its
  original package or restore your full CRM backup.

VALIDATION
PHP syntax lint on all included PHP, JS syntax check and local helper tests
for Malaysia dates, daily contact labels and 72-hour due cutoff.
Live cPanel database and WhatsApp / Contacts import must be tested on device.
