#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
#------------------------------------------------------------
package RPS::ArtistContract::Form;

use strict;
use warnings;

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

use lib '/app/tools/rps/lib';
use RPS::ArtistContract::ArtistContract;
use RPS::ArtistContract::ContractTermSourceList;
use RPS::ArtistContract::ContractRateTypeList;
use RPS::ArtistContract::ArtistContractLicenseIncomeList;
use RPS::LabelList;
use RPS::Region::RegionList;
use RPS::ArtistContract::ChannelList;
use RPS::Price::PriceLevelList;
use RPS::Catalog::AlbumContractWithAlbumList;
use RPS::Track::TrackContractWithTrackList;
use RPS::ServiceList;
use RPS::Expense::ExpenseTypeList;
use RPS::Payor::PayorList;
use RPS::RoyaltyRun::RoyaltyRunStatusList;

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

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

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

	if($args{artistContractID})
	{
		$self->{ArtistContract} = RPS::ArtistContract::ArtistContract->new(artistContractID => $args{artistContractID});

		# we also want a list of albums
		$self->{AlbumContractList} = RPS::Catalog::AlbumContractWithAlbumList->new(artistContractID => $args{artistContractID});

    # And tracks
    #
    $self->{TrackContractList} = RPS::Track::TrackContractWithTrackList->new(artistContractID => $args{artistContractID});
		$self->{ExpenseTypeList} = RPS::Expense::ExpenseTypeList->new(artistContractID => $args{artistContractID});
		$self->{ArtistContractLicenseIncomeList} = RPS::ArtistContract::ArtistContractLicenseIncomeList->new(artistContractID => $args{artistContractID});
	}
	else
	{
		$self->{ArtistContract} = RPS::ArtistContract::ArtistContract->new();
	}

	$self->{ContractTermSourceList} = RPS::ArtistContract::ContractTermSourceList->new();
	$self->{RegionList} = RPS::Region::RegionList->new();
	$self->{ChannelList} = RPS::ArtistContract::ChannelList->new();
	$self->{PriceLevelList} = RPS::Price::PriceLevelList->new();
	$self->{ContractRateTypeList} = RPS::ArtistContract::ContractRateTypeList->new();

	$self->{LabelList} = RPS::LabelList->new();
	$self->{ServiceList} = RPS::ServiceList->new();
	$self->{PayorList} = RPS::Payor::PayorList->new();

	$self->{RoyaltyRunStatus} = new RPS::RoyaltyRun::RoyaltyRunStatusList( artist => 1 );

	return $self;
}

sub _propertyIsEditable
{
	my ($self, $propertyName) = @_;

	# The Product (and contained objects) can be edited.
	#
	# if ($propertyName eq 'Album')
	# {
		# return 1;
	# }

	return 0;
}

sub contractID
{
	my ($self) = @_;
	return $self->{ArtistContract}->ArtistContractID();
}


###
1;#
###
