SHYNAZ V7 - CONSISTENT A4 INVOICES AND SALON WHATSAPP SENDERS
Owner: Jitesh

UPLOAD / ACTIVATE
1. Back up the live website files and export the live database.
2. Extract this ZIP into the existing website root and overwrite matching files.
   Upload ALL included folders, especially app and assets; do not upload only index.php.
3. Keep your existing config.php, uploads and storage/documents. Do not delete
   the existing website first. Your production config/private documents are excluded.
4. Sign in as Supreme Admin and click APPLY V7 UPDATE.
5. Refresh with Ctrl+F5 and reopen the installed app. No manual SQL import is needed.

WHAT CHANGED
- One A4 layout model produces the screen invoice, browser print and PDF download.
- Logo, embedded brand fonts, service table, discount/tax totals, advance/deposit,
  payments and outstanding balance use the same coordinates in all three views.
- Printable pages have built-in margins, page numbers and repeated document headers.
- Service table headings repeat on continuation pages. Normal service rows stay
  together; unusually tall rows can continue on another page without losing text.
- Payment records and notes continue on further pages when necessary.
- Flash messages, menus, buttons and admin forms are excluded from invoice printing.
- The PDF share button prepares its file before a click, avoiding the lost user
  gesture error shown in your screenshot. Unsupported browsers download the PDF
  so you can attach it in WhatsApp.
- WhatsApp text messages use headings, line breaks, numbered services and clear
  total, advance, received and balance lines, plus the document link.
- Each salon has its own WhatsApp sender number and API settings.
- Exact PDF snapshots are saved when invoices are prepared, confirmed, paid or edited.
  Admin can open Saved invoice PDF copies or the exact PDF linked to a dispatch.
- Website/dashboard styles are delivered inline. JavaScript, logos and fonts can
  be delivered through root asset.php, avoiding public asset-folder request issues.

PRINT / DOWNLOAD / SHARE
Open an invoice and choose Download branded PDF.
Print A4 / open PDF opens that same PDF in the browser: use its printer button.
This is the preferred route for the most predictable physical output.
Print this layout prints the on-screen A4 pages. Select A4 portrait, 100% scale,
no extra margins and turn off browser headers/footers. The document already
contains approximately 12.7 mm internal margins and its own page numbers.
Printer non-printable areas and driver settings can still affect physical output.
Share invoice PDF uses the device's share sheet where supported. Choose WhatsApp.
On desktop, if file sharing is unsupported, download and attach the PDF manually.
Prepare formatted WhatsApp message opens readable text with the PDF link.
A WhatsApp click-to-chat URL cannot attach a PDF automatically or force which
logged-in WhatsApp account sends a manual message.

WHATSAPP NUMBERS
Nakodar: +91 9559558557
Dasuya:  +91 7889245500
These numbers are saved by the V7 update as the corresponding salon sender/contact.
For new salons, set Salon WhatsApp sender number in Branch settings. Then configure
that salon in Website & messages > WhatsApp delivery.

AUTOMATIC DELIVERY - REQUIRED EXTERNAL SETUP
A phone number alone cannot send automated WhatsApp messages. Register each number
with Meta WhatsApp Cloud API (or the approved provider you use) first.
For EACH salon, enter its own:
- Registered Meta phone-number ID (not the visible phone number).
- Access token; it is encrypted when saved.
- Current Graph API version.
- Approved utility template name and matching language code.
The template must have a DOCUMENT header and exactly three positional body values:
client name, invoice number and total.
Example body: Hello {{1}}, your SHYNAZ document {{2}} for {{3}} is attached.
Confirm that the Meta sender ID belongs to the salon number and enable automatic
sending for that salon. Each branch is separate; V6 global credentials are not
silently copied to both senders, as this could use the wrong number.
The public HTTPS PDF URL must be reachable by Meta. The exact archived PDF version
is used in the message. Booking, confirmation and payment triggers remain in place.
Invoice creation messages respect the booking WhatsApp option; reception-created
invoices are prepared for WhatsApp using the client's saved phone number.

MESSAGE RECORD
Admin > WhatsApp delivery lists invoice, salon, configured sender, result, timestamp
and saved PDF. The invoice also shows the latest attempt and has a retry action.
Manual required: automation is not enabled/configured; use manual PDF sharing.
Accepted: Meta accepted the request, not independently confirmed phone delivery.
Failed: configuration, network or provider error; review before retrying.
This version does not receive Meta delivery/read webhooks. Before retrying a timeout,
check provider status to avoid sending a repeated message.
No messages were sent while developing/testing this package; your live Meta
credentials and approved templates are not available in this conversation.
Official setup:
https://developers.facebook.com/documentation/business-messaging/whatsapp/business-phone-numbers/registration
https://developers.facebook.com/documentation/business-messaging/whatsapp/get-started

PDF ARCHIVE
Private snapshots are stored under storage/documents and registered in the database.
Keep database, config.php (encryption key) and private storage backed up together.
The supplied .htaccess files protect storage, app and database on compatible Apache
hosting. Nginx must have equivalent deny rules. Snapshot links use the invoice's
private token; share them only with the client or authorised staff.
Changing an invoice does not overwrite its earlier saved PDF. A repeated identical
version reuses the existing saved copy. Download links without a version show the
current invoice; archived links show the saved copy.
The PDF and SVG use the same embedded Latin brand fonts. Unsupported writing systems
are transliterated where possible; full complex-script typesetting is not included.

EXISTING V6 FUNCTIONS
Service booking does not require an artist. Reception can record an advance, assign
one or more performing artists per service and then receive the final balance.
Client IDs, service catalogue, courses, admission, quiz, salary, expense, inventory,
attendance restrictions and assigned staff permissions remain in place.
Do not re-import an old database backup over live records.

VALIDATION
New runtime checks cover A4 output, single/two/many pages, archives, per-salon sender
routing, encrypted tokens, malformed asset requests and missing static CSS fallback.
The V6 and earlier regression checks also pass. Generated PDFs were rendered and
reviewed. Live Meta/SMTP delivery, browser-native print dialogs and physical printer
output still require testing on your hosting/devices. This ZIP does not deploy itself.
