Adds pagination
parent
8a2f082b09
commit
2478f84e85
|
@ -9,7 +9,7 @@ class Conference {
|
||||||
|
|
||||||
|
|
||||||
// search/list specific conference ID
|
// search/list specific conference ID
|
||||||
public function conferenceById($conference_id, $from_time, $until_time) {
|
public function conferenceById($conference_id, $from_time, $until_time, $offset=0, $items_per_page='') {
|
||||||
|
|
||||||
// time period drill-down
|
// time period drill-down
|
||||||
// FIXME make it similar to the bash version
|
// FIXME make it similar to the bash version
|
||||||
|
@ -69,6 +69,11 @@ AND (event_time >= '%s 00:00:00' AND event_time <= '%s 23:59:59')
|
||||||
ORDER BY
|
ORDER BY
|
||||||
pe.time";
|
pe.time";
|
||||||
|
|
||||||
|
if ($items_per_page) {
|
||||||
|
$items_per_page = (int)$items_per_page;
|
||||||
|
$sql .= ' LIMIT ' . $offset . ',' . $items_per_page;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = sprintf($sql, $conference_id, $from_time, $until_time, $conference_id, $from_time, $until_time);
|
$sql = sprintf($sql, $conference_id, $from_time, $until_time, $conference_id, $from_time, $until_time);
|
||||||
|
|
||||||
$query = $this->db->prepare($sql);
|
$query = $this->db->prepare($sql);
|
||||||
|
@ -79,7 +84,7 @@ ORDER BY
|
||||||
|
|
||||||
|
|
||||||
// search/list specific conference name
|
// search/list specific conference name
|
||||||
public function conferenceByName($conference_name, $from_time, $until_time) {
|
public function conferenceByName($conference_name, $from_time, $until_time, $offset=0, $items_per_page='') {
|
||||||
|
|
||||||
// time period drill-down
|
// time period drill-down
|
||||||
// FIXME make it similar to the bash version
|
// FIXME make it similar to the bash version
|
||||||
|
@ -139,6 +144,11 @@ AND (event_time >= '%s 00:00:00' AND event_time <= '%s 23:59:59')
|
||||||
ORDER BY
|
ORDER BY
|
||||||
pe.time";
|
pe.time";
|
||||||
|
|
||||||
|
if ($items_per_page) {
|
||||||
|
$items_per_page = (int)$items_per_page;
|
||||||
|
$sql .= ' LIMIT ' . $offset . ',' . $items_per_page;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = sprintf($sql, $conference_name, $from_time, $until_time, $conference_name, $from_time, $until_time);
|
$sql = sprintf($sql, $conference_name, $from_time, $until_time, $conference_name, $from_time, $until_time);
|
||||||
|
|
||||||
$query = $this->db->prepare($sql);
|
$query = $this->db->prepare($sql);
|
||||||
|
@ -149,7 +159,7 @@ ORDER BY
|
||||||
|
|
||||||
|
|
||||||
// list of all conferences
|
// list of all conferences
|
||||||
public function conferencesAllFormatted($from_time, $until_time) {
|
public function conferencesAllFormatted($from_time, $until_time, $offset=0, $items_per_page='') {
|
||||||
|
|
||||||
// time period drill-down
|
// time period drill-down
|
||||||
// FIXME make it similar to the bash version
|
// FIXME make it similar to the bash version
|
||||||
|
@ -234,6 +244,11 @@ WHERE (ce.time >= '%s 00:00:00' AND ce.time <= '%s 23:59:59')
|
||||||
ORDER BY
|
ORDER BY
|
||||||
c.id";
|
c.id";
|
||||||
|
|
||||||
|
if ($items_per_page) {
|
||||||
|
$items_per_page = (int)$items_per_page;
|
||||||
|
$sql .= ' LIMIT ' . $offset . ',' . $items_per_page;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = sprintf($sql, $from_time, $until_time);
|
$sql = sprintf($sql, $from_time, $until_time);
|
||||||
|
|
||||||
$query = $this->db->prepare($sql);
|
$query = $this->db->prepare($sql);
|
||||||
|
|
|
@ -9,7 +9,7 @@ class Participant {
|
||||||
|
|
||||||
|
|
||||||
// search/list specific participant ID
|
// search/list specific participant ID
|
||||||
public function conferenceByParticipantId($participant_id, $from_time, $until_time) {
|
public function conferenceByParticipantId($participant_id, $from_time, $until_time, $offset=0, $items_per_page='') {
|
||||||
|
|
||||||
// time period drill-down
|
// time period drill-down
|
||||||
// FIXME make it similar to the bash version
|
// FIXME make it similar to the bash version
|
||||||
|
@ -69,6 +69,11 @@ AND (event_time >= '%s 00:00:00' AND event_time <= '%s 23:59:59')
|
||||||
ORDER BY
|
ORDER BY
|
||||||
pe.time";
|
pe.time";
|
||||||
|
|
||||||
|
if ($items_per_page) {
|
||||||
|
$items_per_page = (int)$items_per_page;
|
||||||
|
$sql .= ' LIMIT ' . $offset . ',' . $items_per_page;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = sprintf($sql, $participant_id, $from_time, $until_time, $participant_id, $from_time, $until_time);
|
$sql = sprintf($sql, $participant_id, $from_time, $until_time, $participant_id, $from_time, $until_time);
|
||||||
|
|
||||||
$query = $this->db->prepare($sql);
|
$query = $this->db->prepare($sql);
|
||||||
|
@ -79,7 +84,7 @@ ORDER BY
|
||||||
|
|
||||||
|
|
||||||
// search/list specific participant name (stats_id)
|
// search/list specific participant name (stats_id)
|
||||||
public function conferenceByParticipantName($participant_name, $from_time, $until_time) {
|
public function conferenceByParticipantName($participant_name, $from_time, $until_time, $offset=0, $items_per_page='') {
|
||||||
|
|
||||||
// time period drill-down
|
// time period drill-down
|
||||||
// FIXME make it similar to the bash version
|
// FIXME make it similar to the bash version
|
||||||
|
@ -139,6 +144,11 @@ AND (event_time >= '%s 00:00:00' AND event_time <= '%s 23:59:59')
|
||||||
ORDER BY
|
ORDER BY
|
||||||
pe.time";
|
pe.time";
|
||||||
|
|
||||||
|
if ($items_per_page) {
|
||||||
|
$items_per_page = (int)$items_per_page;
|
||||||
|
$sql .= ' LIMIT ' . $offset . ',' . $items_per_page;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = sprintf($sql, $participant_name, $from_time, $until_time, $participant_name, $from_time, $until_time);
|
$sql = sprintf($sql, $participant_name, $from_time, $until_time, $participant_name, $from_time, $until_time);
|
||||||
|
|
||||||
$query = $this->db->prepare($sql);
|
$query = $this->db->prepare($sql);
|
||||||
|
@ -149,7 +159,7 @@ ORDER BY
|
||||||
|
|
||||||
|
|
||||||
// search/list specific participant IP
|
// search/list specific participant IP
|
||||||
public function conferenceByParticipantIP($participant_ip, $from_time, $until_time) {
|
public function conferenceByParticipantIP($participant_ip, $from_time, $until_time, $offset=0, $items_per_page='') {
|
||||||
|
|
||||||
// time period drill-down
|
// time period drill-down
|
||||||
// FIXME make it similar to the bash version
|
// FIXME make it similar to the bash version
|
||||||
|
@ -209,6 +219,11 @@ AND (event_time >= '%s 00:00:00' AND event_time <= '%s 23:59:59')
|
||||||
ORDER BY
|
ORDER BY
|
||||||
pe.time";
|
pe.time";
|
||||||
|
|
||||||
|
if ($items_per_page) {
|
||||||
|
$items_per_page = (int)$items_per_page;
|
||||||
|
$sql .= ' LIMIT ' . $offset . ',' . $items_per_page;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = sprintf($sql, $participant_ip, $from_time, $until_time, $participant_ip, $from_time, $until_time);
|
$sql = sprintf($sql, $participant_ip, $from_time, $until_time, $participant_ip, $from_time, $until_time);
|
||||||
|
|
||||||
$query = $this->db->prepare($sql);
|
$query = $this->db->prepare($sql);
|
||||||
|
@ -219,7 +234,7 @@ ORDER BY
|
||||||
|
|
||||||
|
|
||||||
// list of all participants
|
// list of all participants
|
||||||
public function participantsAll($from_time, $until_time) {
|
public function participantsAll($from_time, $until_time, $offset=0, $items_per_page='') {
|
||||||
|
|
||||||
// time period drill-down
|
// time period drill-down
|
||||||
// FIXME make it similar to the bash version
|
// FIXME make it similar to the bash version
|
||||||
|
@ -246,6 +261,11 @@ WHERE
|
||||||
pe.time >= '%s 00:00:00' AND pe.time <= '%s 23:59:59'
|
pe.time >= '%s 00:00:00' AND pe.time <= '%s 23:59:59'
|
||||||
ORDER BY p.id";
|
ORDER BY p.id";
|
||||||
|
|
||||||
|
if ($items_per_page) {
|
||||||
|
$items_per_page = (int)$items_per_page;
|
||||||
|
$sql .= ' LIMIT ' . $offset . ',' . $items_per_page;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = sprintf($sql, $from_time, $until_time);
|
$sql = sprintf($sql, $from_time, $until_time);
|
||||||
|
|
||||||
$query = $this->db->prepare($sql);
|
$query = $this->db->prepare($sql);
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<div class="pagination">
|
||||||
|
<?php
|
||||||
|
$param = '';
|
||||||
|
if (isset($_GET['id'])) {
|
||||||
|
$param .= '&id=' . $_GET['id'];
|
||||||
|
}
|
||||||
|
if (isset($_GET['name'])) {
|
||||||
|
$param .= '&name=' . $_GET['name'];
|
||||||
|
}
|
||||||
|
if (isset($_GET['ip'])) {
|
||||||
|
$param .= '&ip=' . $_GET['ip'];
|
||||||
|
}
|
||||||
|
if ($browse_page > 1) {
|
||||||
|
echo '<span><a href="' . $url . '&p=1">first</a></span>';
|
||||||
|
} else {
|
||||||
|
echo '<span>first</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($i = 1; $i <= $page_count; $i++) {
|
||||||
|
if ($i === $browse_page) {
|
||||||
|
if ($browse_page > 1) {
|
||||||
|
echo '<span><a href="' . $app_root . '?platform=' . $platform_id . '&page=' . $page . $param . '&p=' . ($browse_page -1) . '"><<</a></span>';
|
||||||
|
} else {
|
||||||
|
echo '<span><<</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '[' . $i . ']';
|
||||||
|
if ($browse_page < $page_count) {
|
||||||
|
echo '<span><a href="' . $app_root . '?platform=' . $platform_id . '&page=' . $page . $param . '&p=' . ($browse_page +1) . '">>></a></span>';
|
||||||
|
} else {
|
||||||
|
echo '<span>>></span>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo '<span><a href="' . $app_root . '?platform=' . $platform_id . '&page=' . $page . $param . '&p=' . $i . '">[' . $i . ']</a></span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($browse_page < $page_count) {
|
||||||
|
echo '<span><a href="' . $app_root . '?platform=' . $platform_id . '&page=' . $page . $param . '&p=' . ($page_count) . '">last</a></span>';
|
||||||
|
} else {
|
||||||
|
echo '<span>last</span>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -31,18 +31,31 @@ if (isset($_REQUEST['id']) && $_REQUEST['id'] != '') {
|
||||||
|
|
||||||
$conferenceObject = new Conference($db);
|
$conferenceObject = new Conference($db);
|
||||||
|
|
||||||
|
// pagination variables
|
||||||
|
$items_per_page = 15;
|
||||||
|
$browse_page = $_REQUEST['p'] ?? 1;
|
||||||
|
$browse_page = (int)$browse_page;
|
||||||
|
$offset = ($browse_page -1) * $items_per_page;
|
||||||
|
|
||||||
// search and list specific conference ID
|
// search and list specific conference ID
|
||||||
if (isset($conferenceId)) {
|
if (isset($conferenceId)) {
|
||||||
$search = $conferenceObject->conferenceById($conferenceId, $from_time, $until_time);
|
$search = $conferenceObject->conferenceById($conferenceId, $from_time, $until_time, $offset, $items_per_page);
|
||||||
|
$search_all = $conferenceObject->conferenceById($conferenceId, $from_time, $until_time);
|
||||||
// search and list specific conference name
|
// search and list specific conference name
|
||||||
} elseif (isset($conferenceName)) {
|
} elseif (isset($conferenceName)) {
|
||||||
$search = $conferenceObject->conferenceByName($conferenceName, $from_time, $until_time);
|
$search = $conferenceObject->conferenceByName($conferenceName, $from_time, $until_time, $offset, $items_per_page);
|
||||||
|
$search_all = $conferenceObject->conferenceByName($conferenceName, $from_time, $until_time);
|
||||||
// list of all conferences (default)
|
// list of all conferences (default)
|
||||||
} else {
|
} else {
|
||||||
$search = $conferenceObject->conferencesAllFormatted($from_time, $until_time);
|
$search = $conferenceObject->conferencesAllFormatted($from_time, $until_time, $offset, $items_per_page);
|
||||||
|
$search_all = $conferenceObject->conferencesAllFormatted($from_time, $until_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($search)) {
|
if (!empty($search)) {
|
||||||
|
// we get total items and number of pages
|
||||||
|
$item_count = count($search_all);
|
||||||
|
$page_count = ceil($item_count / $items_per_page);
|
||||||
|
|
||||||
$conferences = array();
|
$conferences = array();
|
||||||
$conferences['records'] = array();
|
$conferences['records'] = array();
|
||||||
|
|
||||||
|
@ -109,6 +122,7 @@ $widget['name'] = 'Conferences';
|
||||||
$widget['collapsible'] = false;
|
$widget['collapsible'] = false;
|
||||||
$widget['collapsed'] = false;
|
$widget['collapsed'] = false;
|
||||||
$widget['filter'] = true;
|
$widget['filter'] = true;
|
||||||
|
$widget['pagination'] = true;
|
||||||
|
|
||||||
// widget title
|
// widget title
|
||||||
if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
|
if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
|
||||||
|
|
|
@ -34,22 +34,36 @@ if (isset($_REQUEST['id']) && $_REQUEST['id'] != '') {
|
||||||
|
|
||||||
$participantObject = new Participant($db);
|
$participantObject = new Participant($db);
|
||||||
|
|
||||||
|
// pagination variables
|
||||||
|
$items_per_page = 15;
|
||||||
|
$browse_page = $_REQUEST['p'] ?? 1;
|
||||||
|
$browse_page = (int)$browse_page;
|
||||||
|
$offset = ($browse_page -1) * $items_per_page;
|
||||||
|
|
||||||
// search and list specific participant ID
|
// search and list specific participant ID
|
||||||
if (isset($participantId)) {
|
if (isset($participantId)) {
|
||||||
$search = $participantObject->conferenceByParticipantId($participantId, $from_time, $until_time, $participantId, $from_time, $until_time);
|
$search = $participantObject->conferenceByParticipantId($participantId, $from_time, $until_time, $offset, $items_per_page);
|
||||||
|
$search_all = $participantObject->conferenceByParticipantId($participantId, $from_time, $until_time);
|
||||||
// search and list specific participant name (stats_id)
|
// search and list specific participant name (stats_id)
|
||||||
} elseif (isset($participantName)) {
|
} elseif (isset($participantName)) {
|
||||||
$search = $participantObject->conferenceByParticipantName($participantName, $from_time, $until_time);
|
$search = $participantObject->conferenceByParticipantName($participantName, $from_time, $until_time, $offset, $items_per_page);
|
||||||
|
$search_all = $participantObject->conferenceByParticipantName($participantName, $from_time, $until_time);
|
||||||
// search and list specific participant IP
|
// search and list specific participant IP
|
||||||
} elseif (isset($participantIp)) {
|
} elseif (isset($participantIp)) {
|
||||||
$search = $participantObject->conferenceByParticipantIP($participantIp, $from_time, $until_time);
|
$search = $participantObject->conferenceByParticipantIP($participantIp, $from_time, $until_time, $offset, $items_per_page);
|
||||||
|
$search_all = $participantObject->conferenceByParticipantIP($participantIp, $from_time, $until_time);
|
||||||
// list of all participants (default)
|
// list of all participants (default)
|
||||||
} else {
|
} else {
|
||||||
// prepare the result
|
// prepare the result
|
||||||
$search = $participantObject->participantsAll($from_time, $until_time);
|
$search = $participantObject->participantsAll($from_time, $until_time, $offset, $items_per_page);
|
||||||
|
$search_all = $participantObject->participantsAll($from_time, $until_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($search)) {
|
if (!empty($search)) {
|
||||||
|
// we get total items and number of pages
|
||||||
|
$item_count = count($search_all);
|
||||||
|
$page_count = ceil($item_count / $items_per_page);
|
||||||
|
|
||||||
$participants = array();
|
$participants = array();
|
||||||
$participants['records'] = array();
|
$participants['records'] = array();
|
||||||
|
|
||||||
|
@ -116,6 +130,7 @@ $widget['name'] = 'Participants';
|
||||||
$widget['collapsible'] = false;
|
$widget['collapsible'] = false;
|
||||||
$widget['collapsed'] = false;
|
$widget['collapsed'] = false;
|
||||||
$widget['filter'] = true;
|
$widget['filter'] = true;
|
||||||
|
$widget['pagination'] = true;
|
||||||
|
|
||||||
// widget title
|
// widget title
|
||||||
if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
|
if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
|
||||||
|
|
|
@ -68,6 +68,12 @@
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<?php
|
||||||
|
if ($widget['pagination'] && $item_count > $items_per_page) {
|
||||||
|
$url = "$app_root?platform=$platform_id&page=$page";
|
||||||
|
include '../app/helpers/pagination.php';
|
||||||
|
}
|
||||||
|
?>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<p class="m-3">No matching records found.</p>
|
<p class="m-3">No matching records found.</p>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
|
@ -230,3 +230,13 @@
|
||||||
left: 5px;
|
left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
font-size: 0.66em;
|
||||||
|
text-align: center;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination span {
|
||||||
|
margin-left: 5px;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue