=== Prenoteca – Booking Requests ===
Contributors: lucaborghy
Tags: booking, appointments, reservation, form, schedule
Requires at least: 5.3
Tested up to: 7.1
Stable tag: 2.2.0
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Everything you need to collect and manage booking requests on your site, without the weight of a full booking system.

== Description ==

Prenoteca adds a booking request form to any page through a shortcode, and a simple list in your dashboard to manage what comes in. No account, no external service, no calendar sync you did not ask for.

It is built for the case most sites actually have: let people ask for an appointment, get notified, keep a record.

Good for:

* professional practices
* beauty salons and barbers
* consultants and freelancers
* small businesses taking appointments

What it does:

* Responsive booking form, added with a shortcode
* Booking list in the dashboard, filterable by date, status and professional
* CSV export of the bookings you filtered
* Email notification to the site administrator
* Optional confirmation email to the customer
* Notifications page to customise every email subject and text, with placeholders
* Available times, also different for each day of the week, managed from the Times and calendar page
* Optional booking statuses (new, confirmed, completed, cancelled), managed from the booking list; cancelled bookings free their time slot
* Optional cancellation link in the customer email: a personal, token-protected link to cancel the booking
* Optional reminder email to the customer the day before a confirmed appointment
* Optional minimum notice: set how far in advance (minutes, hours or days) a booking must be made
* Optional maximum booking window: set how far ahead (minutes, hours or days) customers can book
* Closing days: single dates, weekly closing days (for example every Sunday) and closing periods such as holidays
* No double bookings: times already taken are disabled in the form, accounting for service duration and breaks
* Daily booking limit
* Works with the WordPress privacy tools: personal data export and erasure, and suggested privacy policy text
* Optional "Book Services": let customers pick a service (duration, break, short description, optional price), managed from the dashboard
* Booking manager role: lets a receptionist manage bookings, professionals and times without being an administrator
* Optional separate calendars: several professionals (for example the doctors of a clinic), each with their own calendar, working days, times and absences; customers pick one and only see that person's free times

No external dependencies and no bloat. Only what you really need.

== Installation ==

1. Upload the `prenoteca-booking` folder to `/wp-content/plugins/`, or install the plugin through the Plugins screen.
2. Activate the plugin through the "Plugins" screen in WordPress.
3. Go to **Bookings → Times and calendar** to configure available times, closing days and the daily limit, and to **Bookings → Settings** for everything else.
4. Add the form to a published page with the shortcode: `[prenoteca_booking_form]`

== Frequently Asked Questions ==

= Where should I place the form? =

In a published page, using the `[prenoteca_booking_form]` shortcode. The cancellation link in the customer email leads back to that page, which shows the cancellation request in place of the form. Do not place the form in widgets, archives or theme templates: there the link falls back to the home page, where customers cannot cancel unless the home page also shows the form. Keep the page published while bookings are active, otherwise links already sent will stop working.

= Can I customise the form? =

You can change its look with CSS from your theme: the form and its main elements have classes and IDs starting with `prenoteca` (for example `.prenoteca-form`, `.prenoteca-btn` and `#prenoteca_name`). Email texts can be edited from **Bookings → Notifications**. Editing the plugin files is not recommended, because changes are lost when the plugin is updated.

= Can I add custom fields? =

Not from the settings. Custom fields require editing the form template and the code that validates and saves the booking (`includes/class-prenoteca-frontend.php`), and changes to the plugin files are lost when the plugin is updated.

= Are the emails customisable? =

Yes. Go to **Bookings → Notifications** to edit the subject and text of every email. Placeholders such as `{nome}`, `{data}` and `{ora}` are replaced with the booking details, and a button restores the default text.

= When is the reminder email sent? =

Enable **Reminder** and **Booking statuses** in **Bookings → Settings**. Between 09:00 and 20:00 (site time) the plugin emails customers whose booking for the next day is confirmed, once per booking. The reminder does not depend on the "Send a confirmation to the customer" option. The check runs every hour, so bookings confirmed later in the day still get their reminder, and a failed email is retried up to 3 times. If it still cannot be sent (or no attempts are left before 20:00), a notice in the admin area and a label in the booking list tell you to contact the customer directly. The text can be edited from **Bookings → Notifications**. The reminder uses WP-Cron, which runs when someone visits the site: on low-traffic sites, disable WP-Cron in `wp-config.php` (`define( 'DISABLE_WP_CRON', true );`) and have your server call `wp-cron.php` every 15 minutes, so reminders are sent on time.

= How do I offer bookable services? =

Enable **Book Services** in **Bookings → Settings**. A **Services** menu appears where you manage the list; the form then asks the customer to pick one. Each booking keeps a copy of the service name and duration, so your history stays accurate even if you later edit or delete the service. Disabling the option hides the field from the form.

= Can I take bookings for several professionals? =

Yes. Enable **Separate calendars** in **Bookings → Settings** (it is off by default) and add the people from the new **Professionals** menu. The form then asks the customer to choose one (the field name, "Medico" by default, can be changed in the settings) and shows only the times that person still has free. Two customers can book the same time with two different professionals. For each professional you can set the days of the week they work, their own available times (or leave them empty to use the general ones), different times for single days of the week, and absence periods such as holidays: the calendar in the form only offers the days they work. Closing days and booking time limits are shared by everyone; the daily limit applies to each calendar. Bookings received before you enabled the option have no professional, so they keep their time slot taken in every calendar. The booking list and the CSV export can be filtered by professional, and emails can show the name with the `{professionista}` placeholder.

= Can a receptionist manage bookings without being an administrator? =

Yes. Give their WordPress user the **Gestore prenotazioni** (booking manager) role, created by the plugin. They can manage the booking list (confirm, complete, cancel, delete, CSV export), the **Professionals** and the **Times and calendar** page, and see the plugin notices. Settings, Notifications, Services and the rest of WordPress stay with administrators. Administrators always have every booking permission.

= Can I change the services created on first activation? =

Yes, with the `prenoteca_default_services` filter, before you enable the option for the first time:

`add_filter( 'prenoteca_default_services', function () {
    return array(
        array( 'nome' => 'Taglio', 'durata_min' => 30, 'pausa_tra_appuntamenti' => 10, 'attivo' => 'si', 'descrizione_breve' => 'Lavaggio incluso', 'prezzo' => '25' ),
    );
} );`

= Can I change the anti-spam limit? =

By default the form accepts at most 3 booking requests per hour from the same IP address; administrators and booking managers are not limited. You can change the number, or set it to 0 to turn the limit off:

`add_filter( 'prenoteca_rate_limit', function () {
    return 5;
} );`

The time window is set with the `prenoteca_rate_limit_period` filter, in seconds.

= Where are the bookings stored? =

In a dedicated database table, `wp_prenoteca_bookings`. Uninstalling the plugin drops that table and removes its options.

= Does it send data anywhere? =

No. Everything stays on your site.

= Does the plugin use cookies? =

Only one technical cookie, and only when a customer opens the cancellation link from their email. The cookie (`prenoteca_cancel_` followed by the booking ID) temporarily stores the cancellation token, so the token can be removed from the page address. It expires after 30 minutes, is deleted once the booking is cancelled, and is not used for tracking. Visitors who only use the booking form receive no cookies from the plugin.

== Screenshots ==

1. Front-end booking form
2. Booking list in the dashboard
3. Settings page

== Changelog ==

= 2.2.0 =
* New "Gestore prenotazioni" (booking manager) role: manages bookings, professionals and the new Times and calendar page without being an administrator
* Fixed: the booking manager could not open "Add new professional" (WordPress blocked the page as if it were "Posts → Add New")
* Available times, closing days and the daily limit moved from Settings to their own page, Bookings → Times and calendar
* Available times can differ by day of the week (Bookings → Times and calendar → Available times → "Different times for each day of the week"); the form shows the times of the chosen date
* Separate calendars (optional, off by default): manage several professionals, each with their own calendar, from the new Professionals menu
* The form asks the customer to choose a professional and shows only the times still free for that person; double bookings are checked per calendar, also when the booking is submitted
* Each professional has their own working days, optional available times (also different for each day of the week) and absence periods; the form calendar and time list follow the chosen professional and date, and the same rules are checked when the booking is submitted
* Admin notice listing, for each professional, the active bookings that no longer fit their calendar (days they are absent, or times removed after the booking was made), with a link to their bookings; bookings without a professional are checked against the general times, also when separate calendars are off
* The daily limit applies to each calendar
* Name of the form field editable in Settings ("Medico" by default)
* Booking list: professional column and filter; the CSV export follows the filter and includes the professional
* New `{professionista}` placeholder; the default email texts show the professional when there is one
* The cancellation page and the personal data export show the professional
* Database: two new columns store the professional of each booking; the table is updated automatically
* Uninstall also removes the anti-spam counters (temporary data of the booking request limit)

= 2.1.0 =
* Reminder: optional email to the customer the day before a confirmed appointment, sent once per booking by an hourly WP-Cron event between 09:00 and 20:00, with up to 3 attempts if sending fails (requires Booking statuses)
* Admin notice and "Reminder not sent" label in the booking list when a reminder still fails after 3 attempts
* Reminder email subject and text editable from Notifications
* Reminders are sent between 09:00 and 20:00 (site time), never at night; disabling the option, or deactivating the plugin, removes the scheduled event
* Weekly closing days: pick the days of the week when you are always closed, with a warning if every day is closed
* Closing periods: add holidays and other closures with a start and an end date, both included
* Requires WordPress 5.3 or later (previously 5.0)
* Weekly closing days and closing periods cannot be picked in the form calendar and are also checked when the booking is submitted
* Settings warns when active bookings fall on closing days added later, so you can cancel them and notify the customers
* Database: a new column records when the reminder was sent; the table is updated automatically

= 2.0.1 =
* Customer email when the administrator cancels a booking (if "Send a confirmation to the customer" is enabled), editable from Notifications
* Phone field accepts only numbers, spaces and the characters + - / ( )
* Minimum notice or maximum booking window set to 0: the option is now turned off with a notice, instead of showing the default value
* The default subject of the "booking received" email to the customer is now "Prenotazione ricevuta", so it is not mistaken for the confirmation email
* Anti-spam: at most 3 booking requests per hour from the same IP address (adjustable with the `prenoteca_rate_limit` and `prenoteca_rate_limit_period` filters; administrators are not limited)

= 2.0.0 =
* Book Services: customers pick a service with duration, break, short description and optional price
* Booking statuses: new, confirmed, completed, cancelled, with an email to the customer on confirmation
* Cancellation link in the customer email, protected by a personal token
* Notifications page to customise every email subject and text, with placeholders
* Minimum notice and maximum booking window
* Closing days
* No double bookings: taken times are disabled in the form, accounting for service duration and breaks
* "Upcoming" and "Today" views in the booking list, sorted by date and time
* Paginated booking list, with the total number of bookings
* CSV export follows the active filters (dates, status, "Upcoming" and "Today" views), with no row limit
* Dates shown as dd-mm-yyyy with a date picker
* Clear error messages in the form, with the entered data kept so customers can correct it
* Works with page caching: the form security token is refreshed automatically
* A booking is confirmed and emailed only after it has been saved
* Personal data export and erasure through the WordPress privacy tools; erased bookings are anonymised, upcoming active bookings are kept until cancelled
* Suggested privacy policy text under Settings → Privacy

= 1.0.0 =
* First stable release
* Front-end booking form
* Booking management in the dashboard
* CSV export
* Administrator and customer emails
* Plugin settings
* Daily limit
* Configurable available times

== Upgrade Notice ==

= 2.2.0 =
Adds optional separate calendars for several professionals and a booking manager role. Available times, closing days and the daily limit move to the new Bookings → Times and calendar page. Separate calendars are off by default.

= 2.1.0 =
Adds an optional reminder email to the customer the day before a confirmed appointment, weekly closing days and closing periods. Now requires WordPress 5.3 or later.

= 2.0.1 =
Adds a cancellation email to the customer, stricter phone validation and a limit on repeated booking requests to reduce spam.

= 2.0.0 =
Adds bookable services, booking statuses, a cancellation link, customisable emails and booking time limits. Recommended for all sites.

= 1.0.0 =
First release.
