From 742027a8bb9c852f4e44262f08aa4297ec3e097d 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 - 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 --- .../bootstrap/en/includes/item-status.inc | 1 + .../bootstrap/en/includes/opac-detail-sidebar.inc | 5 + .../bootstrap/en/includes/title-actions-menu.inc | 4 + .../opac-tmpl/bootstrap/en/includes/usermenu.inc | 9 + .../bootstrap/en/modules/opac-course-details.tt | 2 +- .../opac-tmpl/bootstrap/en/modules/opac-recall.tt | 199 +++++++++++++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-recalls.tt | 151 ++++++++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 2 + .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 1 + .../opac-tmpl/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 ++ 16 files changed, 666 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 7ee2303d80..7db33f3bf3 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc @@ -38,6 +38,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 a110d73a2a..6e45dd4048 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 124c95da4a..3224965bbc 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 # / RequestOnOpac %] + [% 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 80e626df83..7560d6590e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc @@ -130,6 +130,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 ffd3367aa1..dad529e1de 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 @@ -85,7 +85,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..63c4a0f240 --- /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' %] +[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog › Recall +[% 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..b434185fe9 --- /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' %] +[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog › Your recalls history +[% 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 6101759564..1e441477ab 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -199,6 +199,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 %] [% UNLESS ( bibitemloo.bib_available ) %]
    There are no items that can be placed on hold.
    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 e67f3d815c..d5cd79be7d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -477,6 +477,7 @@ [% UNLESS ( SEARCH_RESULT.hidelostitems ) %][% IF ( SEARCH_RESULT.itemlostcount ) %] Lost ([% SEARCH_RESULT.itemlostcount | html %]),[% END %][% END %] [% IF ( SEARCH_RESULT.damagedcount ) %] Damaged ([% SEARCH_RESULT.damagedcount | html %]),[% END %] [% IF ( SEARCH_RESULT.orderedcount ) %] On order ([% SEARCH_RESULT.orderedcount | html %]),[% END %] + [% IF ( SEARCH_RESULT.recalledcount ) %] Recalled ([% SEARCH_RESULT.recalledcount | html %]),[% END %] [% IF ( SEARCH_RESULT.onholdcount ) %] On hold ([% SEARCH_RESULT.onholdcount | html %]),[% END %] [% IF ( SEARCH_RESULT.intransitcount ) %] In transit ([% SEARCH_RESULT.intransitcount | html %]),[% END %] 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 493a59d030..d6fad9d7a7 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -210,6 +210,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') && logged_in_user.article_requests_current %]
  • Article requests ([% logged_in_user.article_requests_current.count | html %])
  • [% END %] [% IF ( OverDriveCirculation ) %]
  • OverDrive Account
  • @@ -308,6 +309,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 %] @@ -668,6 +671,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 logged_in_user.article_requests_current.count %] @@ -993,6 +1074,10 @@ $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber | html %]'); }); } + + $("#cancel_recall").click(function(e){ + return confirmDelete(_("Are you sure you want to remove this recall?")); + }); }); var borrowernumber = "[% borrowernumber | html %]"; diff --git a/opac/opac-course-details.pl b/opac/opac-course-details.pl index 3afa8a921a..0a727565f6 100755 --- a/opac/opac-course-details.pl +++ b/opac/opac-course-details.pl @@ -46,6 +46,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 8d4723e338..6b0df1872b 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -747,16 +747,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..bca72115c2 --- /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; +use C4::Output; +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_with_http_headers $query, $cookie, $template->output, 'html'; diff --git a/opac/opac-recalls.pl b/opac/opac-recalls.pl new file mode 100755 index 0000000000..a54469ef37 --- /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; # get_template_and_user +use C4::Output; +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; diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index a930ddbf76..a9c09a15ee 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -622,6 +622,10 @@ foreach my $biblioNum (@biblionumbers) { $biblioLoopIter{holdable} &&= CanBookBeReserved( $borrowernumber, $biblioNum )->{status} eq 'OK'; + 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 a380d88f01..f052813723 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -298,6 +298,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'); @@ -319,10 +327,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.11.0