From d4cb27dca7f88706addd849257cd2f61111b6277 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Fri, 16 Jun 2017 18:35:56 +0100 Subject: [PATCH] added all query parameter for address transactions --- src/Controller/MainController.php | 22 ++++++++++++++++------ src/Template/Main/address.ctp | 4 ++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 02c2a0f..4db18b8 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -443,15 +443,24 @@ class MainController extends AppController { $stmt = $conn->execute('SELECT COUNT(TransactionId) AS Total FROM TransactionsAddresses WHERE AddressId = ?', [$addressId]); $count = $stmt->fetch(\PDO::FETCH_OBJ); $numTransactions = $count->Total; - $numPages = ceil($numTransactions / $pageLimit); - if ($page < 1) { + $all = $this->request->query('all'); + if ($all === 'true') { + $offset = 0; + $pageLimit = $numTransactions; + $numPages = 1; $page = 1; - } - if ($page > $numPages) { - $page = $numPages; + } else { + $numPages = ceil($numTransactions / $pageLimit); + if ($page < 1) { + $page = 1; + } + if ($page > $numPages) { + $page = $numPages; + } + + $offset = ($page - 1) * $pageLimit; } - $offset = ($page - 1) * $pageLimit; $stmt = $conn->execute('SELECT A.TotalReceived, A.TotalSent FROM Addresses A WHERE A.Id = ?', [$address->Id]); $totals = $stmt->fetch(\PDO::FETCH_OBJ); @@ -481,6 +490,7 @@ class MainController extends AppController { $this->set('numTransactions', $numTransactions); $this->set('numPages', $numPages); $this->set('currentPage', $page); + $this->set('pageLimit', $pageLimit); } public function qr($data = null) { diff --git a/src/Template/Main/address.ctp b/src/Template/Main/address.ctp index 87230a7..2954f99 100644 --- a/src/Template/Main/address.ctp +++ b/src/Template/Main/address.ctp @@ -150,9 +150,9 @@

Recent Transactions

0): - $begin = ($currentPage - 1) * 50 + 1; + $begin = ($currentPage - 1) * $pageLimit + 1; ?> - Showing - of result + Showing - of result