@@ -, +, @@ --- catalogue/detail.pl | 4 + circ/send_recall_notice.pl | 65 ++++++++++++++++++++ .../prog/en/modules/catalogue/detail.tt | 47 ++++++++++++++ 3 files changed, 116 insertions(+), 0 deletions(-) create mode 100644 circ/send_recall_notice.pl --- a/catalogue/detail.pl +++ a/catalogue/detail.pl @@ -174,6 +174,7 @@ my $shelflocations = GetKohaAuthorisedValues('items.location', $fw); my $collections = GetKohaAuthorisedValues('items.ccode' , $fw); my $copynumbers = GetKohaAuthorisedValues('items.copynumber', $fw); my (@itemloop, %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); @@ -184,6 +185,8 @@ foreach my $item (@items) { $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 ) ); @@ -328,6 +331,7 @@ foreach ( keys %{$dat} ) { $template->param( itemloop => \@itemloop, + items_checked_out => $items_checked_out, biblionumber => $biblionumber, ($analyze? 'analyze':'detailview') =>1, subscriptions => \@subs, --- a/circ/send_recall_notice.pl +++ a/circ/send_recall_notice.pl @@ -0,0 +1,65 @@ +#!/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_remaining_permissions" => '1'}); +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/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -42,6 +42,44 @@ function verify_images() { [% IF ( AmazonEnabled ) %]$(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); + } + }); +} + //]]> @@ -285,6 +323,7 @@ function verify_images() { [% IF ( SpineLabelShowPrintOnBibDetails ) %]Spine label[% END %] [% IF ( hostrecords ) %]Host records[% END %] [% IF ( analyze ) %]Used in[% END %] + [% IF ( items_checked_out ) %]Recall[% END %] [% FOREACH itemloo IN itemloop %] @@ -421,6 +460,14 @@ function verify_images() { Create analytics [% END %] + [% IF ( items_checked_out ) %] + + [% IF ( itemloo.onloan ) %] + + [% END %] + + [% END %] + [% END %] --