# Customer tour enquiries

Public website forms:

- `/enquiry/sundarban`
- `/enquiry/international`
- `/enquiry/domestic`

Customers do not need an account. Successful submission displays a unique enquiry number and stores the full form in the backend. Names, mobile numbers, preferred travel dates, adult/child counts, duration, and the relevant destination/ship category are required. Sundarban enquiries begin with a required **Tour type** of *By Ship* or *Resort*; the preferred ship category is asked, and required, only for *By Ship*. A visitor who reaches the form from a ship page has *By Ship* preselected. Other details are optional. Each child requires an age from 0 through 17. Submissions do not create bookings or send messages to customers.

## Setup

Run from `lets_tour_admin` on deployment:

```sh
php artisan migrate --force
php artisan db:seed --class=EnquirySetupSeeder --force
```

Build and deploy `lets_tour_web` using the existing `VITE_API_URL` setting. Configure the public Website URL in Business Settings so the admin's shareable links use the correct domain. Existing CORS configuration must allow that website origin. The frontend host must serve its SPA for `/enquiry/*`, as it already does for other client-side routes.

The incremental seeder adds permissions and the **CRM & Sales → Tour Enquiries** menu without replacing existing menus or account grants. It also runs during normal database seeding.

## Admin and sales workflow

Open **Tour Enquiries** for totals, status/type statistics, and due follow-ups. Tabs provide separate enquiry lists; filters cover type, status, destination, assigned employee, submission/travel date ranges, and customer name/contact/enquiry number.

Admins assign enquiries to active employee profiles. Create or update the employee's panel login from **Employees** to let the assigned employee sign in. Existing `employee` accounts receive enquiry permissions from the setup seeder; their enquiry data is restricted to their own active employee profile. A `sales-representative` role is also available with the same enquiry-only permissions. A sales user cannot reassign enquiries or open another employee's enquiry, including through print/export URLs.

Super admins manage all enquiries. Custom managerial roles require the appropriate `admin.enquiries.*` route permissions plus `admin.enquiries.view-all`; reassignment also requires `admin.enquiries.assign`.

Open a record to view every customer/tour field. Use the call, WhatsApp, or email shortcuts to contact the customer, then save the communication channel and outcome. This records contact time and adds immutable activity history. Internal notes and status/date changes are recorded too. Older contact activity does not overwrite a later last-contacted date. Clear the next follow-up field to remove its schedule. Due-follow-up totals exclude confirmed, cancelled, and closed enquiries.

Possible duplicates share a normalized mobile/WhatsApp number or email. Bangladesh local and international number formats are normalized. Duplicates are flagged and retained; sales users only see duplicate records they are authorized to access.

**Export CSV (Excel)** downloads all rows matching the current filters and the user's access, including tour requirements and communication history. The CSV includes a UTF-8 BOM and escapes formula-like values for spreadsheet use. **Print details** opens the complete record and history in a print-friendly layout.

Statuses: New, Contacted, Follow-up Required, Quotation Sent, Negotiating, Confirmed, Cancelled, Closed, No Response.

## Public API

- `GET /api/enquiries/{type}/form` provides the shared field definition.
- `POST /api/enquiries/{type}` validates and stores an enquiry, returning HTTP 201 with `enquiry_no` and `message`.
- Validation failures return HTTP 422 with field errors; invalid types return HTTP 404.
- Public submissions are throttled to 10 per minute per IP and include a honeypot field.

Customer-supplied assignment, status, or enquiry-number fields are ignored. The server records the submission time and canonical form URL and starts every enquiry as New, unassigned. No public endpoint lists or exposes submitted customer information.

## Form loading and CORS

Form fields are defined in `app/Support/EnquiryFields.php`; they do not need database seeds. A field carrying `showWhen` (`['field' => x, 'value' => y]`) is conditional: the website hides it while field *x* does not hold value *y*, the request drops any value posted for it and stops requiring it, and the admin detail and print views leave it out of the record instead of showing it blank. Adding a conditional field therefore needs no change outside that one definition. The form endpoint must allow the public website origin through CORS. Set `WEBSITE_URL=https://<your-domain>` in the backend environment; the root, www, and beta Let's Go domains are allowed alongside any additional preview origins.

After deploying CORS configuration changes, refresh Laravel's cached configuration:

```sh
php artisan config:clear
php artisan config:cache
```

Permission/menu setup uses `php artisan db:seed --class=EnquirySetupSeeder --force`. This does not control form fields.

International country choices use active records from **Countries**. Preferred places support multiple active destinations belonging to that country. Changing country clears the selected destinations. The API receives country/destination IDs in `destination_country`/`places`, validates their relationship, and saves both IDs and name snapshots for readable historical enquiries. Deploy the updated backend and frontend together.
