# $Id: clone_menu_propagate.pm,v 1.18 2003/10/14 09:07:37 mdf Exp $
# $Log: clone_menu_propagate.pm,v $
# Revision 1.18  2003/10/14  09:07:37  mdf
# Added team names to finisher list
#
# Revision 1.17  2000/03/20  19:01:32  dn1
# *** empty log message ***
#
# Revision 1.16  1999/09/02  17:31:53  dn1
# *** empty log message ***
#
# Revision 1.15  1999/08/31 13:56:30  dn1
# *** empty log message ***
#
# Revision 1.14  1999/08/17 15:16:14  dn1
# *** empty log message ***
#
# Revision 1.13  1999/03/22 18:03:36  dn1
# *** empty log message ***
#

#print STDERR "Using local version of clone_menu_propagate !!!\n";

# DN1
###########################
# load up lists for choice
###########################

package embl_choice;
sub get_list {
  my ($pkg, $dbh) = @_;
  my @choice = ("Unfinished", "Finished");
  my $return = \@choice;
  bless $return, 'embl_choice';
  return ($return);
}

package contig_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select contigname 
from contig
order by contigname
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $name;
    my @names;
    while ($name = $sth->fetchrow()){
	push @names, $name;
    }
    $sth->finish;
    my $return = \@names;
    bless $return, 'contig_choice';
    return ($return);
}

sub get_list_t {
    my ($pkg, $dbh, $type_var) = @_;
    # $type_var can be ("Clone contigs", "Parent contigs", "Custom contigs");
    
    my $statement;
    if ($type_var eq 'Custom contigs'){
	$statement = "
select contigname 
from contig
where contig.manual_map = 1
order by contigname
";
    }

    if ($type_var eq 'Parent contigs'){
	$statement = "
select unique contig.on_contig
from contig
order by contig.on_contig
";
    }

    if ($type_var eq 'Clone contigs'){
	$statement = "
select contigname 
from contig
where contig.on_contig is not NULL
order by contigname
";
    }

    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $name;
    my @names;
    while ($name = $sth->fetchrow()){
	push @names, $name;
    }
    $sth->finish;
    my $return = \@names;
    bless $return, 'contig_choice';
    return ($return);
}

sub get_list_s {
    my ($pkg, $dbh, $species_var) = @_;
    my $statement = "
select contigname 
from contig, chromosomedict, species
where species.speciesname = chromosomedict.speciesname
and chromosomedict.id_dict = contig.chromosome
and species.speciesname = \'$species_var\'
order by contig.contigname
";

    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $name;
    my @names;
    while ($name = $sth->fetchrow()){
	push @names, $name;
    }
    $sth->finish;
    my $return = \@names;
    bless $return, 'contig_choice';
    return ($return);
}

sub get_list_c {
    my ($pkg, $dbh, $chromosome_var) = @_;
        my $statement = "
select contigname 
from contig, chromosomedict
where chromosomedict.id_dict = contig.chromosome
and chromosomedict.chromosome = \'$chromosome_var\'
order by contig.contigname
";

    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $name;
    my @names;
    while ($name = $sth->fetchrow()){
	push @names, $name;
    }
    $sth->finish;
    my $return = \@names;
    bless $return, 'contig_choice';
    return ($return);
}

sub get_list_tsc {
    my ($pkg, $dbh, $type_var, $species_var, $chromosome_var) = @_;
        my $statement;
    if ($type_var eq 'Custom contigs'){
	$statement = "
select contigname
from contig, chromosomedict, species
where species.speciesname = chromosomedict.speciesname
and chromosomedict.id_dict = contig.chromosome
and species.speciesname = \'$species_var\'
and chromosomedict.chromosome = \'$chromosome_var\'
and contig.manual_map = 1
order by contigname
";
    }

    if ($type_var eq 'Parent contigs'){
	$statement = "
select unique contig.on_contig
from contig, chromosomedict, species
where species.speciesname = chromosomedict.speciesname
and chromosomedict.id_dict = contig.chromosome
and species.speciesname = \'$species_var\'
and chromosomedict.chromosome = \'$chromosome_var\'
order by contig.on_contig
";
    }

    if ($type_var eq 'Clone contigs'){
	$statement = "
select contigname 
from contig, chromosomedict, species
where species.speciesname = chromosomedict.speciesname
and chromosomedict.id_dict = contig.chromosome
and species.speciesname = \'$species_var\'
and chromosomedict.chromosome = \'$chromosome_var\'
and contig.on_contig is not NULL
order by contigname
";
    }

    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $name;
    my @names;
    while ($name = $sth->fetchrow()){
	push @names, $name;
    }
    $sth->finish;
    my $return = \@names;
    bless $return, 'contig_choice';
    return ($return);
}

###

sub get_list_sc {
    my ($pkg, $dbh, $species_var, $chromosome_var) = @_;
    my $statement = "
select contigname 
from contig, chromosomedict, species
where species.speciesname = chromosomedict.speciesname
and chromosomedict.id_dict = contig.chromosome
and species.speciesname = \'$species_var\'
and chromosomedict.chromosome = \'$chromosome_var\'
order by contig.contigname
";


    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $name;
    my @names;
    while ($name = $sth->fetchrow()){
	push @names, $name;
    }
    $sth->finish;
    my $return = \@names;
    bless $return, 'contig_choice';
    return ($return);


}

sub get_list_ts {
    my ($pkg, $dbh, $type_var, $species_var) = @_;
    my $statement;
    if ($type_var eq 'Custom contigs'){
	$statement = "
select contigname
from contig, chromosomedict, species
where species.speciesname = chromosomedict.speciesname
and chromosomedict.id_dict = contig.chromosome
and species.speciesname = \'$species_var\'
and contig.manual_map = 1
order by contigname
";
    }

    if ($type_var eq 'Parent contigs'){
	$statement = "
select unique contig.on_contig
from contig, chromosomedict, species
where species.speciesname = chromosomedict.speciesname
and chromosomedict.id_dict = contig.chromosome
and species.speciesname = \'$species_var\'
order by contig.on_contig
";
    }

    if ($type_var eq 'Clone contigs'){
	$statement = "
select contigname 
from contig, chromosomedict, species
where species.speciesname = chromosomedict.speciesname
and chromosomedict.id_dict = contig.chromosome
and species.speciesname = \'$species_var\'
and contig.on_contig is not NULL
order by contigname
";
    }

    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $name;
    my @names;
    while ($name = $sth->fetchrow()){
	push @names, $name;
    }
    $sth->finish;
    my $return = \@names;
    bless $return, 'contig_choice';
    return ($return);
}
##########

sub get_list_sc {
    my ($pkg, $dbh, $species_var, $chromosome_var) = @_;
    my $statement = "
select contigname 
from contig, chromosomedict, species
where species.speciesname = chromosomedict.speciesname
and chromosomedict.id_dict = contig.chromosome
and species.speciesname = \'$species_var\'
and chromosomedict.chromosome = \'$chromosome_var\'
order by contig.contigname
";


    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $name;
    my @names;
    while ($name = $sth->fetchrow()){
	push @names, $name;
    }
    $sth->finish;
    my $return = \@names;
    bless $return, 'contig_choice';
    return ($return);
}

sub get_list_tc {
    my ($pkg, $dbh, $type_var, $chromosome_var) = @_;
        my $statement;
    if ($type_var eq 'Custom contigs'){
	$statement = "
select contigname 
from contig, chromosomedict
where chromosomedict.id_dict = contig.chromosome
and chromosomedict.chromosome = \'$chromosome_var\'
and contig.manual_map = 1
order by contigname
";
    }

    if ($type_var eq 'Parent contigs'){
	$statement = "
select unique contig.on_contig
from contig, chromosomedict
where chromosomedict.id_dict = contig.chromosome
and chromosomedict.chromosome = \'$chromosome_var\'
order by contig.on_contig
";
    }

    if ($type_var eq 'Clone contigs'){
	$statement = "
select contigname 
from contig, chromosomedict
where chromosomedict.id_dict = contig.chromosome
and chromosomedict.chromosome = \'$chromosome_var\'
and contig.on_contig is not NULL
order by contigname
";
    }

    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $name;
    my @names;
    while ($name = $sth->fetchrow()){
	push @names, $name;
    }
    $sth->finish;
    my $return = \@names;
    bless $return, 'contig_choice';
    return ($return);
}

###############
###############

package species_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select speciesname 
from species
order by speciesname
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $species;
    my @species;
    while ($species = $sth->fetchrow()){
	push @species, $species;
    }
    $sth->finish;
    my $return = \@species;
    bless $return, 'species_choice';
    return ($return);
}

sub get_list_depending_on_chromosome_entry {
    my ($pkg, $dbh, $chromosome_var) = @_;

    my $statement = "
select species.speciesname
from species, chromosomedict
where species.speciesname = chromosomedict.speciesname
and chromosomedict.chromosome = \'$chromosome_var\'
order by speciesname
";

    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $species;
    my @species;
    while ($species = $sth->fetchrow()){
	push @species, $species;
    }
    $sth->finish;
    my $return = \@species;
    bless $return, 'species_choice';
    return ($return);
}

sub get_list_depending_on_subregion_entry {
    my ($pkg, $dbh, $subregion) = @_;

    my $statement = "
select species.speciesname
from species, subregion
where species.speciesname = subregion.speciesname
and subregion.subregion = \'$subregion\'
order by species.speciesname
";

    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $species;
    my @species;
    while ($species = $sth->fetchrow()){
	push @species, $species;
    }
    $sth->finish;
    my $return = \@species;
    bless $return, 'species_choice';
    return ($return);
}

sub get_list_depending_on_library_entry {
    my ($pkg, $dbh, $library) = @_;

    my $statement = "
select species.speciesname
from species, library
where species.speciesname = library.speciesname
and library.libraryname  = \'$library\'
order by species.speciesname
";

    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $species;
    my @species;
    while ($species = $sth->fetchrow()){
	push @species, $species;
    }
    $sth->finish;
    my $return = \@species;
    bless $return, 'species_choice';
    return ($return);
}

################################################################################
package subregion_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select subregion
from subregion
order by speciesname, chromosome
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $sub;
    my @sub;
    while ($sub = $sth->fetchrow() ){
	push @sub, $sub;
    }
    $sth->finish;
    my $return = \@sub;
    bless $return, 'subregion_choice';
    return ($return);
}

sub glc {
    my ($pkg, $dbh, $chromosome) = @_;
    my $statement = "
select subregion
from subregion, chromosomedict
where subregion.chromosome = chromosomedict.id_dict
and chromosomedict.chromosome = \'$chromosome\'
order by subregion.chromosome
";

    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $sub;
    my @sub;
    while ($sub = $sth->fetchrow() ){
	push @sub, $sub;
    }
    $sth->finish;
    my $return = \@sub;
    bless $return, 'subregion_choice';
    return ($return);

}


sub get_list_depending_on_species_entry {
    my ($pkg, $dbh, $species) = @_;
    my $statement = "
select subregion
from subregion
where speciesname = \'$species\'
order by speciesname
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $sub;
    my @sub;
    while ($sub = $sth->fetchrow() ){
	push @sub, $sub;
    }
    $sth->finish;
    my $return = \@sub;
    bless $return, 'subregion_choice';
    return ($return);
}
################################################################################


package chromosome_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select unique chromosome
from chromosomedict
order by chromosome
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $chromosome;
    my @chromosome;
    while ($chromosome = $sth->fetchrow() ){
	push @chromosome, $chromosome;
    }
    $sth->finish;
    my $return = \@chromosome;
    bless $return, 'chromosome_choice';
    return ($return);
}


sub get_list_depending_on_species_entry {
    my ($pkg, $dbh, $species_name_var) = @_;
    my $statement = "
select chromosomedict.chromosome 
from species, chromosomedict
where species.speciesname = chromosomedict.speciesname
and species.speciesname = \'$species_name_var\'
order by chromosomedict.id_dict
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $chromosome;
    my @chromosome;
    while ($chromosome = $sth->fetchrow()){
	push @chromosome, $chromosome;
    }
    $sth->finish;
    my $return = \@chromosome;
    bless $return, 'chromosome_choice';
    return ($return);
}

sub get_list_depending_on_stuff {
    my ($pkg, $dbh, $subregion) = @_;
    my $statement = "
select chromosomedict.chromosome 
from chromosomedict, subregion
where subregion.chromosome = chromosomedict.id_dict
and subregion.subregion = \'$subregion\'
order by chromosomedict.chromosome
";

#    warn " $statement \n";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $chromosome;
    my @chromosome;
    while ($chromosome = $sth->fetchrow()){
	push @chromosome, $chromosome;
    }
    $sth->finish;
    my $return = \@chromosome;
    bless $return, 'chromosome_choice';
    return ($return);
}

package sourcename_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select sourcename 
from datasource
order by sourcename
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $sourcename;
    my @sourcename;
    while ($sourcename = $sth->fetchrow()){
	push @sourcename, $sourcename;
    }
    $sth->finish;
    my $return = \@sourcename;
    bless $return, 'sourcename_choice';
    return ($return);
}

#############################################################################

#package labname_choice;
#sub get_list {
#    my ($pkg, $dbh) = @_;
#    my $statement = "
#select labname 
#from lab
#order by labname
#";
#    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
#    $sth->execute || die "ERROR:$DBI::errstr";
#    my $lab;
#    my @lab;
#    while ($lab = $sth->fetchrow()){
#	push @lab, $lab;
#    }
#
#    $sth->finish;
#    my $return = \@lab;
#    bless $return , 'labname_choice';
#    return ($return);
#}

package seq_by_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select organisation.orgtitle
from sequencing_org, organisation
where sequencing_org.id_org = organisation.id_org
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $org;
    my @org;
    while ($org = $sth->fetchrow()){
	push @org, $org;
    }
    $sth->finish;
    my $return = \@org;
    bless $return , 'seq_by_choice';
    return ($return);
}

package fun_by_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select organisation.orgtitle
from funding_org, organisation
where funding_org.id_org = organisation.id_org
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $fun;
    my @fun;
    while ($fun = $sth->fetchrow()){
	push @fun, $fun;
    }
    $sth->finish;
    my $return = \@fun;
    bless $return , 'fun_by_choice';
    return ($return);
}



#############################################################################

package seqreason_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select description
from seqreasondict
order by id_dict
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $seqr;
    my @seqr;
    while ($seqr = $sth->fetchrow()){
	push @seqr, $seqr;
    }

    $sth->finish;
    my $return = \@seqr;
    bless $return , 'seqreason_choice';
    return ($return);
}



package libraryname_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select libraryname 
from library
order by libraryname
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $lib;
    my @lib;
    while ($lib = $sth->fetchrow()){
	push @lib, $lib;
    }
    $sth->finish;
    my $return = \@lib;
    bless $return , 'libraryname_choice';
    return ($return);
    
}

sub get_list_depending_on_species_entry {
    my ($pkg, $dbh, $species) = @_;
    my $statement = "
select libraryname 
from library
where speciesname = \'$species\'
order by libraryname
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $lib;
    my @lib;
    while ($lib = $sth->fetchrow()){
	push @lib, $lib;
    }
    $sth->finish;
    my $return = \@lib;
    bless $return , 'libraryname_choice';
    return ($return);
    
}

package status_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select description  
from clonestatusdict
order by id_dict
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $status;
    my @status;
    while ($status = $sth->fetchrow()){
	push @status, $status;
    }
    $sth->finish;
    my $return = \@status;
    bless $return , 'status_choice';
    return ($return);
}

package clonetype_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select description  
from clonetypedict
order by id_dict
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $type;
    my @type;
    while ($type = $sth->fetchrow()){
	push @type, $type;
    }
    $sth->finish;
    my $return = \@type;
    bless $return , 'clonetype_choice';
    return ($return);
}

package clonepriority_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select description  
from cloneprioritydict
order by id_dict
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $priority;
    my @priority;
    while ($priority = $sth->fetchrow()){
	push @priority, $priority;
    }
    $sth->finish;
    my $return = \@priority;
    bless $return , 'clonepriority_choice';
    return ($return);
}


package confirmation_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select description 
from confirmationdict
order by ID_DICT
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $list;
    my @list;
    push @list, "Not checked";
    while ($list = $sth->fetchrow()){
	push @list, $list;
    }
    $sth->finish;
    my $return = \@list;
    bless $return , 'confirmation_choice';
    return ($return);
}

package variation_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select description 
from variationdict
order by ID_DICT
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $list;
    my @list;
    push @list, "Not checked";
    while ($list = $sth->fetchrow()){
	push @list, $list;
    }
    $sth->finish;
    my $return = \@list;
    bless $return , 'variation_choice';
    return ($return);
}

######################
# Lists for gull_proj 
######################
package type_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select description  
from repositorytypedict
order by id_dict
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $status;
    my @status;
    while ($status = $sth->fetchrow()){
	push @status, $status;
    }
    $sth->finish;
    my $return = \@status;
    bless $return , 'type_choice';
    return ($return);
}

package project_status_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select description  
from projectstatusdict
order by assign_order
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $status;
    my @status;
    while ($status = $sth->fetchrow()){
	push @status, $status;
    }
    $sth->finish;
    my $return = \@status;
    bless $return , 'project_status_choice';
    return ($return);
}

package finisher_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select person.email||' - '||team_person_role.teamname
from person, team_person_role
where person.id_person = team_person_role.id_person
and team_person_role.roletype = 'Finishing'
and person.iscurrent = 1
and team_person_role.iscurrent = 1
order by person.email asc
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $finisher;
    my @finisher;
    while ($finisher = $sth->fetchrow() ){
	push @finisher, $finisher;
    }
    $sth->finish;
    my $return = \@finisher;
    bless $return, 'finisher_choice';
    return ($return);
}


sub get_list_depending_on_team_entry {
    my ($pkg, $dbh, $teamo_var) = @_;
    my $statement = "
select person.email||' - '||team_person_role.teamname
from person, team_person_role
where person.id_person = team_person_role.id_person
and team_person_role.roletype = 'Finishing'
and team_person_role.teamname = \'$teamo_var\'
and person.iscurrent = 1
and team_person_role.iscurrent = 1
order by person.email asc
";

#    warn "\n$statement\n";


    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $finisher;
    my @finisher;
    while ($finisher = $sth->fetchrow() ){
	push @finisher, $finisher;
    }
    $sth->finish;
    my $return = \@finisher;
    bless $return, 'finisher_choice';
    return ($return);
}

##### start new

package checker_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select person.email
from person, team_person_role
where person.id_person = team_person_role.id_person
and team_person_role.roletype = 'Checking'
and person.iscurrent = 1
and team_person_role.iscurrent = 1
order by person.email asc
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $pfinisher;
    my @pfinisher;
    while ($pfinisher = $sth->fetchrow() ){
	push @pfinisher, $pfinisher;
    }
    $sth->finish;
    my $return = \@pfinisher;
    bless $return, 'checker_choice';
    return ($return);
}


sub get_list_depending_on_team_entry {
    my ($pkg, $dbh, $teamo_var) = @_;
    my $statement = "
select person.email
from person, team_person_role
where person.id_person = team_person_role.id_person
and team_person_role.roletype = 'Checking'
and team_person_role.teamname = \'$teamo_var\'
and person.iscurrent = 1
and team_person_role.iscurrent = 1
order by person.email asc
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $pfinisher;
    my @pfinisher;
    while ($pfinisher = $sth->fetchrow() ){
	push @pfinisher, $pfinisher;
    }
    $sth->finish;
    my $return = \@pfinisher;
    bless $return, 'checker_choice';
    return ($return);
}

##### end new

package prefinisher_choice;
sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "
select person.email
from person, team_person_role
where person.id_person = team_person_role.id_person
and team_person_role.roletype = 'Prefinishing'
and person.iscurrent = 1
and team_person_role.iscurrent = 1
order by person.email asc
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $pfinisher;
    my @pfinisher;
    while ($pfinisher = $sth->fetchrow() ){
	push @pfinisher, $pfinisher;
    }
    $sth->finish;
    my $return = \@pfinisher;
    bless $return, 'prefinisher_choice';
    return ($return);
}


sub get_list_depending_on_team_entry {
    my ($pkg, $dbh, $teamo_var) = @_;
    my $statement = "
select person.email
from person, team_person_role
where person.id_person = team_person_role.id_person
and team_person_role.roletype = 'Prefinishing'
and team_person_role.teamname = \'$teamo_var\'
and person.iscurrent = 1
and team_person_role.iscurrent = 1
order by person.email asc
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $pfinisher;
    my @pfinisher;
    while ($pfinisher = $sth->fetchrow() ){
	push @pfinisher, $pfinisher;
    }
    $sth->finish;
    my $return = \@pfinisher;
    bless $return, 'prefinisher_choice';
    return ($return);
}


###############################
###############################

package team_reason_choice;

sub get_list {
    my ($pkg, $dbh) = @_;
    my $statement = "select description from projectownerdict order by id_dict desc";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $reason;
    my @reason;
    while ($reason = $sth->fetchrow() ){
	push @reason, $reason;
    }
    $sth->finish;
    my $return = \@reason;
    bless $return, 'team_reason_choice';
    return ($return);
}


package team_choice;
sub get_list {
    my ($pkg, $dbh) = @_;

    my $statement = "select teamname from team order by teamname desc";

    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $finisher;
    my @finisher;
    while ($finisher = $sth->fetchrow() ){
	push @finisher, $finisher;
    }
    $sth->finish;
    my $return = \@finisher;
    bless $return, 'team_choice';
    return ($return);
}

sub get_list_depending_on_finisher_entry {
    my ($pkg, $dbh, $fin_var) = @_;

#    my $statement = "select teamname from team order by teamname desc";

    my $statement = "
select team.teamname 
from team, team_person, person
where person.id_person = team_person.id_person
and team_person.teamname = team.teamname 
and person.email = \'$fin_var\'
";
    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $finisher;
    my @finisher;
    while ($finisher = $sth->fetchrow() ){
	push @finisher, $finisher;
    }
    $sth->finish;
    my $return = \@finisher;
    bless $return, 'team_choice';
    return ($return);

}

package robot_choice;
sub get_list {
    my ($pkg, $dbh) = @_;

    my $statement = "select robotname from robot";

    my $sth = $dbh->prepare($statement) || die "ERROR:$DBI::errstr";
    $sth->execute || die "ERROR:$DBI::errstr";
    my $robot;
    my @robot;
    while ($robot = $sth->fetchrow() ){
	push @robot, $robot;
    }
    $sth->finish;
    my $return = \@robot;
    bless $return, 'robot_choice';
    return ($return);
}

1;





