From 40ef6a2a7c9498fddaa7d894cdacfc9db2220994 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 3 Mar 2025 15:32:08 -0100 Subject: [PATCH] Bug 37901: UpdateStats after new ILL request is created or completed Signed-off-by: Jeremy Evans --- Koha/ILL/Backend/Standard.pm | 2 ++ Koha/ILL/Request.pm | 53 ++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/Koha/ILL/Backend/Standard.pm b/Koha/ILL/Backend/Standard.pm index 444c0074d97..cb3e6b35ff5 100644 --- a/Koha/ILL/Backend/Standard.pm +++ b/Koha/ILL/Backend/Standard.pm @@ -1017,6 +1017,8 @@ sub add_request { $request->extended_attributes( \@request_details_array ); $request->add_unauthenticated_data( $params->{other} ) if $unauthenticated_request; + $request->after_created; + return $request; } diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm index 4c8453d4dd5..9718aac1154 100644 --- a/Koha/ILL/Request.pm +++ b/Koha/ILL/Request.pm @@ -913,6 +913,7 @@ sub mark_completed { my ($self) = @_; $self->status('COMP')->store; $self->completed( dt_from_string() )->store; + $self->after_completed(); return { error => 0, status => '', @@ -2117,6 +2118,58 @@ sub store { return $ret; } +=head3 after_completed + + $request->after_completed; + +Actions to be done after the request has been completed + +=cut + +sub after_completed { + my ($self) = @_; + + C4::Stats::UpdateStats( + { + borrowernumber => $self->borrowernumber // undef, + branch => $self->branchcode, + categorycode => $self->patron ? $self->patron->categorycode : undef, + ccode => undef, + illrequest_id => $self->illrequest_id, + itemnumber => undef, + itemtype => undef, + location => undef, + type => 'illreq_comp', + } + ); +} + +=head3 after_created + + $request->after_created; + +Actions to be done after the request has been fully created + +=cut + +sub after_created { + my ($self) = @_; + + C4::Stats::UpdateStats( + { + borrowernumber => $self->borrowernumber // undef, + branch => $self->branchcode, + categorycode => $self->patron ? $self->patron->categorycode : undef, + ccode => undef, + illrequest_id => $self->illrequest_id, + itemnumber => undef, + itemtype => undef, + location => undef, + type => 'illreq_created', + } + ); +} + =head3 requested_partners my $partners_string = $request->requested_partners; -- 2.39.5