#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package RPS::Price::Command::List;

use lib '/app/tools/common/lib';
use RSApache::Response::XSLT;

use lib '/app/tools/rps/lib';
use RPS::Price::Price;
use RPS::Price::PriceLevelList;
use RPS::Command;
use base 'RPS::Command';

use constant kTemplate => '/app/tools/rps/templates/price/index.xsl';

sub cmd  { return "list"; }
sub area { return "price"; }

sub execute
{
	my ($self) = @_;

	my $response = $self->SUPER::execute();
	return $response if $response;

	my $prices = RPS::DB::Item::Price->GetAll();

	while ($prices->hasNext())
	{
		my $data = $prices->next();

		push @{$self->{xml}{Price}}, RPS::Price::Price->new(_dbItem => $data);
	}

	$self->{xml}{PriceLevelList} = RPS::Price::PriceLevelList->new();

	$response = RSApache::Response::XSLT->new($self->{xml}, kTemplate);

	return $response;
}


1;
