From c585b5cde5c12a6c7c922e15e55ed09604c533d2 Mon Sep 17 00:00:00 2001 From: Lyon3 Team Date: Tue, 12 Nov 2013 15:50:34 -0400 Subject: [PATCH] Bug 8231 Systematic warning at check in if borrower is restricted Display, at check in, a reminder of an already existing suspension date even if the returned document is not late Test plan : 1) Apply the patch 2) Go to a borrower checkout page and checkout some documents with different passed duedate using "Specify due date" function. Checkout out one with the default duedate. 3) Check in the document with the bigger delay : You will get the message : 'X is now restricted until ...' 4) Check in one of the document with a smaller delay : You'll get a different message : 'Reminder : Patron was earlier restricted until...' 5) Check in the document which is not late : You'll get the same message as the previous one --- C4/Circulation.pm | 19 ++++++++++++++----- circ/returns.pl | 3 +++ .../intranet-tmpl/prog/en/modules/circ/returns.tt | 3 +++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 0a22b76..3b6976c 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1875,10 +1875,16 @@ sub AddReturn { defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->{itemnumber}...) failed!"; # zero is OK, check defined if ( $issue->{overdue} && $issue->{date_due} ) { -# fix fine days - my $debardate = - _debar_user_on_return( $borrower, $item, $issue->{date_due}, $today ); - $messages->{Debarred} = $debardate if ($debardate); + # fix fine days + my ($debardate,$reminder) = _debar_user_on_return( $borrower, $item, $issue->{date_due}, $today ); + if ($reminder){ + $messages->{'PrevDebarred'} = $debardate; + } else { + $messages->{'Debarred'} = $debardate if $debardate; + } + # there's no overdue on the item but borrower had been previously debarred + } elsif ( $issue->{date_due} and $borrower->{debarred} ) { + $messages->{'PrevDebarred'} = $borrower->{'debarred'}; } } @@ -2070,7 +2076,10 @@ sub _debar_user_on_return { expiration => $new_debar_dt->ymd(), type => 'SUSPENSION', }); - + # if borrower was already debarred but does not get an extra debarment + if ( $borrower->{debarred} eq Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber}) ) { + return ($borrower->{debarred},1); + } return $new_debar_dt->ymd(); } } diff --git a/circ/returns.pl b/circ/returns.pl index 93f36f2..0deebda 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -467,6 +467,9 @@ foreach my $code ( keys %$messages ) { $err{debarborrowernumber} = $borrower->{borrowernumber}; $err{debarname} = "$borrower->{firstname} $borrower->{surname}"; } + elsif ( $code eq 'PrevDebarred' ) { + $err{prevdebarred} = $messages->{'PrevDebarred'}; + } else { die "Unknown error code $code"; # note we need all the (empty) elsif's above, or we die. # This forces the issue of staying in sync w/ Circulation.pm diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt index fb30311..f51eaef 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -350,6 +350,9 @@ $(document).ready(function () { [% IF ( errmsgloo.debarred ) %]

[% errmsgloo.debarname %]([% errmsgloo.debarcardnumber %]) is now debarred until [% errmsgloo.debarred | $KohaDates %]

[% END %] + [% IF ( errmsgloo.prevdebarred ) %] +

Reminder: Patron was earlier restricted until [% errmsgloo.prevdebarred | $KohaDates %]

+ [% END %] [% END %] [% IF ( soundon ) %] -- 1.7.2.5