$accountAdded = false;
$accountAddError = false;
$namesList = false;
+ $numbDisplayed = false;
+ $lastDisplayed = false;
// Get any provided option
if (isset($_REQUEST['option'])) {
default:
$where = 'true';
- $accounts = $this->getList();
- $hasAccounts = ( $accounts !== false && count( $accounts > 0 ) ) ? true: false;
- $view = 'account';
+ // 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;
+ }
+ }
// Check if we have a Text Search string
- if (isset($_REQUEST['textSearch']) && trim($_REQUEST['textSearch']) != '') {
- $textSearch = trim($_REQUEST['textSearch']);
+ if ( isset( $_REQUEST['textSearch'] ) && trim( $_REQUEST['textSearch'] ) != '' ) {
+ $textSearch = trim( $_REQUEST['textSearch'] );
$where .= " AND ( lname LIKE '%$textSearch%' OR fname LIKE '%$textSearch%' OR CONCAT_WS( ' ', fname, lname) LIKE '%$textSearch%' )";
}
+ $accountsResult = $this->getList( $where, 'lname', true, 'id', $start, $limit );
+ //echo '<pre>$accountsResult: ' . print_r( $accountsResult, true ) . '</pre>';
+
+ //$accounts = $this->getList( $where );
+ //echo '<pre>$where: ' . print_r( $where, true ) . '</pre>';
+
+ // Get paging results
+ $numbDisplayed = $accountsResult['returned'];
+ $lastDisplayed = $accountsResult['last'];
+ if ($start == 1) {
+ $prevStart = false;
+ } else {
+ $prevStart = $start - $limit;
+ if ($start < 1) {
+ $start = 1;
+ }
+ }
+ if ( $accountsResult['returned'] == $limit ) {
+ $nextStart = $start + $limit;
+ }
+
+ // since we're doing paging, we have to break out just the accounts data
+ $accounts = $accountsResult['list'];
+
+ $hasAccounts = ( $accounts !== false && count( $accounts > 0 ) ) ? true: false;
+ $view = 'account';
+
// Get full list of names matching this where clause for search box
- $namesList = $this->getIdName($where);
+ $namesList = $this->getIdName( $where );
+ unset( $accountsResult );
break;
}
// Compile template data
$templateData = array(
'hasAccounts' => $hasAccounts,
- 'numAccounts' => count($accounts),
+ 'numAccounts' => ($accounts) ? count($accounts) : 0,
'accounts' => $accounts,
'account' => $account,
'limit' => $limit,
'accountAdded' => $accountAdded,
'accountAddError' => $accountAddError,
'namesList' => $namesList,
+ 'numbDisplayed' => $numbDisplayed,
+ 'lastDisplayed' => $lastDisplayed,
);
// Return status, any suggested view, and any data to controller
return array(
<input type="hidden" name="prevStart" value="{$prevStart}">
<input type="hidden" name="nextStart" value="{$nextStart}">
<input type="hidden" name="limit" value="{$limit}">
+
<div class="">
<p>
<span class="glm-nowrap">
<br clear="all">
<p><b>Total found:</b> {$numAccounts} </p>
- {if $paging}
+ {if $paging && $numAccounts}
<input type="Submit" name="pageSelect" value="Previous {$limit} Events" class="button button-secondary glm-button"{if !$prevStart} disabled{/if}>
<input type="Submit" name="pageSelect" value="Next {$limit} Events" class="button button-secondary glm-button"{if !$nextStart} disabled{/if}>
{/if}
</table>
{/if}
- {if $paging}
+ {if $paging && $numAccounts}
<input type="Submit" name="pageSelect" value="Previous {$limit} Events" class="button button-secondary glm-button"{if !$prevStart} disabled{/if}>
<input type="Submit" name="pageSelect" value="Next {$limit} Events" class="button button-secondary glm-button"{if !$nextStart} disabled{/if}>
{/if}