From da6caa4c51f61ea286631374bc1a26032144b2ef Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Mon, 11 May 2020 23:52:52 +0000 Subject: [PATCH] Bug 19532: Recalls on OPAC Content-Type: text/plain; charset=utf-8 - place a biblio-level or item-level recall via the biblio detail page, OPAC search results, or course reserves - view or cancel your active recalls from 'your summary' recalls tab - view all active and inactive (and cancel active) recalls from 'your recall history' - stopped from placing a reserve on an item that the patron has already recalled Signed-off-by: David Nind Signed-off-by: David Nind Signed-off-by: Marcel de Rooy --- .../bootstrap/en/includes/item-status.inc | 1 + .../en/includes/opac-detail-sidebar.inc | 5 + .../en/includes/title-actions-menu.inc | 4 + .../bootstrap/en/includes/usermenu.inc | 9 + .../en/modules/opac-course-details.tt | 2 +- .../bootstrap/en/modules/opac-recall.tt | 199 ++++++++++++++++++ .../bootstrap/en/modules/opac-recalls.tt | 151 +++++++++++++ .../bootstrap/en/modules/opac-reserve.tt | 2 + .../bootstrap/en/modules/opac-user.tt | 85 ++++++++ opac/opac-course-details.pl | 7 + opac/opac-detail.pl | 7 +- opac/opac-recall.pl | 141 +++++++++++++ opac/opac-recalls.pl | 42 ++++ opac/opac-reserve.pl | 4 + opac/opac-user.pl | 10 + 15 files changed, 665 insertions(+), 4 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recall.tt create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recalls.tt create mode 100755 opac/opac-recall.pl create mode 100755 opac/opac-recalls.pl diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc index cd04f9f4a5..a0374c408b 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc @@ -39,6 +39,7 @@ Checked out [% END %] [% END %] + [% IF item.avail_for_recall %]Recall[% END %] [% END %] [% IF NOT ( item.isa('Koha::Item') ) AND item.transfertwhen %] [%# transfertwhen is set in C4::Search, do not have it for course reserves %] 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 09c4e49456..63b9a91dcb 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 @@ -11,6 +11,11 @@ [% END %] [% END %] + [% IF Koha.Preference('UseRecalls') %] +
  • + Place recall
  • + [% END %] +
  • Print
  • [% IF Koha.Preference( 'opacuserlogin' ) == 1 %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/title-actions-menu.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/title-actions-menu.inc index fb7312a17f..7470ab831d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/title-actions-menu.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/title-actions-menu.inc @@ -17,6 +17,10 @@ [% END # / UNLESS items.norequests %] [% END # / OPACHoldRequests %] + [% IF Koha.Preference('UseRecalls') %] + Place recall + [% END %] + [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) %] [% IF items.artreqpossible %] Request article diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc index 78ecd6ba6a..433b80db82 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc @@ -139,6 +139,15 @@ your interlibrary loan requests [% END %] + [% IF Koha.Preference('UseRecalls') %] + [% IF ( recallsview ) %] +
  • + [% ELSE %] +
  • + [% END %] + your recalls history + [% END %] + [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-details.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-details.tt index 9236149bca..0f1e97c980 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-details.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-details.tt @@ -87,7 +87,7 @@ [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.item.ccode, opac => 1 ) | html %] [% cr.item.itemcallnumber | html %] [% cr.item.copynumber | html %] - [% INCLUDE 'item-status.inc' item=cr.item issue=cr.issue %] + [% INCLUDE 'item-status.inc' item=cr.course_item issue=cr.issue %] [% cr.issue.date_due | $KohaDates as_due_date => 1 %] [% IF ( cr.public_note ) %] [% cr.public_note | $raw %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recall.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recall.tt new file mode 100644 index 0000000000..9cec6a056e --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recall.tt @@ -0,0 +1,199 @@ +[% USE Koha %] +[% USE KohaDates %] +[% USE Branches %] +[% USE ItemTypes %] +[% USE AuthorisedValues %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Recall › [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog +[% INCLUDE 'doc-head-close.inc' %] +[% BLOCK cssinclude %][% END %] + + +[% INCLUDE 'masthead.inc' %] + +
    + + +
    +
    +
    + +
    +
    +
    +

    Confirm recalls for: [% INCLUDE 'patron-title.inc' patron = logged_in_user %] ([% logged_in_user.cardnumber | html %])

    + [% IF nosyspref %] + Recalls have not been enabled. Please contact your library. + [% ELSIF error == 'unavailable' %] + There are no items available for recall. + Return to [% biblio.title | html %] + [% ELSE %] + [% IF error %] +
    + [% IF error == 'duplicate' %] + You have reached the maximum number of recalls on this record. + [% ELSIF error == 'unavailable' %] + There are no items available for recall. + [% ELSIF error == 'cannot' %] + You cannot place a recall on this item. + [% ELSE %] + An error has occurred while attempting to place a recall. Please contact your library. + [% END %] +
    + [% END %] + + [% IF success %] +

    Your recall has been placed. The patron the item is currently checked out to has been asked to return the item within [% due_interval | html %] days, by [% due_date | $KohaDates %].

    +

    You will be notified when your item is waiting to be picked up at the library.

    + [% ELSIF not error %] +

    All borrowable material is subject to recall if checked out and needed by someone else. We will ask the person who has checked out this item to return it so you may use it.

    + [% IF logged_in_user %] +
    + +
    +
    + Place a recall on [% biblio.title | html %] ([% biblio.author | html %])? +
      + + [% UNLESS ( single_branch_mode ) %]
    • + + +
    • [% END %] + +
    • [% INCLUDE 'date-format.inc' %]
    • + + + + + + + + + + [% UNLESS ( single_branch_mode ) %] + + + [% END %] + + + + + + + [% FOREACH item IN items %] + + + + [% UNLESS ( single_branch_mode ) %] + + + [% END %] + + + + + + [% END %] +
      Select a specific item:
       Item typeBarcodeHome libraryLast locationCollectionCall numberCopy numberVol infoInformation
      + [% IF item.can_be_recalled( patron => logged_in_user ) %] + + [% ELSE %] + + Cannot be recalled + [% END %] + [% ItemTypes.GetDescription( item.effective_itemtype ) | html %][% item.barcode | html %][% Branches.GetName( item.homebranch ) | html %][% Branches.GetName( item.holdingbranch) | html %][% AuthorisedValues.GetByCode( 'CCODE', item.ccode, 1 ) | html %][% item.itemcallnumber | html %][% item.copynumber | html %][% item.enumchron | html %] + [% IF ( item.checkout ) %] + Due [% item.checkout.date_due | $KohaDates %] + [% ELSIF ( item.get_transfer ) %] + In transit from [% Branches.GetName( item.get_transfer.frombranch ) | html %] to [% Branches.GetName( item.get_transfer.tobranch ) | html %] since [% item.get_transfer.datesent | $KohaDates %] + [% END %] + [% IF ( item.itemlost || item.withdrawn ) %] + Unavailable (lost or missing) + [% END %] + [% IF ( item.notforloan ) %] + Not for loan ([% item.notforloan | html %]) + [% END %] + [% hold = item.current_holds.next %] + [% IF ( item.recall ) %] + + [% IF ( item.recall.waitingdate ) %] + Waiting for patron at [% Branches.GetName( item.recall.branchcode ) | html %] since [% item.recall.waitingdate | $KohaDates %]. + [% ELSE %] + Recalled by patron expected at [% Branches.GetName( item.recall.branchcode ) | html %] since [% item.recall.recalldate | $KohaDates %]. + [% END %] + + [% ELSIF ( hold.waitingdate ) %] + + Waiting for patron at [% Branches.GetName( hold.branchcode ) | html %] since [% hold.waitingdate | $KohaDates %]. + + [% ELSIF ( hold.borrowernumber == logged_in_user.borrowernumber ) %] + + You have already placed a reserve on this item. + + [% END # / IF ( item.recall or hold ) %] +
      +
    +
    + + + + Cancel +
    +
    + +
    + [% ELSE %] +
    You must be logged in to place a recall.
    + [% END %] + [% END %] + [% END %] +
    +
    +
    +
    +
    + +[% INCLUDE 'opac-bottom.inc' %] +[% BLOCK jsinclude %] +[% INCLUDE 'calendar.inc' %] + +[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recalls.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recalls.tt new file mode 100644 index 0000000000..e6520366fe --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-recalls.tt @@ -0,0 +1,151 @@ +[% USE Koha %] +[% USE KohaDates %] +[% INCLUDE 'doc-head-open.inc' %] +Your recalls history › [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog +[% INCLUDE 'doc-head-close.inc' %] +[% BLOCK cssinclude %][% END %] + +[% INCLUDE 'bodytag.inc' bodyid='opac-recalls' bodyclass='scrollto' %] +[% INCLUDE 'masthead.inc' %] +
    + +
    +
    +
    + +
    +
    +
    +

    Recalls history

    + [% IF Koha.Preference('UseRecalls') %] + [% IF RECALLS.count %] +
    + + + + + + + + + + + + + + [% FOREACH RECALL IN RECALLS %] + + + + + + + + + + [% END %] + + +
    TitlePlaced onExpires onPickup locationStatusDue date 
    + + [% RECALL.biblio.title | html %] + [% FOREACH s IN RECALL.biblio.subtitle %] + [% s | html %] + [% END %] + + [% RECALL.biblio.author | html %] + + + Recall date: + [% RECALL.recalldate | $KohaDates %] + + + [% IF ( RECALL.expirationdate ) %] + + Expiration: + [% RECALL.expirationdate | $KohaDates %] + + [% ELSIF ( !RECALL.old ) %] + + Expiration: + Never expires + + [% ELSE %] + - + [% END %] + + Pick up location: + [% RECALL.library.branchname | html %] + + Status: + [% IF ( RECALL.in_transit ) %] + In transit to [% RECALL.library.branchname | html %] + [% ELSIF ( RECALL.waiting ) %] + Ready for pickup + [% ELSIF ( RECALL.overdue ) %] + Overdue to be returned + [% ELSIF ( RECALL.expired ) %] + Expired on [% RECALL.expirationdate | $KohaDates %] + [% ELSIF ( RECALL.cancelled ) %] + Cancelled on [% RECALL.cancellationdate | $KohaDates %] + [% ELSIF ( RECALL.finished ) %] + Fulfilled + [% ELSE %] + Requested + [% END %] + + Due date + [% IF ( RECALL.requested ) %] + Due to be returned by [% RECALL.checkout.date_due | $KohaDates %] + [% ELSIF ( RECALL.waiting and RECALL.expirationdate ) %] + Pick up by [% RECALL.expirationdate | $KohaDates %] + [% ELSE %] + - + [% END %] + + [% IF ( RECALL.requested or RECALL.overdue ) %] +
    + + + + +
    + [% END %] +
    + + [% ELSE %] + No recalls have been made. + [% END # / # RECALLS.count %] + [% ELSE %] + Recalls have not been enabled. Please contact your library. + [% END %] + + + + + + +[% INCLUDE 'opac-bottom.inc' %] +[% BLOCK jsinclude %] + [% INCLUDE 'datatables.inc' %] + +[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt index aff10f9f33..896cf88a21 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -201,6 +201,8 @@ [% END %] [% IF ( bibitemloo.already_reserved ) %]
    You have already requested this title.
    + [% ELSIF ( bibitemloo.recall ) %] +
    You have already placed a recall on this title.
    [% ELSE %] [% IF ( bibitemloo.already_patron_possession ) %]
    This title cannot be requested because it's already in your possession.
    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 d0a5ce3110..b06fb5bf13 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -219,6 +219,7 @@ [% END %] [% IF ( RESERVES.count ) %]
  • Holds ([% RESERVES.count | html %])
  • [% END %] + [% IF Koha.Preference('UseRecalls') && RECALLS.count %]
  • Recalls ([% RECALLS.count | html %])
  • [% END %] [% IF Koha.Preference('ArticleRequests') %]
  • Article requests ([% current_article_requests.size || 0 | html %])
  • [% END %] [% IF ( OverDriveCirculation ) %]
  • OverDrive account
  • @@ -319,6 +320,8 @@ [% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %] [% INCLUDE 'user-star-ratings.inc' item=ISSUE %] [% END %] + + [% IF ( ISSUE.recall ) %]
    This item has been recalled. Please return by the new due date.[% END %] @@ -746,6 +749,84 @@ [% PROCESS 'holds-table.inc' HOLDS = RESERVES, SuspendHoldsOpac = SuspendHoldsOpac, showpriority = showpriority, AutoResumeSuspendedHolds = AutoResumeSuspendedHolds %] + [% IF Koha.Preference('UseRecalls') && RECALLS.count %] +
    +
    [% ISSUE.author | html %]
    + + + + + + + + + + + + + [% FOREACH RECALL IN RECALLS %] + + + + + + + + [% END %] + + +
    Recalls ([% RECALLS.count | html %])
    TitlePlaced onExpires onPickup locationStatus 
    + + [% RECALL.biblio.title | html %] + [% FOREACH s IN RECALL.biblio.subtitle %] + [% s | html %] + [% END %] + + [% RECALL.biblio.author | html %] + + + Recall date: + [% RECALL.recalldate | $KohaDates %] + + + [% IF ( RECALL.expirationdate ) %] + + Expiration: + [% RECALL.expirationdate | $KohaDates %] + + [% ELSE %] + + Expiration: + Never expires + + [% END %] + + Pick up location: + [% RECALL.library.branchname | html %] + + Status: + [% IF ( RECALL.requested ) %] + Requested + [% ELSIF ( RECALL.overdue ) %] + Overdue to be returned + [% ELSIF ( RECALL.in_transit ) %] + In transit to [% RECALL.library.branchname | html %] + [% ELSIF ( RECALL.waiting ) %] + Ready for pickup + [% END %] + + [% IF ( RECALL.requested or RECALL.overdue ) %] +
    + + + + +
    + [% END %] +
    +
    + [% END # / # RECALLS.count %] + [% IF Koha.Preference('ArticleRequests') %]
    [% IF current_article_requests.size %] @@ -1124,6 +1205,10 @@ }); } + $("#cancel_recall").click(function(e){ + return confirmDelete(_("Are you sure you want to remove this recall?")); + }); + $("body").on("click", ".btn-add-note", function(e){ e.preventDefault(); var title = $(this).data("title"); diff --git a/opac/opac-course-details.pl b/opac/opac-course-details.pl index 415cade52f..bf9abdfb88 100755 --- a/opac/opac-course-details.pl +++ b/opac/opac-course-details.pl @@ -44,6 +44,13 @@ die("No course_id given") unless ($course_id); my $course = GetCourse($course_id); my $course_reserves = GetCourseReserves( course_id => $course_id, include_items => 1, include_count => 1 ); +foreach my $cr ( @$course_reserves ) { + if ( $cr->{issue}->{date_due} and $cr->{issue}->{borrowernumber} and $borrowernumber != $cr->{issue}->{borrowernumber} and C4::Context->preference('UseRecalls') ) { + $cr->{course_item}->{avail_for_recall} = 1; + $cr->{course_item}->{biblionumber} = Koha::Items->find( $cr->{itemnumber} )->biblionumber; + } +} + $template->param( course => $course, course_reserves => $course_reserves, diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 1c705db734..c43caecd08 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -730,16 +730,17 @@ if ( not $viewallitems and @items > $max_items_to_display ) { } my $reserve_status = C4::Reserves::GetReserveStatus($itm->{itemnumber}); - if( $reserve_status eq "Waiting"){ $itm->{'waiting'} = 1; } + my $recall_status = Koha::Recalls->search({ itemnumber => $itm->{itemnumber}, status => 'W', old => undef }); + if( $reserve_status eq "Waiting" or $recall_status->count ){ $itm->{'waiting'} = 1; } if( $reserve_status eq "Reserved"){ $itm->{'onhold'} = 1; } - + my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($itm->{itemnumber}); if ( defined( $transfertwhen ) && $transfertwhen ne '' ) { $itm->{transfertwhen} = $transfertwhen; $itm->{transfertfrom} = $transfertfrom; $itm->{transfertto} = $transfertto; } - + if ( C4::Context->preference('OPACAcquisitionDetails') ) { $itm->{on_order} = 1 if grep { $_ eq $itm->{itemnumber} } @itemnumbers_on_order; diff --git a/opac/opac-recall.pl b/opac/opac-recall.pl new file mode 100755 index 0000000000..fbc2cd0d8c --- /dev/null +++ b/opac/opac-recall.pl @@ -0,0 +1,141 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Copyright 2020 Aleisha Amohia +# +# 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 qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); +use C4::Context; + +my $query = new CGI; +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "opac-recall.tt", + query => $query, + type => "opac", + authnotrequired => 0, + } +); + +my $op = $query->param('op') || ''; +my $biblionumber = $query->param('biblionumber'); +my $biblio = Koha::Biblios->find( $biblionumber ); + +if ( C4::Context->preference('UseRecalls') ) { + + my $patron = Koha::Patrons->find( $borrowernumber ); + my $error; + + unless ( $biblio->can_be_recalled({ patron => $patron }) ) { $error = 'unavailable'; } + + my $items = Koha::Items->search({ biblionumber => $biblionumber }); + + # check if already recalled + my $recalled = scalar $biblio->recalls; + if ( defined $recalled and $recalled > 0 ) { + my $recalls_per_record = Koha::CirculationRules->get_effective_rule({ + categorycode => $patron->categorycode, + branchcode => undef, + itemtype => undef, + rule_name => 'recalls_per_record' + }); + if ( defined $recalls_per_record and $recalls_per_record->rule_value and $recalled >= $recalls_per_record->rule_value ){ + $error = 'duplicate'; + } + } + + # submitting recall request + if ($op eq 'request'){ + + if ( defined $error and $error eq 'unavailable' ){ + # no items available for recall + print $query->redirect("/cgi-bin/koha/opac-recall.pl?biblionumber=$biblionumber&error=unavailable"); + + } elsif ( !defined $error ){ + # can recall + + my $level = $query->param('type'); + my $pickuploc = $query->param('pickup'); + my $expdate = $query->param('expirationdate'); + my $itemnumber = $query->param('itemnumber'); + + my ( $recall, $due_interval, $due_date ); + if ( $level eq 'itemlevel' and defined $itemnumber ) { + my $item = Koha::Items->find( $itemnumber ); + if ( $item->can_be_recalled({ patron => $patron }) ) { + ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({ + patron => $patron, + biblio => $biblio, + branchcode => $pickuploc, + item => $item, + expirationdate => $expdate, + interface => 'OPAC', + }); + } else { + $error = 'cannot'; + } + } else { + if ( $biblio->can_be_recalled({ patron => $patron }) ) { + ( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({ + patron => $patron, + biblio => $biblio, + branchcode => $pickuploc, + expirationdate => $expdate, + interface => 'OPAC', + }); + } else { + $error = 'cannot'; + } + } + if ( defined $recall ) { + $template->param( + success => 1, + due_interval => $due_interval, + due_date => $due_date, + ); + } else { + $error = 'failed'; + } + } + } elsif ($op eq 'cancel'){ + my $recall_id = $query->param('recall_id'); + Koha::Recalls->find( $recall_id )->set_cancelled; + print $query->redirect('/cgi-bin/koha/opac-user.pl'); + } + + my $branches = Koha::Libraries->search(); + my $single_branch_mode = $branches->count == 1; + + $template->param( + biblio => $biblio, + error => $error, + items => $items, + single_branch_mode => $single_branch_mode, + branches => $branches, + ); + +} else { + # UseRecalls disabled + $template->param( + nosyspref => 1, + biblio => $biblio, + ); +} + +output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; diff --git a/opac/opac-recalls.pl b/opac/opac-recalls.pl new file mode 100755 index 0000000000..96b0c788db --- /dev/null +++ b/opac/opac-recalls.pl @@ -0,0 +1,42 @@ +#!/usr/bin/perl + +# Copyright 2020 Aleisha Amohia +# +# 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 Encode qw( encode ); +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); +use Koha::Recalls; + +my $input = new CGI; +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "opac-recalls.tt", + query => $input, + type => "opac", + authnotrequired => 0, + } +); + +my $recalls = Koha::Recalls->search({ borrowernumber => $borrowernumber }, { order_by => { -desc => 'recalldate' } }); +$template->param( + RECALLS => $recalls, + recallsview => 1 +); + +output_html_with_http_headers $input, $cookie, $template->output, undef, { force_no_caching => 1 }; diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index a339200561..568a3c73de 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -633,6 +633,10 @@ foreach my $biblioNum (@biblionumbers) { $biblioLoopIter{holdable} &&= $status eq 'OK'; $biblioLoopIter{already_patron_possession} = $status eq 'alreadypossession'; + if ( CanBookBeReserved( $borrowernumber, $biblioNum )->{status} eq 'recall' ){ + $biblioLoopIter{recall} = 1; + } + # For multiple holds per record, if a patron has previously placed a hold, # the patron can only place more holds of the same type. That is, if the # patron placed a record level hold, all the holds the patron places must diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 83ef251cdc..35d52498a8 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -306,6 +306,14 @@ if ( $pending_checkouts->count ) { # Useless test $issue->{biblionumber} ? $my_summary_html =~ s/{BIBLIONUMBER}/$issue->{biblionumber}/g : $my_summary_html =~ s/{BIBLIONUMBER}//g; $issue->{MySummaryHTML} = $my_summary_html; } + + my @maybe_recalls = Koha::Recalls->search({ biblionumber => $issue->{biblionumber}, itemnumber => [ undef, $issue->{itemnumber} ], old => undef }); + foreach my $recall ( @maybe_recalls ) { + if ( $recall->checkout and $recall->checkout->issue_id == $issue->{issue_id} ) { + $issue->{recall} = 1; + last; + } + } } } my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing'); @@ -327,10 +335,12 @@ $template->param( show_barcode => 1 ) if $show_barcode; # now the reserved items.... my $reserves = Koha::Holds->search( { borrowernumber => $borrowernumber } ); +my $recalls = Koha::Recalls->search({ borrowernumber => $borrowernumber, old => undef }); $template->param( RESERVES => $reserves, showpriority => $show_priority, + RECALLS => $recalls, ); if (C4::Context->preference('BakerTaylorEnabled')) { -- 2.20.1