isLoggedIn() || !$auth->isAdmin()) {
redirectTo('dashboard.php');
}
$currentUser = $auth->getCurrentUser();
$db = Database::getInstance();
// Get pagination and filtering parameters for impossible combinations
$page = isset($_GET['page']) ? max(1, (int)$_GET['page']) : 1;
$limit = isset($_GET['limit']) ? max(1, min(50, (int)$_GET['limit'])) : 10;
$statusFilter = isset($_GET['status']) && in_array($_GET['status'], ['pending', 'approved', 'declined']) ? $_GET['status'] : '';
$offset = ($page - 1) * $limit;
// Get optimization statistics
$stats = ['total' => 0, 'processed' => 0, 'impossible' => 0, 'progress' => 0];
try {
// Total combinations
$totalResult = $db->query("SELECT COUNT(*) as count FROM panel_directives");
$stats['total'] = $totalResult ? $totalResult->fetch_assoc()['count'] : 0;
// Processed combinations
$processedResult = $db->query("SELECT COUNT(*) as count FROM panel_directives WHERE llm_checked = 1");
$stats['processed'] = $processedResult ? $processedResult->fetch_assoc()['count'] : 0;
// Impossible combinations
$impossibleResult = $db->query("SELECT COUNT(*) as count FROM panel_directives WHERE llm_checked = 1 AND is_impossible = 1");
$stats['impossible'] = $impossibleResult ? $impossibleResult->fetch_assoc()['count'] : 0;
// Progress percentage
$stats['progress'] = $stats['total'] > 0 ? ($stats['processed'] / $stats['total']) * 100 : 0;
} catch (Exception $e) {
$stats = ['total' => 0, 'processed' => 0, 'impossible' => 0, 'progress' => 0];
}
// Get impossible combinations with pagination and filtering
$impossibleCombinations = [];
$totalImpossibleCount = 0;
$totalPages = 0;
try {
// Build the WHERE clause for filtering
$whereClause = "WHERE llm_checked = 1 AND is_impossible = 1";
$params = [];
$types = '';
if ($statusFilter) {
$whereClause .= " AND status = ?";
$params[] = $statusFilter;
$types .= 's';
}
// Get total count for pagination
$countQuery = "SELECT COUNT(*) as total FROM panel_directives " . $whereClause;
if ($params) {
$countStmt = $db->prepare($countQuery);
$countStmt->bind_param($types, ...$params);
$countStmt->execute();
$totalImpossibleCount = $countStmt->get_result()->fetch_assoc()['total'];
} else {
$countResult = $db->query($countQuery);
$totalImpossibleCount = $countResult ? $countResult->fetch_assoc()['total'] : 0;
}
$totalPages = ceil($totalImpossibleCount / $limit);
// Get paginated impossible combinations
$dataQuery = "
SELECT
id,
attribute1_name,
choice1,
attribute2_name,
choice2,
status,
llm_reasoning,
updated_at
FROM panel_directives
" . $whereClause . "
ORDER BY updated_at DESC
LIMIT ? OFFSET ?
";
$dataParams = $params;
$dataParams[] = $limit;
$dataParams[] = $offset;
$dataTypes = $types . 'ii';
$dataStmt = $db->prepare($dataQuery);
$dataStmt->bind_param($dataTypes, ...$dataParams);
$dataStmt->execute();
$result = $dataStmt->get_result();
while ($row = $result->fetch_assoc()) {
$impossibleCombinations[] = $row;
}
} catch (Exception $e) {
// Ignore errors
}
?>
Total Combinations
Demographic combinations to analyze
Analyzed
Combinations processed by AI
Impossible Found
Unrealistic combinations identified
Optimization Rate
0 ? round(($stats['impossible'] / $stats['total']) * 100, 1) : 0; ?>%
Percentage of impossible combinations
π§ OptimAIze interface loaded and ready
1): ?>
| Directive ID |
Impossible Combination Detail |
Status |
Actions |
|
OPT-
|
=
+
=
100 ? '...' : ''; ?>
|
|
|
|
No impossible combinations found with status:
No impossible combinations found yet. Run the analysis to identify problematic demographic combinations.
|