2020-09-13 20:32:49 +08:00
|
|
|
<?php
|
2021-10-30 06:54:23 +08:00
|
|
|
if (empty($_REQUEST['eid'])) ajaxError('Event Id Not Provided');
|
|
|
|
if (empty($_REQUEST['fid'])) ajaxError('Frame Id Not Provided');
|
2020-09-13 20:32:49 +08:00
|
|
|
|
|
|
|
$eid = $_REQUEST['eid'];
|
|
|
|
$fid = $_REQUEST['fid'];
|
|
|
|
$row = ( isset($_REQUEST['row']) ) ? $_REQUEST['row'] : '';
|
2020-12-14 03:20:26 +08:00
|
|
|
$raw = isset($_REQUEST['raw']);
|
2020-09-13 20:32:49 +08:00
|
|
|
$data = array();
|
|
|
|
|
2021-10-30 06:54:23 +08:00
|
|
|
if ($raw) {
|
2022-01-08 05:21:34 +08:00
|
|
|
$data['raw'] = array();
|
2021-10-30 06:54:23 +08:00
|
|
|
$sql = 'SELECT S.*,E.*,Z.Name AS ZoneName,Z.Units,Z.Area,M.Name AS MonitorName
|
|
|
|
FROM Stats AS S LEFT JOIN Events AS E ON S.EventId = E.Id LEFT JOIN Zones AS Z ON S.ZoneId = Z.Id LEFT JOIN Monitors AS M ON E.MonitorId = M.Id
|
|
|
|
WHERE S.EventId = ? AND S.FrameId = ? ORDER BY S.ZoneId';
|
|
|
|
$stats = dbFetchAll($sql, NULL, array($eid, $fid));
|
|
|
|
foreach ($stats as $stat) {
|
2020-12-14 03:20:26 +08:00
|
|
|
$stat['ZoneName'] = validHtmlStr($stat['ZoneName']);
|
|
|
|
$stat['PixelDiff'] = validHtmlStr($stat['PixelDiff']);
|
2021-10-30 06:54:23 +08:00
|
|
|
$stat['AlarmPixels'] = sprintf('%d (%d%%)', $stat['AlarmPixels'], (100*$stat['AlarmPixels']/$stat['Area']));
|
|
|
|
$stat['FilterPixels'] = sprintf('%d (%d%%)', $stat['FilterPixels'], (100*$stat['FilterPixels']/$stat['Area']));
|
|
|
|
$stat['BlobPixels'] = sprintf('%d (%d%%)', $stat['BlobPixels'], (100*$stat['BlobPixels']/$stat['Area']));
|
2020-12-14 03:20:26 +08:00
|
|
|
$stat['Blobs'] = validHtmlStr($stat['Blobs']);
|
2021-10-30 06:54:23 +08:00
|
|
|
if ($stat['Blobs'] > 1) {
|
|
|
|
$stat['BlobSizes'] = sprintf('%d-%d (%d%%-%d%%)', $stat['MinBlobSize'], $stat['MaxBlobSize'], (100*$stat['MinBlobSize']/$stat['Area']), (100*$stat['MaxBlobSize']/$stat['Area']));
|
2020-12-14 03:20:26 +08:00
|
|
|
} else {
|
2021-10-30 06:54:23 +08:00
|
|
|
$stat['BlobSizes'] = sprintf('%d (%d%%)', $stat['MinBlobSize'], 100*$stat['MinBlobSize']/$stat['Area']);
|
2020-12-14 03:20:26 +08:00
|
|
|
}
|
2021-10-30 06:54:23 +08:00
|
|
|
$stat['AlarmLimits'] = validHtmlStr($stat['MinX'].','.$stat['MinY'].'-'.$stat['MaxX'].','.$stat['MaxY']);
|
|
|
|
$data['raw'][] = $stat;
|
|
|
|
} # end foreach stat/zone
|
2020-12-14 03:20:26 +08:00
|
|
|
} else {
|
|
|
|
$data['html'] = getStatsTableHTML($eid, $fid, $row);
|
|
|
|
$data['id'] = '#contentStatsTable' .$row;
|
|
|
|
}
|
2020-09-13 20:32:49 +08:00
|
|
|
|
|
|
|
ajaxResponse($data);
|
|
|
|
return;
|
|
|
|
?>
|