#------------------------------------------------------------
# Copyright (C) 2011 RoyaltyShare, Inc.   All Rights Reserved
#------------------------------------------------------------
package RPS::Report::Dynamic::Command::Delete;
use strict;
use warnings;


use Data::Dumper;

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

use lib '/app/tools/rps/lib';
use RPS::CommandLog;
use RPS::Report::Dynamic::Factory;
use RPS::Report::Dynamic::Command::List;

use base 'RPS::Command';

sub cmd  { return 'delete'; }
sub area { return 'report'; }

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

    my $params;

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

    RPS::CommandLog::Log($self);

    my $reportID = $self->getParam('ReportID');
    my $report = RPS::Report::Dynamic::Factory->Fetch( $reportID );

    die "TODO:  Report not found" unless( $report );

    $report->delete();

    my $command = RPS::Report::Dynamic::Command::List->new();
    return RSApache::Response::Redirect->new($command->getRedirect());
}

1;
