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

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

use lib '/app/tools/rps/lib';
use RPS::DB::Item::ProductType;
use RPS::Product::TypeList;
use RPS::Product::StatusList;
use RPS::Product::ProductList;
use RPS::Mechanical::UK::McpsLicenseList;
use RPS::RoyaltyRun::RoyaltyRunStatusList;

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

sub GetNumUKLicenses {
    my ($albumID) = @_;

    # This will need to be updated to check for MCPS licenses _and_ direct license.
    # But for now, we'll only check for MCPS.

    my $collection = RPS::DB::Item::ProductType->GetPhysicalTypesByAlbum($albumID);
    return $collection->size();
}

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

    assert( $args{albumID} );

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

    #
    #
    $self->{McpsLicenseList} = RPS::Mechanical::UK::McpsLicenseList->new( albumID => $args{albumID} );

    # Licenses have product ids stored in them, so we need the full lists to map those to names.
    #
    #

    $self->{TypeList}    = RPS::Product::TypeList->new( albumID => $args{albumID}, physicalOnly => 1 );
    $self->{StatusList}  = RPS::Product::StatusList->new();
    $self->{ProductList} = RPS::Product::ProductList->new( albumID => $args{albumID}, loadSubs => 0 );

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

    return $self;
}

###
1;    #
###
