Fixes the pagination for components
parent
76e061e1cb
commit
5d06a7222c
|
@ -9,7 +9,7 @@ class Component {
|
||||||
|
|
||||||
|
|
||||||
// list of component events
|
// list of component events
|
||||||
public function jitsiComponents($jitsi_component, $component_id, $from_time, $until_time) {
|
public function jitsiComponents($jitsi_component, $component_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
|
||||||
|
@ -37,6 +37,11 @@ AND
|
||||||
ORDER BY
|
ORDER BY
|
||||||
time";
|
time";
|
||||||
|
|
||||||
|
if ($items_per_page) {
|
||||||
|
$items_per_page = (int)$items_per_page;
|
||||||
|
$sql .= ' LIMIT ' . $offset . ',' . $items_per_page;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = sprintf($sql, $jitsi_component, $component_id, $from_time, $until_time);
|
$sql = sprintf($sql, $jitsi_component, $component_id, $from_time, $until_time);
|
||||||
|
|
||||||
$query = $this->db->prepare($sql);
|
$query = $this->db->prepare($sql);
|
||||||
|
|
|
@ -31,10 +31,21 @@ if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
|
||||||
// list of all component events (default)
|
// list of all component events (default)
|
||||||
$componentObject = new Component($db);
|
$componentObject = new Component($db);
|
||||||
|
|
||||||
|
// pagination variables
|
||||||
|
$items_per_page = 15;
|
||||||
|
$browse_page = $_REQUEST['p'] ?? 1;
|
||||||
|
$browse_page = (int)$browse_page;
|
||||||
|
$offset = ($browse_page -1) * $items_per_page;
|
||||||
|
|
||||||
// prepare the result
|
// prepare the result
|
||||||
$search = $componentObject->jitsiComponents($jitsi_component, $component_id, $from_time, $until_time);
|
$search = $componentObject->jitsiComponents($jitsi_component, $component_id, $from_time, $until_time, $offset, $items_per_page);
|
||||||
|
$search_all = $componentObject->jitsiComponents($jitsi_component, $component_id, $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);
|
||||||
|
|
||||||
$components = array();
|
$components = array();
|
||||||
$components['records'] = array();
|
$components['records'] = array();
|
||||||
|
|
||||||
|
@ -60,6 +71,7 @@ $widget['name'] = 'AllComponents';
|
||||||
$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'] != '') {
|
||||||
|
|
|
@ -69,6 +69,8 @@ $widget['filter'] = false;
|
||||||
if (!empty($searchConferenceNumber) && !empty($searchParticipantNumber)) {
|
if (!empty($searchConferenceNumber) && !empty($searchParticipantNumber)) {
|
||||||
$widget['full'] = true;
|
$widget['full'] = true;
|
||||||
}
|
}
|
||||||
|
$widget['pagination'] = false;
|
||||||
|
|
||||||
|
|
||||||
// display the widget
|
// display the widget
|
||||||
include '../app/templates/widget-monthly.php';
|
include '../app/templates/widget-monthly.php';
|
||||||
|
@ -127,6 +129,7 @@ if (!empty($conferences['records'])) {
|
||||||
$widget['table_headers'] = array_keys($conferences['records'][0]);
|
$widget['table_headers'] = array_keys($conferences['records'][0]);
|
||||||
$widget['table_records'] = $conferences['records'];
|
$widget['table_records'] = $conferences['records'];
|
||||||
}
|
}
|
||||||
|
$widget['pagination'] = false;
|
||||||
|
|
||||||
// display the widget
|
// display the widget
|
||||||
include '../app/templates/widget.php';
|
include '../app/templates/widget.php';
|
||||||
|
@ -187,6 +190,7 @@ $widget['title'] = 'The last ' . $conference_number . ' conferences';
|
||||||
$widget['collapsible'] = true;
|
$widget['collapsible'] = true;
|
||||||
$widget['collapsed'] = false;
|
$widget['collapsed'] = false;
|
||||||
$widget['filter'] = false;
|
$widget['filter'] = false;
|
||||||
|
$widget['pagination'] = false;
|
||||||
|
|
||||||
if (!empty($conferences['records'])) {
|
if (!empty($conferences['records'])) {
|
||||||
$widget['full'] = true;
|
$widget['full'] = true;
|
||||||
|
|
Loading…
Reference in New Issue