# Copyright 2000-2003 Katipo Communications
# Copyright 2010 BibLibre
+# Parts Copyright 2010 Catalyst IT
#
# This file is part of Koha.
#
my $query;
my $sth;
if ($borrowernumber) {
- $sth = $dbh->prepare("select borrowers.*,category_type,categories.description from borrowers left join categories on borrowers.categorycode=categories.categorycode where borrowernumber=?");
+ $sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee 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 from borrowers left join categories on borrowers.categorycode=categories.categorycode where cardnumber=?");
+ $sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE cardnumber=?");
$sth->execute($cardnumber);
}
else {
$sth->execute( $borrower->{'categorycode'} );
my $enrolment = $sth->fetchrow;
$borrower->{'enrolmentperiod'} = $enrolment;
+
return ($borrower); #, $flags, $accessflagshash);
}
#'
sub GetPendingIssues {
- my (@borrowernumbers) = @_;
+ my @borrowernumbers = @_;
+
+ unless (@borrowernumbers ) { # return a ref_to_array
+ return \@borrowernumbers; # to not cause surprise to caller
+ }
# Borrowers part of the query
my $bquery = '';
for (my $i = 0; $i < @borrowernumbers; $i++) {
- $bquery .= " borrowernumber = ?";
- $bquery .= " OR" if ($i < (scalar(@borrowernumbers) - 1));
+ $bquery .= ' borrowernumber = ?';
+ if ($i < $#borrowernumbers ) {
+ $bquery .= ' OR';
+ }
}
# must avoid biblioitems.* to prevent large marc and marcxml fields from killing performance
$sth->execute(@borrowernumbers);
my $data = $sth->fetchall_arrayref({});
my $today = C4::Dates->new->output('iso');
- foreach (@$data) {
- $_->{date_due} or next;
- ($_->{date_due} lt $today) and $_->{overdue} = 1;
+ foreach (@{$data}) {
+ if ($_->{date_due} and $_->{date_due} lt $today) {
+ $_->{overdue} = 1;
+ }
}
return $data;
}