array( 'terms' => array( array('attr'=>'StartDateTime', 'op'=>'>=', 'val'=>$minTime, 'obr'=>'1'), array('attr'=>'StartDateTime', 'op'=>'<=', 'val'=>$maxTime, 'cnj'=>'and', 'cbr'=>'1'), ) ), ); if ( count($selected_monitor_ids) ) { $filter['Query']['terms'][] = (array('attr'=>'MonitorId', 'op'=>'IN', 'val'=>implode(',', $selected_monitor_ids), 'cnj'=>'and')); } else if ( ( $group_id != 0 || isset($_SESSION['ServerId']) || isset($_SESSION['StorageId']) || isset($_SESSION['Status']) ) ) { # this should be redundant for ( $i=0; $i < count($displayMonitors); $i++ ) { if ( $i == 0 ) { $filter['Query']['terms'][] = array('attr'=>'MonitorId', 'op'=>'=', 'val'=>$displayMonitors[$i]['Id'], 'cnj'=>'and', 'obr'=>'1'); } else if ( $i == count($displayMonitors)-1 ) { $filter['Query']['terms'][] = array('attr'=>'MonitorId', 'op'=>'=', 'val'=>$displayMonitors[$i]['Id'], 'cnj'=>'or', 'cbr'=>'1'); } else { $filter['Query']['terms'][] = array('attr'=>'MonitorId', 'op'=>'=', 'val'=>$displayMonitors[$i]['Id'], 'cnj'=>'or'); } } } parseFilter($filter); $filterQuery = $filter['query']; ZM\Debug($filterQuery); $eventsSql = 'SELECT *, UNIX_TIMESTAMP(E.StartTime) AS StartTimeSecs, UNIX_TIMESTAMP(EndTime) AS EndTimeSecs FROM Events AS E WHERE 1 > 0 '; if ( !empty($user['MonitorIds']) ) { $eventsSql .= ' AND MonitorId IN ('.$user['MonitorIds'].')'; } if ( count($selected_monitor_ids) ) { $eventsSql .= ' AND MonitorId IN ('.implode(',', $selected_monitor_ids).')'; } if ( isset($minTime) && isset($maxTime) ) { $eventsSql .= " AND EndTime > '" . $minTime . "' AND StartTime < '" . $maxTime . "'"; } $eventsSql .= ' ORDER BY Id ASC'; $result = dbQuery($eventsSql); if ( !$result ) { ZM\Fatal('SQL-ERR'); return; } $EventsByMonitor = array(); while ( $event = $result->fetch(PDO::FETCH_ASSOC) ) { $Event = new ZM\Event($event); if ( ! isset($EventsByMonitor[$event['MonitorId']]) ) $EventsByMonitor[$event['MonitorId']] = array('Events'=>array(), 'MinGap'=>0, 'MaxGap'=>0, 'FileMissing'=>array(), 'ZeroSize'=>array()); if ( count($EventsByMonitor[$event['MonitorId']]['Events']) ) { $last_event = end($EventsByMonitor[$event['MonitorId']]['Events']); #Debug(print_r($last_event,true)); $gap = $last_event->EndTimeSecs() - $event['StartTimeSecs']; if ( $gap < $EventsByMonitor[$event['MonitorId']]['MinGap'] ) $EventsByMonitor[$event['MonitorId']]['MinGap'] = $gap; if ( $gap > $EventsByMonitor[$event['MonitorId']]['MaxGap'] ) $EventsByMonitor[$event['MonitorId']]['MaxGap'] = $gap; } # end if has previous events if ( !$Event->file_exists() ) { $EventsByMonitor[$event['MonitorId']]['FileMissing'][] = $Event; } else if ( ! $Event->file_size() ) { $EventsByMonitor[$event['MonitorId']]['ZeroSize'][] = $Event; } $EventsByMonitor[$event['MonitorId']]['Events'][] = $Event; } # end foreach event ?>
to
'and', 'attr'=>'MonitorId', 'op'=>'=', 'val'=>$monitor['Id']) ); parseFilter($monitor_filter); if ( isset($EventsByMonitor[$Monitor->Id()]) ) { $EventCounts = $EventsByMonitor[$Monitor->Id()]; $MinGap = $EventCounts['MinGap']; $MaxGap = $EventCounts['MaxGap']; $FileMissing = $EventCounts['FileMissing']; $ZeroSize = $EventCounts['ZeroSize']; $FirstEvent = $EventCounts['Events'][0]; $LastEvent = end($EventCounts['Events']); } else { $MinGap = 0; $MaxGap = 0; $FileMissing = array(); $ZeroSize = array(); $FirstEvent = 0; $LastEvent = 0; } if ( count($FileMissing) ) { $FileMissing_filter = array( 'Query' => array( 'terms' => array( array('attr'=>'Id', 'op'=>'IN', 'val'=>implode(',', array_map(function($Event){return $Event->Id();}, $FileMissing))) ) ) ); parseFilter($FileMissing_filter); } if ( count($ZeroSize) ) { $ZeroSize_filter = array( 'Query' => array( 'terms' => array( array('attr'=>'Id', 'op'=>'IN', 'val'=>implode(',', array_map(function($Event){return $Event->Id();}, $ZeroSize))) ) ) ); parseFilter($ZeroSize_filter); } ?>
videocam 

', array_map(function($group_id){ $Group = new ZM\Group($group_id); $Groups = $Group->Parents(); array_push($Groups, $Group); return implode(' > ', array_map(function($Group){ return ''.$Group->Name().''; }, $Groups )); }, $Monitor->GroupIds())); ?>
Server()->Name())?> Id()])?count($EventsByMonitor[$Monitor->Id()]['Events']):0 ?> link_to($FirstEvent->Id().' at '.$FirstEvent->StartTime()) : 'none'?> link_to($LastEvent->Id().' at '.$LastEvent->StartTime()) : 'none'?> '.count($FileMissing).'' : '0' ?> '.count($ZeroSize).'' : '0' ?>