diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 50c4e9012..e9df807f7 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -203,6 +203,7 @@ CREATE TABLE `Events` ( `Messaged` tinyint(3) unsigned NOT NULL default '0', `Executed` tinyint(3) unsigned NOT NULL default '0', `Notes` text, + `StateId` int(10) unsigned NOT NULL, PRIMARY KEY (`Id`,`MonitorId`), KEY `MonitorId` (`MonitorId`), KEY `StartTime` (`StartTime`), diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 9b6202966..00e4e38a0 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -77,10 +77,14 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string gettimeofday( &start_time, 0 ); } - static char sql[ZM_SQL_MED_BUFSIZ]; + unsigned int state_id = 0; + if ( MYSQL_ROW dbrow = zmDbFetchOne( "SELECT Id FROM States WHERE IsActive=1" ) ) { + state_id = atoi(dbrow[0]); + } + static char sql[ZM_SQL_MED_BUFSIZ]; struct tm *stime = localtime( &start_time.tv_sec ); - snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, Name, StartTime, Width, Height, Cause, Notes ) values ( %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s' )", monitor->Id(), start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str() ); + snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, Name, StartTime, Width, Height, Cause, Notes, StateId ) values ( %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s', %d )", monitor->Id(), start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str(), state_id ); if ( mysql_query( &dbconn, sql ) ) { Error( "Can't insert event: %s", mysql_error( &dbconn ) ); diff --git a/web/includes/functions.php b/web/includes/functions.php index 36a80cf2e..bd1375b73 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -1243,6 +1243,7 @@ function parseFilter( &$filter, $saveToSession=false, $querySep='&' ) { case 'MaxScore': case 'Cause': case 'Notes': + case 'StateId': case 'Archived': $filter['sql'] .= 'E.'.$filter['terms'][$i]['attr']; break; diff --git a/web/lang/en_gb.php b/web/lang/en_gb.php index 4adb1fc7f..922ca1e21 100644 --- a/web/lang/en_gb.php +++ b/web/lang/en_gb.php @@ -127,6 +127,7 @@ $SLANG = array( 'AttrMonitorName' => 'Monitor Name', 'AttrServerId' => 'Server Id', 'AttrServerName' => 'Server Name', + 'AttrStateId' => 'Run State', 'AttrName' => 'Name', 'AttrNotes' => 'Notes', 'AttrSystemLoad' => 'System Load', diff --git a/web/skins/classic/views/filter.php b/web/skins/classic/views/filter.php index 390e94ee1..465777bd3 100644 --- a/web/skins/classic/views/filter.php +++ b/web/skins/classic/views/filter.php @@ -97,6 +97,7 @@ $attrTypes = array( 'DiskPercent' => translate('AttrDiskPercent'), 'DiskBlocks' => translate('AttrDiskBlocks'), 'SystemLoad' => translate('AttrSystemLoad'), + 'StateId' => translate('AttrStateId'), 'ServerId' => translate('AttrServerId'), 'ServerName' => translate('AttrServerName'), ); @@ -217,6 +218,17 @@ for ( $i = 0; isset($_REQUEST['filter']) && $i < count($_REQUEST['filter']['term ?>