From 90b91f97c8eb9d93b36d665487b321efd964c0d7 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 | 169 +++++++++++++++++- .../prog/en/modules/circ/request-article.tt | 2 + .../bootstrap/en/modules/opac-user.tt | 2 + svc/article_request | 3 + 11 files changed, 213 insertions(+), 16 deletions(-) diff --git a/Koha/ArticleRequest.pm b/Koha/ArticleRequest.pm index 6b8809bc33..3ea325d83d 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 be9561f583..31c52a14da 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -372,6 +372,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 e202fecdb7..3670313a05 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -993,6 +993,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 61e94ca026..435d813b05 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 @@