Add EndTime to event list

pull/2077/head
Isaac Connor 2018-04-03 06:57:22 -07:00
parent 793f630ee0
commit 614170c181
1 changed files with 40 additions and 16 deletions

View File

@ -18,12 +18,12 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
if ( !canView( 'Events' ) || (!empty($_REQUEST['execute']) && !canEdit('Events')) ) {
if ( !canView('Events') || (!empty($_REQUEST['execute']) && !canEdit('Events')) ) {
$view = 'error';
return;
}
require_once( 'includes/Event.php' );
require_once('includes/Event.php');
$countSql = 'SELECT count(E.Id) AS EventCount FROM Monitors AS M INNER JOIN Events AS E ON (M.Id = E.MonitorId) WHERE';
$eventsSql = 'SELECT E.*,M.Name AS MonitorName,M.DefaultScale FROM Monitors AS M INNER JOIN Events AS E on (M.Id = E.MonitorId) WHERE';
@ -37,21 +37,19 @@ if ( $user['MonitorIds'] ) {
}
parseSort();
parseFilter( $_REQUEST['filter'] );
parseFilter($_REQUEST['filter']);
$filterQuery = $_REQUEST['filter']['query'];
if ( $_REQUEST['filter']['sql'] ) {
$countSql .= $_REQUEST['filter']['sql'];
$eventsSql .= $_REQUEST['filter']['sql'];
} else {
Error("No filtering in events, will load ALL!");
}
$eventsSql .= " ORDER BY $sortColumn $sortOrder";
$page = isset($_REQUEST['page']) ? validInt($_REQUEST['page']) : 0;
$limit = isset($_REQUEST['limit']) ? validInt($_REQUEST['limit']) : 0;
$nEvents = dbFetchOne( $countSql, 'EventCount' );
$nEvents = dbFetchOne($countSql, 'EventCount');
if ( !empty($limit) && $nEvents > $limit ) {
$nEvents = $limit;
}
@ -71,20 +69,26 @@ if ( !empty($page) ) {
$limitAmount = ($limitLeft>ZM_WEB_EVENTS_PER_PAGE)?ZM_WEB_EVENTS_PER_PAGE:$limitLeft;
}
$eventsSql .= " limit $limitStart, $limitAmount";
} elseif ( !empty( $limit ) ) {
} elseif ( !empty($limit) ) {
$eventsSql .= ' limit 0, '.$limit;
}
$maxShortcuts = 5;
$pagination = getPagination( $pages, $page, $maxShortcuts, $filterQuery.$sortQuery.$limitQuery );
$pagination = getPagination($pages, $page, $maxShortcuts, $filterQuery.$sortQuery.$limitQuery);
$focusWindow = true;
if ($_POST) {
header("Location: " . $_SERVER['REQUEST_URI'].htmlspecialchars_decode($filterQuery).htmlspecialchars_decode($sortQuery).$limitQuery.'&page='.$page);
if ( $_POST ) {
header('Location: ' . $_SERVER['REQUEST_URI'].htmlspecialchars_decode($filterQuery).htmlspecialchars_decode($sortQuery).$limitQuery.'&page='.$page);
exit();
}
$storage_areas = Storage::find_all();
$StorageById = array();
foreach ( $storage_areas as $S ) {
$StorageById[$S->Id()] = $S;
}
xhtmlHeaders(__FILE__, translate('Events') );
?>
@ -93,7 +97,7 @@ xhtmlHeaders(__FILE__, translate('Events') );
<?php echo getNavBarHTML() ?>
<div id="header">
<div id="info">
<h2><?php echo sprintf( $CLANG['EventCount'], $nEvents, zmVlang( $VLANG['Event'], $nEvents ) ) ?></h2>
<h2><?php echo sprintf($CLANG['EventCount'], $nEvents, zmVlang($VLANG['Event'], $nEvents)) ?></h2>
<a id="refreshLink" href="#" onclick="location.reload(true);"><?php echo translate('Refresh') ?></a>
</div>
<div id="pagination">
@ -139,9 +143,9 @@ $count = 0;
$disk_space_total = 0;
Logger::Debug("EventSql: $eventsSql");
$results = dbQuery( $eventsSql );
while ( $event_row = dbFetchNext( $results ) ) {
$event = new Event( $event_row );
$results = dbQuery($eventsSql);
while ( $event_row = dbFetchNext($results) ) {
$event = new Event($event_row);
if ( $event_row['Archived'] )
$archived = true;
else
@ -162,6 +166,11 @@ while ( $event_row = dbFetchNext( $results ) ) {
<th class="colAvgScore"><a href="<?php echo sortHeader( 'AvgScore' ) ?>"><?php echo translate('AvgBrScore') ?><?php echo sortTag( 'AvgScore' ) ?></a></th>
<th class="colMaxScore"><a href="<?php echo sortHeader( 'MaxScore' ) ?>"><?php echo translate('MaxBrScore') ?><?php echo sortTag( 'MaxScore' ) ?></a></th>
<?php
if ( count($storage_areas) > 1 ) {
?>
<th class="colStorage"><?php echo translate('Storage') ?></th>
<?php
}
if ( ZM_WEB_EVENT_DISK_SPACE ) {
?>
<th class="colDiskSpace"><a href="<?php echo sortHeader( 'DiskSpace' ) ?>"><?php echo translate('DiskSpace') ?><?php echo sortTag( 'DiskSpace' ) ?></a></th>
@ -184,7 +193,9 @@ while ( $event_row = dbFetchNext( $results ) ) {
<td class="colName"><a href="?view=event&amp;eid=<?php echo $event->Id().$filterQuery.$sortQuery.'&amp;page=1"> '.validHtmlStr($event->Name()).($event->Archived()?'*':'') ?></a></td>
<td class="colMonitorName"><?php echo makePopupLink( '?view=monitor&amp;mid='.$event->MonitorId(), 'zmMonitor'.$event->Monitorid(), 'monitor', $event->MonitorName(), canEdit( 'Monitors' ) ) ?></td>
<td class="colCause"><?php echo makePopupLink( '?view=eventdetail&amp;eid='.$event->Id(), 'zmEventDetail', 'eventdetail', validHtmlStr($event->Cause()), canEdit( 'Events' ), 'title="'.htmlspecialchars($event->Notes()).'"' ) ?></td>
<td class="colTime"><?php echo strftime( STRF_FMT_DATETIME_SHORTER, strtotime($event->StartTime()) ) ?></td>
<td class="colTime"><?php echo strftime(STRF_FMT_DATETIME_SHORTER, strtotime($event->StartTime())) .
( $event->EndTime() ? ' until ' . strftime(STRF_FMT_DATETIME_SHORTER, strtotime($event->EndTime()) ) : '' ) ?>
</td>
<td class="colDuration"><?php echo gmdate("H:i:s", $event->Length() ) ?></td>
<td class="colFrames"><?php echo makePopupLink( '?view=frames&amp;eid='.$event->Id(), 'zmFrames', 'frames', $event->Frames() ) ?></td>
<td class="colAlarmFrames"><?php echo makePopupLink( '?view=frames&amp;eid='.$event->Id(), 'zmFrames', 'frames', $event->AlarmFrames() ) ?></td>
@ -192,6 +203,12 @@ while ( $event_row = dbFetchNext( $results ) ) {
<td class="colAvgScore"><?php echo $event->AvgScore() ?></td>
<td class="colMaxScore"><?php echo makePopupLink( '?view=frame&amp;eid='.$event->Id().'&amp;fid=0', 'zmImage', array( 'image', reScale( $event->Width(), $scale ), reScale( $event->Height(), $scale ) ), $event->MaxScore() ) ?></td>
<?php
if ( count($storage_areas) > 1 ) {
?>
<td class="colStorage"><?php echo $storage_areas[$event->StorageId()]->Name() ?></td>
<?php
}
if ( ZM_WEB_EVENT_DISK_SPACE ) {
$disk_space_total += $event->DiskSpace();
?>
@ -232,6 +249,13 @@ while ( $event_row = dbFetchNext( $results ) ) {
<tfoot>
<tr>
<td colspan="11">Totals:</td>
<?php
if ( count($storage_areas)>1 ) {
?>
<td class="colStorage"></td>
<?php
}
?>
<td class="colDiskSpace"><?php echo human_filesize( $disk_space_total ) ?></td>
<?php
if ( ZM_WEB_LIST_THUMBS ) {