# List of Values (LOVs) Documentation

This document contains all 12 List of Values defined in the APEX application.

## Overview

| LOV Name | Source Type | Description |
|----------|-------------|-------------|
| ARTICOLI | SQL Query | Article selection |
| CATEGORIE | SQL Query | Category selection |
| CLIENTI | SQL Query | Client selection |
| LOCATION | SQL Query | Location selection |
| RISORSE | SQL Query | Resource (staff) selection |
| STATO_EVENTO | Static | Event status values |
| TIPI MAT | SQL Query | Material type selection |
| TIPI RISORSE | SQL Query | Resource type selection |
| TIPO_EVENTO | SQL Query | Event type selection |
| TIPO_OSPITI | SQL Query | Guest type selection |
| TIPO_PASTO | Static | Meal type values |
| USERS | SQL Query | User selection |

---

## ARTICOLI

**Source Type:** SQL Query (LEGACY_SQL)

**Query:**
```sql
select /*a.cod_categ || ' - ' || c.descrizione || ' - ' ||*/ a.DESCRIZIONE as descrizione, a.COD_ARTICOLO
from articoli a
join tb_codici_categ c on a.cod_categ = c.cod_categ
order by 1
```

**Usage:** Selecting articles in pick lists and event details.

---

## CATEGORIE

**Source Type:** SQL Query (LEGACY_SQL)

**Query:**
```sql
SELECT descrizione as d,
       cod_categ as r
FROM tb_codici_categ
ORDER BY 1
```

**Usage:** Filtering articles by category, category selection in forms.

---

## CLIENTI

**Source Type:** SQL Query (LEGACY_SQL)

**Query:**
```sql
select CLIENTE, ID
from clienti
```

**Usage:** Client selection in event forms.

---

## LOCATION

**Source Type:** SQL Query (LEGACY_SQL)

**Query:**
```sql
select location || ' - ' || indirizzo, id 
from location
```

**Usage:** Location selection in event forms. Displays location name with address.

---

## RISORSE

**Source Type:** SQL Query (LEGACY_SQL)

**Query:**
```sql
select NOME || ' ' || COGNOME d, id r
from risorse
```

**Usage:** Resource (staff) assignment in events. Displays full name.

---

## STATO_EVENTO

**Source Type:** Static

**Values:**

| Display Value | Return Value | Sequence |
|---------------|--------------|----------|
| Scheda Evento (Preparazione) | 0 | 10 |
| Preventivo | 10 | 20 |
| Confermato | 20 | 30 |

**Note:** The actual status values in the database have been expanded:
- 100 = Preventivo
- 200 = Scheda
- 300 = Confermata
- 350 = Quasi Confermato
- 400 = Confermato
- 900 = Superato

**Usage:** Event status display and selection.

---

## TIPI MAT

**Source Type:** SQL Query (LEGACY_SQL)

**Query:**
```sql
SELECT descrizione as d,
       cod_tipo as r
FROM tb_tipi_mat
ORDER BY 1
```

**Usage:** Material type filtering in pick lists. Controls the step-by-step wizard flow.

---

## TIPI RISORSE

**Source Type:** SQL Query (LEGACY_SQL)

**Query:**
```sql
select descrizione, cod_tipo
from tb_tipi_risorsa
```

**Usage:** Resource type classification (camerieri, cuochi, etc.).

---

## TIPO_EVENTO

**Source Type:** SQL Query (LEGACY_SQL)

**Query:**
```sql
select trim(DESCRIZIONE) || decode(tipo_pasto, 'C', ' - Cena', 'P', ' - Pranzo', null) as d, 
       COD_TIPO as r
from tb_tipi_evento
```

**Usage:** Event type selection. Displays description with meal type indicator (Pranzo/Cena).

---

## TIPO_OSPITI

**Source Type:** SQL Query (LEGACY_SQL)

**Query:**
```sql
select descrizione as d,
       cod_tipo as r
from tb_tipi_ospiti
order by 1
```

**Usage:** Guest type selection in event guest details.

---

## TIPO_PASTO

**Source Type:** Static

**Values:**

| Display Value | Return Value | Sequence |
|---------------|--------------|----------|
| Pranzo | P | 1 |
| Cena | C | 2 |
| Pranzo Buffet | A | 3 |
| Cena Buffet | B | 4 |

**Usage:** Meal type classification for events and event types.

---

## USERS

**Source Type:** SQL Query

**Query:**
```sql
select user_name D, user_name R
from WWV_FLOW_USERS
```

**Return Column:** R
**Display Column:** D

**Usage:** User selection for permissions and assignments.

---

## Migration Notes

When migrating to React TypeScript:

1. **Static LOVs** (STATO_EVENTO, TIPO_PASTO) can be implemented as TypeScript enums or const objects
2. **SQL-based LOVs** should be converted to API endpoints
3. Consider caching strategy for frequently used LOVs (CATEGORIE, TIPI MAT, etc.)
4. TIPO_EVENTO uses Oracle `decode()` function - convert to CASE WHEN or handle in API

### Example TypeScript Implementation

```typescript
// Static LOV - TIPO_PASTO
export const TIPO_PASTO = {
  PRANZO: { value: 'P', label: 'Pranzo' },
  CENA: { value: 'C', label: 'Cena' },
  PRANZO_BUFFET: { value: 'A', label: 'Pranzo Buffet' },
  CENA_BUFFET: { value: 'B', label: 'Cena Buffet' },
} as const;

// Dynamic LOV - API endpoint
// GET /api/lovs/articoli
// GET /api/lovs/categorie
// GET /api/lovs/clienti
// etc.
```
