From f48039cf41bc635a209d65e8ab9a1c52a94ee3a8 Mon Sep 17 00:00:00 2001 From: charles Date: Mon, 9 Mar 2015 10:02:32 -0400 Subject: [PATCH] Bug 8688 - Add a Recall button to the biblio record details page. This patch is a fusion of all previous patches for this feature, in addition to a system preference to control the appearance of the "Recall" button. --- catalogue/detail.pl | 5 ++ circ/send_recall_notice.pl | 64 ++++++++++++++++++++++ .../data/mysql/en/mandatory/sample_notices.sql | 1 + installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 11 ++++ .../en/modules/admin/preferences/circulation.pref | 6 ++ .../prog/en/modules/catalogue/detail.tt | 40 ++++++++++++++ 7 files changed, 128 insertions(+) create mode 100644 circ/send_recall_notice.pl diff --git a/catalogue/detail.pl b/catalogue/detail.pl index adf6823..a7e7bcc 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -91,6 +91,7 @@ if (C4::Context->preference("XSLTDetailsDisplay") ) { } $template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") ); +$template->param( 'ShowRecallButton' => C4::Context->preference("ShowRecallButton") ); $template->param( ocoins => GetCOinSBiblio($record) ); # some useful variables for enhanced content; @@ -186,6 +187,7 @@ my $shelflocations = GetKohaAuthorisedValues('items.location', $fw); my $collections = GetKohaAuthorisedValues('items.ccode' , $fw); my $copynumbers = GetKohaAuthorisedValues('items.copynumber', $fw); my (@itemloop, @otheritemloop, %itemfields); +my $items_checked_out = 0; my $norequests = 1; my $authvalcode_items_itemlost = GetAuthValCode('items.itemlost',$fw); my $authvalcode_items_damaged = GetAuthValCode('items.damaged', $fw); @@ -201,6 +203,8 @@ foreach my $item (@items) { my $itembranchcode = $item->{$separatebranch}; $item->{homebranch} = GetBranchName($item->{homebranch}); + $items_checked_out++ if $item->{'onloan'}; + # can place holds defaults to yes $norequests = 0 unless ( ( $item->{'notforloan'} > 0 ) || ( $item->{'itemnotforloan'} > 0 ) ); @@ -359,6 +363,7 @@ foreach ( keys %{$dat} ) { $template->param( AmazonTld => get_amazon_tld() ) if ( C4::Context->preference("AmazonCoverImages")); $template->param( itemloop => \@itemloop, + items_checked_out => $items_checked_out, otheritemloop => \@otheritemloop, biblionumber => $biblionumber, ($analyze? 'analyze':'detailview') =>1, diff --git a/circ/send_recall_notice.pl b/circ/send_recall_notice.pl new file mode 100644 index 0000000..bbc6e73 --- /dev/null +++ b/circ/send_recall_notice.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl + +# Author : Frédérick Capovilla, 2011 - SYS-TECH +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use strict; +use warnings; + +use C4::Message; +use C4::Circulation; +use C4::Items; +use C4::Auth; +use CGI; +use CGI::Cookie; + +my $input = new CGI; +my $itemnumber = $input->param('itemnumber'); + +# Check the user's permissions +my %cookies = fetch CGI::Cookie; +my $sessid = $cookies{'CGISESSID'}->value || $input->param('CGISESSID'); +my ($auth_status, $auth_sessid) = C4::Auth::check_cookie_auth($sessid, {circulate => 'circulate_remaining_permissions'}); +if ($auth_status ne "ok") { + print $input->header; + print "UNAUTHORIZED"; + exit 0; +} + +# Generate the message + +my $borrower = C4::Circulation::GetItemIssue($itemnumber); +my $item = C4::Items::GetItem($itemnumber); + +my $letter = C4::Letters::GetPreparedLetter( + 'module' => 'circulation', + 'letter_code' => 'RECALL', + 'tables' => { + 'biblio' => $item->{biblionumber}, + 'biblioitems' => $item->{biblionumber}, + 'items' => $itemnumber, + 'borrowers' => $borrower->{borrowernumber}, + 'branches' => $item->{homebranch}, + }, +); + +# Try to add the message to the message queue. +if( C4::Letters::EnqueueLetter({letter => $letter, borrowernumber => $borrower->{borrowernumber}, message_transport_type => 'email'}) ) { + print $input->header; + print "SUCCESS"; +} diff --git a/installer/data/mysql/en/mandatory/sample_notices.sql b/installer/data/mysql/en/mandatory/sample_notices.sql index 2281739..c9a44d1 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.sql +++ b/installer/data/mysql/en/mandatory/sample_notices.sql @@ -16,6 +16,7 @@ VALUES ('circulation','ODUE','Overdue Notice','Item Overdue','Dear <> <>,\n\nYou have suggested that the library acquire <> by <>.\n\nThe library has reviewed your suggestion today. The item will be ordered as soon as possible. You will be notified by mail when the order is completed, and again when the item arrives at the library.\n\nIf you have any questions, please email us at <>.\n\nThank you,\n\n<>', 'email'), ('suggestions','AVAILABLE','Suggestion available', 'Suggested purchase available','Dear <> <>,\n\nYou have suggested that the library acquire <> by <>.\n\nWe are pleased to inform you that the item you requested is now part of the collection.\n\nIf you have any questions, please email us at <>.\n\nThank you,\n\n<>', 'email'), ('suggestions','ORDERED','Suggestion ordered', 'Suggested item ordered','Dear <> <>,\n\nYou have suggested that the library acquire <> by <>.\n\nWe are pleased to inform you that the item you requested has now been ordered. It should arrive soon, at which time it will be processed for addition into the collection.\n\nYou will be notified again when the book is available.\n\nIf you have any questions, please email us at <>\n\nThank you,\n\n<>', 'email'), +('circulation','RECALL','Item recall','Item recall','Dear <> <>,\r\n\r\nA recall was made on an item in your possession. Please return the item to the library as soon as possible.\r\n\r\n<>\r\n<>\r\n<> <>\r\nPhone: <>\r\nFax: <>\r\nEmail: <>\r\n\r\nThe following item must be returned to the library as soon as possible :\r\n\r\n\"<>\" by <>, <>, Barcode: <>\r\n\r\nThank you.\r\n\r\n<> \r\n'), ('suggestions','REJECTED','Suggestion rejected', 'Purchase suggestion declined','Dear <> <>,\n\nYou have suggested that the library acquire <> by <>.\n\nThe library has reviewed your request today, and has decided not to accept the suggestion at this time.\n\nThe reason given is: <>\n\nIf you have any questions, please email us at <>.\n\nThank you,\n\n<>', 'email'); INSERT INTO `letter` (module, code, name, title, content, is_html) VALUES ('circulation','ISSUESLIP','Issue Slip','Issue Slip', '

<>

diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 9020b4b..dfb0229 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -378,6 +378,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('ShelfBrowserUsesHomeBranch','1','1','Use the item home branch when finding items for the shelf browser.','YesNo'), ('ShelfBrowserUsesLocation','1','1','Use the item location when finding items for the shelf browser.','YesNo'), ('ShowPatronImageInWebBasedSelfCheck','0','','If ON, displays patron image when a patron uses web-based self-checkout','YesNo'), +('ShowRecallButton','0','','If on, show a button to recall a checked out item in the holdings list of the biblio record details page.','YesNo'), ('ShowReviewer','full','none|full|first|surname|firstandinitial|username','Choose how a commenter\'s identity is presented alongside comments in the OPAC','Choice'), ('ShowReviewerPhoto','1','','If ON, photo of reviewer will be shown beside comments in OPAC','YesNo'), ('singleBranchMode','0',NULL,'Operate in Single-branch mode, hide branch selection in the OPAC','YesNo'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index bd39629..667bffc 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -9804,6 +9804,17 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = 'XXX'; +if ( CheckVersion($DBversion) ) { + $dbh->do("INSERT INTO `letter` (`module`, `code`, `name`, `title`, `content`) VALUES +('circulation','RECALL','Item recall','Item recall','Dear <> <>,\r\n\r\nA recall was made on an item in your possession. Please return the item to the library as soon as possible.\r\n\r\n<>\r\n<>\r\n<> <>\r\nPhone: <>\r\nFax: <>\r\nEmail: <>\r\n\r\nThe following item must be returned to the library as soon as possible :\r\n\r\n\"<>\" by <>, <>, Barcode: <>\r\n\r\nThank you.\r\n\r\n<> \r\n'); +"); + $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ShowRecallButton','0','','If on, show a button to recall a checked out item in the holdings list of the biblio record details page.','YesNo')"); + print "Upgrade to $DBversion done (Bug 8688: Add the 'RECALL' letter)\n"; + SetVersion ($DBversion); +} + + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index a296bf6..24b32dd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -136,6 +136,12 @@ Circulation: yes: Enable no: "Do not enable" - "offline circulation on regular circulation computers. (NOTE: This system preference does not affect the Firefox plugin or the desktop application)" + - + - pref: ShowRecallButton + choices: + yes: Show + no: "Don't show" + - a button to recall a checked out item in the holdings list of the biblio record details page. Checkout Policy: - diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index ee5915e..2ebafd0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -189,6 +189,43 @@ function verify_images() { [% IF ( AmazonCoverImages ) %]$(window).load(function() { verify_images(); });[% END %] + + //AJAX call to send a recall notice to the user who currently has the item. + function recall_item(itemnumber) { + var button = $("#recall_"+itemnumber); + + if(!confirm(_('A request for the immediate return of the item will be sent to the user who currently has it in its possession.\n\nAre you sure you want to send a recall notice?'))) { + return; + } + + //Disable the button to prevent spamming + button.attr("disabled",true); + + $.ajax({ + url: '/cgi-bin/koha/circ/send_recall_notice.pl', + type: 'POST', + dataType: 'text', + data: {itemnumber: itemnumber}, + success: function(msg){ + if(msg == "SUCCESS") { + button.attr("value",_("Recall sent")); + } + else if(msg == "UNAUTHORIZED") { + alert(_("Failed to send the recall notice:")+"\n"+_("You do not have the required permissions to do this action.")+" (circulate_remaining_permissions)"); + button.attr("disabled",false); + } + else { + alert(_("Failed to send the recall notice:")+"\n"+msg); + button.attr("disabled",false); + } + }, + error: function(request,status){ + alert(_("Failed to send the recall notice:")+"\n"+status); + button.attr("disabled",false); + } + }); + } + //]]> @@ -612,6 +649,9 @@ function verify_images() { [% END %] : due [% item.datedue %] + [% IF ( ShowRecallButton ) %] + + [% END %] [% ELSIF ( item.transfertwhen ) %] In transit from [% item.transfertfrom %] to [% item.transfertto %] since [% item.transfertwhen %] -- 1.9.1