From 2568e165e654c94e6a702e58e9d1d8241d551955 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sat, 1 May 2010 11:58:23 -0400 Subject: [PATCH 1/3] bug 4036: do not count item overdue if it is due today * use curdate() instead of now() to test whether item is overdue * enhanced POD of IsMemberBlocked Signed-off-by: Galen Charlton --- C4/Members.pm | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 60a3164e64..848fdd1c10 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -579,17 +579,26 @@ sub GetMember { =over 4 -my $blocked = IsMemberBlocked( $borrowernumber ); - -return the status, and the number of day or documents, depends his punishment - -return : --1 if the user have overdue returns -1 if the user is punished X days -0 if the user is authorised to loan +my ($block_status, $count) = IsMemberBlocked( $borrowernumber ); =back +Returns whether a patron has overdue items that may result +in a block or whether the patron has active fine days +that would block circulation privileges. + +C<$block_status> can have the following values: + +-1 if the patron has overdue items, in which case C<$count> is the number of them + +1 if the patron has outstanding fine days, in which case C<$count> is the number of them + +0 if the patron has no overdue items or outstanding fine days, in which case C<$count> is 0 + +FIXME: this needs to be split into two functions; a potential block +based on the number of current overdue items could be orthogonal +to a block based on whether the patron has any fine days accrued. + =cut sub IsMemberBlocked { @@ -600,7 +609,7 @@ sub IsMemberBlocked { "SELECT COUNT(*) as latedocs FROM issues WHERE borrowernumber = ? - AND date_due < now()" + AND date_due < curdate()" ); $sth->execute($borrowernumber); my $latedocs = $sth->fetchrow_hashref->{'latedocs'}; @@ -638,7 +647,7 @@ sub IsMemberBlocked { return (1, $blockedcount) if $blockedcount > 0; - return 0 + return (0, 0); } =head2 GetMemberIssuesAndFines From a445e956ebfec3ce932533f51c2ace19db49e1f7 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sat, 1 May 2010 12:08:17 -0400 Subject: [PATCH 2/3] bug 4429: do not include items due today in overdue count Use curdate() instead of now() in GetMemberIssuesAndFines. Signed-off-by: Galen Charlton --- C4/Members.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/Members.pm b/C4/Members.pm index 848fdd1c10..19cc9fa299 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -678,7 +678,7 @@ sub GetMemberIssuesAndFines { $sth = $dbh->prepare( "SELECT COUNT(*) FROM issues WHERE borrowernumber = ? - AND date_due < now()" + AND date_due < curdate()" ); $sth->execute($borrowernumber); my $overdue_count = $sth->fetchrow_arrayref->[0]; From d575278cbaf59e0937632ae6abcc0eaca5852429 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sat, 1 May 2010 12:43:07 -0400 Subject: [PATCH 3/3] bug 4036, 4405: overdue and fine day block improvements * Adopted wording suggested by Kyle Hall for the USERBLOCKEDREMAINING and USERBLOCKEDOVERDUE circulation blocks * Updated IsMemberBlocked so that if a patron has accrued fine days, that will be tested for first before testing to see if the patron has current overdue items; this solves a problem introduced in the patch series for bug 4505 where accrued fine days would be ignored if (a) the patron has current overdue items but (b) the library has chosen to set the OverduesBlockCirc syspref to noblock. * Now correctly assigns the USERBLOCKEDREMAINING and USERBLOCKEDOVERDUE blocks; prior to this patch, they had been swapped. FIXME: IsMemberBlock ought to be split into two functions Signed-off-by: Galen Charlton --- C4/Circulation.pm | 22 ++++++------ C4/Members.pm | 34 +++++++++++-------- .../prog/en/modules/circ/circulation.tmpl | 12 ++++--- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 833d44d3c5..a052d13092 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -732,17 +732,17 @@ sub CanBookBeIssued { } my ($blocktype, $count) = C4::Members::IsMemberBlocked($borrower->{'borrowernumber'}); - if($blocktype == -1){ - ## remaining overdue documentsi - if ( C4::Context->preference("OverduesBlockCirc") eq 'block'){ - $issuingimpossible{USERBLOCKEDREMAINING} = $count; - } - elsif ( C4::Context->preference("OverduesBlockCirc") eq 'confirmation'){ - $needsconfirmation{USERBLOCKEDREMAINING} = $count; - } - }elsif($blocktype == 1){ - ## blocked because of overdue return - $issuingimpossible{USERBLOCKEDOVERDUE} = $count; + if ($blocktype == -1) { + ## patron has outstanding overdue loans + if ( C4::Context->preference("OverduesBlockCirc") eq 'block'){ + $issuingimpossible{USERBLOCKEDOVERDUE} = $count; + } + elsif ( C4::Context->preference("OverduesBlockCirc") eq 'confirmation'){ + $needsconfirmation{USERBLOCKEDOVERDUE} = $count; + } + } elsif($blocktype == 1) { + # patron has accrued fine days + $issuingimpossible{USERBLOCKEDREMAINING} = $count; } # diff --git a/C4/Members.pm b/C4/Members.pm index 19cc9fa299..30e9f2d78b 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -589,12 +589,15 @@ that would block circulation privileges. C<$block_status> can have the following values: --1 if the patron has overdue items, in which case C<$count> is the number of them - 1 if the patron has outstanding fine days, in which case C<$count> is the number of them +-1 if the patron has overdue items, in which case C<$count> is the number of them + 0 if the patron has no overdue items or outstanding fine days, in which case C<$count> is 0 +Outstanding fine days are checked before current overdue items +are. + FIXME: this needs to be split into two functions; a potential block based on the number of current overdue items could be orthogonal to a block based on whether the patron has any fine days accrued. @@ -604,25 +607,14 @@ to a block based on whether the patron has any fine days accrued. sub IsMemberBlocked { my $borrowernumber = shift; my $dbh = C4::Context->dbh; - # if he have late issues - my $sth = $dbh->prepare( - "SELECT COUNT(*) as latedocs - FROM issues - WHERE borrowernumber = ? - AND date_due < curdate()" - ); - $sth->execute($borrowernumber); - my $latedocs = $sth->fetchrow_hashref->{'latedocs'}; - - return (-1, $latedocs) if $latedocs > 0; + # does patron have current fine days? my $strsth=qq{ SELECT ADDDATE(returndate, finedays * DATEDIFF(returndate,date_due) ) AS blockingdate, DATEDIFF(ADDDATE(returndate, finedays * DATEDIFF(returndate,date_due)),NOW()) AS blockedcount FROM old_issues }; - # or if he must wait to loan if(C4::Context->preference("item-level_itypes")){ $strsth.= qq{ LEFT JOIN items ON (items.itemnumber=old_issues.itemnumber) @@ -639,7 +631,7 @@ sub IsMemberBlocked { AND borrowernumber = ? ORDER BY blockingdate DESC, blockedcount DESC LIMIT 1}; - $sth=$dbh->prepare($strsth); + my $sth=$dbh->prepare($strsth); $sth->execute($borrowernumber); my $row = $sth->fetchrow_hashref; my $blockeddate = $row->{'blockeddate'}; @@ -647,6 +639,18 @@ sub IsMemberBlocked { return (1, $blockedcount) if $blockedcount > 0; + # if he have late issues + $sth = $dbh->prepare( + "SELECT COUNT(*) as latedocs + FROM issues + WHERE borrowernumber = ? + AND date_due < curdate()" + ); + $sth->execute($borrowernumber); + my $latedocs = $sth->fetchrow_hashref->{'latedocs'}; + + return (-1, $latedocs) if $latedocs > 0; + return (0, 0); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl index a2b1d09ad3..7515deef97 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl @@ -242,8 +242,8 @@ function refocus(calendar) {
  • Item is normally not for loan. Check out anyway?
  • - -
  • This patron has overdue items. Check out anyway?
  • + +
  • Patron has overdue item(s). Check out anyway?
  • @@ -340,9 +340,13 @@ function refocus(calendar) {
  • This item belongs to and cannot be issued from this location.
  • + + +
  • Patron has had overdue items and is blocked for day(s).
  • + - -
  • Patron has overdue items
  • + +
  • Patron has overdue item(s). Check out anyway?