#------------------------------------------------------------
# Copyright (C) 2011 RoyaltyShare, Inc.   All Rights Reserved
#------------------------------------------------------------
package RPS::Report::Dynamic::Command::List;
use strict;
use warnings;


use lib '/app/tools/appuser/lib';
use lib '/app/tools/common/lib';
use Common::Util;

use lib '/app/tools/rps/lib';
use RPS::CommandLog;
use RPS::Report::Dynamic::Factory;
use RPS::Report::Dynamic::ReportList;

use AppUser::User::User;
use base 'RPS::Command';

sub cmd  { return 'list'; }
sub area { return 'report'; }

use constant kTemplate => "/app/tools/rps/templates/report/dynamic/list.xsl";

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

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

    RPS::CommandLog::Log($self);


    my $userID = Common::RSApp::GetActiveUserID();
    my $user = AppUser::User::User->new(userID => $userID, loadSubs => 0);
    my $accessLevel = $user->AccessLevel();
    $self->{xml}->{Form} = RPS::Report::Dynamic::Factory->GetGroupTypeXML( $accessLevel );
    $self->{xml}->{Form}->{ReportList} = Report::Dynamic::ReportList->new( active => 1, accessLevel => $accessLevel );

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

    return $response;
}

1;
