#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package Raptor::Help::Command::DownloadPhysicalSalesTemplate;
use strict;
use warnings;
use IO::File;

use lib '/app/tools/raptor/lib';
use Raptor::Command;
use base 'Raptor::Command';

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

use base 'RPS::Command';

sub cmd  { return 'physical_sales_template'; }
sub area { return 'help'; }

use constant kPath => "/app/tools/rps/docs/help/physical_sales_template.xls";

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

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

    my $fullPath       = kPath;
    my $prettyFileName = 'RoyaltyShare_PhysicalSalesTemplate_v1_22.xls';

    my $fh = new IO::File;
    open( $fh, "$fullPath" ) or die "ERROR: Unable to open $fullPath for reading: $!";

    my @stat     = $fh->stat;
    my $fileSize = $stat[7];

    my $contentType = 'application/octet-stream';

    $response = RSApache::Response::Download->new( $fh, $contentType, $prettyFileName, $fileSize );
    return $response;
}

1;
