From 3fc76156e29a345bd7e603b390c93303a11463d7 Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Tue, 30 Mar 2021 10:52:31 -0300 Subject: [PATCH] Bug 27944: Add "requested" stage in article request process This patch adds the stage "requested" in article request process, which is previous to pending stage. To test: 1. apply this patch 2. updatedatabase 3. enable ArticleRequests syspref 4. from staff inteface and from opac search for a record and place an article request 5. koha-mysql kohadev 6. query: select subject, content, letter_code from message_queue; CHECK => There is a message for each article request with code AR_REQUESTED => In opac-user.pl, in "Article requests" tab you should see a row in the table with "Requested" status 5. in staff go to Circulation -> Article Requests SUCCESS => You should see 3 tabs, one for Requested stage (with two requests), one for Pending stage and one for Processing stage. 6. play with actions buttons CHECK => you should see a new action called "Set request as pending" SUCCESS => All action buttons behave as expected, and tab counts updates correctly. Signed-off-by: Marcel de Rooy Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- Koha/ArticleRequest.pm | 17 +- Koha/ArticleRequest/Status.pm | 21 ++- Koha/ArticleRequests.pm | 11 ++ Koha/Biblio.pm | 1 + Koha/Patron.pm | 1 + Koha/Template/Plugin/Biblio.pm | 1 + circ/article-requests.pl | 1 + .../prog/en/modules/circ/article-requests.tt | 173 +++++++++++++++++- .../prog/en/modules/circ/request-article.tt | 2 + .../bootstrap/en/modules/opac-user.tt | 2 + svc/article_request | 3 + 11 files changed, 217 insertions(+), 16 deletions(-) diff --git a/Koha/ArticleRequest.pm b/Koha/ArticleRequest.pm index 05b0e32542..b73f5ff81f 100644 --- a/Koha/ArticleRequest.pm +++ b/Koha/ArticleRequest.pm @@ -39,6 +39,19 @@ Koha::ArticleRequest - Koha Article Request Object class =cut +=head3 request + +=cut + +sub request { + my ($self) = @_; + + $self->status(Koha::ArticleRequest::Status::Requested); + $self->SUPER::store(); + $self->notify(); + return $self; +} + =head3 open =cut @@ -105,7 +118,7 @@ sub notify { if ( my $letter = C4::Letters::GetPreparedLetter( module => 'circulation', - letter_code => "AR_$status", # AR_PENDING, AR_PROCESSING, AR_COMPLETED, AR_CANCELED + letter_code => "AR_$status", # AR_REQUESTED, AR_PENDING, AR_PROCESSING, AR_COMPLETED, AR_CANCELED message_transport_type => 'email', lang => $self->borrower->lang, tables => { @@ -198,7 +211,7 @@ sub store { return $self->SUPER::store; } else { $self->created_on( dt_from_string() ); - return $self->open; + return $self->request; } } diff --git a/Koha/ArticleRequest/Status.pm b/Koha/ArticleRequest/Status.pm index 42de00d551..859e9f4a56 100644 --- a/Koha/ArticleRequest/Status.pm +++ b/Koha/ArticleRequest/Status.pm @@ -19,6 +19,22 @@ package Koha::ArticleRequest::Status; use Modern::Perl; +=head1 AUTHOR + +Kyle M Hall + +=cut + +=head2 Requested + + returns constant string 'REQUESTED' + +=cut + +sub Requested { + return 'REQUESTED'; +} + sub Pending { return 'PENDING'; } @@ -35,10 +51,5 @@ sub Canceled { return 'CANCELED'; } -=head1 AUTHOR - -Kyle M Hall - -=cut 1; diff --git a/Koha/ArticleRequests.pm b/Koha/ArticleRequests.pm index 2d3dce5627..662677af64 100644 --- a/Koha/ArticleRequests.pm +++ b/Koha/ArticleRequests.pm @@ -60,6 +60,17 @@ sub search_limited { return $self->search( $params, $attributes ); } +=head3 requested + +=cut + +sub requested { + my ( $self, $branchcode ) = @_; + my $params = { status => Koha::ArticleRequest::Status::Requested }; + $params->{'me.branchcode'} = $branchcode if $branchcode; + return Koha::ArticleRequests->search_limited($params); +} + =head3 pending =cut diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 4cd70ef388..286389864a 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -371,6 +371,7 @@ sub article_requests_current { { biblionumber => $self->biblionumber(), -or => [ + { status => Koha::ArticleRequest::Status::Requested }, { status => Koha::ArticleRequest::Status::Pending }, { status => Koha::ArticleRequest::Status::Processing } ] diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 941dace0df..b861e53e9e 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -992,6 +992,7 @@ sub article_requests_current { { borrowernumber => $self->id(), -or => [ + { status => Koha::ArticleRequest::Status::Requested }, { status => Koha::ArticleRequest::Status::Pending }, { status => Koha::ArticleRequest::Status::Processing } ] diff --git a/Koha/Template/Plugin/Biblio.pm b/Koha/Template/Plugin/Biblio.pm index e9d7a73009..5ec3542294 100644 --- a/Koha/Template/Plugin/Biblio.pm +++ b/Koha/Template/Plugin/Biblio.pm @@ -44,6 +44,7 @@ sub ArticleRequestsActiveCount { biblionumber => $biblionumber, status => [ -or => [ + status => Koha::ArticleRequest::Status::Requested, status => Koha::ArticleRequest::Status::Pending, status => Koha::ArticleRequest::Status::Processing ] diff --git a/circ/article-requests.pl b/circ/article-requests.pl index 3e918dd4c6..026483bdc7 100755 --- a/circ/article-requests.pl +++ b/circ/article-requests.pl @@ -39,6 +39,7 @@ my $branchcode = defined( $query->param('branchcode') ) ? $query->param('branchc $template->param( branchcode => $branchcode, + article_requests_requested => scalar Koha::ArticleRequests->requested($branchcode), article_requests_pending => scalar Koha::ArticleRequests->pending($branchcode), article_requests_processing => scalar Koha::ArticleRequests->processing($branchcode), ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt index 61e94ca026..fabf326dd2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt @@ -19,6 +19,11 @@