FINAL INSTALLATION

Upload all files into public_html/apply:
- index.php
- submit.php
- functions.php
- config.php
- counter.txt
- applications.csv
- .htaccess
- uploads folder

No MySQL/database needed.

IMPORTANT:
1. Rename old index.html to old-index.html.
2. Link: https://strydomfuneralhome.co.za/apply/
3. Applications are stored in applications.csv.
4. Documents/signatures are stored in uploads.
5. Policy number is generated only when Submit is clicked.
6. Pay@ number is generated after submit: 1160299000 + policy number without LA.

WHATSAPP:
Open config.php and set:
define('WHATSAPP_ENABLED', true);
define('WHATSAPP_INSTANCE_ID', 'your_instance');
define('WHATSAPP_TOKEN', 'your_token');
define('ADMIN_WHATSAPP_NUMBER', '27795160145');

The client receives the welcome message after successful submit.
Admin can also receive a WhatsApp notification.

UPDATE:
- WhatsApp number field added.
- Checkbox duplicates cellphone number to WhatsApp number.
- Full application summary is sent to client by WhatsApp after submit when WhatsApp API is enabled in config.php.

MANUAL WHATSAPP UPDATE:
- No WhatsApp API is needed.
- After successful submit, the page shows buttons:
  1. Stuur aansoek oor WhatsApp
  2. Nuwe aansoek
  3. Print PDF
  4. Close
- WhatsApp opens with the full application message already filled in.

UPDATE:
- Signature date is automatically set to today's application date in DD/MM/YYYY.
- Print PDF prints the full application, not only the confirmation screen.

UPDATE:
- Test warning removed.
- Email button added after submit to send application summary to client via mailto.


FINAL UPDATE ADDED TO YOUR CURRENT ZIP:
1. Transfer Policy / Waiver of Waiting Periods section added.
2. Duplicate ID check added using existing_members.csv.
3. CSV format supports your Visual Cash export:
   identity_nr = ID number
   policy_nr = policy number
   name + surname = client name
   tel = contact number
4. Recall Previous Application added.
5. Online applications are saved as JSON in data/ folder for recall.

UPLOAD YOUR EXISTING MEMBERS CSV:
- Save Visual Cash export as CSV UTF-8.
- Rename to existing_members.csv.
- Upload/replace it in public_html/apply/.
- Keep first row headings exactly as exported.

PERMISSIONS:
- counter.txt: 664
- applications.csv: 664
- existing_members.csv: 664
- uploads folder: 755
- data folder: 755


FINAL CHANGE:
- Duplicate ID check now checks every ID field on the whole application, including dependants and extended family.
- It also checks that the same ID is not repeated on the same new application.
- Banking proof upload removed because debit orders are not handled.
- Waiver waiting period final column calculates automatically:
  Natural: 6 months minus served months
  Accidental: 0 months
  Suicide: 12 months minus served months


CASH COVER VERIFICATION FINAL:
- Cash Cover fields appear only when Product Plan = Cash Cover.
- Only existing funeral policy number and Cash Cover amount are required.
- The existing policy number is verified against existing_members.csv using policy_nr.
- If policy number is not found, Cash Cover application cannot be submitted.
- Extended family Cash Cover premium is calculated per member based on ID age.


CASH COVER EXTENDED FAMILY FIX:
- Extended family premium is now calculated only when the extended member has a complete 13 digit ID number.
- Blank extended family rows are ignored.
- This prevents incorrect totals such as 10 blank rows being calculated.
