diff --git a/C4/Circulation.pm b/C4/Circulation.pm index ca9c669faf..2e45a82735 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -22,6 +22,7 @@ use Modern::Perl; use DateTime; use POSIX qw( floor ); use Encode; +use Try::Tiny; use C4::Context; use C4::Stats qw( UpdateStats ); @@ -1736,7 +1737,14 @@ sub AddIssue { ); } $issue->discard_changes; - $patron->update_lastseen('check_out'); + #Update borrowers.lastseen + try{ + $patron->update_lastseen('check_out'); + } + catch { + my $exception = $_; + warn "Problem updating lastseen date for borrowernumber " . $patron->borrowernumber . ": $exception"; + }; if ( $item_object->location && $item_object->location eq 'CART' && ( !$item_object->permanent_location || $item_object->permanent_location ne 'CART' ) ) { ## Item was moved to cart via UpdateItemLocationOnCheckin, anything issued should be taken off the cart. @@ -2499,7 +2507,14 @@ sub AddReturn { if C4::Context->preference("ReturnLog"); #Update borrowers.lastseen - $patron->update_lastseen('check_in'); + try{ + $patron->update_lastseen('check_in'); + } + catch { + my $exception = $_; + warn "Problem updating lastseen date for borrowernumber " . $patron->borrowernumber . ": $exception"; + $messages->{UpdateLastSeenError} = "$exception"; + }; } # Check if this item belongs to a biblio record that is attached to an @@ -3410,7 +3425,14 @@ sub AddRenewal { } ); #Update borrowers.lastseen - $patron->update_lastseen('renewal'); + try{ + $patron->update_lastseen('renewal'); + } + catch { + my $exception = $_; + warn "Problem updating lastseen date for borrowernumber " . $patron->borrowernumber . ": $exception"; + }; + #Log the renewal logaction("CIRCULATION", "RENEWAL", $borrowernumber, $itemnumber) if C4::Context->preference("RenewalLog"); diff --git a/circ/returns.pl b/circ/returns.pl index f9c2519fa9..a9975a816a 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -768,6 +768,8 @@ foreach my $code ( keys %$messages ) { ; } elsif ( $code eq 'InBundle' ) { $template->param( InBundle => $messages->{InBundle} ); + } elsif ( $code eq 'UpdateLastSeenError' ) { + $err{UpdateLastSeenError} = $messages->{UpdateLastSeenError}; } 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 19d6413316..cd6f35ffe2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -267,8 +267,17 @@

[% item.barcode | html %]: [% title | html %]

[% END %] [% FOREACH errmsgloo IN errmsgloop %] + [% IF ( errmsgloo.UpdateLastSeenError ) %] +
+

Error updating patron's last seen date

+

The item has been checked in, but the issue below must be corrected:

+

The system encountered an error when updating the patron's last seen date:

+

[% errmsgloo.UpdateLastSeenError | html %]

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

+ [% IF errmsgloo.NotForLoanStatusUpdated.to == 'ONLYMESSAGE' %] [% AuthorisedValues.GetByCode( 'NOT_LOAN', errmsgloo.NotForLoanStatusUpdated.from ) | html %] [% ELSE %]