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

use strict;
use warnings;

use lib '/app/tools/common/lib';
use Common::Assert;
use Common::DB::ItemCollection;
use Common::DB::Item;
use base 'Common::DB::Item';

use constant kTable => 'distributor_contract_term';
use constant kDB => Common::DB::Item::kClientDB();

sub GetAll
{
    my ($class) = @_;
    my $sql = "SELECT * FROM ".kTable." ORDER by distributor_contract_id, label_id";
#    my $sql = "SELECT dct.*, l.label_name from distributor_contract_term as dct, label as l"
#     . " where dct.label_id = l.label_id order by l.label_name, dct.distributor_contract_id";

    return $class->SUPER::GetAll($sql);
}

sub GetByDistributorContractID
{
    my ($class, $distributorContractID) = @_;
	assert($distributorContractID);

	my $order = "ORDER BY label_id";
	my $sql = "SELECT * FROM ".kTable." WHERE distributor_contract_id=$distributorContractID $order";

    return $class->SUPER::GetAll($sql);
}

sub GetByLabelID
{
    my ($class, $labelID) = @_;
    assert($labelID);
    
    return $class->SUPER::GetAll("SELECT * FROM ".kTable." WHERE label_id=$labelID");
}

1;

