2003-07-11 17:27:56 +08:00
< ? php
2004-01-08 19:45:57 +08:00
//
// ZoneMinder web watch events view file, $Date$, $Revision$
2006-01-17 19:32:47 +08:00
// Copyright (C) 2003, 2004, 2005, 2006 Philip Coombes
2004-01-08 19:45:57 +08:00
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
if ( ! canView ( 'Events' ) )
{
$view = " error " ;
return ;
}
2004-03-10 22:23:22 +08:00
2005-11-07 03:06:33 +08:00
$sort_field = " DateTime " ;
$sort_asc = false ;
2004-03-10 22:23:22 +08:00
parseSort ();
2005-02-24 18:42:55 +08:00
if ( ! $max_events )
{
$max_events = MAX_EVENTS ;
}
2004-01-08 19:45:57 +08:00
if ( ZM_WEB_REFRESH_METHOD == " http " )
2004-04-19 19:23:40 +08:00
header ( " Refresh: " . ZM_WEB_REFRESH_EVENTS . " ; URL= $PHP_SELF ?view=watchevents&mid= $mid &max_events= " . MAX_EVENTS );
2006-03-28 06:01:33 +08:00
noCacheHeaders ();
2003-12-03 23:29:52 +08:00
2004-01-08 19:45:57 +08:00
$result = mysql_query ( " select * from Monitors where Id = ' $mid ' " );
if ( ! $result )
die ( mysql_error () );
$monitor = mysql_fetch_assoc ( $result );
2006-01-15 21:09:30 +08:00
mysql_free_result ( $result );
2003-12-03 23:29:52 +08:00
2003-07-11 17:27:56 +08:00
?>
2004-12-29 03:22:23 +08:00
<! DOCTYPE HTML PUBLIC " -//W3C//DTD HTML 4.01 Transitional//EN " >
2003-07-11 17:27:56 +08:00
< html >
< head >
2005-05-06 20:24:57 +08:00
< title >< ? = ZM_WEB_TITLE_PREFIX ?> - <?= $monitor['Name'] ?> - <?= $zmSlangEvents ?></title>
2004-12-29 02:20:11 +08:00
< link rel = " stylesheet " href = " zm_html_styles.css " type = " text/css " >
2004-12-29 03:29:43 +08:00
< script type = " text/javascript " >
2003-07-11 17:27:56 +08:00
function newWindow ( Url , Name , Width , Height )
{
2005-11-21 23:32:04 +08:00
var Win = window . open ( Url , Name , " resizable,scrollbars,width= " + Width + " ,height= " + Height );
2003-07-11 17:27:56 +08:00
}
2003-12-03 23:29:52 +08:00
function eventWindow ( Url , Name )
{
2005-11-21 23:32:04 +08:00
var Win = window . open ( Url , Name , " resizable,width=<?= $monitor['Width'] + $jws['event'] ['w'] ?>,height=<?= $monitor['Height'] + $jws['event'] ['h'] ?> " );
2003-12-03 23:29:52 +08:00
}
2003-07-11 17:27:56 +08:00
function closeWindow ()
{
top . window . close ();
}
2005-11-21 23:32:04 +08:00
function toggleCheck ( element , name )
{
var form = element . form ;
var checked = element . checked ;
2003-07-11 17:27:56 +08:00
for ( var i = 0 ; i < form . elements . length ; i ++ )
if ( form . elements [ i ] . name . indexOf ( name ) == 0 )
2005-11-21 23:32:04 +08:00
form . elements [ i ] . checked = checked ;
form . delete_btn . disabled = ! checked ;
2003-07-11 17:27:56 +08:00
}
2005-11-21 23:32:04 +08:00
function configureButton ( element , name )
2003-07-11 17:27:56 +08:00
{
2005-11-21 23:32:04 +08:00
var form = element . form ;
var checked = element . checked ;
if ( ! checked )
2003-07-11 17:27:56 +08:00
{
2005-11-21 23:32:04 +08:00
for ( var i = 0 ; i < form . elements . length ; i ++ )
2003-07-11 17:27:56 +08:00
{
2005-11-21 23:32:04 +08:00
if ( form . elements [ i ] . name . indexOf ( name ) == 0 )
2003-07-11 17:27:56 +08:00
{
2005-11-21 23:32:04 +08:00
if ( form . elements [ i ] . checked )
{
checked = true ;
break ;
}
2003-07-11 17:27:56 +08:00
}
}
}
2005-11-21 23:32:04 +08:00
if ( ! element . checked )
form . toggle_check . checked = false ;
2003-07-11 17:27:56 +08:00
form . delete_btn . disabled = ! checked ;
}
< ? php
2004-01-08 19:45:57 +08:00
if ( ZM_WEB_REFRESH_METHOD == " javascript " )
{
2003-07-11 17:27:56 +08:00
?>
2004-04-19 19:23:40 +08:00
window . setTimeout ( " window.location.replace( '<?= " $PHP_SELF ? view = watchevents & mid = $mid & max_events = " .MAX_EVENTS ?>' ) " , < ? = ZM_WEB_REFRESH_EVENTS * 1000 ?> );
2003-07-11 17:27:56 +08:00
< ? php
2004-01-08 19:45:57 +08:00
}
2003-07-11 17:27:56 +08:00
?>
</ script >
</ head >
< body >
< form name = " event_form " method = " get " action = " <?= $PHP_SELF ?> " >
< input type = " hidden " name = " view " value = " <?= $view ?> " >
< input type = " hidden " name = " action " value = " delete " >
< input type = " hidden " name = " mid " value = " <?= $mid ?> " >
< input type = " hidden " name = " max_events " value = " <?= $max_events ?> " >
< center >< table width = " 96% " align = " center " border = " 0 " cellspacing = " 1 " cellpadding = " 0 " >
< tr >
2005-12-02 18:17:30 +08:00
< td colspan = " 2 " valign = " top " >< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
2003-07-11 17:27:56 +08:00
< ? php
2004-01-08 19:45:57 +08:00
$sql = " select E.Id,E.Name,E.StartTime,E.Length,E.Frames,E.AlarmFrames,E.AvgScore,E.MaxScore from Monitors as M left join Events as E on M.Id = E.MonitorId where M.Id = ' $mid ' and E.Archived = 0 " ;
$sql .= " order by $sort_column $sort_order " ;
$sql .= " limit 0, $max_events " ;
$result = mysql_query ( $sql );
if ( ! $result )
{
die ( mysql_error () );
}
$n_events = mysql_num_rows ( $result );
2003-07-11 17:27:56 +08:00
?>
< tr >
2005-11-21 23:32:04 +08:00
< td width = " 30% " align = " left " class = " text " >< b >< ? = sprintf ( $zmClangLastEvents , $n_events , strtolower ( zmVlang ( $zmVlangEvent , $n_events ) ) ) ?> </b></td>
2004-02-16 03:42:00 +08:00
< td align = " center " class = " text " >< ? = makeLink ( " javascript: newWindow( ' $PHP_SELF ?view=events&page=1&filter=1&trms=1&attr1=MonitorId&op1=%3d&val1= " . $monitor [ 'Id' ] . " ', 'zmEvents', " . $jws [ 'events' ][ 'w' ] . " , " . $jws [ 'events' ][ 'h' ] . " ); " , $zmSlangAll , canView ( 'Events' ) ) ?> </td>
2005-11-21 23:32:04 +08:00
< td width = " 30% " align = " right " class = " text " >< ? = makeLink ( " javascript: newWindow( ' $PHP_SELF ?view=events&page=1&filter=1&trms=2&attr1=MonitorId&op1=%3d&val1= " . $monitor [ 'Id' ] . " &cnj2=and&attr2=Archived&val2=1', 'zmEvents', " . $jws [ 'events' ][ 'w' ] . " , " . $jws [ 'events' ][ 'h' ] . " ); " , $zmSlangArchive , canView ( 'Events' ) ) ?> </td>
2003-07-11 17:27:56 +08:00
</ tr >
2005-11-21 23:32:04 +08:00
< tr >< td colspan = " 3 " class = " text " >& nbsp ; </ td ></ tr >
< tr >< td colspan = " 3 " >< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " bgcolor = " #7F7FB2 " >
2003-07-11 17:27:56 +08:00
< tr align = " center " bgcolor = " #FFFFFF " >
2004-01-07 20:57:07 +08:00
< td width = " 4% " class = " text " >< a href = " <?= $PHP_SELF ?>?view=watchevents&mid=<?= $mid ?>&max_events=<?= $max_events ?>&sort_field=Id&sort_asc=<?= $sort_field == 'Id'?! $sort_asc :0 ?> " >< ? = $zmSlangId ?> <?php if ( $sort_field == "Id" ) if ( $sort_asc ) echo "(^)"; else echo "(v)"; ?></a></td>
< td width = " 24% " class = " text " >< a href = " <?= $PHP_SELF ?>?view=watchevents&mid=<?= $mid ?>&max_events=<?= $max_events ?>&sort_field=Name&sort_asc=<?= $sort_field == 'Name'?! $sort_asc :0 ?> " >< ? = $zmSlangName ?> <?php if ( $sort_field == "Name" ) if ( $sort_asc ) echo "(^)"; else echo "(v)"; ?></a></td>
2004-03-10 22:35:22 +08:00
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=watchevents&mid=<?= $mid ?>&max_events=<?= $max_events ?>&sort_field=StartTime&sort_asc=<?= $sort_field == 'StartTime'?! $sort_asc :0 ?> " >< ? = $zmSlangTime ?> <?php if ( $sort_field == "StartTime" ) if ( $sort_asc ) echo "(^)"; else echo "(v)"; ?></a></td>
2004-06-30 22:39:08 +08:00
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=watchevents&mid=<?= $mid ?>&max_events=<?= $max_events ?>&sort_field=Length&sort_asc=<?= $sort_field == 'Length'?! $sort_asc :0 ?> " >< ? = $zmSlangSecs ?> <?php if ( $sort_field == "Length" ) if ( $sort_asc ) echo "(^)"; else echo "(v)"; ?></a></td>
2004-01-07 20:57:07 +08:00
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=watchevents&mid=<?= $mid ?>&max_events=<?= $max_events ?>&sort_field=Frames&sort_asc=<?= $sort_field == 'Frames'?! $sort_asc :0 ?> " >< ? = $zmSlangFrames ?> <?php if ( $sort_field == "Frames" ) if ( $sort_asc ) echo "(^)"; else echo "(v)"; ?></a></td>
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=watchevents&mid=<?= $mid ?>&max_events=<?= $max_events ?>&sort_field=Score&sort_asc=<?= $sort_field == 'Score'?! $sort_asc :0 ?> " >< ? = $zmSlangScore ?> <?php if ( $sort_field == "Score" ) if ( $sort_asc ) echo "(^)"; else echo "(v)"; ?></a></td>
2005-11-21 23:32:04 +08:00
< td class = " text " >< input type = " checkbox " name = " toggle_check " value = " 1 " onClick = " toggleCheck( this, 'mark_eids' ); " < ? php if ( ! canEdit ( 'Events' ) ) { ?> disabled<?php } ?>></td>
2003-07-11 17:27:56 +08:00
</ tr >
< ? php
2004-01-08 19:45:57 +08:00
while ( $event = mysql_fetch_assoc ( $result ) )
{
2003-07-11 17:27:56 +08:00
?>
< tr bgcolor = " #FFFFFF " >
2004-03-10 22:35:22 +08:00
< td align = " center " class = " text " >< a href = " javascript: eventWindow( '<?= $PHP_SELF ?>?view=event&eid=<?= $event['Id'] ?>&trms=1&attr1=MonitorId&op1=%3d&val1=<?= $mid ?><?= $sort_query ?>&page=1', 'zmEvent' ); " >< ? = $event [ 'Id' ] ?> </a></td>
< td align = " center " class = " text " >< a href = " javascript: eventWindow( '<?= $PHP_SELF ?>?view=event&eid=<?= $event['Id'] ?>&trms=1&attr1=MonitorId&op1=%3d&val1=<?= $mid ?><?= $sort_query ?>&page=1', 'zmEvent' ); " >< ? = $event [ 'Name' ] ?> </a></td>
2006-03-28 06:01:33 +08:00
< td align = " center " class = " text " >< ? = strftime ( STRF_FMT_DATETIME_SHORTER , strtotime ( $event [ 'StartTime' ]) ) ?> </td>
2004-01-08 18:09:35 +08:00
< td align = " center " class = " text " >< ? = $event [ 'Length' ] ?> </td>
2004-02-16 03:42:00 +08:00
< td align = " center " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=frames&eid=<?= $event['Id'] ?>', 'zmFrames', <?= $jws['frames'] ['w'] ?>, <?= $jws['frames'] ['h'] ?> ); " >< ? = $event [ 'Frames' ] ?> /<?= $event['AlarmFrames'] ?></a></td>
2004-01-08 18:55:16 +08:00
< td align = " center " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=frame&eid=<?= $event['Id'] ?>&fid=0', 'zmImage', <?= $monitor['Width'] + $jws['image'] ['w'] ?>, <?= $monitor['Height'] + $jws['image'] ['h'] ?> ); " >< ? = $event [ 'AvgScore' ] ?> /<?= $event['MaxScore'] ?></a></td>
2005-11-21 23:32:04 +08:00
< td align = " center " class = " text " >< input type = " checkbox " name = " mark_eids[] " value = " <?= $event['Id'] ?> " onClick = " configureButton( this, 'mark_eids' ); " < ? php if ( ! canEdit ( 'Events' ) ) { ?> disabled<?php } ?>></td>
2003-07-11 17:27:56 +08:00
</ tr >
< ? php
2004-01-08 19:45:57 +08:00
}
2006-01-15 21:09:30 +08:00
mysql_free_result ( $result );
2003-07-11 17:27:56 +08:00
?>
</ table ></ td ></ tr >
</ table ></ td >
</ tr >
2005-12-09 06:17:51 +08:00
< tr >
2005-12-02 18:17:30 +08:00
< td align = " left " >< input type = " button " value = " <?= $zmSlangZones ?> " class = " form " onClick = " javascript: newWindow( '<?= $PHP_SELF ?>?view=zones&mid=<?= $monitor['Id'] ?>', 'zmZones', <?= $monitor['Width'] + $jws['zones'] ['w'] ?>, <?= $monitor['Height'] + $jws['zones'] ['h'] ?> ); " < ? php if ( ! canView ( 'Monitors' ) ) { ?> disabled<?php } ?>></td>
< td align = " right " >< input type = " submit " name = " delete_btn " value = " <?= $zmSlangDelete ?> " class = " form " disabled ></ td >
</ tr >
2003-07-11 17:27:56 +08:00
</ table ></ center >
</ form >
</ body >
</ html >