# Copyright 2000-2002 Katipo Communications
+# copyright 2010 BibLibre
#
# This file is part of Koha.
#
# subs to move to Members.pm
push @EXPORT, qw(
&CheckBorrowerDebarred
- &UpdateBorrowerDebarred
);
# subs to move to Biblio.pm
push @EXPORT, qw(
sub checkoverdues {
my $borrowernumber = shift or return;
+ # don't select biblioitems.marc or biblioitems.marcxml... too slow on large systems
my $sth = C4::Context->dbh->prepare(
- "SELECT * FROM issues
+ "SELECT biblio.*, items.*, issues.*,
+ biblioitems.volume,
+ biblioitems.number,
+ biblioitems.itemtype,
+ biblioitems.isbn,
+ biblioitems.issn,
+ biblioitems.publicationyear,
+ biblioitems.publishercode,
+ biblioitems.volumedate,
+ biblioitems.volumedesc,
+ biblioitems.collectiontitle,
+ biblioitems.collectionissn,
+ biblioitems.collectionvolume,
+ biblioitems.editionstatement,
+ biblioitems.editionresponsibility,
+ biblioitems.illus,
+ biblioitems.pages,
+ biblioitems.notes,
+ biblioitems.size,
+ biblioitems.place,
+ biblioitems.lccn,
+ biblioitems.url,
+ biblioitems.cn_source,
+ biblioitems.cn_class,
+ biblioitems.cn_item,
+ biblioitems.cn_suffix,
+ biblioitems.cn_sort,
+ biblioitems.totalissues
+ FROM issues
LEFT JOIN items ON issues.itemnumber = items.itemnumber
LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber
LEFT JOIN biblioitems ON items.biblioitemnumber = biblioitems.biblioitemnumber
if ( my $data = $sth->fetchrow_hashref ) {
- # we're updating an existing fine. Only modify if we're adding to the charge.
+ # we're updating an existing fine. Only modify if amount changed
# Note that in the current implementation, you cannot pay against an accruing fine
# (i.e. , of accounttype 'FU'). Doing so will break accrual.
if ( $data->{'amount'} != $amount ) {
my $diff = $amount - $data->{'amount'};
- $diff = 0 if ( $data->{amount} > $amount);
+ #3341: diff could be positive or negative!
my $out = $data->{'amountoutstanding'} + $diff;
my $query = "
UPDATE accountlines
sub GetBranchcodesWithOverdueRules {
my $dbh = C4::Context->dbh;
- my $rqoverduebranches = $dbh->prepare("SELECT DISTINCT branchcode FROM overduerules WHERE delay1 IS NOT NULL AND branchcode <> ''");
+ my $rqoverduebranches = $dbh->prepare("SELECT DISTINCT branchcode FROM overduerules WHERE delay1 IS NOT NULL AND branchcode <> '' ORDER BY branchcode");
$rqoverduebranches->execute;
my @branches = map { shift @$_ } @{ $rqoverduebranches->fetchall_arrayref };
+ if (!$branches[0]) {
+ my $availbranches = C4::Branch::GetBranches();
+ @branches = keys %$availbranches;
+ }
return @branches;
}
SELECT debarred
FROM borrowers
WHERE borrowernumber=?
+ AND debarred > NOW()
|;
my $sth = $dbh->prepare($query);
$sth->execute($borrowernumber);
- my ($debarredstatus) = $sth->fetchrow;
- return ( $debarredstatus eq '1' ? 1 : 0 );
+ my $debarredstatus = $sth->fetchrow;
+ return $debarredstatus;
}
-=head2 UpdateBorrowerDebarred
-
- ($borrowerstatut) = &UpdateBorrowerDebarred($borrowernumber);
-
-update status of borrowers in borrowers table (field debarred)
-
-C<$borrowernumber> borrower number
-
-=cut
-
-sub UpdateBorrowerDebarred{
- my($borrowernumber) = @_;
- my $dbh = C4::Context->dbh;
- my $query=qq|UPDATE borrowers
- SET debarred='1'
- WHERE borrowernumber=?
- |;
- my $sth=$dbh->prepare($query);
- $sth->execute($borrowernumber);
- $sth->finish;
- return 1;
-}
=head2 CheckExistantNotifyid