# Customer Enquiry Form - Automatic Workflow

## Overview
The customer workflow now automatically routes customers to the correct submenu based on their **Advance Paid** and **Registration Number** values. No manual checkboxes required!

## How It Works

### Step 1: Customer Form (ALL Checkboxes Commented Out)
- **ALL THREE checkboxes have been commented out** in the customer form:
  1. **Prospect/Enquiry** checkbox
  2. **Customer** checkbox
  3. **Registered Customers** checkbox
- The workflow is now **fully automatic** based on field values
- Location: `htdocs/societe/card.php` (lines ~1501-1516 and ~2357-2372)

### Step 2: Enquiry List
**Shows:** Customers with **NO** Advance Paid AND **NO** Registration Number

**Access URL:**
```
/htdocs/societe/list.php?contextpage=enquiry
```

**Filter Logic:**
- `advance_paid` is NULL, 0, or empty
- `registration_number` is NULL or empty

### Step 3: Booked Customers List
**Shows:** Customers **WITH** Advance Paid but **NO** Registration Number

**Access URL:**
```
/htdocs/societe/list.php?contextpage=booked_customers
```

**Filter Logic:**
- `advance_paid` has a value (NOT NULL, NOT 0, NOT empty)
- `registration_number` is NULL or empty

### Step 4: Registered Customers List
**Shows:** Customers **WITH** Registration Number

**Access URL:**
```
/htdocs/societe/list.php?contextpage=registered_customers
```

**Filter Logic:**
- `registration_number` has a value (NOT NULL, NOT empty)

## Workflow Example

1. **New Customer Created** → Appears in **Enquiry** list
   - Advance Paid: (empty)
   - Registration Number: (empty)

2. **Customer Pays Advance** → Automatically moves to **Booked Customers** list
   - Advance Paid: 5000 (or any value)
   - Registration Number: (empty)

3. **Customer Gets Registration Number** → Automatically moves to **Registered Customers** list
   - Advance Paid: 5000
   - Registration Number: REG-2024-001

## Implementation Details

### Files Modified:
1. **htdocs/societe/card.php**
   - Commented out ALL THREE checkboxes: Prospect/Enquiry, Customer, and Registered Customers (Step 1)
   - Lines ~1501-1516 (create form)
   - Lines ~2357-2372 (edit form)

2. **htdocs/societe/list.php**
   - Added context page handling for workflow (lines ~225-244)
   - Added automatic SQL filtering based on field values (lines ~829-843)

### Required Extrafields:
Make sure these extrafields exist in Setup > Third Parties > Extrafields:
- `advance_paid` (Type: price)
- `registration_number` (Type: varchar)

## Testing

You can test the workflow by:
1. Creating a new customer (should appear in Enquiry list)
2. Adding an Advance Paid value (should appear in Booked Customers list)
3. Adding a Registration Number (should appear in Registered Customers list)

## Notes
- Customers automatically move between lists as values are added
- A customer can only appear in ONE list at a time
- The workflow is based purely on data values, not manual selection
