-my $sth = dbh->prepare("SELECT DISTINCT otaker FROM cust_credit")
- or die dbh->errstr;
-$sth->execute or die $sth->errstr;
-my @otakers = map { $_->[0] } @{$sth->fetchall_arrayref};
+my $access_user = $FS::CurrentUser::CurrentUser->access_users_hashref('table' => 'cust_credit');
+
+my $unapplied = $cgi->param('unapplied') ? 1 : 0;
+
+my $title = $cgi->param('unapplied') ?
+ 'Unapplied credit report' : 'Credit report';