From d953fe24131ba5594abf361b0bcfa5a4ee1deb4c Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 25 May 2018 16:51:16 -0400 Subject: [PATCH] Adding Paging Need to work on the search paramaters and passing them to edit page. --- models/admin/travel/index.php | 42 ++++++++++++++++++++++++++++++++++- views/admin/travel/index.html | 23 +++++++++++++++++-- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/models/admin/travel/index.php b/models/admin/travel/index.php index 4a9daf3..53054ce 100644 --- a/models/admin/travel/index.php +++ b/models/admin/travel/index.php @@ -109,6 +109,7 @@ class GlmMembersAdmin_travel_index extends GlmDataTravelLeads $entry = false; $hasSearch = false; $tab = 0; + $params = false; // Get any provided option if ( isset( $_REQUEST['option'] ) ) { @@ -262,8 +263,46 @@ class GlmMembersAdmin_travel_index extends GlmDataTravelLeads } $order = "T.lname, T.fname"; } + // Check if we're doing paging + if (isset($_REQUEST['pageSelect'])) { + // If request is for Next + if ($_REQUEST['pageSelect'][0] == 'N') { + $newStart = $_REQUEST['nextStart'] - 0; + + // Otherwise it must be Previous + } else { + $newStart = $_REQUEST['prevStart'] - 0; + } + + if ($newStart > 0) { + $start = $newStart; + } + } + // $entry = $this->getList( $where ); + $orderBy = 'T.company ASC,T.lname ASC,T.fname ASC,T.updated DESC'; + $entryResults = $this->getList( $where, $orderBy, true, 'id', $start, $limit ); + + // Get paging results + $numbDisplayed = $entryResults['returned']; + $leadCount = $numbDisplayed; + $lastDisplayed = $entryResults['last']; + if ( $start == 1 ) { + $prevStart = false; + } else { + $prevStart = $start - $limit; + if ( $start < 1 ) { + $start = 1; + } + } + if ( $entryResults['returned'] == $limit ) { + $nextStart = $start + $limit; + } + $entry = $entryResults['list']; + if ( count( $entry ) > 0 ) { + $haveLeads = true; + } - $entry = $this->getList( $where ); + $leadCount = count( $entry ); $view = 'index.html'; @@ -277,6 +316,7 @@ class GlmMembersAdmin_travel_index extends GlmDataTravelLeads // Common things to place into the $templateData array $templateData = array( 'hasSearch' => $hasSearch, + 'params' => $params, 'lead' => $entry, 'haveLeads' => $haveLeads, 'leadCount' => $leadCount, diff --git a/views/admin/travel/index.html b/views/admin/travel/index.html index aedc873..3a96c1b 100644 --- a/views/admin/travel/index.html +++ b/views/admin/travel/index.html @@ -3,6 +3,19 @@ {include file='admin/travel/searchForm.html'} {if $lead} +
+ + + + + +
+

Total found: {$leadCount}  

+ {if $paging} + + + {/if} + @@ -16,8 +29,8 @@ {foreach $lead as $e} - - + + @@ -27,6 +40,12 @@ {/foreach}
Edit
Edit {$e.company} {$e.fname} {$e.lname}
+ + {if $paging} + + + {/if} +
{else} No search results! {/if} -- 2.17.1