[FEAT] Visura auto-fill, adesione volontaria, modulo NCR/CAPA
1. Fix auto-fill visura: mapping corretto suggested_sector e employees_range, indicatori visivi verdi sui campi auto-compilati, fatturato sempre manuale 2. Adesione volontaria: colonna voluntary_compliance, checkbox in onboarding step 5 quando not_applicable, toggle in settings, reset su ri-classificazione 3. Modulo NCR/CAPA: NonConformityController con 10 endpoint API, tabelle non_conformities + capa_actions, generazione NCR dai gap assessment, predisposizione integrazione SistemiG.agile (webhook + sync) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -154,7 +154,7 @@ class OrganizationController extends BaseController
|
||||
$allowedFields = [
|
||||
'name', 'vat_number', 'fiscal_code', 'sector', 'employee_count',
|
||||
'annual_turnover_eur', 'country', 'city', 'address', 'website',
|
||||
'contact_email', 'contact_phone',
|
||||
'contact_email', 'contact_phone', 'voluntary_compliance',
|
||||
];
|
||||
|
||||
foreach ($allowedFields as $field) {
|
||||
@@ -170,11 +170,25 @@ class OrganizationController extends BaseController
|
||||
// Ri-classifica se cambiano settore, dipendenti o fatturato
|
||||
if (isset($updates['sector']) || isset($updates['employee_count']) || isset($updates['annual_turnover_eur'])) {
|
||||
$org = Database::fetchOne('SELECT * FROM organizations WHERE id = ?', [$id]);
|
||||
$updates['entity_type'] = $this->classifyNis2Entity(
|
||||
$newEntityType = $this->classifyNis2Entity(
|
||||
$updates['sector'] ?? $org['sector'],
|
||||
(int) ($updates['employee_count'] ?? $org['employee_count']),
|
||||
(float) ($updates['annual_turnover_eur'] ?? $org['annual_turnover_eur'])
|
||||
);
|
||||
$updates['entity_type'] = $newEntityType;
|
||||
// Reset voluntary compliance if no longer not_applicable
|
||||
if ($newEntityType !== 'not_applicable') {
|
||||
$updates['voluntary_compliance'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure voluntary_compliance is only set when entity_type is not_applicable
|
||||
if (isset($updates['voluntary_compliance'])) {
|
||||
$currentOrg = $org ?? Database::fetchOne('SELECT entity_type FROM organizations WHERE id = ?', [$id]);
|
||||
$currentType = $updates['entity_type'] ?? $currentOrg['entity_type'];
|
||||
if ($currentType !== 'not_applicable') {
|
||||
$updates['voluntary_compliance'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Database::update('organizations', $updates, 'id = ?', [$id]);
|
||||
@@ -302,11 +316,12 @@ class OrganizationController extends BaseController
|
||||
$entityType = $this->classifyNis2Entity($sector, $employees, $turnover);
|
||||
|
||||
$this->jsonSuccess([
|
||||
'entity_type' => $entityType,
|
||||
'sector' => $sector,
|
||||
'employee_count' => $employees,
|
||||
'entity_type' => $entityType,
|
||||
'sector' => $sector,
|
||||
'employee_count' => $employees,
|
||||
'annual_turnover_eur' => $turnover,
|
||||
'explanation' => $this->getClassificationExplanation($entityType, $sector, $employees, $turnover),
|
||||
'allows_voluntary' => $entityType === 'not_applicable',
|
||||
'explanation' => $this->getClassificationExplanation($entityType, $sector, $employees, $turnover),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user