#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
#------------------------------------------------------------
package RPS::Statement::Command::Main;
use strict;
use warnings;

use lib '/app/tools/appuser/lib';
use AppUser::User::User;

use lib '/app/tools/rps/lib';
use RPS::LabelList;
use RPS::Statement::RecentlyViewedStatementList;
use RPS::Payor::PayorList;
use RPS::Mechanical::US::MechanicalRunList;
use RPS::Mechanical::CA::MechanicalRunList;
use RPS::Mechanical::UK::UKMechanicalRunList;
use RPS::ArtistRoyalty::ArtistRoyaltyRunList;
use RPS::LabelRoyalty::LabelRoyaltyRunList;

use RPS::Command;
use base 'RPS::Command';

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

sub cmd  { return 'main'; }
sub area { return 'statement'; }

use constant kTemplate => "/app/tools/rps/templates/statement/main.xsl";

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

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

    $self->{xml}{RecentlyViewed} = RPS::Statement::RecentlyViewedStatementList->new(user_id => $self->_getUser()->UserID());
    $self->{xml}{PayorList} = RPS::Payor::PayorList->new();
    $self->{xml}{MechanicalRunList} = RPS::Mechanical::US::MechanicalRunList->new();
    $self->{xml}{CAMechanicalRunList} = RPS::Mechanical::CA::MechanicalRunList->new();
    $self->{xml}{UKMechanicalRunList} = RPS::Mechanical::UK::UKMechanicalRunList->new();
    $self->{xml}{ArtistRoyaltyRunList} = RPS::ArtistRoyalty::ArtistRoyaltyRunList->new();
    $self->{xml}{LabelRoyaltyRunList} = RPS::LabelRoyalty::LabelRoyaltyRunList->new();
      
    # Check for mechanical report preference
    #
    my $mechReportPref = Common::Preference::Get("mech_report_pref");
    
    if ($mechReportPref)
    {
        $self->{xml}{MechReportPref} = $mechReportPref->value();    
    }    

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



1;
