package RT::CustomFieldValues::MinMaxisteClientId;

use strict;
use warnings;

use base qw(RT::CustomFieldValues::External);

sub SourceDescription {
	return 'MinMaxiste Client';
}

sub ExternalValues {
	my $self = shift;

	my $dbh = DBI->connect(
		"dbi:Pg:dbname=minmaxiste",
		"",
		"",
		{AutoCommit => 0, RaiseError => 1});
	my $sth = $dbh->prepare("select name from clients order by name");
	$sth->execute();
	$dbh->rollback();

	my @res;
	my $i = 0;
	while (my $row = $sth->fetchrow_hashref()) {
		push (@res, {
			name =>$row->{'name'},
			sortorder => $i++,
		});
		
	}
	$sth->finish();
	return \@res;
}

1;
