=== Lenca Booking ===
Contributors: getlenca
Tags: booking, appointments, scheduling, crm, estimates
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 8.1
Stable tag: 0.1.17
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Scheduling, client CRM, estimates, invoices, and reminders for service businesses.

== Description ==

Lenca Booking helps service businesses manage appointment requests, clients, staff, calendar availability, estimates, invoices, and reminders inside WordPress.

The plugin includes an administrator dashboard and a public booking form shortcode:

`[lenca_booking_form]`

Core features:

* Client database with contact details, address fields, notes, stain or service notes, and preferred contact method.
* Staff records and staff assignment for appointments.
* Appointment management with pending, confirmed, completed, and cancelled statuses.
* Calendar view with arrival windows, day blocking, and time-window blocking.
* Public booking form that uses administrator-created service types and arrival windows.
* Admin email notification and optional customer confirmation email when a request is submitted.
* Estimate and invoice builder with client links, service line items, notes, terms, document status, and service photos.
* Document email sending and optional SMS/webhook delivery for client links.
* Reminder email tools and webhook/filter support for SMS reminders.
* Business reports for revenue, appointments, clients, estimates, and invoices.
* Client CSV import with flexible headers and phone number normalization.
* Marketing campaign builder with preview, test email, full audience sending, SMS copy, and audience CSV export.
* Mobile and desktop app API bootstrap data for appointments, clients, staff, reports, documents, and marketing counts.
* Private app API key for connecting approved Lenca phone and desktop apps to the business WordPress site.
* Branded Lenca dashboard introduction and setup guide.

Lenca Booking stores data in custom WordPress database tables and limits management screens to administrator-level users with the `manage_options` capability.

== Installation ==

1. Upload the `lenca-booking` folder to `/wp-content/plugins/`, or install the ZIP through **Plugins > Add New Plugin > Upload Plugin**.
2. Activate **Lenca Booking**.
3. Open **Lenca Booking** and follow the dashboard setup guide.
4. Open **Lenca Booking > Settings** to configure service types, arrival windows, email sender details, booking form text, SMS consent text, document settings, starting document numbers, and optional webhooks.
5. Add `[lenca_booking_form]` to the page where visitors should request appointments.
6. For phone or desktop app sync, open **Lenca Booking > Settings > Mobile App Connection**, copy the Website URL and Mobile App API Key, then paste them into the Lenca app connection screen.

== Frequently Asked Questions ==

= Does this plugin require a paid Lenca account? =

No. This first public plugin build works inside WordPress without a separate hosted account.

= How do the phone app and desktop app connect? =

The plugin stores a private Mobile App API Key in **Lenca Booking > Settings > Mobile App Connection**. Enter the business website URL and that API key inside the Lenca phone or desktop app. Keep the key private because it can read and manage CRM records through the app API.

= Whose Mobile App API Key is shown in settings? =

Each WordPress site receives its own private Mobile App API Key. The key shown in **Lenca Booking > Settings > Mobile App Connection** belongs only to that business website. It is not a shared Lenca key, and it is not connected to another business account.

= Does Lenca Booking include any prefilled SMS or webhook account? =

No. Public installs do not include a shared Twilio, Telnyx, Make, Zapier, or Lenca webhook account. New booking, reminder, document SMS, and incoming reply webhook fields are blank or generated locally so each business can connect its own provider.

= Can I send SMS reminders? =

The plugin includes webhook/filter support for SMS reminders and incoming SMS replies. You must connect your own SMS provider or automation service, such as Twilio, Telnyx, or Make.

= How do I set up email marketing? =

Use **Lenca Booking > Marketing** to build and preview a campaign, then send a test email before sending to the client audience. For reliable inbox delivery, configure WordPress email through an authenticated SMTP provider using the same From domain as the business email address, and keep SPF, DKIM, and DMARC records passing at the domain DNS provider.

= How do incoming SMS replies work? =

Open **Lenca Booking > Settings > Incoming SMS Replies** and copy the CRM Incoming Reply URL and Incoming Reply Secret. Your automation service should receive the SMS reply from Twilio, Telnyx, or another SMS provider, then POST the reply to that URL with `secret`, `from`, `body`, and optionally `message_sid`.

= Does the public plugin include another business's settings? =

No. The public plugin defaults to the installing website name, website URL, administrator email/domain-based sender defaults, blank webhook URLs, and locally generated secrets.

= Who can manage the CRM? =

Only WordPress users with the `manage_options` capability can access the CRM admin pages.

= Does uninstalling remove business data? =

No. Deactivation does not remove client, appointment, estimate, invoice, or settings data.

== Screenshots ==

1. Lenca Booking dashboard with setup guide, quick actions, and business stats.
2. Public booking form with client details, service selection, and additional services.
3. Public booking form address, appointment date, arrival window, and notes fields.
4. Public booking form SMS consent and appointment request submission.
5. Appointment calendar with service colors, arrival windows, blocking tools, and quick appointment creation.
6. Appointment list with staff assignment, service details, status, address, and actions.
7. Estimates and invoices dashboard with document status, client links, email, and text actions.
8. Mobile-friendly estimate view with client details, totals, notes, and approval tracking.
9. Marketing campaign builder with email preview, SMS preview, audience counts, and test sending.
10. Settings page for service types, appointment colors, and arrival time windows.

== Changelog ==

= 0.1.17 =
* Improved Plugin Check compatibility for sanitization, nonce documentation, upload handling, and public URL handling.

= 0.1.16 =
* Addressed WordPress.org pre-review feedback by moving inline JavaScript behavior into enqueued scripts, checking admin action nonces before dispatch, and updating the Plugin URI to a live public page.

= 0.1.15 =
* Centralized custom database table access through internal wrapper methods to reduce Plugin Checker custom-table warnings while preserving CRM behavior.
* Added focused request-handling and WP_DEBUG logging notes for public document links, admin navigation state, and marketing form sanitization.

= 0.1.14 =
* Fixed Plugin Checker errors for public WordPress.org readiness, including translator comments, escaped admin preview output, enqueued public document styles, date handling, CSV import/export file handling, and the mobile app appointment query check.

= 0.1.13 =
* Removed UTF-8 byte order marks from plugin files so activation does not produce unexpected output or headers warnings.

= 0.1.12 =
* Fixed the database upgrade hook callback visibility so WordPress can call the guarded upgrade check without causing a critical admin error.

= 0.1.11 =
* Moved database upgrade checks out of the plugin constructor so normal WordPress admin pages and plugin search are not affected by Lenca setup routines.
* Added guarded upgrade handling and an admin notice if a future database setup step cannot complete.

= 0.1.10 =
* Hardened the public booking form completion flow so saved appointment requests return to the same page with the success message even if a webhook or email notification fails.
* Added a fallback public redirect screen so booking submissions cannot leave customers on a blank page if a redirect header is blocked.

= 0.1.9 =
* Added a fallback redirect screen after admin saves so saved settings cannot leave the browser on a blank page if a redirect header is blocked.

= 0.1.8 =
* Added a protected Settings page callback so an unexpected saved option cannot leave the admin screen blank.
* Hardened saved setting sanitization for text, email, URL, color, API key, and document branding fields.

= 0.1.7 =
* Hardened settings saves so unexpected field values are logged and redirected back to Settings instead of causing a blank admin screen.
* Added safer document number handling for estimate and invoice counters.

= 0.1.6 =
* Added mobile/desktop API endpoints for creating, viewing, and editing client records.
* Expanded synced client payloads with notes, stain/service notes, and created/updated timestamps.
* Updated public plugin sample data and app storage keys so the public package is Lenca-branded.

= 0.1.5 =
* Matched the marketing campaign preview layout to the fixed email template width so header images, copy, and SMS previews no longer clip in the admin screen.

= 0.1.4 =
* Added client CSV import tools.
* Added marketing campaign builder with email preview, test send, full client audience sending, SMS preview, and audience export.
* Added marketing, business reports, and recent document data to the mobile API bootstrap.
* Synced the public plugin with the latest pilot CRM feature set.

= 0.1.3 =
* Added direct dashboard setup links to specific settings sections.
* Improved estimate and invoice numbering so users enter the last used number and Lenca prepares the next number automatically.
* Tightened document photo card alignment and document status timestamp formatting.
* Added clearer webhook and SMS setup guidance inside settings.

= 0.1.2 =
* Fixed dashboard overflow caused by oversized Lenca artwork in the admin menu and tightened dashboard logo sizing.

= 0.1.1 =
* Added Lenca brand assets, dashboard introduction, setup guide, and branded mobile web app icon.

= 0.1.0 =
* Initial public plugin preparation release.
