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

use strict;
use warnings;

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

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

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->{LabelContract} = [];
    my $coll;
    if ($args{labelPayeeID})
    {
        $coll = RPS::DB::Item::LabelContract->GetByPayee($args{labelPayeeID});
    }
    elsif ($args{payorID})
    {
        $coll = RPS::DB::Item::LabelContract->GetByPayor($args{payorID});
    }

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

    return $self;
}


1;

