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

use strict;
use warnings;
use lib '/app/tools/common/lib';

use lib '/app/tools/rps/lib';
use RPS::ServiceList;
use RPS::ServiceCategoryList;
use RPS::RoyaltyRun::RoyaltyRunStatusList;

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

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

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

    $self->{ServiceCategoryList} = RPS::ServiceCategoryList->new();

    $self->{ServiceList} = RPS::ServiceList->new();
    $self->{RoyaltyRunStatus} = new RPS::RoyaltyRun::RoyaltyRunStatusList( caMechanical => 1, usMechanical => 1 );

    return $self;
}

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

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

sub save {
    my ($self) = @_;

    $self->{ServiceCategoryList}->save();
    $self->{ServiceList}->save();
}

sub validate {
    my ($self) = @_;

    my $valid = $self->{ServiceList}->validate();

    return $valid;
}

###
1;    #
###
