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

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



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

    my $sql = "SELECT * from " .kTable ." WHERE ca_mechanical_run_id=$id";
    return $class->GetAll($sql);
}


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

	my $sql = "SELECT * FROM ".kTable." WHERE ca_mechanical_run_id=$id AND ca_license_reserve_id NOT IN (select ca_license_reserve_id from ca_license_reserve)";

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


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

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

}


###
1;#
###



