#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package RPS::DB::Item::Alert;

use strict;
use warnings;

use lib '/app/tools/common/lib';
use Common::Util qw(escape_mysql_regexp escape_mysql_like);
use Common::DB::ItemCollection;
use Common::Assert;

use Common::DB::Item;
use base 'Common::DB::Item';

use constant kTable => 'alert';
use constant kDB => Common::DB::Item::kClientDB;

use constant kAlertLevelInfo => 1;
use constant kAlertLevelCaution => 2;
use constant kAlertLevelCritical => 3;


sub GetCurrentAlert
{
    my ($class) = @_;

    # !!! Going to keep this simple - the 'current' alert is the one in the table with
    # the highest id.
    #
    my $sql = "SELECT * FROM ".kTable. " WHERE alert_id =  ( select MAX(alert_id) from ".kTable.")";
	my $collection = Common::DB::ItemCollection->new(
	 class => "RPS::DB::Item::Alert",
	 query => $sql,
	 dbID => kDB,
	);

    return $collection->next();
}

1;


