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

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 => 'label_contract_term';
use constant kDB => Common::DB::Item::kClientDB();

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

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

sub GetByLabelContractID
{
    my ($class, $labelContractID) = @_;
	assert($labelContractID);

	my $order = "ORDER BY label_id";
	my $sql = "SELECT * FROM ".kTable." WHERE label_contract_id=$labelContractID $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;

