Adds widget for monthly conferences number
parent
c0c072884f
commit
42f9738128
|
@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
|
||||||
### Added
|
### Added
|
||||||
- Added collapsible front page widgets
|
- Added collapsible front page widgets
|
||||||
- Added widgets to conferences, participants and components pages
|
- Added widgets to conferences, participants and components pages
|
||||||
|
- Added front page widget for monthly conferences number
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- MVC design - models(classes folder), views(templates folder) and controllers(pages folder)
|
- MVC design - models(classes folder), views(templates folder) and controllers(pages folder)
|
||||||
|
|
|
@ -84,6 +84,30 @@ class Conference {
|
||||||
return $query->fetchAll(PDO::FETCH_ASSOC);
|
return $query->fetchAll(PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// number of conferences
|
||||||
|
public function conferencesNumber($from_time, $until_time) {
|
||||||
|
|
||||||
|
// time period drill-down
|
||||||
|
// FIXME make it similar to the bash version
|
||||||
|
if (empty($from_time)) {
|
||||||
|
$from_time = '0000-01-01';
|
||||||
|
}
|
||||||
|
if (empty($until_time)) {
|
||||||
|
$until_time = '9999-12-31';
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is needed for compatibility with the bash version, so we use '%s' placeholders
|
||||||
|
$from_time = htmlspecialchars(strip_tags($from_time));
|
||||||
|
$until_time = htmlspecialchars(strip_tags($until_time));
|
||||||
|
$sql = $this->queries['conferences_number'];
|
||||||
|
$sql = sprintf($sql, $from_time, $until_time);
|
||||||
|
|
||||||
|
$query = $this->db->prepare($sql);
|
||||||
|
$query->execute();
|
||||||
|
|
||||||
|
return $query->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,64 @@
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
|
// number of conferences for time period (if given)
|
||||||
|
'conferences_number' => "
|
||||||
|
SELECT COUNT(c.conference_id) as conferences
|
||||||
|
FROM
|
||||||
|
conferences c
|
||||||
|
LEFT JOIN
|
||||||
|
conference_events ce ON c.conference_id = ce.conference_id
|
||||||
|
WHERE (ce.time >= '%s 00:00:00' AND ce.time <= '%s 23:59:59')",
|
||||||
|
|
||||||
|
|
||||||
|
// search for a conference by its ID for a time period (if given)
|
||||||
|
'conference_by_id' => "
|
||||||
|
SELECT
|
||||||
|
pe.time,
|
||||||
|
c.conference_id,
|
||||||
|
c.conference_name,
|
||||||
|
c.conference_host,
|
||||||
|
pe.loglevel,
|
||||||
|
pe.event_type,
|
||||||
|
p.endpoint_id AS participant_id,
|
||||||
|
pe.event_param
|
||||||
|
FROM
|
||||||
|
conferences c
|
||||||
|
LEFT JOIN
|
||||||
|
conference_events ce ON c.conference_id = ce.conference_id
|
||||||
|
LEFT JOIN
|
||||||
|
participants p ON c.conference_id = p.conference_id
|
||||||
|
LEFT JOIN
|
||||||
|
participant_events pe ON p.endpoint_id = pe.participant_id
|
||||||
|
WHERE
|
||||||
|
c.conference_id = '%s'
|
||||||
|
AND (pe.time >= '%s 00:00:00' AND pe.time <= '%s 23:59:59')
|
||||||
|
|
||||||
|
UNION
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
ce.time AS event_time,
|
||||||
|
c.conference_id,
|
||||||
|
c.conference_name,
|
||||||
|
c.conference_host,
|
||||||
|
ce.loglevel,
|
||||||
|
ce.conference_event AS event_type,
|
||||||
|
NULL AS participant_id,
|
||||||
|
ce.conference_param AS event_param
|
||||||
|
FROM
|
||||||
|
conferences c
|
||||||
|
LEFT JOIN
|
||||||
|
conference_events ce ON c.conference_id = ce.conference_id
|
||||||
|
WHERE
|
||||||
|
c.conference_id = '%s'
|
||||||
|
AND (event_time >= '%s 00:00:00' AND event_time <= '%s 23:59:59')
|
||||||
|
|
||||||
|
ORDER BY
|
||||||
|
pe.time;",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// list of conferences for time period (if given)
|
// list of conferences for time period (if given)
|
||||||
// fields: component, duration, conference ID, conference name, number of participants, name count (the conf name is found), conference host
|
// fields: component, duration, conference ID, conference name, number of participants, name count (the conf name is found), conference host
|
||||||
'conferences_all_formatted' => "
|
'conferences_all_formatted' => "
|
||||||
|
|
|
@ -83,27 +83,27 @@ if (in_array($page, $allowed_urls)) {
|
||||||
setcookie('username', "", time() - 100, $config['folder'], $config['domain'], isset($_SERVER['HTTPS']), true);
|
setcookie('username', "", time() - 100, $config['folder'], $config['domain'], isset($_SERVER['HTTPS']), true);
|
||||||
|
|
||||||
$notice = "You were logged out.<br />You can log in again.";
|
$notice = "You were logged out.<br />You can log in again.";
|
||||||
include 'templates/header.php';
|
include 'templates/page-header.php';
|
||||||
include 'templates/menu.php';
|
include 'templates/page-menu.php';
|
||||||
include 'templates/message.php';
|
include 'templates/block-message.php';
|
||||||
include 'pages/login.php';
|
include 'pages/login.php';
|
||||||
|
|
||||||
// all other normal pages
|
// all other normal pages
|
||||||
} else {
|
} else {
|
||||||
include 'templates/header.php';
|
include 'templates/page-header.php';
|
||||||
include 'templates/menu.php';
|
include 'templates/page-menu.php';
|
||||||
include 'templates/message.php';
|
include 'templates/block-message.php';
|
||||||
include "pages/{$page}.php";
|
include "pages/{$page}.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
// the page is not in allowed urls, loading front page
|
// the page is not in allowed urls, loading front page
|
||||||
} else {
|
} else {
|
||||||
include 'templates/header.php';
|
include 'templates/page-header.php';
|
||||||
include 'templates/menu.php';
|
include 'templates/page-menu.php';
|
||||||
include 'templates/message.php';
|
include 'templates/block-message.php';
|
||||||
include 'pages/front.php';
|
include 'pages/front.php';
|
||||||
}
|
}
|
||||||
include 'templates/footer.php';
|
include 'templates/page-footer.php';
|
||||||
|
|
||||||
// clear errors and notices before next page just in case
|
// clear errors and notices before next page just in case
|
||||||
unset($_SESSION['error']);
|
unset($_SESSION['error']);
|
||||||
|
|
|
@ -37,7 +37,7 @@ try {
|
||||||
$db = new Database($config['jilo_database']);
|
$db = new Database($config['jilo_database']);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$error = 'Error: ' . $e->getMessage();
|
$error = 'Error: ' . $e->getMessage();
|
||||||
include 'templates/message.php';
|
include 'templates/block-message.php';
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ try {
|
||||||
$db = new Database($config['jilo_database']);
|
$db = new Database($config['jilo_database']);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$error = 'Error: ' . $e->getMessage();
|
$error = 'Error: ' . $e->getMessage();
|
||||||
include 'templates/message.php';
|
include 'templates/block-message.php';
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ try {
|
||||||
$db = new Database($config['jilo_database']);
|
$db = new Database($config['jilo_database']);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$error = 'Error: ' . $e->getMessage();
|
$error = 'Error: ' . $e->getMessage();
|
||||||
include 'templates/message.php';
|
include 'templates/block-message.php';
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,11 +16,67 @@ try {
|
||||||
// dashboard widget listings
|
// dashboard widget listings
|
||||||
//
|
//
|
||||||
|
|
||||||
// conferences in last 7 days
|
|
||||||
try {
|
////
|
||||||
|
// monthly usage
|
||||||
$conference = new Conference($db);
|
$conference = new Conference($db);
|
||||||
|
|
||||||
// conferences for last 2 days
|
// monthly conferences for the last year
|
||||||
|
$fromMonth = (new DateTime())->sub(new DateInterval('P1Y'));
|
||||||
|
$fromMonth->modify('first day of this month');
|
||||||
|
$thisMonth = new DateTime();
|
||||||
|
$from_time = $fromMonth->format('Y-m-d');
|
||||||
|
$until_time = $thisMonth->format('Y-m-d');
|
||||||
|
|
||||||
|
$widget['table_headers'] = array();
|
||||||
|
$widget['table_records'] = array();
|
||||||
|
|
||||||
|
// loop 1 year in the past
|
||||||
|
while ($fromMonth < $thisMonth) {
|
||||||
|
|
||||||
|
$untilMonth = clone $fromMonth;
|
||||||
|
$untilMonth->modify('last day of this month');
|
||||||
|
|
||||||
|
$search = $conference->conferencesNumber($fromMonth->format('Y-m-d'), $untilMonth->format('Y-m-d'));
|
||||||
|
|
||||||
|
// pretty format for displaying the month in the widget
|
||||||
|
$month = $fromMonth->format('F Y');
|
||||||
|
|
||||||
|
// populate the table
|
||||||
|
array_push($widget['table_headers'], $month);
|
||||||
|
if (isset($search[0]['conferences'])) {
|
||||||
|
array_push($widget['table_records'], $search[0]['conferences']);
|
||||||
|
} else {
|
||||||
|
array_push($widget['table_records'], '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
// move everything one month in future
|
||||||
|
$untilMonth->add(new DateInterval('P1M'));
|
||||||
|
$fromMonth->add(new DateInterval('P1M'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$time_range_specified = true;
|
||||||
|
|
||||||
|
// prepare the widget
|
||||||
|
$widget['full'] = false;
|
||||||
|
$widget['name'] = 'LastYearMonths';
|
||||||
|
$widget['title'] = 'Conferences monthly number for the last year';
|
||||||
|
$widget['collapsible'] = true;
|
||||||
|
$widget['collapsed'] = false;
|
||||||
|
$widget['filter'] = false;
|
||||||
|
if (!empty($search)) {
|
||||||
|
$widget['full'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// display the widget
|
||||||
|
include('templates/widget-monthly.php');
|
||||||
|
|
||||||
|
|
||||||
|
////
|
||||||
|
// conferences in last 2 days
|
||||||
|
$conference = new Conference($db);
|
||||||
|
|
||||||
|
// time range limit
|
||||||
$from_time = date('Y-m-d', time() - 60 * 60 * 24 * 2);
|
$from_time = date('Y-m-d', time() - 60 * 60 * 24 * 2);
|
||||||
$until_time = date('Y-m-d', time());
|
$until_time = date('Y-m-d', time());
|
||||||
$time_range_specified = true;
|
$time_range_specified = true;
|
||||||
|
@ -58,12 +114,6 @@ try {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$error = 'Error: ' . $e->getMessage();
|
|
||||||
include 'templates/message.php';
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
// prepare the widget
|
// prepare the widget
|
||||||
$widget['full'] = false;
|
$widget['full'] = false;
|
||||||
$widget['name'] = 'LastDays';
|
$widget['name'] = 'LastDays';
|
||||||
|
@ -81,8 +131,8 @@ if (!empty($conferences['records'])) {
|
||||||
include('templates/widget.php');
|
include('templates/widget.php');
|
||||||
|
|
||||||
|
|
||||||
|
////
|
||||||
// last 10 conferences
|
// last 10 conferences
|
||||||
try {
|
|
||||||
$conference = new Conference($db);
|
$conference = new Conference($db);
|
||||||
|
|
||||||
// all time
|
// all time
|
||||||
|
@ -130,12 +180,6 @@ try {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$error = 'Error: ' . $e->getMessage();
|
|
||||||
include 'templates/message.php';
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
// prepare the widget
|
// prepare the widget
|
||||||
$widget['full'] = false;
|
$widget['full'] = false;
|
||||||
$widget['name'] = 'LastConferences';
|
$widget['name'] = 'LastConferences';
|
||||||
|
|
|
@ -42,7 +42,7 @@ try {
|
||||||
$db = new Database($config['jilo_database']);
|
$db = new Database($config['jilo_database']);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$error = 'Error: ' . $e->getMessage();
|
$error = 'Error: ' . $e->getMessage();
|
||||||
include 'templates/message.php';
|
include 'templates/block-message.php';
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ try {
|
||||||
$error = $e->getMessage();
|
$error = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
include 'templates/message.php';
|
include 'templates/block-message.php';
|
||||||
include 'templates/form-register.php';
|
include 'templates/form-register.php';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
<?php if ($widget['collapsible'] === true) { ?>
|
||||||
|
<a style="text-decoration: none;" data-toggle="collapse" href="#collapse<?= $widget['name'] ?>" role="button" aria-expanded="true" aria-controls="collapse<?= $widget['name'] ?>">
|
||||||
|
<div class="card w-auto bg-light card-body" style="flex-direction: row;"><?= $widget['title'] ?></div>
|
||||||
|
<?php } else { ?>
|
||||||
|
<div class="card w-auto bg-light border-light card-body" style="flex-direction: row;"><?= $widget['title'] ?></div>
|
||||||
|
<?php } ?>
|
||||||
|
<?php if ($widget['filter'] === true) {
|
||||||
|
include('templates/block-results-filter.php'); } ?>
|
||||||
|
<?php if ($widget['collapsible'] === true) { ?>
|
||||||
|
</a>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="collapse show" id="collapse<?= $widget['name'] ?>">
|
||||||
|
<?php if ($time_range_specified) { ?>
|
||||||
|
<p class="m-3">time period: <strong><?= $from_time ?> - <?= $until_time ?></strong></p>
|
||||||
|
<?php } ?>
|
||||||
|
<div class="mb-5">
|
||||||
|
<?php if ($widget['full'] === true) { ?>
|
||||||
|
<table class="table table-striped table-hover table-bordered">
|
||||||
|
<thead class="thead-dark">
|
||||||
|
<tr>
|
||||||
|
<?php foreach ($widget['table_headers'] as $header) { ?>
|
||||||
|
<th scope="col"><?= htmlspecialchars($header) ?></th>
|
||||||
|
<?php } ?>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<?php foreach ($widget['table_records'] as $row) { ?>
|
||||||
|
<td><?= htmlspecialchars($row ?? '') ?></td>
|
||||||
|
<?php } ?>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php } else { ?>
|
||||||
|
<p class="m-3">No matching records found.</p>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -8,8 +8,7 @@
|
||||||
<div class="card w-auto bg-light border-light card-body" style="flex-direction: row;"><?= $widget['title'] ?></div>
|
<div class="card w-auto bg-light border-light card-body" style="flex-direction: row;"><?= $widget['title'] ?></div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ($widget['filter'] === true) {
|
<?php if ($widget['filter'] === true) {
|
||||||
include('templates/results-filter.php');
|
include('templates/block-results-filter.php'); } ?>
|
||||||
} ?>
|
|
||||||
<?php if ($widget['collapsible'] === true) { ?>
|
<?php if ($widget['collapsible'] === true) { ?>
|
||||||
</a>
|
</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
Loading…
Reference in New Issue