diff --git a/public/userarea/filter_records.php b/public/userarea/filter_records.php index 6c47bdab..0cb90a91 100644 --- a/public/userarea/filter_records.php +++ b/public/userarea/filter_records.php @@ -39,8 +39,14 @@ if (!empty($explicitIds)) { // Scoping di sicurezza: solo record del template/utente/import corretti. $conds = ['d.templateid = ?', 'd.status = ?']; $params = [$templateId, $status]; - if (!$showAll) { $conds[] = 'd.user_id = ?'; $params[] = $userId; } - if ($importref !== '') { $conds[] = 'd.importreferencecode = ?'; $params[] = $importref; } + if (!$showAll) { + $conds[] = 'd.user_id = ?'; + $params[] = $userId; + } + if ($importref !== '') { + $conds[] = 'd.importreferencecode = ?'; + $params[] = $importref; + } $ph = implode(',', array_fill(0, count($explicitIds), '?')); $conds[] = "d.iddatadb IN ($ph)"; foreach ($explicitIds as $id) $params[] = $id; @@ -57,7 +63,7 @@ if (!empty($explicitIds)) { $idStmt = $pdo->prepare(" SELECT d.iddatadb FROM datadb d 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} "); $idStmt->execute($params); @@ -356,7 +362,7 @@ try { SELECT d.iddatadb FROM datadb d {$joinSql} 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} "); $pageStmt->execute($params); @@ -379,7 +385,7 @@ try { $allStmt = $pdo->prepare(" SELECT d.iddatadb FROM datadb d {$joinSql} 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 . " "); $allStmt->execute($params);