From 5b26e3982846b637993622d9ad6de26ab9d352e6 Mon Sep 17 00:00:00 2001
From: AndreaChirulescu
Date: Fri, 11 Feb 2022 09:54:30 +0100
Subject: more pagination details fixes
---
includes/admin/views/_concerts_table.php | 83 ++++++++++++++++++++++----------
1 file changed, 57 insertions(+), 26 deletions(-)
(limited to 'includes/admin/views')
diff --git a/includes/admin/views/_concerts_table.php b/includes/admin/views/_concerts_table.php
index 2c72cf2..0302111 100644
--- a/includes/admin/views/_concerts_table.php
+++ b/includes/admin/views/_concerts_table.php
@@ -48,18 +48,9 @@ if (!class_exists("GiglogAdmin_ConcertsTable"))
$content .= '';
//pagination. Change value as needed
- $total_records_per_page = 10;
+ $total_records_per_page = 15;
+
- if (isset($_GET['page_no']) && $_GET['page_no']!="") {
- $page_no = $_GET['page_no'];
- } else {
- $page_no = 1;
- }
- //calculate OFFSET Value and SET other Variables
- $offset = ($page_no-1) * $total_records_per_page;
- $previous_page = $page_no - 1;
- $next_page = $page_no + 1;
- $adjacents = "2";
$filter = [];
@@ -74,17 +65,34 @@ if (!class_exists("GiglogAdmin_ConcertsTable"))
$filter['venue_id'] = $venue;
}
+ $smonth = filter_input( INPUT_POST, 'selectmonth', FILTER_SANITIZE_SPECIAL_CHARS );
+ if ($smonth) {
+ $filter['month'] = $smonth;
+ }
+
if(isset($_POST['ownconcerts']) && $_POST['ownconcerts'] == '1') {
$filter['currentuser'] = wp_get_current_user()->user_login;
}
$concerts = GiglogAdmin_Concert::find_concerts($filter);
+
//get number of pages for pagination
$total_records = count($concerts);
$total_no_of_pages = ceil($total_records / $total_records_per_page);
$second_last = $total_no_of_pages - 1; // total pages minus 1
+ if (isset($_GET['page_no']) && $_GET['page_no']!="" && $_GET['page_no']<=$total_no_of_pages) {
+ $page_no = $_GET['page_no'];
+ } else {
+ $page_no = 1;
+ }
+ //calculate OFFSET Value and SET other Variables
+ $offset = ($page_no-1) * $total_records_per_page;
+ $previous_page = $page_no - 1;
+ $next_page = $page_no + 1;
+ $adjacents = "2";
+
$filter['offset'] = $offset;
$filter['recperpage'] = $total_records_per_page;
@@ -138,22 +146,31 @@ if (!class_exists("GiglogAdmin_ConcertsTable"))
$content .= '';
$lastType = $concert->venue()->city();
}
- $content .= '';
- // $content .='Page '.$page_no.' of '.$total_no_of_pages.'
';
-
- $content .='
';
// return the table
return $content;
@@ -182,13 +199,27 @@ if (!class_exists("GiglogAdmin_ConcertsTable"))
filter_input(INPUT_POST, 'selectvenue', FILTER_SANITIZE_SPECIAL_CHARS),
"Select venue...");
}
+
+ $select.=' Filter by month: ';
+ $select.= '';
+
if(is_admin()) {
//option to select own concerts only
$select .= '';
+
}
- $select .= '';
+ //NOTE that I remvoed and mvoed them up to render_concerts_table function
+ $select .= '';
return $select;
}
--
cgit v1.2.3