diff --git a/application/controllers/ServicesController.php b/application/controllers/ServicesController.php index ee6fac8..ae654ad 100644 --- a/application/controllers/ServicesController.php +++ b/application/controllers/ServicesController.php @@ -1626,7 +1626,7 @@ class ServicesController extends BaseController $controls = Database::fetchAll( "SELECT id, control_code, framework, title, status, - implementation_percentage, nis2_article, next_review_date, updated_at + implementation_percentage, next_review_date FROM compliance_controls WHERE {$where} ORDER BY framework, control_code", @@ -1640,24 +1640,30 @@ class ServicesController extends BaseController $s = $c['status'] ?? 'not_started'; if (isset($stats[$s])) $stats[$s]++; + $code = $c['control_code'] ?? ''; // Derive mog_area from control_code $mogArea = 'other'; - $code = $c['control_code'] ?? ''; foreach ($mogAreaMap as $prefix => $area) { if (str_starts_with($code, $prefix)) { $mogArea = $area; break; } } if ($mogArea === 'other' && str_starts_with($code, 'ISO')) $mogArea = 'iso27001_control'; + // Derive nis2_article from code (e.g. "NIS2-21.2.a" → "Art.21.2.a") + $nis2Article = null; + if (preg_match('/^NIS2-(\S+)/', $code, $m)) { + $nis2Article = 'Art.' . $m[1]; + } + $measures[] = [ - 'id' => (int) $c['id'], - 'code' => $code, - 'framework' => $c['framework'], - 'title' => $c['title'], - 'status' => $s, + 'id' => (int) $c['id'], + 'code' => $code, + 'framework' => $c['framework'], + 'title' => $c['title'], + 'status' => $s, 'implementation_percentage' => (int) ($c['implementation_percentage'] ?? 0), - 'nis2_article' => $c['nis2_article'], - 'mog_area' => $mogArea, - 'next_review_date' => $c['next_review_date'], + 'nis2_article' => $nis2Article, + 'mog_area' => $mogArea, + 'next_review_date' => $c['next_review_date'], ]; }