$_POST['pwd_min_length'] ?? '8', 'pwd_require_upper' => isset($_POST['pwd_require_upper']) ? '1' : '0', 'pwd_require_lower' => isset($_POST['pwd_require_lower']) ? '1' : '0', 'pwd_require_numbers' => isset($_POST['pwd_require_numbers']) ? '1' : '0', 'pwd_no_common_words' => isset($_POST['pwd_no_common_words']) ? '1' : '0' ]; foreach ($prefs as $key => $val) { $stmt = db()->prepare("INSERT INTO system_preferences (tenant_id, pref_key, pref_value) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE pref_value = VALUES(pref_value)"); $stmt->execute([$tenant_id, $key, $val]); } $stmt = db()->prepare("INSERT INTO activity_log (tenant_id, action, details) VALUES (?, ?, ?)"); $stmt->execute([$tenant_id, 'Settings Updated', 'Updated system preferences and password requirements']); header("Location: system_preferences.php?success=1"); exit; } // Fetch current preferences $stmt = db()->prepare("SELECT pref_key, pref_value FROM system_preferences WHERE tenant_id = ?"); $stmt->execute([$tenant_id]); $prefs = $stmt->fetchAll(PDO::FETCH_KEY_PAIR); $pageTitle = "SR&ED Manager - System Preferences"; include __DIR__ . '/includes/header.php'; ?>