#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
#------------------------------------------------------------
package Support::Reports::Command::AlbumSearch;
use strict;
use warnings;

use lib '/app/tools/support/lib';
use Support::Reports::AlbumSearch;

use base 'Support::Command::Submit';

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

use lib '/app/tools/distribution/lib';

sub cmd  { return 'search_albums'; }
sub area { return 'reports'; }

use constant kTemplate => "/app/tools/support/templates/reports/album_search.xsl";

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

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

    my $client = $self->getParam('client');
    my $page   = $self->getParam('page');
    my $limit  = $self->getParam('limit') || 25;
    my $query  = $self->getParam('query');

    my $report = new Support::Reports::AlbumSearch(
        clientID => $client,
        limit    => $limit,
        page     => $page
    );

    $report->run($query) if ( $self->isSubmit() );

    $self->{xml}{Collection} = $report;

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

1;
