#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package RPS::DistributorContract::DistributorContractList;

use strict;
use warnings;

use lib '/app/tools/common/lib';
use Common::Assert;

use lib '/app/tools/rps/lib';
use RPS::DistributorContract::DistributorContract;

use Common::FormObject;
use base 'Common::FormObject';

# This is a read-only XMLObject, so we don't need any
# of the accessor methods, just create the list of
# items and be on your way.
#

sub _init {
    my ( $self, %args ) = @_;

    $self->SUPER::_init(%args);

    $self->{DistributorContract} = [];
    my $coll;
    if ( $args{distributorPayeeID} ) {
        $coll = RPS::DB::Item::DistributorContract->GetByPayee( $args{distributorPayeeID} );
    } elsif ( $args{payorID} ) {
        $coll = RPS::DB::Item::DistributorContract->GetByPayor( $args{payorID} );
    }

    if ($coll) {
        while ( $coll->hasNext() ) {
            my $contractObj = $coll->next;
            push @{ $self->{DistributorContract} },
              RPS::DistributorContract::DistributorContract->new( _dbItem => $contractObj, loadSubs => 0 );
        }
    }

    return $self;
}

1;

