From d1339cae547101c26296c06a0dfca48bbbdee4af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9rick?= Date: Fri, 26 Apr 2013 17:44:12 -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 | 10 +++ .../en/modules/admin/preferences/circulation.pref | 6 ++ .../prog/en/modules/catalogue/detail.tt | 41 +++++++++++++ 7 files changed, 128 insertions(+), 0 deletions(-) create mode 100755 circ/send_recall_notice.pl diff --git a/catalogue/detail.pl b/catalogue/detail.pl index a5b32c6..7216cd0 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -90,6 +90,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; @@ -176,6 +177,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); @@ -191,6 +193,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 ) ); @@ -349,6 +353,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 100755 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 2d09971..533055c 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<>'), ('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<>'), ('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<>'), +('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<>'); 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 5d536c5..265a18b 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -422,4 +422,5 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('TimeFormat','24hr','12hr|24hr','Defines the global time format for visual output.','Choice'); INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('DisplayIconsXSLT', '1', '', 'If ON, displays the format, audience, and material type icons in XSLT MARC21 results and detail pages.', 'YesNo'); INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPAC','0','','If on, and a patron is logged into the OPAC, items from his or her home library will be emphasized and shown first in search results and item details.','YesNo'); +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'); INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPACWhich','PatronBranch','PatronBranch|OpacURLBranch','Decides which branch''s items to emphasize. If PatronBranch, emphasize the logged in user''s library''s items. If OpacURLBranch, highlight the items of the Apache var BRANCHCODE defined in Koha''s Apache configuration file.','Choice') diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 7c97a51..9aeb4cc 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6771,6 +6771,16 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = 'XXX'; +if (C4::Context->preference("Version") < TransformToNum($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 ( Add the 'RECALL' letter )\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS 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 f88d964..50090e0 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 @@ -123,6 +123,12 @@ Circulation: - The following fields should be excluded from the patron checkout history CSV or iso2709 export - pref: ExportRemoveFields - (separate fields with space, e.g. 100a 200b 300c) + - + - 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 8f40e31..fec901b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -43,6 +43,44 @@ 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); + } + }); +} + //]]> @@ -401,6 +439,9 @@ function verify_images() { [% END %] : due [% item.datedue %] + [% IF ( ShowRecallButton ) %] + + [% END %] [% ELSIF ( item.transfertwhen ) %] In transit from [% item.transfertfrom %], -- 1.7.2.5