diff --git a/index.php b/index.php index a50dd78..51cda76 100644 --- a/index.php +++ b/index.php @@ -290,6 +290,7 @@ function renderPagination($currentPage, $totalPages) { + @@ -3466,10 +3467,19 @@ switch ($page) { $data['backup_settings'] = $stmt->fetchAll(PDO::FETCH_KEY_PAIR); break; case 'accounting': + // Pagination for Journal Entries + $page = isset($_GET['p']) ? max(1, (int)$_GET['p']) : 1; + $limit = isset($_GET['limit']) ? (int)$_GET['limit'] : 20; + $offset = ($page - 1) * $limit; + + $total_entries = db()->query("SELECT COUNT(*) FROM acc_journal_entries")->fetchColumn(); + $data['total_pages'] = ceil($total_entries / $limit); + $data['current_page'] = $page; + $data['journal_entries'] = db()->query("SELECT je.*, (SELECT SUM(debit) FROM acc_ledger WHERE journal_entry_id = je.id) as total_debit FROM acc_journal_entries je - ORDER BY je.entry_date DESC, je.id DESC LIMIT 100")->fetchAll(); + ORDER BY je.entry_date DESC, je.id DESC LIMIT $limit OFFSET $offset")->fetchAll(); $data['accounts'] = db()->query("SELECT * FROM acc_accounts ORDER BY code ASC")->fetchAll(); if (isset($_GET['action']) && $_GET['action'] === 'get_entry_details') {