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

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::CAPublisher;

use RPS::Publisher::BasePublisherSimple;
use base 'RPS::Publisher::BasePublisherSimple';

sub _publisherDB { return "RPS::DB::Item::CAPublisher"; }
sub _publisherID { return "ca_publisher_id"; }


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

    $self->SUPER::_initProperties($props);

    $self->{PublisherID} = Common::FormObject::Scalar->new( value => $props->{ $self->_publisherID() }, readOnly => 1 );
    $self->{PublisherName} = Common::FormObject::Scalar::String->new( value => $props->{publisher_name}, required => 1 );
    $self->{ClientAccountID} = Common::FormObject::Scalar::String->new( value => $props->{client_account_id} );

    # Combining Publisher Name and ClientAccountID for autocomplete purposes
    #
    my $clientAccountID = $props->{client_account_id} || '';
    my $nameAndClientAccountID = $props->{publisher_name} . " (" . $clientAccountID . ")";
    $nameAndClientAccountID .= ' Administrator' if $props->{is_admin};
    $nameAndClientAccountID .= ' Agency'        if $props->{is_agency};
    $self->{NameAndClientAccountID} = Common::FormObject::Scalar::String->new( value => $nameAndClientAccountID );

    # Also adding the artist payee ID in a more generic element for the auto-complete.
    $self->{PayeeID} = Common::FormObject::Scalar->new( value => $props->{ $self->_publisherID() }, readOnly => 1 );

    return $self;
}

###
1;    #
###

