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

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Aleisha Amohia 2020-05-11 23:52:52 +00:00 committed by Fridolin Somers
parent b800c2e68d
commit 52b5cdf79b
15 changed files with 665 additions and 4 deletions

View File

@ -39,6 +39,7 @@
<span class="item-status checkedout">Checked out</span>
[% END %]
[% END %]
[% IF item.avail_for_recall %]<a href="/cgi-bin/koha/opac-recall.pl?biblionumber=[% item.biblionumber | uri %]" class="btn btn-default btn-xs">Recall</a>[% END %]
[% END %]
[% IF NOT ( item.isa('Koha::Item') ) AND item.transfertwhen %] [%# transfertwhen is set in C4::Search, do not have it for course reserves %]

View File

@ -11,6 +11,11 @@
[% END %]
[% END %]
[% IF Koha.Preference('UseRecalls') %]
<li><a class="recall btn btn-link btn-lg" href="/cgi-bin/koha/opac-recall.pl?biblionumber=[% biblio.biblionumber | html %]"><i class="fa fa-fw fa-bookmark-o"></i>
Place recall</a></li>
[% END %]
<li><a class="print-large btn btn-link btn-lg" href="#"><i class="fa fa-fw fa-print" aria-hidden="true"></i> Print</a></li>
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]

View File

@ -17,6 +17,10 @@
[% END # / UNLESS items.norequests %]
[% END # / OPACHoldRequests %]
[% IF Koha.Preference('UseRecalls') %]
<span class="actions"><a class="btn btn-link recall" href="/cgi-bin/koha/opac-recall.pl?biblionumber=[% items.biblionumber | html %]"><i class="fa fa-fw fa-bookmark-o" aria-hidden="true"></i> Place recall</a></span>
[% END %]
[% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) %]
[% IF items.artreqpossible %]
<span class="actions"><a href="/cgi-bin/koha/opac-request-article.pl?biblionumber=[% items.biblionumber | uri %]" class="btn btn-link btn-sm"><i class="fa fa-file-text" aria-hidden="true"></i> Request article</a></span>

View File

@ -139,6 +139,15 @@
<a href="/cgi-bin/koha/opac-illrequests.pl">your interlibrary loan requests</a></li>
[% END %]
[% IF Koha.Preference('UseRecalls') %]
[% IF ( recallsview ) %]
<li class="active">
[% ELSE %]
<li>
[% END %]
<a href="/cgi-bin/koha/opac-recalls.pl">your recalls history</a>
[% END %]
</ul>
</div>
[% END %]

View File

@ -87,7 +87,7 @@
<td>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => cr.item.ccode, opac => 1 ) | html %]</td>
<td>[% cr.item.itemcallnumber | html %]</td>
<td>[% cr.item.copynumber | html %]</td>
<td>[% INCLUDE 'item-status.inc' item=cr.item issue=cr.issue %]</td>
<td>[% INCLUDE 'item-status.inc' item=cr.course_item issue=cr.issue %]</td>
<td data-order="[% cr.issue.date_due | html %]">[% cr.issue.date_due | $KohaDates as_due_date => 1 %]</td>
<td>[% IF ( cr.public_note ) %]
[% cr.public_note | $raw %]

View File

@ -0,0 +1,199 @@
[% USE Koha %]
[% USE KohaDates %]
[% USE Branches %]
[% USE ItemTypes %]
[% USE AuthorisedValues %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Recall &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %][% END %]
</head>
<body id="opac-recall" class="scrollto">
[% INCLUDE 'masthead.inc' %]
<div class="main">
<ul class="breadcrumb">
<li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
<li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblio.biblionumber | uri %]">Details for: [% biblio.title | html %]</a> <span class="divider">&rsaquo;</span></li>
<li><a href="/cgi-bin/koha/opac-recall.pl?biblionumber=[% biblio.biblionumber | uri %]">Place recall</a></li>
</ul>
<div class="container-fluid">
<div class="row-fluid">
<div class="span2">
<div id="navigation">
[% INCLUDE 'navigation.inc' IsPatronPage=1 %]
</div>
</div>
<div class="span10">
<div id="recall" class="maincontent">
<h1>Confirm recalls for: [% INCLUDE 'patron-title.inc' patron = logged_in_user %] ([% logged_in_user.cardnumber | html %])</h1>
[% IF nosyspref %]
Recalls have not been enabled. Please contact your library.
[% ELSIF error == 'unavailable' %]
There are no items available for recall.
<a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblio.biblionumber | uri %]">Return to [% biblio.title | html %]</a>
[% ELSE %]
[% IF error %]
<div class="dialog alert">
[% 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 %]
</div>
[% END %]
[% IF success %]
<p>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 %].</p>
<p>You will be notified when your item is waiting to be picked up at the library.</p>
[% ELSIF not error %]
<p>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.</p>
[% IF logged_in_user %]
<div class="dialog">
<form id="recallform" action="/cgi-bin/koha/opac-recall.pl" method="get">
<fieldset class="rows" id="options">
<legend>Place a recall on <b>[% biblio.title | html %]</b> ([% biblio.author | html %])?</legend>
<ul>
[% UNLESS ( single_branch_mode ) %]<li>
<label for="pickup">Pick up location:</label>
<select name="pickup" id="pickup">
[% FOREACH branch IN branches %]
[% IF branch.branchcode == logged_in_user.branchcode %]
<option value="[% branch.branchcode | html %]" selected>[% Branches.GetName( branch.branchcode ) | html %]</option>
[% ELSE %]
<option value="[% branch.branchcode | html %]">[% Branches.GetName( branch.branchcode ) | html %]</option>
[% END %]
[% END %]
</select>
</li>[% END %]
<li><label for="expirationdate">Recall not needed after:</label> <input type="text" name="expirationdate" id="expirationdate" size="20"> <a id="cleartext" style="display:none;">Clear text</a><span id="expiration-hint">[% INCLUDE 'date-format.inc' %]</span></li>
<li class="level-option" style="display:none;"><label for="bibliolevel">Recall next available item</label> <input type="radio" name="type" id="bibliolevel" value="bibliolevel" checked></li>
<li class="level-option" style="display:none;"><label for="itemlevel">Recall a specific item</label> <input type="radio" name="type" id="itemlevel" value="itemlevel"></li>
<table class="table table-bordered table-striped" id="items">
<caption>Select a specific item:</caption>
<tr>
<th>&nbsp;</th>
<th>Item type</th>
<th>Barcode</th>
[% UNLESS ( single_branch_mode ) %]
<th>Home library</th>
<th>Last location</th>
[% END %]
<th>Collection</th>
<th>Call number</th>
<th>Copy number</th>
<th>Vol info</th>
<th>Information</th>
</tr>
[% FOREACH item IN items %]<tr>
<td>
[% IF item.can_be_recalled( patron => logged_in_user ) %]
<input type="radio" class="itemnumber" name="itemnumber" value="[% item.itemnumber | html %]">
[% ELSE %]
<input disabled="disabled" type="radio" class="itemnumber" name="itemnumber" value="[% item.itemnumber | html %]" style="display:none;" />
<img src="[% interface | html %]/lib/famfamfam/cross.png" alt="Cannot be recalled" title="Cannot be recalled" />
[% END %]
</td>
<td>[% ItemTypes.GetDescription( item.effective_itemtype ) | html %]</td>
<td>[% item.barcode | html %]</td>
[% UNLESS ( single_branch_mode ) %]
<td>[% Branches.GetName( item.homebranch ) | html %]</td>
<td>[% Branches.GetName( item.holdingbranch) | html %]</td>
[% END %]
<td>[% AuthorisedValues.GetByCode( 'CCODE', item.ccode, 1 ) | html %]</td>
<td>[% item.itemcallnumber | html %]</td>
<td>[% item.copynumber | html %]</td>
<td>[% item.enumchron | html %]</td>
<td>
[% IF ( item.checkout ) %]
<span class="checkedout">Due [% item.checkout.date_due | $KohaDates %]</span>
[% ELSIF ( item.get_transfer ) %]
<span class="intransit">In transit from [% Branches.GetName( item.get_transfer.frombranch ) | html %] to [% Branches.GetName( item.get_transfer.tobranch ) | html %] since [% item.get_transfer.datesent | $KohaDates %]</span>
[% END %]
[% IF ( item.itemlost || item.withdrawn ) %]
<span class="lost">Unavailable (lost or missing)</span>
[% END %]
[% IF ( item.notforloan ) %]
<span class="notforloan">Not for loan ([% item.notforloan | html %])</span>
[% END %]
[% hold = item.current_holds.next %]
[% IF ( item.recall ) %]
<span class="waiting">
[% 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 %]
</span>
[% ELSIF ( hold.waitingdate ) %]
<span class="waiting">
Waiting for patron at [% Branches.GetName( hold.branchcode ) | html %] since [% hold.waitingdate | $KohaDates %].
</span>
[% ELSIF ( hold.borrowernumber == logged_in_user.borrowernumber ) %]
<span class="waiting">
You have already placed a <a href="/cgi-bin/koha/opac-user.pl#opac-user-holds">reserve</a> on this item.
</span>
[% END # / IF ( item.recall or hold ) %]
</td>
</tr>[% END %]
</table>
</fieldset>
<fieldset class="action">
<input type="hidden" name="op" value="request">
<input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]">
<input type="submit" class="btn" value="Confirm">
<a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblio.biblionumber | uri %]" class="cancel">Cancel</a>
</fieldset>
</form>
</div>
[% ELSE %]
<div class="dialog alert">You must be logged in to place a recall.</div>
[% END %]
[% END %]
[% END %] <!-- norecalls -->
</div> <!-- / #recall -->
</div> <!-- / .span10 -->
</div> <!-- / .row-fluid -->
</div> <!-- / .container-fluid -->
</div> <!-- / .main -->
[% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %]
[% INCLUDE 'calendar.inc' %]
<script>
$(document).ready(function(){
$(".level-option").show();
$("#cleartext").show();
$("#items").hide();
$("#expiration-hint").hide();
$("#cleartext").click(function(){
$(this).siblings("input").val("");
});
$("#itemlevel").click(function(){
if ( $("#itemlevel").is(':checked') ){
$("#items").show();
$("input:radio[name='itemnumber']:not(:disabled)").first().attr("checked", "checked"); // selects first item in table
}
});
$("#bibliolevel").click(function(){
if ( $("#bibliolevel").is(':checked') ){
$("#items").hide();
}
});
$("#expirationdate").datepicker({
minDate: 0,
});
});
</script>
[% END %]

View File

@ -0,0 +1,151 @@
[% USE Koha %]
[% USE KohaDates %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Your recalls history &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %][% END %]
</head>
[% INCLUDE 'bodytag.inc' bodyid='opac-recalls' bodyclass='scrollto' %]
[% INCLUDE 'masthead.inc' %]
<div class="main">
<ul class="breadcrumb">
<li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
<li><a href="#">Your recalls history</a></li>
</ul>
<div class="container-fluid">
<div class="row-fluid">
<div class="span2">
<div id="navigation">
[% INCLUDE 'navigation.inc' IsPatronPage=1 %]
</div>
</div>
<div class="span10">
<div id="recalls" class="maincontent">
<h2>Recalls history</h2>
[% IF Koha.Preference('UseRecalls') %]
[% IF RECALLS.count %]
<div id="opac-user-recalls">
<table id="recalls-table" class="table table-bordered table-striped">
<thead>
<tr>
<th class="anti-the">Title</th>
<th class="psort title-string">Placed on</th>
<th class="title-string">Expires on</th>
<th>Pickup location</th>
<th>Status</th>
<th>Due date</th>
<th class="nosort">&nbsp;</th>
</tr>
</thead>
<tbody>
[% FOREACH RECALL IN RECALLS %]
<tr>
<td class="title">
<a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% RECALL.biblionumber | html %]">
[% RECALL.biblio.title | html %]
[% FOREACH s IN RECALL.biblio.subtitle %]
[% s | html %]
[% END %]
</a>
[% RECALL.biblio.author | html %]
</td>
<td class="recalldate">
<span title="[% RECALL.recalldate | html %]">
<span class="tdlabel">Recall date:</span>
[% RECALL.recalldate | $KohaDates %]
</span>
</td>
<td class="expirationdate">
[% IF ( RECALL.expirationdate ) %]
<span title="[% RECALL.expirationdate | html %]">
<span class="tdlabel">Expiration:</span>
[% RECALL.expirationdate | $KohaDates %]
</span>
[% ELSIF ( !RECALL.old ) %]
<span title="0000-00-00">
<span class="tdlabel">Expiration:</span>
Never expires
</span>
[% ELSE %]
<span title="0000-00-00">-</span>
[% END %]
</td>
<td class="branch">
<span class="tdlabel">Pick up location:</span>
[% RECALL.library.branchname | html %]
</td>
<td class="status">
<span class="tdlabel">Status:</span>
[% 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 %]
</td>
<td class="due_date">
<span class="tdlabel">Due date</span>
[% 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 %]
</td>
<td class="cancelrecall">
[% IF ( RECALL.requested or RECALL.overdue ) %]
<form action="/cgi-bin/koha/opac-recall.pl" method="post">
<input type="hidden" name="op" value="cancel">
<input type="hidden" name="recall_id" value="[% RECALL.recall_id | html %]">
<input type="hidden" name="biblionumber" value="[% RECALL.biblionumber | html %]">
<input type="submit" name="submit" class="btn btn-danger cancel_recall" value="Cancel">
</form>
[% END %]
</td>
[% END %]
</tr>
</tbody>
<table>
</div>
[% ELSE %]
No recalls have been made.
[% END # / # RECALLS.count %]
[% ELSE %]
Recalls have not been enabled. Please contact your library.
[% END %]
</div> <!-- /#recalls -->
</div> <!-- /.span10 -->
</div> <!-- /.row-fluid -->
</div> <!-- /.container-fluid -->
</div> <!-- /#main -->
[% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %]
[% INCLUDE 'datatables.inc' %]
<script type="text/JavaScript">
//<![CDATA[
$(document).ready(function(){
$(".cancel_recall").click(function(){
return confirmDelete(_("Are you sure you want to remove this recall?"));
});
$("#recalls-table").dataTable($.extend(true, {}, dataTablesDefaults, {
"aoColumnDefs": [
{ "aTargets": [ "nosort" ],"bSortable": false,"bSearchable": false },
{ "sType": "anti-the", "aTargets" : [ "anti-the" ] },
{ "sType": "title-string", "aTargets" : [ "title-string" ] }
]
}));
});
</script>
[% END %]

View File

@ -201,6 +201,8 @@
[% END %]
[% IF ( bibitemloo.already_reserved ) %]
<div class="alert alert-warning">You have already requested this title.</div>
[% ELSIF ( bibitemloo.recall ) %]
<div class="alert alert-warning">You have already placed a recall on this title.</div>
[% ELSE %]
[% IF ( bibitemloo.already_patron_possession ) %]
<div class="alert alert-warning">This title cannot be requested because it's already in your possession.</div>

View File

@ -219,6 +219,7 @@
[% END %]
[% IF ( RESERVES.count ) %]<li><a href="#opac-user-holds">Holds ([% RESERVES.count | html %])</a></li>[% END %]
[% IF Koha.Preference('UseRecalls') && RECALLS.count %]<li><a href="#opac-user-recalls">Recalls ([% RECALLS.count | html %])</a></li>[% END %]
[% IF Koha.Preference('ArticleRequests') %]<li><a href="#opac-user-article-requests">Article requests ([% current_article_requests.size || 0 | html %])</a></li>[% END %]
[% IF ( OverDriveCirculation ) %]
<li><a href="#opac-user-overdrive">OverDrive account</a></li>
@ -319,6 +320,8 @@
[% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %]
[% INCLUDE 'user-star-ratings.inc' item=ISSUE %]
[% END %]
[% IF ( ISSUE.recall ) %]<br><i>This item has been recalled. Please return by the new due date.</i>[% END %]
</td>
<td class="author">[% ISSUE.author | html %]</td>
@ -746,6 +749,84 @@
[% PROCESS 'holds-table.inc' HOLDS = RESERVES, SuspendHoldsOpac = SuspendHoldsOpac, showpriority = showpriority, AutoResumeSuspendedHolds = AutoResumeSuspendedHolds %]
[% IF Koha.Preference('UseRecalls') && RECALLS.count %]
<div id="opac-user-recalls">
<table id="recalls-table" class="table table-bordered table-striped">
<caption>Recalls <span class="count">([% RECALLS.count | html %])</span></caption>
<thead>
<tr>
<th class="anti-the">Title</th>
<th class="psort title-string">Placed on</th>
<th class="title-string">Expires on</th>
<th>Pickup location</th>
<th>Status</th>
<th class="nosort">&nbsp;</th>
</tr>
</thead>
<tbody>
[% FOREACH RECALL IN RECALLS %]
<tr>
<td class="title">
<a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% RECALL.biblionumber | html %]">
[% RECALL.biblio.title | html %]
[% FOREACH s IN RECALL.biblio.subtitle %]
[% s | html %]
[% END %]
</a>
[% RECALL.biblio.author | html %]
</td>
<td class="recalldate">
<span title="[% RECALL.recalldate | html %]">
<span class="tdlabel">Recall date:</span>
[% RECALL.recalldate | $KohaDates %]
</span>
</td>
<td class="expirationdate">
[% IF ( RECALL.expirationdate ) %]
<span title="[% RECALL.expirationdate | html %]">
<span class="tdlabel">Expiration:</span>
[% RECALL.expirationdate | $KohaDates %]
</span>
[% ELSE %]
<span title="0000-00-00">
<span class="tdlabel">Expiration:</span>
Never expires
</span>
[% END %]
</td>
<td class="branch">
<span class="tdlabel">Pick up location:</span>
[% RECALL.library.branchname | html %]
</td>
<td class="status">
<span class="tdlabel">Status:</span>
[% 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 %]
</td>
<td class="cancelrecall">
[% IF ( RECALL.requested or RECALL.overdue ) %]
<form action="/cgi-bin/koha/opac-recall.pl" method="post">
<input type="hidden" name="op" value="cancel">
<input type="hidden" name="recall_id" value="[% RECALL.recall_id | html %]">
<input type="hidden" name="biblionumber" value="[% RECALL.biblionumber | html %]">
<button type="submit" name="submit" class="btn btn-sm btn-danger" id="cancel_recall"><i class="icon-remove icon-white"></i> Cancel</button>
</form>
[% END %]
</td>
[% END %]
</tr>
</tbody>
</table>
</div>
[% END # / # RECALLS.count %]
[% IF Koha.Preference('ArticleRequests') %]
<div id="opac-user-article-requests">
[% 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");

View File

@ -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,

View File

@ -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;

141
opac/opac-recall.pl Executable file
View File

@ -0,0 +1,141 @@
#!/usr/bin/perl
# This file is part of Koha.
#
# Copyright 2020 Aleisha Amohia <aleisha@catalyst.net.nz>
#
# 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 <http://www.gnu.org/licenses>.
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 };

42
opac/opac-recalls.pl Executable file
View File

@ -0,0 +1,42 @@
#!/usr/bin/perl
# Copyright 2020 Aleisha Amohia <aleisha@catalyst.net.nz>
#
# 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 <http://www.gnu.org/licenses>.
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 };

View File

@ -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

View File

@ -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')) {