From f7c325a6ecc24d57e0d4c38acad1051e6a39a55e Mon Sep 17 00:00:00 2001 From: Lyon3 Team <koha@univ-lyon3.fr> Date: Thu, 14 Feb 2013 17:58:38 +0100 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 --- C4/Circulation.pm | 16 ++++++++++------ circ/returns.pl | 3 +++ .../intranet-tmpl/prog/en/modules/circ/returns.tt | 3 +++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index f1c8662..ab7f780 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1832,11 +1832,14 @@ sub AddReturn { my $fix = _FixOverduesOnReturn($borrowernumber, $item->{itemnumber}, $exemptfine, $dropbox); defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->{itemnumber}...) failed!"; # zero is OK, check defined - if ( $issue->{overdue} && $issue->{date_due} ) { + if ( $issue->{date_due} && ( $issue->{overdue} or $borrower->{'debarred'} )) { # fix fine days - my $debardate = - _debar_user_on_return( $borrower, $item, $issue->{date_due}, $today ); - $messages->{Debarred} = $debardate if ($debardate); + my ($debardate,$reminder) = _debar_user_on_return( $borrower, $item, $issue->{date_due}, $today ); + if ($reminder){ + $messages->{'PrevDebarred'} = $debardate; + } else { + $messages->{'Debarred'} = $debardate if $debardate; + } } } @@ -2012,12 +2015,13 @@ sub _debar_user_on_return { $dt_today->clone()->add_duration( $deltadays * $finedays ); if ( $borrower->{debarred} ) { my $borrower_debar_dt = dt_from_string( $borrower->{debarred} ); - + $borrower_debar_dt->truncate(to => 'day'); + $new_debar_dt->truncate(to=>'day'); # Update patron only if new date > old if ( DateTime->compare( $borrower_debar_dt, $new_debar_dt ) != -1 ) { - return; + return ($borrower_debar_dt,1); } } diff --git a/circ/returns.pl b/circ/returns.pl index 9472797..22246ec 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -457,6 +457,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 7fd8d1d..415da8a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -349,6 +349,9 @@ $(document).ready(function () { [% IF ( errmsgloo.debarred ) %] <p class="problem"><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% errmsgloo.debarborrowernumber %]">[% errmsgloo.debarname %]([% errmsgloo.debarcardnumber %])</a> is now debarred until [% errmsgloo.debarred | $KohaDates %] </p> [% END %] + [% IF ( errmsgloo.prevdebarred ) %] + <p class="problem"><b>Reminder: </b>Patron was earlier restricted until [% errmsgloo.prevdebarred | $KohaDates %]</p> + [% END %] [% END %] [% IF ( soundon ) %] <audio src="/intranet-tmpl/prog/sound/critical.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio> -- 1.7.2.5