#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package RPS::DB::Item::LicenseReserveRun;
use strict;
use warnings;
use lib '/app/tools/common/lib';
use Common::DB::Item;
use base 'Common::DB::Item';

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



sub GetByMechanicalRunID
{
    my ($class, $id) = @_;

    my $sql = "SELECT * from license_reserve_run WHERE mechanical_run_id=$id";
    return $class->GetAll($sql);
}


sub CountMissingRunReserves
{
	my ($class, $id) = @_;

	my $sql = "SELECT * FROM license_reserve_run WHERE mechanical_run_id=$id AND license_reserve_id NOT IN (select license_reserve_id from license_reserve)";

	my $c = $class->GetAll($sql);
	return $c->size();
}


sub DeleteByMechanicalRunID
{
    my ($class, $id) = @_;

    my $sql = "DELETE from " . kTable . " WHERE mechanical_run_id=$id";
	my $dbo = Common::RSApp::GetClientDB();
    $dbo->DoCmd($sql);

}


###
1;#
###



