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

use strict;
use warnings;

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

use lib '/app/tools/rps/lib';
use RPS::Payor::Payor;
use Common::FormObject;
use base 'Common::FormObject';

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

    my $searchTerm = $args{searchTerm};
    my $runType    = $args{runType};

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

    $self->{Payor} = [];

    my $payors;

    if ($searchTerm) {
        $payors = RPS::DB::Item::Payor->Search($searchTerm);
    } elsif ( $args{ids} ) {
        $payors = RPS::DB::Item::Payor->GetFromIDList( $args{ids} );
    } else {
        $payors = RPS::DB::Item::Payor->GetAll();
    }

    while ( $payors->hasNext() ) {
        my $data = $payors->next();

        push @{ $self->{Payor} }, $self->_getPayorFromDBItem( $data, $runType );
    }

    return $self;
}

sub _getPayorFromDBItem {
    my ( $self, $dbItem ) = @_;
    return RPS::Payor::Payor->new( _dbItem => $dbItem );
}

sub _listProperties {
    return { Payor => 1 };
}

###
1;    #
###
