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

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

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

use base 'RSApache::Command::XMLCommand';

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

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

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

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

	my $albumID = $self->getParam("AlbumID");

    my $justCountFlag = $self->getParam('count');

    if ($justCountFlag)
    {
        my $count = RPS::Catalog::UKLicenseForm::GetNumUKLicenses($albumID);
        $response = RSApache::Response::JSON->new($count);
    }
    else
    {
	    my $form = RPS::Catalog::UKLicenseForm->new(albumID => $albumID);

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

	return $response;
}



1;
