@@ -, +, @@ page. --- 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 --- a/catalogue/detail.pl +++ a/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, --- a/circ/send_recall_notice.pl +++ a/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"; +} --- a/installer/data/mysql/en/mandatory/sample_notices.sql +++ a/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', '

<>

--- a/installer/data/mysql/sysprefs.sql +++ a/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'), --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -10025,6 +10025,16 @@ 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); +} + # DEVELOPER PROCESS, search for anything to execute in the db_update directory # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. @@ -10038,6 +10048,7 @@ while ( my $file = readdir $dirh ) { my $rv = $installer->load_sql( $update_dir . $file ) ? 0 : 1; } + =head1 FUNCTIONS =head2 TableExists($table) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ a/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: - --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -195,6 +195,43 @@ function verify_images() { [% IF ( AmazonCoverImages || LocalCoverImages ) %]$(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); + } + }); + } + //]]> @@ -648,6 +685,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 %] --