diff --git a/application/controllers/ServicesController.php b/application/controllers/ServicesController.php index 795d460..98fa1f9 100644 --- a/application/controllers/ServicesController.php +++ b/application/controllers/ServicesController.php @@ -548,8 +548,12 @@ class ServicesController extends BaseController ]; $rawSector = strtolower($company['sector'] ?? 'ict'); $nis2Sector = $sectorMap[$rawSector] ?? $rawSector; - $nis2EntityType = in_array($company['nis2_entity_type'] ?? '', ['essential', 'important', 'voluntary']) - ? $company['nis2_entity_type'] : 'important'; + $rawEntityType = $company['nis2_entity_type'] ?? 'important'; + $nis2EntityType = match($rawEntityType) { + 'essential' => 'essential', + 'voluntary' => 'not_applicable', + default => 'important', + }; if ($existing) { $orgId = (int) $existing['id']; @@ -557,22 +561,16 @@ class ServicesController extends BaseController // ── 4. Crea organizzazione ─────────────────────────────────── Database::query( 'INSERT INTO organizations - (name, legal_form, vat_number, fiscal_code, ateco_code, ateco_description, - legal_address, pec, phone, annual_turnover_eur, employees, - sector, nis2_entity_type, status, + (name, vat_number, fiscal_code, + annual_turnover_eur, employee_count, + sector, entity_type, is_active, provisioned_by, provisioned_at, license_plan, license_expires_at, license_max_users, lg231_company_id, lg231_order_id) - VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,\'active\',?,NOW(),?,?,?,?,?)', + VALUES (?,?,?,?,?,?,?,1,?,NOW(),?,?,?,?,?)', [ $ragioneSociale, - $company['forma_giuridica'] ?? null, $partitaIva, $company['codice_fiscale'] ?? null, - $company['ateco_code'] ?? null, - $company['ateco_description'] ?? null, - $company['sede_legale'] ?? null, - $company['pec'] ?? null, - $company['telefono'] ?? null, $company['fatturato_annuo'] ?? null, $company['numero_dipendenti'] ?? null, $nis2Sector, diff --git a/simulate-nis2.php b/simulate-nis2.php index 93d2193..efaf89a 100644 --- a/simulate-nis2.php +++ b/simulate-nis2.php @@ -426,7 +426,7 @@ $COMPANIES = [ 'ateco_desc' => 'Produzione di software non connesso all\'edizione', 'employees' => 320, 'annual_turnover'=> 18500000, - 'sector' => 'ict', + 'sector' => 'ict_services', 'nis2_type' => 'essential', 'city' => 'Milano', 'province' => 'MI', @@ -468,7 +468,7 @@ $COMPANIES = [ 'ateco_desc' => 'Servizi ospedalieri', 'employees' => 750, 'annual_turnover'=> 42000000, - 'sector' => 'healthcare', + 'sector' => 'health', 'nis2_type' => 'important', 'city' => 'Roma', 'province' => 'RM', @@ -644,7 +644,7 @@ foreach ($COMPANIES as $slug => $comp) { 'vat_number' => $comp['vat_number'], 'ateco_code' => $comp['ateco_code'], 'sector' => $comp['sector'], - 'employees_count' => $comp['employees'], + 'employee_count' => $comp['employees'], 'annual_turnover_eur' => $comp['annual_turnover'], 'city' => $comp['city'], 'province' => $comp['province'],