From b211a5e7c1d8cc70410e1ebb31c7a96027157062 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 28 Jul 2015 11:53:36 -0400 Subject: [PATCH] Bug 14610 - Add ability to place document delivery / article requests in Koha --- C4/Letters.pm | 25 +- Koha/ArticleRequest.pm | 81 +++++ Koha/ArticleRequest/Status.pm | 44 +++ Koha/ArticleRequests.pm | 37 ++- Koha/Biblio.pm | 175 ++++++++++ Koha/Biblios.pm | 2 +- Koha/Borrower.pm | 70 ++++ Koha/Item.pm | 47 +++- Koha/Schema/Result/ArticleRequest.pm | 25 ++- Koha/Template/Plugin/Biblio.pm | 11 + circ/article-request-slip.pl | 66 ++++ circ/article-requests.pl | 44 +++ circ/request-article-cancel.pl | 45 +++ circ/request-article-do.pl | 68 ++++ circ/request-article.pl | 53 +++ installer/data/mysql/atomicupdate/bug_14610.sql | 2 + .../prog/en/includes/biblio-view-menu.inc | 1 + .../prog/en/modules/catalogue/results.tt | 1 + .../prog/en/modules/circ/article-requests.tt | 352 ++++++++++++++++++++ .../prog/en/modules/circ/circulation-home.tt | 3 + .../prog/en/modules/circ/request-article.tt | 245 ++++++++++++++ .../intranet-tmpl/prog/en/modules/intranet-main.tt | 9 + .../bootstrap/en/includes/opac-detail-sidebar.inc | 8 + .../bootstrap/en/modules/opac-request-article.tt | 157 +++++++++ .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 4 + .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 90 +++++ koha-tmpl/opac-tmpl/bootstrap/less/opac.less | 18 + mainpage.pl | 3 + opac/opac-article-request-cancel.pl | 47 +++ opac/opac-request-article-do.pl | 67 ++++ opac/opac-request-article.pl | 53 +++ opac/opac-user.pl | 2 + svc/article_request | 58 ++++ 33 files changed, 1894 insertions(+), 19 deletions(-) create mode 100644 Koha/ArticleRequest/Status.pm create mode 100755 circ/article-request-slip.pl create mode 100755 circ/article-requests.pl create mode 100755 circ/request-article-cancel.pl create mode 100755 circ/request-article-do.pl create mode 100755 circ/request-article.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt create mode 100755 opac/opac-article-request-cancel.pl create mode 100755 opac/opac-request-article-do.pl create mode 100755 opac/opac-request-article.pl create mode 100755 svc/article_request diff --git a/C4/Letters.pm b/C4/Letters.pm index db9f987..3108230 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -746,18 +746,19 @@ sub _parseletter_sth { # broke things for the rest of us. prepare_cached is a better # way to cache statement handles anyway. my $query = - ($table eq 'biblio' ) ? "SELECT * FROM $table WHERE biblionumber = ?" : - ($table eq 'biblioitems' ) ? "SELECT * FROM $table WHERE biblionumber = ?" : - ($table eq 'items' ) ? "SELECT * FROM $table WHERE itemnumber = ?" : - ($table eq 'issues' ) ? "SELECT * FROM $table WHERE itemnumber = ?" : - ($table eq 'old_issues' ) ? "SELECT * FROM $table WHERE itemnumber = ? ORDER BY timestamp DESC LIMIT 1" : - ($table eq 'reserves' ) ? "SELECT * FROM $table WHERE borrowernumber = ? and biblionumber = ?" : - ($table eq 'borrowers' ) ? "SELECT * FROM $table WHERE borrowernumber = ?" : - ($table eq 'branches' ) ? "SELECT * FROM $table WHERE branchcode = ?" : - ($table eq 'suggestions' ) ? "SELECT * FROM $table WHERE suggestionid = ?" : - ($table eq 'aqbooksellers') ? "SELECT * FROM $table WHERE id = ?" : - ($table eq 'aqorders' ) ? "SELECT * FROM $table WHERE ordernumber = ?" : - ($table eq 'opac_news' ) ? "SELECT * FROM $table WHERE idnew = ?" : + ($table eq 'biblio' ) ? "SELECT * FROM $table WHERE biblionumber = ?" : + ($table eq 'biblioitems' ) ? "SELECT * FROM $table WHERE biblionumber = ?" : + ($table eq 'items' ) ? "SELECT * FROM $table WHERE itemnumber = ?" : + ($table eq 'issues' ) ? "SELECT * FROM $table WHERE itemnumber = ?" : + ($table eq 'old_issues' ) ? "SELECT * FROM $table WHERE itemnumber = ? ORDER BY timestamp DESC LIMIT 1" : + ($table eq 'reserves' ) ? "SELECT * FROM $table WHERE borrowernumber = ? and biblionumber = ?" : + ($table eq 'borrowers' ) ? "SELECT * FROM $table WHERE borrowernumber = ?" : + ($table eq 'branches' ) ? "SELECT * FROM $table WHERE branchcode = ?" : + ($table eq 'suggestions' ) ? "SELECT * FROM $table WHERE suggestionid = ?" : + ($table eq 'aqbooksellers') ? "SELECT * FROM $table WHERE id = ?" : + ($table eq 'aqorders' ) ? "SELECT * FROM $table WHERE ordernumber = ?" : + ($table eq 'opac_news' ) ? "SELECT * FROM $table WHERE idnew = ?" : + ($table eq 'article_requests') ? "SELECT * FROM $table WHERE id = ?" : ($table eq 'borrower_modifications') ? "SELECT * FROM $table WHERE verification_token = ?" : undef ; unless ($query) { diff --git a/Koha/ArticleRequest.pm b/Koha/ArticleRequest.pm index 1adf17a..cd51264 100644 --- a/Koha/ArticleRequest.pm +++ b/Koha/ArticleRequest.pm @@ -22,6 +22,10 @@ use Modern::Perl; use Carp; use Koha::Database; +use Koha::Borrowers; +use Koha::Biblios; +use Koha::Items; +use Koha::ArticleRequest::Status; use base qw(Koha::Object); @@ -35,6 +39,83 @@ Koha::ArticleRequest - Koha Article Request Object class =cut +=head3 process + +=cut + +sub process { + my ( $self ) = @_; + + $self->status( Koha::ArticleRequest::Status::Processing ); + return $self->store(); +} + +=head3 complete + +=cut + +sub complete { + my ( $self ) = @_; + + $self->status( Koha::ArticleRequest::Status::Completed ); + return $self->store(); +} + +=head3 cancel + +=cut + +sub cancel { + my ( $self, $notes ) = @_; + + $self->status( Koha::ArticleRequest::Status::Canceled ); + $self->notes( $notes ) if $notes; + return $self->store(); +} + + +=head3 biblio + +Returns the Koha::Biblio object for this article request + +=cut + +sub biblio { + my ( $self ) = @_; + + $self->{_biblio} ||= Koha::Biblios->find( $self->biblionumber() ); + + return $self->{_biblio}; +} + +=head3 item + +Returns the Koha::Item object for this article request + +=cut + +sub item { + my ( $self ) = @_; + + $self->{_item} ||= Koha::Items->find( $self->itemnumber() ); + + return $self->{_item}; +} + +=head3 borrower + +Returns the Koha::Borrower object for this article request + +=cut + +sub borrower { + my ( $self ) = @_; + + $self->{_borrower} ||= Koha::Borrowers->find( $self->borrowernumber() ); + + return $self->{_borrower}; +} + =head3 type =cut diff --git a/Koha/ArticleRequest/Status.pm b/Koha/ArticleRequest/Status.pm new file mode 100644 index 0000000..e3d4d3f --- /dev/null +++ b/Koha/ArticleRequest/Status.pm @@ -0,0 +1,44 @@ +package Koha::ArticleRequest::Status; + +# Copyright ByWater Solutions 2015 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +sub Open { + return 'OPEN'; +} + +sub Processing { + return 'PROCESSING'; +} + +sub Completed { + return 'COMPLETED'; +} + +sub Canceled { + return 'CANCELED'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/ArticleRequests.pm b/Koha/ArticleRequests.pm index b110966..26f3338 100644 --- a/Koha/ArticleRequests.pm +++ b/Koha/ArticleRequests.pm @@ -23,7 +23,8 @@ use Carp; use Koha::Database; -use Koha::Borrower; +use Koha::ArticleRequest; +use Koha::ArticleRequest::Status; use base qw(Koha::Objects); @@ -37,12 +38,44 @@ Koha::ArticleRequests - Koha ArticleRequests Object class =cut +=head3 open + +=cut + +sub open { + return Koha::ArticleRequests->search( { status => Koha::ArticleRequest::Status::Open } ); +} + +=head3 processing + +=cut + +sub processing { + return Koha::ArticleRequests->search( { status => Koha::ArticleRequest::Status::Processing } ); +} + +=head3 completed + +=cut + +sub completed { + return Koha::ArticleRequests->search( { status => Koha::ArticleRequest::Status::Completed } ); +} + +=head3 canceled + +=cut + +sub canceled { + return Koha::ArticleRequests->search( { status => Koha::ArticleRequest::Status::Completed } ); +} + =head3 type =cut sub type { - return 'ArticleRequests'; + return 'ArticleRequest'; } sub object_class { diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 9c467d7..fce5a55 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -25,6 +25,11 @@ use Koha::Database; use base qw(Koha::Object); +use C4::Circulation qw(GetIssuingRule); +use Koha::Items; +use Koha::ArticleRequests; +use Koha::ArticleRequest::Status; + =head1 NAME Koha::Biblio - Koha Biblio Object class @@ -35,6 +40,176 @@ Koha::Biblio - Koha Biblio Object class =cut +=head3 can_article_request + +my $bool = $biblio->can_article_request( $borrower ); + +Returns true if article requests can be made for this record + +$borrower must be a Koha::Borrower object + +=cut + +sub can_article_request { + my ( $self, $borrower ) = @_; + + my $rule = $self->article_request_type($borrower); + return q{} if $rule eq 'item_only' && !$self->items()->count(); + return 1 if $rule && $rule ne 'no'; + + return q{}; +} + +=head3 article_request_type + +my $type = $biblio->article_request_type( $borrower ); + +Returns the article request type based on items, or on the record +itself if there are no items. + +$borrower must be a Koha::Borrower object + +=cut + +sub article_request_type { + my ( $self, $borrower ) = @_; + + my $rule = $self->article_request_type_for_items( $borrower ); + return $rule if $rule; + + # If the record has no items that are requestable, go by the record itemtype + $rule = $self->article_request_type_for_bib($borrower); + return $rule if $rule; + + return q{}; +} + +=head3 article_request_type_for_bib + +my $type = $biblio->article_request_type_for_bib + +Returns the article request type 'yes', 'no', 'item_only', 'bib_only', for the given record + +=cut + +sub article_request_type_for_bib { + my ( $self, $borrower ) = @_; + + my $borrowertype = $borrower->categorycode; + my $itemtype = $self->itemtype(); + my $rules = GetIssuingRule( $borrowertype, $itemtype ); + + return $rules->{article_requests} || q{}; +} + +=head3 article_request_type_for_items + +my $type = $biblio->article_request_type_for_items + +Returns the article request type 'yes', 'no', 'item_only', 'bib_only', for the given record's items + +If there is a conflict where some items are 'bib_only' and some are 'item_only', 'bib_only' will be returned. + +=cut + +sub article_request_type_for_items { + my ( $self, $borrower ) = @_; + + my $counts; + foreach my $item ( $self->items()->as_list() ) { + my $rule = $item->article_request_type($borrower); + return $rule if $rule eq 'bib_only'; # we don't need to go any further + $counts->{$rule}++; + } + + return 'item_only' if $counts->{item_only}; + return 'yes' if $counts->{yes}; + return 'no' if $counts->{no}; + return q{}; +} + +=head3 article_requests + +my @requests = $biblio->article_requests + +Returns the article requests associated with this Biblio + +=cut + +sub article_requests { + my ( $self, $borrower ) = @_; + + $self->{_article_requests} ||= Koha::ArticleRequests->search( { biblionumber => $self->biblionumber() } ); + + return wantarray ? $self->{_article_requests}->as_list : $self->{_article_requests}; +} + +=head3 article_requests_current + +my @requests = $biblio->article_requests_current + +Returns the article requests associated with this Biblio that are incomplete + +=cut + +sub article_requests_current { + my ( $self, $borrower ) = @_; + + $self->{_article_requests_current} ||= Koha::ArticleRequests->search( + { + biblionumber => $self->biblionumber(), + -or => [ + { status => Koha::ArticleRequest::Status::Open }, + { status => Koha::ArticleRequest::Status::Processing } + ] + } + ); + + return wantarray ? $self->{_article_requests_current}->as_list : $self->{_article_requests_current}; +} + +=head3 article_requests_finished + +my @requests = $biblio->article_requests_finished + +Returns the article requests associated with this Biblio that are completed + +=cut + +sub article_requests_finished { + my ( $self, $borrower ) = @_; + + $self->{_article_requests_finished} ||= Koha::ArticleRequests->search( + { + biblionumber => $self->biblionumber(), + -or => [ + { status => Koha::ArticleRequest::Status::Completed }, + { status => Koha::ArticleRequest::Status::Canceled } + ] + } + ); + + return wantarray ? $self->{_article_requests_finished}->as_list : $self->{_article_requests_finished}; +} + +=head3 items + +my @items = $biblio->items(); +my $items = $biblio->items(); + +Returns a list of Koha::Item objects or a Koha::Items object of +items associated with this bib + +=cut + +sub items { + my ( $self ) = @_; + + $self->{_items} ||= Koha::Items->search({ biblionumber => $self->biblionumber() }); + + return $self->{_items}; +} + =head3 type =cut diff --git a/Koha/Biblios.pm b/Koha/Biblios.pm index cba48ea..020f933 100644 --- a/Koha/Biblios.pm +++ b/Koha/Biblios.pm @@ -1,6 +1,6 @@ package Koha::Biblios; -# Copyright ByWater Solutions 2014 +# Copyright ByWater Solutions 2015 # # This file is part of Koha. # diff --git a/Koha/Borrower.pm b/Koha/Borrower.pm index 93426bf..84ce27a 100644 --- a/Koha/Borrower.pm +++ b/Koha/Borrower.pm @@ -23,6 +23,9 @@ use Carp; use Koha::Database; +use Koha::ArticleRequests; +use Koha::ArticleRequest::Status; + use base qw(Koha::Object); =head1 NAME @@ -35,6 +38,73 @@ Koha::Borrower - Koha Borrower Object class =cut +=head3 article_requests + +my @requests = $borrower->article_requests(); +my $requests = $borrower->article_requests(); + +Returns either a list of ArticleRequests objects, +or an ArtitleRequests object, depending on the +calling context. + +=cut + +sub article_requests { + my ( $self ) = @_; + + $self->{_article_requests} ||= Koha::ArticleRequests->search({ borrowernumber => $self->borrowernumber() }); + + return $self->{_article_requests}; +} + +=head3 article_requests_current + +my @requests = $patron->article_requests_current + +Returns the article requests associated with this patron that are incomplete + +=cut + +sub article_requests_current { + my ( $self ) = @_; + + $self->{_article_requests_current} ||= Koha::ArticleRequests->search( + { + borrowernumber => $self->id(), + -or => [ + { status => Koha::ArticleRequest::Status::Open }, + { status => Koha::ArticleRequest::Status::Processing } + ] + } + ); + + return $self->{_article_requests_current}; +} + +=head3 article_requests_finished + +my @requests = $biblio->article_requests_finished + +Returns the article requests associated with this patron that are completed + +=cut + +sub article_requests_finished { + my ( $self, $borrower ) = @_; + + $self->{_article_requests_finished} ||= Koha::ArticleRequests->search( + { + borrowernumber => $self->id(), + -or => [ + { status => Koha::ArticleRequest::Status::Completed }, + { status => Koha::ArticleRequest::Status::Canceled } + ] + } + ); + + return $self->{_article_requests_finished}; +} + =head3 type =cut diff --git a/Koha/Item.pm b/Koha/Item.pm index 2dcccfb..b6f84c4 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -21,8 +21,8 @@ use Modern::Perl; use Carp; -use Koha::Database; - +use C4::Context; +use C4::Circulation qw(GetIssuingRule); use Koha::Branches; use base qw(Koha::Object); @@ -73,6 +73,49 @@ sub holding_branch { return $self->{_holding_branch}; } +=head3 can_article_request + +my $bool = $item->can_article_request( $borrower ) + +Returns true if item can be specifically requested + +$borrower must be a Koha::Borrower object + +=cut + +sub can_article_request { + my ( $self, $borrower ) = @_; + + my $rule = $self->article_request_type($borrower); + + return 1 if $rule && $rule ne 'no' && $rule ne 'bib_only'; + return q{}; +} + +=head3 article_request_type + +my $type = $item->article_request_type( $borrower ) + +returns 'yes', 'no', 'bib_only', or 'item_only' + +$borrower must be a Koha::Borrower object + +=cut + +sub article_request_type { + my ( $self, $borrower ) = @_; + + my $branch_control = C4::Context->preference('HomeOrHoldingBranch'); + my $branchcode = + $branch_control eq 'homebranch' ? $self->homebranch + : $branch_control eq 'holdingbranch' ? $self->holdingbranch + : undef; + my $borrowertype = $borrower->categorycode; + my $itemtype = $self->effective_itemtype(); + my $rules = GetIssuingRule( $borrowertype, $itemtype, $branchcode ); + + return $rules->{article_requests} || q{}; +} =head3 type diff --git a/Koha/Schema/Result/ArticleRequest.pm b/Koha/Schema/Result/ArticleRequest.pm index ffa282b..03f5b1d 100644 --- a/Koha/Schema/Result/ArticleRequest.pm +++ b/Koha/Schema/Result/ArticleRequest.pm @@ -82,6 +82,18 @@ __PACKAGE__->table("article_requests"); data_type: 'text' is_nullable: 1 +=head2 status + + data_type: 'enum' + default_value: 'OPEN' + extra: {list => ["OPEN","PROCESSING","COMPLETED","CANCELED"]} + is_nullable: 0 + +=head2 notes + + data_type: 'text' + is_nullable: 1 + =head2 created_on data_type: 'timestamp' @@ -120,6 +132,15 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, "chapters", { data_type => "text", is_nullable => 1 }, + "status", + { + data_type => "enum", + default_value => "OPEN", + extra => { list => ["OPEN", "PROCESSING", "COMPLETED", "CANCELED"] }, + is_nullable => 0, + }, + "notes", + { data_type => "text", is_nullable => 1 }, "created_on", { data_type => "timestamp", @@ -200,8 +221,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07040 @ 2015-07-28 10:40:02 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Gcq0lkNV972sKkcueQq19w +# Created by DBIx::Class::Schema::Loader v0.07040 @ 2015-09-02 13:10:22 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KfP2PsyQthZxHfzWAOxGIg # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/Koha/Template/Plugin/Biblio.pm b/Koha/Template/Plugin/Biblio.pm index 3f9cc4f..79a6df0 100644 --- a/Koha/Template/Plugin/Biblio.pm +++ b/Koha/Template/Plugin/Biblio.pm @@ -23,6 +23,8 @@ use Template::Plugin; use base qw( Template::Plugin ); use Koha::Holds; +use Koha::Biblios; +use Koha::Borrowers; sub HoldsCount { my ( $self, $biblionumber ) = @_; @@ -32,4 +34,13 @@ sub HoldsCount { return $holds->count(); } +sub CanArticleRequest { + my ( $self, $biblionumber, $borrowernumber ) = @_; + + my $biblio = Koha::Biblios->find( $biblionumber ); + my $borrower = Koha::Borrowers->find( $borrowernumber ); + + return $biblio ? $biblio->can_article_request( $borrower ) : 0; +} + 1; diff --git a/circ/article-request-slip.pl b/circ/article-request-slip.pl new file mode 100755 index 0000000..b7929f1 --- /dev/null +++ b/circ/article-request-slip.pl @@ -0,0 +1,66 @@ +#!/usr/bin/perl + +# Copyright 2015 ByWater Solutions +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use CGI qw( -utf8 ); + +use C4::Context; +use C4::Output; +use C4::Auth; +use Koha::ArticleRequests; + +my $cgi = new CGI; + +my $id = $cgi->param('id'); + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "circ/printslip.tt", + query => $cgi, + type => "intranet", + authnotrequired => 0, + flagsrequired => { circulate => "circulate_remaining_permissions" }, + } +); + +my $ar = Koha::ArticleRequests->find($id); + +$template->param( article_request => $ar ); + +my $slip = C4::Letters::GetPreparedLetter( + module => 'circulation', + letter_code => 'AR_PRINT', + 'message_transport_type' => 'print', + tables => { + 'article_requests' => $ar->id, + 'borrowers' => $ar->borrowernumber, + 'biblio' => $ar->biblionumber, + 'items' => $ar->itemnumber, + }, +); + +$template->param( + slip => $slip->{content}, + caller => 'article-request', + plain => !$slip->{is_html}, +); + +output_html_with_http_headers $cgi, $cookie, $template->output; + diff --git a/circ/article-requests.pl b/circ/article-requests.pl new file mode 100755 index 0000000..3980e39 --- /dev/null +++ b/circ/article-requests.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl + +# Copyright 2015 ByWater Solutions +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use CGI qw ( -utf8 ); + +use C4::Auth; +use C4::Output; +use Koha::ArticleRequests; + +my $query = new CGI; +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "circ/article-requests.tt", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { circulate => "circulate_remaining_permissions" }, + } +); + +$template->param( + article_requests_open => scalar Koha::ArticleRequests->open(), + article_requests_processing => scalar Koha::ArticleRequests->processing(), +); + +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/circ/request-article-cancel.pl b/circ/request-article-cancel.pl new file mode 100755 index 0000000..23a999d --- /dev/null +++ b/circ/request-article-cancel.pl @@ -0,0 +1,45 @@ +#!/usr/bin/perl + +# Copyright 2015 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use CGI qw ( -utf8 ); + +use C4::Output; +use C4::Auth; +use Koha::ArticleRequests; + +my $cgi = new CGI; + +my ( $template, $librarian, $cookie, $flags ) = get_template_and_user( + { + template_name => "circ/request-article.tt", + query => $cgi, + type => "intranet", + authnotrequired => 0, + flagsrequired => { circulate => 'circulate_remaining_permissions' }, + } +); + +my $id = $cgi->param('id'); +my $ar = Koha::ArticleRequests->find($id); +$ar->cancel(); +my $biblionumber = $ar->biblionumber; + +print $cgi->redirect("/cgi-bin/koha/circ/request-article.pl?biblionumber=$biblionumber"); diff --git a/circ/request-article-do.pl b/circ/request-article-do.pl new file mode 100755 index 0000000..eee2c8a --- /dev/null +++ b/circ/request-article-do.pl @@ -0,0 +1,68 @@ +#!/usr/bin/perl + +# Copyright ByWater Solutions 2015 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use CGI qw ( -utf8 ); + +use C4::Auth; +use C4::Output; + +use Koha::ArticleRequest; + +my $cgi = new CGI; + +my ( $template, $librarian, $cookie, $flags ) = get_template_and_user( + { + template_name => "circ/request-article.tt", + query => $cgi, + type => "intranet", + authnotrequired => 0, + flagsrequired => { circulate => 'circulate_remaining_permissions' }, + } +); + +my $biblionumber = $cgi->param('biblionumber'); +my $borrowernumber = $cgi->param('borrowernumber'); + +my $itemnumber = $cgi->param('itemnumber') || undef; +my $title = $cgi->param('title') || undef; +my $author = $cgi->param('author') || undef; +my $volume = $cgi->param('volume') || undef; +my $issue = $cgi->param('issue') || undef; +my $date = $cgi->param('date') || undef; +my $pages = $cgi->param('pages') || undef; +my $chapters = $cgi->param('chapters') || undef; + +my $ar = Koha::ArticleRequest->new( + { + borrowernumber => $borrowernumber, + biblionumber => $biblionumber, + itemnumber => $itemnumber, + title => $title, + author => $author, + volume => $volume, + issue => $issue, + date => $date, + pages => $pages, + chapters => $chapters, + } +)->store(); + +print $cgi->redirect("/cgi-bin/koha/circ/request-article.pl?biblionumber=$biblionumber"); diff --git a/circ/request-article.pl b/circ/request-article.pl new file mode 100755 index 0000000..20ee9d6 --- /dev/null +++ b/circ/request-article.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl + +# Copyright 2015 ByWater Solutions +# Copyright 2000-2002 Katipo Communications +# Copyright 2011 Catalyst IT +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use C4::Output; +use C4::Auth; +use Koha::Biblios; +use Koha::Borrowers; +use Koha::ArticleRequests; + +my $input = new CGI; + +my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( + { + template_name => "circ/request-article.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { circulate => 'circulate_remaining_permissions' }, + } +); + +my $biblionumber = $input->param('biblionumber'); +my $patron_cardnumber = $input->param('patron_cardnumber'); + +my $biblio = Koha::Biblios->find($biblionumber); +my $patron = Koha::Borrowers->find( { cardnumber => $patron_cardnumber } ); + +$template->param( + biblio => $biblio, + patron => $patron, +); + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/installer/data/mysql/atomicupdate/bug_14610.sql b/installer/data/mysql/atomicupdate/bug_14610.sql index 0611768..781af4f 100644 --- a/installer/data/mysql/atomicupdate/bug_14610.sql +++ b/installer/data/mysql/atomicupdate/bug_14610.sql @@ -10,6 +10,8 @@ CREATE TABLE `koha_kohaqa`.`article_requests` ( `date` TEXT NULL DEFAULT NULL , `pages` TEXT NULL DEFAULT NULL , `chapters` TEXT NULL DEFAULT NULL , + `status` enum('OPEN','PROCESSING','COMPLETED','CANCELED') NOT NULL DEFAULT 'OPEN', + `notes` text, `created_on` TIMESTAMP NOT NULL , `updated_on` TIMESTAMP NULL DEFAULT NULL , INDEX ( `borrowernumber` ), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc index 4258aa3..9c123a4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc @@ -26,6 +26,7 @@ [% IF ( holdsview ) %]
  • [% ELSE %]
  • [% END %]Holds ([% Biblio.HoldsCount( biblio_object_id ) %])
  • [% END %] [% IF ( EasyAnalyticalRecords ) %][% IF ( analyze ) %]
  • [% ELSE %]
  • [% END %]Analytics
  • [% END %] + [% IF ( article_requests_view ) %]
  • [% ELSE %]
  • [% END %]Article requests
  • [% IF ( subscriptionsnumber ) %]
  • Subscription(s)
  • [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt index 4b1c94b..a49344a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -536,6 +536,7 @@ var holdForPatron = function () { Holds [% IF ( holdfor ) %] | Place hold for [% holdfor_firstname %] [% holdfor_surname %] ([% holdfor_cardnumber %])[% END %] [% END %] + | Request article [% IF ( CAN_user_editcatalogue_edit_catalogue ) %] | Edit record [% END %] 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 new file mode 100644 index 0000000..d8d2500 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt @@ -0,0 +1,352 @@ +[% USE KohaDates %] +[% USE ItemTypes %] +[% USE Branches %] +[% USE AuthorisedValues %] + +[% INCLUDE 'doc-head-open.inc' %] +Koha › Circulation › Article requests +[% INCLUDE 'doc-head-close.inc' %] + + + + + [% INCLUDE 'header.inc' %] + [% INCLUDE 'cat-search.inc' %] + + + + + +
    +
    +
    +
    + +

    Article requests

    + +
    + + +
    + [% IF article_requests_open.count %] + + + + + + + + + + + + + + + + + + + [% FOREACH ar IN article_requests_open %] + + + + + + + + + + + + + + [% END %] + +
    TitleRequested articleCollectionItem typeCall numberCopy numberEnumerationBarcodePatronDateActions
    +

    + + [% ar.biblio.title | html %] + [% FOREACH s IN itemsloo.subtitle %] [% s %][% END %] + +

    + +

    +

    [% ar.biblionumber %]
    +
    [% ar.biblio.author %]
    +
    + [% ar.biblio.biblioitem.publishercode %] + + [% IF ar.biblio.biblioitem.publicationyear %] + , [% ar.biblio.biblioitem.publicationyear %] + [% ELSIF ar.biblio.copyrightdate %] + , [% ar.biblio.copyrightdate %] + [% END %] + + [% IF ar.biblio.biblioitem.pages %] + : [% ar.biblio.biblioitem.pages %] + [% END %] + + [% r.biblio.biblioitem.size %] + + [% IF ar.biblio.biblioitem.isbn %] + ISBN: [% ar.biblio.biblioitem.isbn %] + [% END %] +
    +

    +
    + [% IF ar.title %]

    Title: [% ar.title %]

    [% END %] + [% IF ar.author %]

    Author: [% ar.author %]

    [% END %] + [% IF ar.volume %]

    Volume: [% ar.volume %]

    [% END %] + [% IF ar.issue %]

    Issue: [% ar.issue %]

    [% END %] + [% IF ar.date %]

    Date: [% ar.date %]

    [% END %] + [% IF ar.pages %]

    Pages: [% ar.pages %]

    [% END %] + [% IF ar.chapters %]

    Chapters: [% ar.chapters %]

    [% END %] +
    [% AuthorisedValues.GetByCode( 'CCODE', ar.item.ccode ) %][% ItemTypes.GetDescription( ar.item.effective_itemtype ) %] + [% IF ar.item.location %] + [% AuthorisedValues.GetByCode( 'LOC', ar.item.location ) %] + [% END %] + + [% ar.item.itemcallnumber %] + [% ar.item.copynumber %][% ar.item.enumchron %][% ar.item.barcode %] +

    + + [% ar.borrower.surname %], [% ar.borrower.firstname %] ([% ar.borrower.cardnumber %]) + +

    + +

    [% ar.borrower.phone %]

    +
    [% ar.created_on | $KohaDates %] + +
    + [% ELSE %] + There are currently no open article requests. + [% END %] +
    + +
    + [% IF article_requests_processing.count %] + + + + + + + + + + + + + + + + + + + [% FOREACH ar IN article_requests_processing %] + + + + + + + + + + + + + + [% END %] + +
    TitleRequested articleCollectionItem typeCall numberCopy numberEnumerationBarcodePatronDateActions
    +

    + + [% ar.biblio.title | html %] + [% FOREACH s IN itemsloo.subtitle %] [% s %][% END %] + +

    + +

    +

    [% ar.biblionumber %]
    +
    [% ar.biblio.author %]
    +
    + [% ar.biblio.biblioitem.publishercode %] + + [% IF ar.biblio.biblioitem.publicationyear %] + , [% ar.biblio.biblioitem.publicationyear %] + [% ELSIF ar.biblio.copyrightdate %] + , [% ar.biblio.copyrightdate %] + [% END %] + + [% IF ar.biblio.biblioitem.pages %] + : [% ar.biblio.biblioitem.pages %] + [% END %] + + [% r.biblio.biblioitem.size %] + + [% IF ar.biblio.biblioitem.isbn %] + ISBN: [% ar.biblio.biblioitem.isbn %] + [% END %] +
    +

    +
    + [% IF ar.title %]

    Title: [% ar.title %]

    [% END %] + [% IF ar.author %]

    Author: [% ar.author %]

    [% END %] + [% IF ar.volume %]

    Volume: [% ar.volume %]

    [% END %] + [% IF ar.issue %]

    Issue: [% ar.issue %]

    [% END %] + [% IF ar.date %]

    Date: [% ar.date %]

    [% END %] + [% IF ar.pages %]

    Pages: [% ar.pages %]

    [% END %] + [% IF ar.chapters %]

    Chapters: [% ar.chapters %]

    [% END %] +
    [% AuthorisedValues.GetByCode( 'CCODE', ar.item.ccode ) %][% ItemTypes.GetDescription( ar.item.effective_itemtype ) %] + [% IF ar.item.location %] + [% AuthorisedValues.GetByCode( 'LOC', ar.item.location ) %] + [% END %] + + [% ar.item.itemcallnumber %] + [% ar.item.copynumber %][% ar.item.enumchron %][% ar.item.barcode %] +

    + + [% ar.borrower.surname %], [% ar.borrower.firstname %] ([% ar.borrower.cardnumber %]) + +

    + +

    [% ar.borrower.phone %]

    +
    [% ar.created_on | $KohaDates %] + +
    + [% ELSE %] + There are currently no article requests being processed. + [% END %] +
    +
    +
    +
    +
    +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt index 9450aaa..a1b2e6b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt @@ -41,6 +41,9 @@
  • Holds to pull
  • Holds awaiting pickup
  • Hold ratios
  • +
  • + Article requests +
  • Transfers to receive
  • [% IF ( CAN_user_circulate_overdues_report ) %]
  • Overdues - Warning: This report is very resource intensive on diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt new file mode 100644 index 0000000..2c45af7 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt @@ -0,0 +1,245 @@ +[% USE KohaDates %] +[% SET article_requests_view = 1 %] +[% SET biblionumber = biblio.biblionumber %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Circulation › Request article +[% INCLUDE 'doc-head-close.inc' %] + +[% INCLUDE 'datatables.inc' %] + + + + + + [% INCLUDE 'header.inc' %] + [% INCLUDE 'circ-search.inc' %] + + + +
    +
    +
    +
    + +

    Request article from [% biblio.title | html %]

    + + [% UNLESS patron %] +
    +
    + +
    Enter patron card number or partial name:
    + + + +
    +
    + [% ELSE %] + [% IF biblio.can_article_request( patron ) %] + +
    + + + +
    + Place article request from [% biblio.title %] for [% patron.firstname %] [% patron.surname %] ( [% patron.cardnumber %] ) +

    +

      +
    • + + +
    • + +
    • + + +
    • + +
    • + + +
    • + +
    • + + +
    • + +
    • + + +
    • + +
    • + + +
    • + +
    • + + +
    • +
    +
    + + [% SET article_request_type = biblio.article_request_type( patron ) %] + [% IF article_request_type != 'bib_only' %] + + + + + + + + + + + + + + [% FOREACH item IN biblio.items %] + [% IF item.can_article_request( patron ) %] + + + + + + + + [% END %] + [% END %] + + [% IF article_request_type != 'item_only' %] + + + + + [% END %] + +
    Select item:
     Item typeBarcodeHome libraryCall number
    + [% IF article_request_type == 'item_only' && !checked %] + [% SET checked = 1 %] + + [% ELSE %] + + [% END %] + + [% item.itype %] + + [% item.barcode %] + + [% item.homebranch %] + + [% item.itemcallnumber %] +
    + + + Any item +
    + [% END %] + +

    + +

    +
    + [% ELSE %] + No article requests can be made for this record. + [% END %] + + [% END %] + + [% IF biblio.article_requests_current && !patron %] +
    + Current article requests + + + + + + + + + + + + + + + + + + [% FOREACH ar IN biblio.article_requests_current %] + + + + + + + + + + + + + + [% END %] +
    Placed onPatronTitleAuthorVolumeIssueDatePagesChaptersItemStatus 
    [% ar.created_on | $KohaDates %][% ar.borrower.firstname %] [% ar.borrower.surname %][% ar.title %][% ar.author %][% ar.volume %][% ar.issue %][% ar.date %][% ar.pages %][% ar.chapters %] + [% IF ar.item %] + [% ar.item.barcode %] + [% END %] + + [% IF ar.status == 'OPEN' %] + Open + [% ELSIF ar.status == 'PROCESSING' %] + Processing + [% ELSIF ar.status == 'COMPLETED' %] + Completed + [% ELSIF ar.status == 'CANCELED' %] + Canceled + [% END %] + + + Cancel + +
    +
    + [% END %] +
    +
    + +
    + [% INCLUDE 'biblio-view-menu.inc' %] +
    +
    +
    +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt index 8440526..b40d5c2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -113,8 +113,17 @@ || ( CAN_user_borrowers && pending_borrower_modifications ) || ( CAN_user_acquisition && pendingsuggestions ) || ( CAN_user_borrowers && pending_discharge_requests ) + || pending_article_requests ) %]
    + [% IF pending_article_requests %] +
    + + Article requests: + [% pending_article_requests %] +
    + [% END %] + [% IF ( CAN_user_acquisition && pendingsuggestions ) %]
    diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc index a4ef40e..f2a7697 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc @@ -1,3 +1,4 @@ +[% USE Biblio %]
      [% UNLESS ( norequests ) %] [% IF Koha.Preference( 'opacuserlogin' ) == 1 %] @@ -8,6 +9,13 @@ [% END %] [% END %] [% END %] + + [% IF Koha.Preference( 'opacuserlogin' ) == 1 %] + [% IF Biblio.CanArticleRequest( biblionumber, borrowernumber ) %] +
    • Request article
    • + [% END %] + [% END %] +
    • Print
    • [% IF Koha.Preference( 'virtualshelves' ) == 1 %] [% IF ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && loggedinusername ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt new file mode 100644 index 0000000..9f7f283 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-request-article.tt @@ -0,0 +1,157 @@ +[% INCLUDE 'doc-head-open.inc' %] +[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Request article +[% INCLUDE 'doc-head-close.inc' %] +[% BLOCK cssinclude %][% END %] + + +[% INCLUDE 'bodytag.inc' bodyid='opac-holds' %] +[% INCLUDE 'masthead.inc' %] + +
      + + +
      + [% IF biblio.can_article_request( patron ) %] +

      Place article request for [% biblio.title %]

      + +
      + + +
      +
        +
      • + + +
      • + +
      • + + +
      • + +
      • + + +
      • + +
      • + + +
      • + +
      • + + +
      • + +
      • + + +
      • + +
      • + + +
      • +
      +
      + + [% SET article_request_type = biblio.article_request_type( patron ) %] + [% IF article_request_type != 'bib_only' %] + + + + + + + + + + + + + + [% FOREACH item IN biblio.items %] + [% IF item.can_article_request( patron ) %] + + + + + + + + [% END %] + [% END %] + + [% IF article_request_type != 'item_only' %] + + + + + [% END %] + +
      Select a specific item:
       Item typeBarcodeHome libraryCall number
      + [% IF article_request_type == 'item_only' && !checked %] + [% SET checked = 1 %] + + [% ELSE %] + + [% END %] + + [% item.itype %] + + [% item.barcode %] + + [% item.homebranch %] + + [% item.itemcallnumber %] +
      + + + Any item +
      + [% END %] + + +
      + [% ELSE %] + No article requests can be made for this record. + [% END %] + +
      +
      + +[% INCLUDE 'opac-bottom.inc' %] + +[% BLOCK jsinclude %] + +[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt index da1d62d..7a70fbc 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -509,6 +509,10 @@ [% END # UNLESS SEARCH_RESULT.norequests %] [% END # IF RequestOnOpac %] + [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) %] + Request article + [% END %] + [% IF ( TagsInputEnabled ) %] [% IF ( loggedinusername ) %] Add tag diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index b5bc8d2..5630d8a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -112,6 +112,7 @@ [% END %] [% IF ( waiting_count ) %][% IF ( BORROWER_INF.atdestination ) %]
    • Waiting ([% waiting_count %])
    • [% END %][% END %] [% IF ( reserves_count ) %]
    • Holds ([% reserves_count %])
    • [% END %] + [% IF ( borrower.article_requests_current ) %]
    • Article requests ([% borrower.article_requests_current.count %])
    • [% END %]
    @@ -667,6 +668,95 @@ [% END %]
    [% END # / #reserves_count %] + + [% IF ( borrower.article_requests_current.count ) %] +
    + + + + + + + + + + + + + + + + + + + + + [% FOREACH ar IN borrower.article_requests_current %] + + + + + + + + + + + + + + + + + + + + + + + [% END %] + +
    Article requests ([% borrower.article_requests_current.count %] total)
    Record titlePlaced onTitleAuthorVolumeIssueDatePagesChaptersStatus 
    + + [% ar.biblio.title %] + [% ar.item.enumchron %] + + [% ar.biblio.author %] + [% IF ar.itemnumber %] (only [% ar.item.barcode %])[% END %] + + [% ar.created_on | $KohaDates %] + + [% ar.title %] + + [% ar.author %] + + [% ar.volume %] + + [% ar.issue %] + + [% ar.date %] + + [% ar.pages %] + + [% ar.chapters %] + + [% IF ar.status == 'OPEN' %] + Open + [% ELSIF ar.status == 'PROCESSING' %] + Processing + [% ELSIF ar.status == 'COMPLETED' %] + Completed + [% ELSIF ar.status == 'CANCELED' %] + Canceled + [% END %] + + Cancel: + Cancel + +
    +
    + [% END %] +
  • diff --git a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less b/koha-tmpl/opac-tmpl/bootstrap/less/opac.less index 6da32e5..f1f2af7 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less +++ b/koha-tmpl/opac-tmpl/bootstrap/less/opac.less @@ -266,6 +266,14 @@ td { padding-left : 21px; text-decoration : none; } + &.article_request { + background-image : url("../images/sprite.png"); /* Place hold small */ + background-position : -2px -26px; + background-repeat: no-repeat; + margin-right : 1em; + padding-left : 21px; + text-decoration : none; + } &.addtocart { background-image : url("../images/sprite.png"); /* Cart small */ background-position : -5px -572px; @@ -1345,6 +1353,7 @@ a.print-large, a.removeitems, a.removeitems.disabled, a.reserve, +a.article_request, a.send, a.tag_add, a.removefromlist, @@ -1473,6 +1482,11 @@ a.reserve { padding-left : 35px; } +a.article_request { + background-position: 0px -24px; /* Place article request */ + padding-left : 35px; +} + a.send { background-position : 2px -386px; /* Email */ text-decoration : none; @@ -2490,4 +2504,8 @@ a.reviewlink:visited { font-size: 90%; } +.btn-danger { + color: white !important; +} + @import "responsive.less"; diff --git a/mainpage.pl b/mainpage.pl index 1ccffad..c327e73 100755 --- a/mainpage.pl +++ b/mainpage.pl @@ -30,6 +30,7 @@ use C4::Suggestions qw/CountSuggestion/; use C4::Tags qw/get_count_by_tag_status/; use Koha::Borrower::Modifications; use Koha::Borrower::Discharge; +use Koha::ArticleRequests; my $query = new CGI; @@ -67,6 +68,7 @@ my $pendingsuggestions = CountSuggestion("ASKED"); my $pending_borrower_modifications = Koha::Borrower::Modifications->GetPendingModificationsCount( $branch ); my $pending_discharge_requests = Koha::Borrower::Discharge::count({ pending => 1 }); +my $pending_article_requests = Koha::ArticleRequests->count(); $template->param( pendingcomments => $pendingcomments, @@ -74,6 +76,7 @@ $template->param( pendingsuggestions => $pendingsuggestions, pending_borrower_modifications => $pending_borrower_modifications, pending_discharge_requests => $pending_discharge_requests, + pending_article_requests => $pending_article_requests, ); # diff --git a/opac/opac-article-request-cancel.pl b/opac/opac-article-request-cancel.pl new file mode 100755 index 0000000..baaa0ae --- /dev/null +++ b/opac/opac-article-request-cancel.pl @@ -0,0 +1,47 @@ +#!/usr/bin/perl + +# Copyright 2015 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use CGI qw ( -utf8 ); + +use C4::Output; +use C4::Auth; +use Koha::ArticleRequests; + +my $query = new CGI; + +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "opac-account.tt", + query => $query, + type => "opac", + authnotrequired => 0, + debug => 1, + } +); + +my $id = $query->param('id'); + +if ( $id && $borrowernumber ) { + my $ar = Koha::ArticleRequests->find( $id ); + $ar->cancel() if $ar; +} + +print $query->redirect("/cgi-bin/koha/opac-user.pl#opac-user-article-requests"); diff --git a/opac/opac-request-article-do.pl b/opac/opac-request-article-do.pl new file mode 100755 index 0000000..57c6e8c --- /dev/null +++ b/opac/opac-request-article-do.pl @@ -0,0 +1,67 @@ +#!/usr/bin/perl + +# Copyright ByWater Solutions 2015 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use CGI qw ( -utf8 ); + +use C4::Auth; +use C4::Output; + +use Koha::ArticleRequest; + +my $cgi = new CGI; + +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "opac-request-article.tt", + query => $cgi, + type => "opac", + authnotrequired => 0, + debug => 1, + } +); + +my $biblionumber = $cgi->param('biblionumber'); + +my $itemnumber = $cgi->param('itemnumber') || undef; +my $title = $cgi->param('title') || undef; +my $author = $cgi->param('author') || undef; +my $volume = $cgi->param('volume') || undef; +my $issue = $cgi->param('issue') || undef; +my $date = $cgi->param('date') || undef; +my $pages = $cgi->param('pages') || undef; +my $chapters = $cgi->param('chapters') || undef; + +my $ar = Koha::ArticleRequest->new( + { + borrowernumber => $borrowernumber, + biblionumber => $biblionumber, + itemnumber => $itemnumber, + title => $title, + author => $author, + volume => $volume, + issue => $issue, + date => $date, + pages => $pages, + chapters => $chapters, + } +)->store(); + +print $cgi->redirect("/cgi-bin/koha/opac-user.pl#opac-user-article-requests"); diff --git a/opac/opac-request-article.pl b/opac/opac-request-article.pl new file mode 100755 index 0000000..2577ec1 --- /dev/null +++ b/opac/opac-request-article.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl + +# Copyright ByWater Solutions 2015 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use CGI qw ( -utf8 ); + +use C4::Auth; +use C4::Output; + +use Koha::Biblios; +use Koha::Borrowers; + +my $cgi = new CGI; + +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "opac-request-article.tt", + query => $cgi, + type => "opac", + authnotrequired => 0, + debug => 1, + } +); + +my $biblionumber = $cgi->param('biblionumber'); + +my $biblio = Koha::Biblios->find($biblionumber); +my $patron = Koha::Borrowers->find($borrowernumber); + +$template->param( + biblio => $biblio, + patron => $patron, +); + +output_html_with_http_headers $cgi, $cookie, $template->output; + diff --git a/opac/opac-user.pl b/opac/opac-user.pl index d4fbbe3..05a1c7a 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -36,6 +36,7 @@ use C4::Letters; use C4::Branch; # GetBranches use Koha::DateUtils; use Koha::Borrower::Debarments qw(IsDebarred); +use Koha::Borrowers; use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE'; @@ -394,6 +395,7 @@ $template->param( SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'), AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'), OpacHoldNotes => C4::Context->preference('OpacHoldNotes'), + borrower => Koha::Borrowers->find($borrowernumber), ); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/svc/article_request b/svc/article_request new file mode 100755 index 0000000..449aefd --- /dev/null +++ b/svc/article_request @@ -0,0 +1,58 @@ +#!/usr/bin/perl + +# Copyright 2015 ByWater Solutions +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +use Modern::Perl; + +use CGI; +use JSON qw(to_json); + +use C4::Auth qw(check_cookie_auth); +use Koha::ArticleRequests; + +my $cgi = new CGI; + +my ( $auth_status, $sessionID ) = + check_cookie_auth( $cgi->cookie('CGISESSID'), { circulate => 'circulate_remaining_permissions' } ); +if ( $auth_status ne "ok" ) { + exit 0; +} + +binmode STDOUT, ':encoding(UTF-8)'; +print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' ); + +my $id = $cgi->param('id'); +my $action = $cgi->param('action') || q{}; +my $notes = $cgi->param('notes'); + +my $ar = Koha::ArticleRequests->find($id); + +if ($ar) { + if ( $action eq 'cancel' ) { + $ar = $ar->cancel( $notes ); + } + elsif ( $action eq 'process' ) { + $ar = $ar->process(); + } + elsif ( $action eq 'complete' ) { + $ar = $ar->complete(); + } +} + +print to_json( { success => $ar ? 1 : 0 } ); -- 1.7.2.5