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

use lib '/app/tools/rps/lib';
use RPS::Catalog::Form;
use RPS::Command;
use RPS::CommandLog;
use base 'RPS::Command';

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

sub cmd  { return 'show'; }
sub area { return 'catalog'; }

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

# These constants refer to the tabs on the main show page.
# This will allow us to specify (abstractly) which tab should be enabled
# when redirecting back to the show page, by specifying tab => CONSTANT
#
use constant kTabMain           => 'mainTab';
use constant kTabContracts      => 'contractTab';
use constant kTabLicenses       => 'licenseTab';
use constant kTabUKLicenses     => 'ukLicenseTab';
use constant kTabCALicenses     => 'caLicenseTab';
use constant kTabDistribution   => 'distributionTab';

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

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

	my $albumID = $self->getParam("AlbumID");
	my $form = RPS::Catalog::Form->new(albumID => $albumID);
    $form->{Album}->validateForDistribution();

    RPS::CommandLog::Log($self, $albumID);
	$self->{xml}{Form} = $form;

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



1;
