From 5ff0647adadeea93c1d8332f5aa2943c1912aec9 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. --- 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 | 162 +++++++++++++++++- .../prog/en/modules/circ/request-article.tt | 2 + .../bootstrap/en/modules/opac-user.tt | 2 + svc/article_request | 3 + 11 files changed, 208 insertions(+), 14 deletions(-) diff --git a/Koha/ArticleRequest.pm b/Koha/ArticleRequest.pm index 2c47dd03fe..6a8716204d 100644 --- a/Koha/ArticleRequest.pm +++ b/Koha/ArticleRequest.pm @@ -40,6 +40,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 @@ -106,7 +119,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 => { @@ -199,7 +212,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 9b27615573..ac7c82a163 100644 --- a/Koha/ArticleRequests.pm +++ b/Koha/ArticleRequests.pm @@ -61,6 +61,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 fc1affe233..1356683bb9 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -368,6 +368,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 8c1592c3f2..0980b36400 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -983,6 +983,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 3e856bcafa..10bdab4497 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 eec1c7432e..7fb8c59e90 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 @@