#---------------------------------------------------------------
# ____                   _ _         ____  _
#|  _ \ ___  _   _  __ _| | |_ _   _/ ___|| |__   __ _ _ __ ___
#| |_) / _ \| | | |/ _` | | __| | | \___ \| '_ \ / _` | '__/ _ \
#|  _ < (_) | |_| | (_| | | |_| |_| |___) | | | | (_| | | |  __/
#|_| \_\___/ \__, |\__,_|_|\__|\__, |____/|_| |_|\__,_|_|  \___|
#            |___/             |___/
#
# Copyright (C) 2011 RoyaltyShare, Inc.   All Rights Reserved
#---------------------------------------------------------------

package RPS::Report::Dynamic::Transactions::Label;

use strict;
use warnings;

use lib '/app/tools/common/lib';
use lib '/app/tools/rps/lib';
use lib '/app/tools/report/lib';
use RPS::DB::Item::DynamicReport::Transactions::Label;
use Common::Client;
use Common::Log;

use base 'RPS::Report::Dynamic::Transactions::APLBase';

sub Type           { 'Label' }
sub FilenameType   { 'Transactions Label' }
sub ClientTypeMask { return Common::Client::kLabel; }

sub _getCollection {
    my $self = shift;

    my $dateType;
    my $dateTypeParam = $self->parameters()->{Criteria}->DateType();
    if ($dateTypeParam) {
        if ( 'Date Created' eq $dateTypeParam ) {
            $dateType = 'date_created';
        } elsif ( 'Date Modified' eq $dateTypeParam ) {
            $dateType = 'date_modified';
        }
    }

    # Need to determine whether we're sending processed or unprocessed
    my $transTypes = $self->parameters()->{OptionalData}->ReportType();

    my $processed   = 1 if ( 'All' eq $transTypes || 'Processed' eq $transTypes );
    my $unprocessed = 1 if ( 'All' eq $transTypes || 'Pending' eq $transTypes );

    return RPS::DB::Item::DynamicReport::Transactions::Label->ReportQuery(
        dateType        => $dateType,
        startDate       => $self->parameters()->{Criteria}->StartDate(),
        endDate         => $self->parameters()->{Criteria}->EndDate(),
        showProcessed   => $processed,
        showUnprocessed => $unprocessed,

        #        showProcessed => $self->_showProcessed(),
        #        showUnprocessed => $self->_showUnprocessed(),
    );
}

1;
