diff --git a/pages/sales_purchases_logic.php b/pages/sales_purchases_logic.php index e47a240..72b9ab1 100644 --- a/pages/sales_purchases_logic.php +++ b/pages/sales_purchases_logic.php @@ -1,5 +1,27 @@ (string)($page ?? ''), + 'requested_limit' => isset($_GET['limit']) ? (string)$_GET['limit'] : 'unset', + 'applied_limit' => 20, + ]); + } + if (function_exists('app_debug_file_log')) { + app_debug_file_log( + 'runtime_debug.log', + date('Y-m-d H:i:s') . " [sales_purchases_limit_fallback] page=" . (string)($page ?? '') + . " requested_limit=" . (isset($_GET['limit']) ? (string)$_GET['limit'] : 'unset') + . " applied_limit=20" + ); + } + } + $limit = min(500, max(5, $requestedLimit > 0 ? $requestedLimit : 20)); + $page_num = isset($page_num) ? max(1, (int)$page_num) : (isset($_GET['p']) ? max(1, (int)$_GET['p']) : 1); + $offset = ($page_num - 1) * $limit; + $type = ($page === 'sales') ? 'sale' : 'purchase'; $table = ($type === 'purchase') ? 'purchases' : 'invoices'; $cust_supplier_col = ($type === 'purchase') ? 'supplier_id' : 'customer_id';