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

use strict;
use warnings;
use Carp;

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


use lib '/app/tools/rps/lib';
use RPS::DB::Item::Affiliate;
use Common::FormObject;


use base 'Common::FormObject';

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

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

    my %properties;
	if ($args{_dbItem})
	{
		$self->_propertiesFromDBItem(\%properties, $args{_dbItem});
	}
	elsif ($args{affiliateID})
	{
		$self->_propertiesFromDB(\%properties, $args{affiliateID});
	}
	else
	{
		$self->_propertiesFromDefaults(\%properties);
	}

    $self->_initProperties(\%properties);
    return $self;
}


sub _propertiesFromDB
{
	my ($self, $hrProperties, $affiliateID) = @_;

	my $dbItem = RPS::DB::Item::Affiliate->Lookup(affiliate_id => $affiliateID);
	$self->_initFromDBItem($hrProperties, $dbItem);
}


sub _propertiesFromDBItem
{
    my ($self, $hrProperties, $dbItem) = @_;

	$hrProperties->{affiliate_id}   = $dbItem->affiliate_id;
	$hrProperties->{name}           = $dbItem->name;
	$hrProperties->{description}    = $dbItem->description;
}

sub _initProperties
{
	my ($self, $props) = @_;

	$self->{AffiliateID} =  Common::FormObject::Scalar->new(value => $props->{affiliate_id}, readOnly => 1);
	$self->{Name} =         Common::FormObject::Scalar::String->new(value => $props->{name});
	$self->{Description} =  Common::FormObject::Scalar::String->new(value => $props->{description});

	return $self;
}


sub _propertiesFromDefaults
{
	my ($self, $hrProperties) = @_;
}



###
1;#
###
