fixed filter

This commit is contained in:
2026-10-26 16:48:14 +01:00
parent 65f02b9212
commit ae78bf0393
+11 -5
View File
@@ -39,8 +39,14 @@ if (!empty($explicitIds)) {
// Scoping di sicurezza: solo record del template/utente/import corretti. // Scoping di sicurezza: solo record del template/utente/import corretti.
$conds = ['d.templateid = ?', 'd.status = ?']; $conds = ['d.templateid = ?', 'd.status = ?'];
$params = [$templateId, $status]; $params = [$templateId, $status];
if (!$showAll) { $conds[] = 'd.user_id = ?'; $params[] = $userId; } if (!$showAll) {
if ($importref !== '') { $conds[] = 'd.importreferencecode = ?'; $params[] = $importref; } $conds[] = 'd.user_id = ?';
$params[] = $userId;
}
if ($importref !== '') {
$conds[] = 'd.importreferencecode = ?';
$params[] = $importref;
}
$ph = implode(',', array_fill(0, count($explicitIds), '?')); $ph = implode(',', array_fill(0, count($explicitIds), '?'));
$conds[] = "d.iddatadb IN ($ph)"; $conds[] = "d.iddatadb IN ($ph)";
foreach ($explicitIds as $id) $params[] = $id; foreach ($explicitIds as $id) $params[] = $id;
@@ -57,7 +63,7 @@ if (!empty($explicitIds)) {
$idStmt = $pdo->prepare(" $idStmt = $pdo->prepare("
SELECT d.iddatadb FROM datadb d SELECT d.iddatadb FROM datadb d
WHERE {$whereSql} WHERE {$whereSql}
ORDER BY d.excelrow ASC, d.iddatadb ASC ORDER BY CAST(d.excelrow AS UNSIGNED) ASC, d.excelrow ASC, d.iddatadb ASC
LIMIT {$perPage} OFFSET {$offset} LIMIT {$perPage} OFFSET {$offset}
"); ");
$idStmt->execute($params); $idStmt->execute($params);
@@ -356,7 +362,7 @@ try {
SELECT d.iddatadb SELECT d.iddatadb
FROM datadb d {$joinSql} FROM datadb d {$joinSql}
WHERE {$whereSql} WHERE {$whereSql}
ORDER BY d.excelrow ASC, d.iddatadb ASC ORDER BY CAST(d.excelrow AS UNSIGNED) ASC, d.excelrow ASC, d.iddatadb ASC
LIMIT {$perPage} OFFSET {$offset} LIMIT {$perPage} OFFSET {$offset}
"); ");
$pageStmt->execute($params); $pageStmt->execute($params);
@@ -379,7 +385,7 @@ try {
$allStmt = $pdo->prepare(" $allStmt = $pdo->prepare("
SELECT d.iddatadb FROM datadb d {$joinSql} SELECT d.iddatadb FROM datadb d {$joinSql}
WHERE {$whereSql} WHERE {$whereSql}
ORDER BY d.excelrow ASC, d.iddatadb ASC ORDER BY CAST(d.excelrow AS UNSIGNED) ASC, d.excelrow ASC, d.iddatadb ASC
LIMIT " . FILTER_ALLIDS_CAP . " LIMIT " . FILTER_ALLIDS_CAP . "
"); ");
$allStmt->execute($params); $allStmt->execute($params);