#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package RPS::Track::Command::ExpenseView;
use strict;
use warnings;

use lib '/app/tools/rps/lib';
use RPS::Track::ExpenseForm;
use RPS::ArtistContract::Command::Search;

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

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

sub cmd  { return 'expense'; }
sub area { return 'track'; }

use constant kTemplate => "/app/tools/rps/templates/track/index.xsl";

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

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

    my $trackContractID = $self->getParam('TrackContractID');
    my $form;

    if ($trackContractID) {
        $form = RPS::Track::ExpenseForm->new( trackContractID => $trackContractID );
    } else {
        my $command = RPS::ArtistContract::Command::Search->new();
        return RSApache::Response::Redirect->new( $command->getRedirect() );
    }

    $self->{xml}{Form} = $form;

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

    return $response;
}

1;
