my $query;
my $sth;
if ($borrowernumber) {
- $sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE borrowernumber=?");
+ $sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee,enrolmentperiod FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE borrowernumber=?");
$sth->execute($borrowernumber);
}
elsif ($cardnumber) {
- $sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE cardnumber=?");
+ $sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee,enrolmentperiod FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE cardnumber=?");
$sth->execute($cardnumber);
}
else {
$borrower->{'flags'} = $flags;
$borrower->{'authflags'} = $accessflagshash;
- # find out how long the membership lasts
- $sth =
- $dbh->prepare(
- "select enrolmentperiod from categories where categorycode = ?");
- $sth->execute( $borrower->{'categorycode'} );
- my $enrolment = $sth->fetchrow;
- $borrower->{'enrolmentperiod'} = $enrolment;
-
+ # For the purposes of making templates easier, we'll define a
+ # 'showname' which is the alternate form the user's first name if
+ # 'other name' is defined.
+ if ($borrower->{category_type} eq 'I') {
+ $borrower->{'showname'} = $borrower->{'othernames'};
+ $borrower->{'showname'} .= " $borrower->{'firstname'}" if $borrower->{'firstname'};
+ } else {
+ $borrower->{'showname'} = $borrower->{'firstname'};
+ }
+
return ($borrower); #, $flags, $accessflagshash);
}