From 6f7b57b235d270dbe93aeda5982391ef8286025a Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 20 Mar 2026 05:45:17 +0000 Subject: [PATCH] adding paginations --- index.php | 10 +++++++- license_manager/manage.php | 50 +++++++++++++++++++++++++++++++++++++- outlets_html.php | 1 + 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 360aee8..e8ea716 100644 --- a/index.php +++ b/index.php @@ -3289,7 +3289,13 @@ switch ($page) { header("Location: index.php?page=outlets"); exit; } - $data['outlets'] = db()->query("SELECT * FROM outlets ORDER BY id ASC")->fetchAll(); + $countStmt = db()->query("SELECT COUNT(*) FROM outlets"); + $total_records = (int)$countStmt->fetchColumn(); + $data['total_pages'] = ceil($total_records / $limit); + $data['current_page'] = $page_num; + $stmt = db()->prepare("SELECT * FROM outlets ORDER BY id ASC LIMIT $limit OFFSET $offset"); + $stmt->execute(); + $data['outlets'] = $stmt->fetchAll(); break; case 'copy_outlet_data': require 'pages/copy_outlet_data_logic.php'; break; case 'settings': @@ -6604,6 +6610,7 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System'; + @@ -6728,6 +6735,7 @@ $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Accounting System'; + diff --git a/license_manager/manage.php b/license_manager/manage.php index c4bc31b..996e3d8 100644 --- a/license_manager/manage.php +++ b/license_manager/manage.php @@ -10,6 +10,44 @@ ini_set('display_errors', 1); require_once __DIR__ . '/config.php'; +function renderPagination($currentPage, $totalPages) { + if ($totalPages <= 1) return ''; + $url = 'manage.php?page='; + + $html = ''; + return $html; +} + + // SIMPLE PASSWORD PROTECTION $admin_password = "Meezan@2026"; @@ -148,7 +186,16 @@ if (isset($_SESSION['flash_message'])) { // Fetch Licenses try { - $licenses = $pdo->query("SELECT * FROM licenses ORDER BY created_at DESC")->fetchAll(); + // Pagination + $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; + if ($page < 1) $page = 1; + $limit = 20; + $offset = ($page - 1) * $limit; + + $total = $pdo->query("SELECT COUNT(*) FROM licenses")->fetchColumn(); + $totalPages = ceil($total / $limit); + + $licenses = $pdo->query("SELECT * FROM licenses ORDER BY created_at DESC LIMIT $limit OFFSET $offset")->fetchAll(); } catch (Exception $e) { $licenses = []; $error = "Failed to fetch licenses: " . $e->getMessage(); @@ -321,6 +368,7 @@ try { + diff --git a/outlets_html.php b/outlets_html.php index 619cca4..0ce7b50 100644 --- a/outlets_html.php +++ b/outlets_html.php @@ -46,6 +46,7 @@ +