From 64f99d0280b3bbbed05f4abbd9becb0f936ccaab Mon Sep 17 00:00:00 2001 From: Bitha17 <16521076@mahasiswa.itb.ac.id> Date: Sun, 8 Oct 2023 18:33:38 +0700 Subject: [PATCH] add history pagination and edit display history by user id --- app/Views/history/history.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/app/Views/history/history.php b/app/Views/history/history.php index 52750e5..77552fd 100644 --- a/app/Views/history/history.php +++ b/app/Views/history/history.php @@ -22,7 +22,12 @@ $minStock = isset($_GET['min_stock']) ? $_GET['min_stock'] : null; // Get search results or all pembelian (history) - $pembelians = $pembelianController->getAllPembelian(); + $pembelians = $pembelianController->getPembelianByUserId($_SESSION['user_id']); + $paginationData = $pembelianController->paginateHistory($pembelians); + $pembelians = $paginationData['pembelian']; + $totalEvents = $paginationData['total']; + $currentPage = $paginationData['page']; + $maxPage = $paginationData['maxpage']; ?> <!DOCTYPE html> @@ -39,6 +44,7 @@ <link rel="stylesheet" type="text/css" href="/../../styles/container.css"> <link rel="stylesheet" type="text/css" href="/../../styles/auth.css"> <link rel="stylesheet" type="text/css" href="/../../styles/dropdown.css"> + <link rel="stylesheet" type="text/css" href="/../../styles/pagination.css"> </head> <body> @@ -52,6 +58,20 @@ include '../template/history.php'; endforeach;?> </div> + <div class="pagination"> + <?php if ($currentPage > 1) : ?> + <a href="?page=<?= $currentPage - 1 ?>">Previous</a> + <?php endif; ?> + + <?php for ($i = 1; $i <= $maxPage; $i++) : ?> + <a href="?page=<?= $i ?>" <?= ($i == $currentPage) ? 'class="active"' : '' ?>><?= $i ?></a> + <?php endfor; ?> + + <?php if ($currentPage < $maxPage) : ?> + <a href="?page=<?= $currentPage + 1 ?>">Next</a> + <?php endif; ?> + </div> + </div> <?php include '../template/footer.php';?> -- GitLab