+ [% IF ( recall.in_transit ) %]
+ In transit to [% recall.library.branchname %]
+ [% ELSIF ( recall.waiting ) %]
+ Ready for pickup
+ [% ELSIF ( recall.expired ) %]
+ Expired on [% recall.expirationdate | $KohaDates %]
+ [% ELSIF ( recall.cancelled ) %]
+ Cancelled on [% recall.cancellationdate | $KohaDates %]
+ [% ELSIF ( recall.overdue ) %]
+ Overdue to be returned
+ [% ELSIF ( recall.finished ) %]
+ Fulfilled
+ [% ELSE %]
+ Requested
+ [% END %]
+
+
+
+ [% 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 %]
+
+ [% END %]
[% INCLUDE "checkouts-table.inc" %]
@@ -782,6 +790,12 @@
[% END %]
+ [% IF Koha.Preference('UseRecalls') %]
+
+ [% INCLUDE 'recalls.inc' %]
+
+ [% END %]
+
[% INCLUDE borrower_debarments.inc %]
[% IF ( CAN_user_circulate_circulate_remaining_permissions ) %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/recallshistory.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/recallshistory.tt
@@ -0,0 +1,45 @@
+[% USE KohaDates %]
+[% USE Koha %]
+[% USE Asset %]
+[% SET footerjs = 1 %]
+[% INCLUDE 'doc-head-open.inc' %]
+Recalls history for [% INCLUDE 'patron-title.inc' %]
+[% INCLUDE 'doc-head-close.inc' %]
+[% Asset.css("css/datatables.css") %]
+
+
+
+ [% INCLUDE 'header.inc' %]
+ [% INCLUDE 'patron-search.inc' %]
+
+
+ Home ›
+ Patrons ›
+ Recalls history for [% INCLUDE 'patron-title.inc' %]
+
+
+
+
+
+ [% INCLUDE 'members-toolbar.inc' %]
+
Recalls history
+ [% IF Koha.Preference('UseRecalls') %]
+ [% INCLUDE 'recalls.inc' %]
+ [% ELSE %]
+
Recalls have not been enabled. Enable the UseRecalls system preference to use recalls.
+ [% END %]
+
+
+
+
+
+
+
+[% MACRO jsinclude BLOCK %]
+ [% INCLUDE 'datatables.inc' %]
+ [% Asset.js("js/recalls.js") %]
+[% END %]
+
+[% INCLUDE 'intranet-bottom.inc' %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_old_queue.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_old_queue.tt
@@ -0,0 +1,57 @@
+[% USE Koha %]
+[% USE KohaDates %]
+[% USE Asset %]
+[% SET footerjs = 1 %]
+[% INCLUDE 'doc-head-open.inc' %]
+Koha › Circulation › Old recalls
+[% INCLUDE 'doc-head-close.inc' %]
+
+[% Asset.css("css/datatables.css") %]
+
+
+[% INCLUDE 'header.inc' %]
+[% INCLUDE 'cat-search.inc' %]
+
+
+ [% INCLUDE 'biblio-default-view.inc' biblionumber=recall.biblio.biblionumber %]
+ [% INCLUDE 'biblio-title.inc' biblio=recall.biblio %]
+ [% IF recall.biblio.author %] by [% recall.biblio.author %][% END %]
+
+
+
+ [% FOREACH library IN recall.libraries %]
+
[% Branches.GetName( library ) %]
+ [% END %]
+
+
+
+
+ [% FOREACH callnumber IN recall.callnumbers %]
+
[% END # /IF exceeded_maxreserves %]
[% ELSE # UNLESS multi_hold %]
--- a/koha-tmpl/intranet-tmpl/prog/js/recalls.js
+++ a/koha-tmpl/intranet-tmpl/prog/js/recalls.js
@@ -0,0 +1,172 @@
+$(document).ready(function() {
+
+ $(".cancel_recall").click(function(e){
+ if (confirmDelete(_("Are you sure you want to remove this recall?"))){
+ var $self = $(this);
+ var $recall_id = $(this).data('id');
+ var $action = $(this).data('action');
+ var ajaxData = {
+ 'recall_id': $recall_id,
+ 'action' : $action,
+ };
+ var $howmanyparents = $(this).data('parent');
+
+ $.ajax({
+ url: '/cgi-bin/koha/svc/recall',
+ type: 'POST',
+ dataType: 'json',
+ data: ajaxData,
+ })
+ .done(function(data) {
+ var message = "";
+ if(data.success == 0) {
+ message = _("The recall may have already been cancelled. Please refresh the page.");
+ } else {
+ message = _("Cancelled");
+ }
+ if ( $howmanyparents == "one" ){
+ $self.parent().html(message);
+ } else {
+ $self.parent().parent().parent().parent().html(message);
+ }
+ });
+ }
+ });
+
+ $(".checkin_recall").click(function(e){
+ if (confirmDelete(_("Are you sure you want to check in this item and confirm the recall as 'waiting'?"))){
+ var $self = $(this);
+ var $recall_id = $(this).data('id');
+ var $action = $(this).data('action');
+ var ajaxData = {
+ 'recall_id': $recall_id,
+ 'action' : $action,
+ };
+
+ $.ajax({
+ url: '/cgi-bin/koha/svc/recall',
+ type: 'POST',
+ dataType: 'json',
+ data: ajaxData,
+ })
+ .done(function(data) {
+ var message = "";
+ if(data.success == 0) {
+ message = _("The recall may have already been checked in. Please refresh the page.");
+ } else {
+ message = _("Completed");
+ }
+ $self.parent().parent().parent().parent().html(message);
+ });
+ }
+ });
+
+ $(".expire_recall").click(function(e){
+ if (confirmDelete(_("Are you sure you want to expire this recall?"))){
+ var $self = $(this);
+ var $recall_id = $(this).data('id');
+ var $action = $(this).data('action');
+ var ajaxData = {
+ 'recall_id': $recall_id,
+ 'action' : $action,
+ };
+
+ var $howmanyparents = $(this).data('parent');
+
+ $.ajax({
+ url: '/cgi-bin/koha/svc/recall',
+ type: 'POST',
+ dataType: 'json',
+ data: ajaxData,
+ })
+ .done(function(data) {
+ var message = "";
+ if(data.success == 0) {
+ message = _("The recall may have already been expired. Please refresh the page.");
+ } else {
+ message = _("Expired");
+ }
+ if ( $howmanyparents == "one" ){
+ $self.parent().html(message);
+ } else {
+ $self.parent().parent().parent().parent().html(message);
+ }
+ });
+ }
+ });
+
+ $(".revert_recall").click(function(e){
+ if (confirmDelete(_("Are you sure you want to revert the waiting status of this recall?"))){
+ var $self = $(this);
+ var $recall_id = $(this).data('id');
+ var $action = $(this).data('action');
+ var ajaxData = {
+ 'recall_id': $recall_id,
+ 'action' : $action,
+ };
+
+ var $howmanyparents = $(this).data('parent');
+
+ $.ajax({
+ url: '/cgi-bin/koha/svc/recall',
+ type: 'POST',
+ dataType: 'json',
+ data: ajaxData,
+ })
+ .done(function(data) {
+ var message = "";
+ if(data.success == 0) {
+ message = _("The recall waiting status may have already been reverted. Please refresh the page.");
+ } else {
+ message = _("Status updated");
+ }
+ if ( $howmanyparents == "one" ){
+ $self.parent().html(message);
+ } else {
+ $self.parent().parent().parent().parent().html(message);
+ }
+ });
+ }
+ });
+
+ $("#recalls-table").dataTable($.extend(true, {}, dataTablesDefaults, {
+ "aoColumnDefs": [
+ { 'bSortable': false, 'aTargets': [ 'nosort' ] },
+ { "sType": "title-string", "aTargets" : [ "title-string" ] },
+ { "sType": "anti-the", "aTargets": [ "anti-the" ] }
+ ],
+ "sPaginationType": "full_numbers"
+ }));
+
+ $("#cancel_selected").click(function(e){
+ if ($("input[name='recall_ids']:checked").length > 0){
+ return confirmDelete(_("Are you sure you want to remove the selected recall(s)?"));
+ } else {
+ alert(_("Please make a selection."));
+ }
+ });
+
+ $("#expire_selected").click(function(e){
+ if ($("input[name='recall_ids']:checked").length > 0){
+ return confirmDelete(_("Are you sure you want to expire the selected recall(s)?"));
+ } else {
+ alert(_("Please make a selection."));
+ }
+ });
+
+ $("#select_all").click(function(){
+ if ($("#select_all").prop("checked")){
+ $("input[name='recall_ids']").prop("checked", true);
+ } else {
+ $("input[name='recall_ids']").prop("checked", false);
+ }
+ });
+
+ $("#hide_old").click(function(){
+ if ($("#hide_old").prop("checked")){
+ $(".old").show();
+ } else {
+ $(".old").hide();
+ }
+ });
+});
--- a/members/moremember.pl
+++ a/members/moremember.pl
@@ -210,6 +210,8 @@ $template->param(
relatives_issues_count => $relatives_issues_count,
relatives_borrowernumbers => \@relatives,
logged_in_user => $logged_in_user,
+ recalls => $patron->recalls,
+ specific_patron => 1,
);
output_html_with_http_headers $input, $cookie, $template->output;
--- a/members/recallshistory.pl
+++ a/members/recallshistory.pl
@@ -0,0 +1,47 @@
+#!/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 C4::Auth;
+use C4::Output;
+
+my $input = CGI->new;
+my ($template, $loggedinuser, $cookie)= get_template_and_user(
+ {
+ template_name => "members/recallshistory.tt",
+ query => $input,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { recalls => 1 },
+ debug => 1,
+ }
+);
+
+my $borrowernumber = $input->param('borrowernumber');
+my $recalls = Koha::Recalls->search({ borrowernumber => $borrowernumber });
+my $patron = Koha::Patrons->find( $borrowernumber );
+
+$template->param(
+ patron => $patron,
+ recalls => $recalls,
+ recallsview => 1,
+ specific_patron => 1,
+);
+
+output_html_with_http_headers $input, $cookie, $template->output;
--- a/recalls/recalls_old_queue.pl
+++ a/recalls/recalls_old_queue.pl
@@ -0,0 +1,47 @@
+#!/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 C4::Auth;
+use C4::Output;
+use Koha::BiblioFrameworks;
+
+my $query = new CGI;
+my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
+ {
+ template_name => "recalls/recalls_old_queue.tt",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { recalls => "manage_recalls" },
+ debug => 1,
+ }
+);
+
+my $recalls = Koha::Recalls->search({ old => 1 });
+$template->param(
+ recalls => $recalls,
+ viewing_old => 1
+);
+
+# Checking if there is a Fast Cataloging Framework
+$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
+
+# writing the template
+output_html_with_http_headers $query, $cookie, $template->output;
--- a/recalls/recalls_overdue.pl
+++ a/recalls/recalls_overdue.pl
@@ -0,0 +1,61 @@
+#!/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 C4::Auth;
+use C4::Output;
+use Koha::BiblioFrameworks;
+use Koha::DateUtils;
+
+my $query = new CGI;
+my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
+ {
+ template_name => "recalls/recalls_overdue.tt",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { recalls => "manage_recalls" },
+ debug => 1,
+ }
+);
+
+my $op = $query->param('op') || 'list';
+my @recall_ids = $query->multi_param('recall_ids');
+
+if ( $op eq 'cancel_multiple_recalls' ) {
+ foreach my $id ( @recall_ids ) {
+ Koha::Recalls->find( $id )->set_cancelled;
+ }
+ $op = 'list'
+}
+
+if ( $op eq 'list' ) {
+ my $recalls = Koha::Recalls->search({ status => 'O' });
+ # will be set as Overdue by the misc/cronjobs/recall/overdue_recalls.pl cronjob
+ $template->param(
+ recalls => $recalls,
+ checkboxes => 1,
+ );
+}
+
+# Checking if there is a Fast Cataloging Framework
+$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
+
+# writing the template
+output_html_with_http_headers $query, $cookie, $template->output;
--- a/recalls/recalls_queue.pl
+++ a/recalls/recalls_queue.pl
@@ -0,0 +1,57 @@
+#!/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 C4::Auth;
+use C4::Output;
+use Koha::BiblioFrameworks;
+
+my $query = new CGI;
+my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
+ {
+ template_name => "recalls/recalls_queue.tt",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { recalls => 'manage_recalls' },
+ debug => 1,
+ }
+);
+
+my $op = $query->param('op') || 'list';
+my @recall_ids = $query->multi_param('recall_ids');
+if ( $op eq 'cancel_multiple_recalls' ) {
+ foreach my $id ( @recall_ids ) {
+ Koha::Recalls->find( $id )->set_cancelled;
+ }
+ $op = 'list'
+}
+elsif ( $op eq 'list' ) {
+ my $recalls = Koha::Recalls->search({ old => undef });
+ $template->param(
+ recalls => $recalls,
+ checkboxes => 1,
+ );
+}
+
+# Checking if there is a Fast Cataloging Framework
+$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
+
+# writing the template
+output_html_with_http_headers $query, $cookie, $template->output;
--- a/recalls/recalls_to_pull.pl
+++ a/recalls/recalls_to_pull.pl
@@ -0,0 +1,95 @@
+#!/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 C4::Auth;
+use C4::Output;
+use Koha::BiblioFrameworks;
+
+my $query = new CGI;
+my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
+ {
+ template_name => "recalls/recalls_to_pull.tt",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { recalls => 'manage_recalls' },
+ debug => 1,
+ }
+);
+
+my $op = $query->param('op') || 'list';
+my $recall_id = $query->param('recall_id');
+if ( $op eq 'cancel' ) {
+ Koha::Recalls->find( $recall_id )->set_cancelled;
+ $op = 'list';
+}
+elsif ( $op eq 'list' ) {
+ my @recalls = Koha::Recalls->search({ status => [ 'R','O' ] });
+ my @pull_list;
+ foreach my $recall ( @recalls ) {
+ my @items = Koha::Items->search({ biblionumber => $recall->biblionumber });
+ my $distinct_recalls = Koha::Recalls->search({ biblionumber => $recall->biblionumber, status => [ 'R','O' ] }, { columns => [ 'borrowernumber' ], distinct => 1, order_by => { -asc => 'recalldate' } });
+ my $recalls_count = $distinct_recalls->count;
+ my $first_recall = $distinct_recalls->next;
+ my $items_count;
+ my @callnumbers;
+ my @copynumbers;
+ my @enumchrons;
+ my @itemtypes;
+ my @locations;
+ my @libraries;
+ foreach my $item ( @items ) {
+ if ( $item->can_be_waiting_recall ) {
+ $items_count++;
+ push( @callnumbers, $item->itemcallnumber );
+ push( @copynumbers, $item->copynumber );
+ push( @enumchrons, $item->enumchron );
+ push( @itemtypes, $item->effective_itemtype );
+ push( @locations, $item->location );
+ push( @libraries, $item->holdingbranch );
+ }
+ }
+ push( @pull_list, {
+ recall => $recall,
+ biblio => $recall->biblio,
+ items_count => $items_count,
+ recalls_count => $recalls_count,
+ pull_count => $items_count <= $recalls_count ? $items_count : $recalls_count,
+ first_patron => $first_recall->patron,
+ first_date => $first_recall->recalldate,
+ first_library => $first_recall->library,
+ callnumbers => @callnumbers,
+ copynumbers => @copynumbers,
+ enumchrons => @enumchrons,
+ itemtypes => @itemtypes,
+ locations => @locations,
+ libraries => @libraries,
+ });
+ }
+ $template->param(
+ recalls => \@pull_list,
+ );
+}
+
+# Checking if there is a Fast Cataloging Framework
+$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
+
+# writing the template
+output_html_with_http_headers $query, $cookie, $template->output;
--- a/recalls/recalls_waiting.pl
+++ a/recalls/recalls_waiting.pl
@@ -0,0 +1,76 @@
+#!/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 C4::Auth;
+use C4::Output;
+use Koha::Recalls;
+use Koha::BiblioFrameworks;
+use Koha::DateUtils;
+use Koha::Patrons;
+
+my $query = new CGI;
+my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
+ {
+ template_name => "recalls/recalls_waiting.tt",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { recalls => "manage_recalls" },
+ debug => 1,
+ }
+);
+
+my $op = $query->param('op') || 'list';
+
+if ( $op eq 'modify' ) {
+ my $expire = $query->param('expire');
+ my $revert = $query->param('revert');
+ my $recall_id = $query->param('recall_id');
+ if ( $expire ) {
+ Koha::Recalls->find( $recall_id )->set_expired({ interface => 'INTRANET' });
+ } elsif ( $revert ) {
+ Koha::Recalls->find( $recall_id )->revert_waiting;
+ }
+ $op = 'list';
+}
+
+elsif ( $op eq 'list' ) {
+ my @recalls = Koha::Recalls->search({ status => 'W' });
+ my $borrower = Koha::Patrons->find( $loggedinuser );
+ my @over;
+ my $maxdelay = C4::Context->preference('RecallsMaxPickUpDelay') || 7;
+ my $today = dt_from_string();
+ foreach my $r ( @recalls ){
+ my $lastwaitingday = dt_from_string( $r->waitingdate )->add( days => $maxdelay );
+ if ( $today > $lastwaitingday ){
+ push @over, $r;
+ }
+ }
+ $template->param(
+ recalls => \@recalls,
+ over => \@over,
+ );
+}
+
+# Checking if there is a Fast Cataloging Framework
+$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
+
+# writing the template
+output_html_with_http_headers $query, $cookie, $template->output;
--- a/recalls/request.pl
+++ a/recalls/request.pl
@@ -0,0 +1,63 @@
+#!/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 C4::Auth;
+use C4::Output;
+use C4::Search;
+use Koha::Recalls;
+use Koha::Biblios;
+
+my $input = CGI->new;
+my ($template, $loggedinuser, $cookie)= get_template_and_user(
+ {
+ template_name => "recalls/request.tt",
+ query => $input,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { recalls => "manage_recalls" },
+ debug => 1,
+ }
+);
+
+my $op = $input->param('op') || 'list';
+my @recall_ids = $input->multi_param('recall_ids');
+my $biblionumber = $input->param('biblionumber');
+my $recalls = Koha::Recalls->search({ biblionumber => $biblionumber, old => undef });
+my $biblio = Koha::Biblios->find( $biblionumber );
+
+if ( $op eq 'cancel_multiple_recalls' ) {
+ foreach my $id ( @recall_ids ) {
+ Koha::Recalls->find( $id )->set_cancelled;
+ }
+ $op = 'list'
+} else {
+ $recalls = Koha::Recalls->search({ biblionumber => $biblionumber, old => undef });
+ $biblio = Koha::Biblios->find( $biblionumber );
+}
+
+$template->param(
+ recalls => $recalls,
+ recallsview => 1,
+ biblio => $biblio,
+ checkboxes => 1,
+ C4::Search::enabled_staff_search_views,
+);
+
+output_html_with_http_headers $input, $cookie, $template->output;
--- a/reserve/request.pl
+++ a/reserve/request.pl
@@ -314,6 +314,10 @@ foreach my $biblionumber (@biblionumbers) {
$template->param( $canReserve->{status} => 1 );
$biblioloopiter{ $canReserve->{status} } = 1;
}
+ elsif ( $canReserve->{status} eq 'recall' ) {
+ $template->param( $canReserve->status} } = 1 );
+ $biblioloopiter{ $canReserve->{status} } = 1;
+ }
else {
$biblioloopiter{ $canReserve->{status} } = 1;
}
--- a/svc/recall
+++ a/svc/recall
@@ -0,0 +1,96 @@
+#!/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, 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(encode_json);
+
+use C4::Context;
+use C4::Auth qw(check_cookie_auth);
+use C4::Output qw(output_with_http_headers);
+use C4::Circulation qw(AddReturn);
+use Koha::Recalls;
+
+my $input = new CGI;
+
+my ( $auth_status, $sessionID ) = check_cookie_auth( $input->cookie('CGISESSID'), { recall => 'manage_recalls' } );
+
+if ( $auth_status ne "ok" ) {
+ print $input->header(-type => 'text/plain', -status => '403 Forbidden');
+ exit 0;
+}
+
+my $recall_id = $input->param('recall_id');
+my $recall = Koha::Recalls->find( $recall_id );
+unless ( $recall ) {
+ my $json = encode_json({ success => 0 });
+ output_with_http_headers( $input, undef, $json, "json" );
+ exit;
+}
+
+my $op = $input->param('action');
+
+if ( $op eq 'cancel' ) {
+ # cancel recall
+ $recall->set_cancelled;
+} elsif ( $op eq 'checkin' ) {
+ # check in recall and set to waiting
+ my $branch = $input->param('branchcode');
+ my $item;
+ if ( $recall->item_level_recall ) {
+ $item = $recall->item;
+ } elsif ( $recall->checkout ) {
+ # biblio-level recall with a relevant item that is still checked out to another borrower
+ $item = $recall->checkout->item;
+ } else {
+ # biblio-level recall with no items checked out, so take the first available and recallable item
+ my @items = Koha::Items->search({ biblionumber => $recall->biblionumber });
+ foreach ( @items ) {
+ if ( $_->can_be_waiting_recall ){
+ $item = $_;
+ last;
+ }
+ }
+ }
+
+ my $barcode = $item->barcode;
+
+ my ( $result, $messages ) = AddReturn( $barcode, $branch );
+
+ foreach my $code ( %$messages ) {
+ if ( $code eq 'RecallFound' ) {
+ my $expirationdate = $recall->calc_expirationdate;
+ if ( $recall->item_level_recall ) {
+ $recall->set_waiting({ expirationdate => $expirationdate });
+ } else {
+ $recall->set_waiting({ expirationdate => $expirationdate, item => $item });
+ }
+ }
+ }
+} elsif ( $op eq 'expire' ) {
+ # expire recall
+ $recall->set_expired({ interface => 'INTRANET' });
+} elsif ( $op eq 'revert' ) {
+ # revert recall waiting status
+ $recall->revert_waiting;
+}
+
+my $json = encode_json({ success => 1 });
+output_with_http_headers( $input, undef, $json, "json" );
--- a/tools/letter.pl
+++ a/tools/letter.pl
@@ -248,7 +248,7 @@ sub add_form {
{value => 'items.fine', text => 'items.fine'},
add_fields('borrowers');
if ($module eq 'circulation') {
- push @{$field_selection}, add_fields('opac_news');
+ push @{$field_selection}, add_fields('opac_news', 'recalls');
}
--