PORTMAN PAYMENTS - SAFE TEST COPY (nothing touches the live system)
=====================================================================
Idea: a full COPY of the website and database at test.portmanltd.com.
Staff test there with copied data. The live site, live database, live
money and live WhatsApp are never touched. When you are happy, the same
files go to the live site (go-live package).

THREE SAFETY LOCKS on the copy
  1. Its own database (a copy). Nothing done there reaches the live data.
  2. WhatsApp switched off: the key is removed from every file of the copy,
     and the message code itself only writes to a log in test mode.
  3. Every phone number in the copy is replaced with your test number,
     so even a message from a page we have not seen can only reach you.
  Plus: a password on the whole test site, and a red "TEST SYSTEM" bar.

STEPS (cPanel, about 30 minutes)
---------------------------------
A. Subdomain
   cPanel > Domains (or Subdomains) > create  test.portmanltd.com
   Folder: public_html/test   (or whatever cPanel proposes)

B. Copy the files
   cPanel > File Manager > public_html > select everything EXCEPT the new
   "test" folder > Compress (zip) > then Extract that zip inside the "test" folder.
   (You can skip big upload folders such as uploads/ to save time.)

C. Copy the database
   1. phpMyAdmin > select the live database > Export > Quick > SQL > Go (save the file).
   2. cPanel > MySQL Databases > create a NEW database, e.g.  fajoagkg_portman_test
      and a NEW user with a new password; add the user to it with ALL PRIVILEGES.
   3. phpMyAdmin > select the NEW database > Import > the file from step 1.
      CHECK the left side of phpMyAdmin: you must be on the _test database.

D. Point the copy at the copy
   Open  test/includes/db_connect.php  (the one INSIDE the test folder):
   1. change the database name, user and password to the NEW ones from C.2
   2. at the very top (line 2, after <?php) add the line from
      db_connect_TEST_ADD_AT_TOP.php :
         if (!defined('PORTMAN_TEST_MODE')) define('PORTMAN_TEST_MODE', true);
   NEVER change the live  public_html/includes/db_connect.php  in this step.

E. Lock WhatsApp and phones in the copy
   1. phpMyAdmin > the _test database > SQL > paste test_setup.sql
      (change the phone number on the first line to your test phone) > Go.
   2. Upload  disable_whatsapp_in_test.php  into the test folder, open
         https://test.portmanltd.com/disable_whatsapp_in_test.php
      It refuses to run anywhere except the test copy. Then DELETE it.

F. Password on the test site
   cPanel > Directory Privacy > the test folder > "Password protect" > add a user.
   Only the testers get it.

G. Do NOT copy the cron jobs (GPS updater etc.) - the test copy does not need them.

H. Put the new system on the copy
   Upload everything inside 2_FILES_TO_UPLOAD into the TEST folder (same folders:
   root files to test/, includes/ files to test/includes/) and follow its
   READ_ME_FIRST.txt, running the SQL files on the _test database only.
   No cron on the copy: the fixed cost check runs by itself every 15 minutes
   whenever someone opens Payments or Reports.

I. Test (with real people, on the copy)
   - A requester raises a payment (old Vouchers page / Records "Request Payment").
   - Level 1, Level 2 (and Level 3) approve in https://test.portmanltd.com/payments.php
     Try: requester approving his own; same person on two levels; an admin who is
     not an approver. All three must be refused.
   - Busy Ref person adds a Busy Ref; try a duplicate (must be refused).
   - The agent confirms paid; check the agent balance on the Agent page.
   - Find a payment: check the full record, the change log, and "Guest" never appears.
   - Old WhatsApp link: open any old approve link with "test." in front - it must
     say "This link is no longer used".
   - Check the WhatsApp log: test/logs/whatsapp_messages_<date>.log shows each
     message as TEST-NOT-SENT, so you can read what WOULD have been sent.

I2. Test the fixed cost + trip budget (21 Oct)
   - Trip budget > Rules: type driver allowance / loading / offloading, tick ON, tick a
     budget approver (NOT the usual final approver). Prices: enter this month's fuel price.
   - Lots > Fixed Payment > a lot with a BOOKED import truck: press READY TO GO TO LOAD.
     Check: the truck shows "READY TO LOAD - requested by <you>", L1 APPROVE appears.
     Try L1 APPROVE with the same person who pressed READY: must be refused.
     Another Accounts person does L1, Shilpa does L2.
   - Lot button "READY TO GO TO LOAD (all import trucks)": starts every truck not started yet.
   - Enter a loading date on an export truck (offloaded import before): within 15 minutes
     (open Payments) its export fixed cost shows AUTO, waiting Level 1.
   - Fixed Destinations: change a price with today's date + reason, and another with a
     future date. Trucks already started keep their old amount; new ones take the new one.
     Price history shows both; the future one waits with its date.
   - Raise a voucher on a trip that is already fully paid (extra payment): the final
     approval must be REFUSED with "OVER BUDGET". The budget approver allows it in
     Payments > Over budget with a reason; then the approver finishes it. The budget
     approver must NOT be able to approve a level of the same voucher.
   - A breakdown voucher on the same trip must NOT be stopped by the budget.
   - Trip budget > Trips: check the fuel liters (issued / ration) of a truck against the
     fuel page, and the Budget plan per mine.
   - WhatsApp log (test/logs/...): one "FIXED COST" summary per run, NO link in it.

J. When everything is right
   Do the go-live package on the LIVE site (with a backup first).
   Afterwards you can keep the test copy for future changes, or delete the
   test folder and the _test database.
