Bug 8004 - Items on Hold Lose Transfer After Being Scanned Twice
authorKyle M Hall <kyle@bywatersolutions.com>
Tue, 24 Apr 2012 15:43:40 +0000 (11:43 -0400)
committerPaul Poulain <paul.poulain@biblibre.com>
Mon, 11 Jun 2012 13:53:57 +0000 (15:53 +0200)
When a hold is placed on an item where the pickup location is
different than the holding library, Koha initiates a branch
transfer for that item to fill that hold when items is run through
the returns system.

If the item is then run through returns a second time, the system is
supposed to close that transfer as a 'wrongtransfer', and open a new
transfer with the same from and to branches as the original.

The problem is that the original transfer is closed, but the new
transfer is not created. This is because at some point, someone
replaced the template variable WrongTransfer, which had previously
contained the branchcode for the library to transfer to, with the
full name of the library instead ( I assume to make a look nicer ).

Solved by removing the line that was changing the variable contents
from the branchcode to the branch name, and adding a new TT filter,
KohaBranchName that functions in the same way as KohaDates, except
it takes a branchcode and returns the branch name for the given
branchcode.

The consequence of this, is the the name of the library is passed to updateWrongTransfer instead of the branchcode, causing the failure.

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Koha/Template/Plugin/KohaBranchName.pm [new file with mode: 0644]
circ/returns.pl
koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt

diff --git a/Koha/Template/Plugin/KohaBranchName.pm b/Koha/Template/Plugin/KohaBranchName.pm
new file mode 100644 (file)
index 0000000..a39aba0
--- /dev/null
@@ -0,0 +1,35 @@
+package Koha::Template::Plugin::KohaBranchName;
+
+# Copyright Bywater Solutions 2012
+
+# 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 Template::Plugin::Filter;
+use base qw( Template::Plugin::Filter );
+use warnings;
+use strict;
+
+use C4::Branch qw( GetBranchName );;
+
+sub filter {
+    my ($self,$branchcode) = @_;
+    return GetBranchName( $branchcode );
+}
+
+1;
index bd60d42..38e9887 100755 (executable)
@@ -337,7 +337,6 @@ if ( $messages->{'Wrongbranch'} ){
 # case of wrong transfert, if the document wasn't transfered to the right library (according to branchtransfer (tobranch) BDD)
 
 if ( $messages->{'WrongTransfer'} and not $messages->{'WasTransfered'}) {
-    $messages->{'WrongTransfer'} = GetBranchName( $messages->{'WrongTransfer'} );
     $template->param(
         WrongTransfer  => 1,
         TransferWaitingAt => $messages->{'WrongTransfer'},
index 835724f..1ed01f0 100644 (file)
@@ -1,4 +1,6 @@
 [% USE KohaDates %]
+[% USE KohaBranchName %]
+
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Circulation &rsaquo; Check in [% title |html %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
@@ -91,7 +93,7 @@ $(document).ready(function () {
 </div>
 [% END %]
 <!-- case of a mistake in transfer loop -->
-[% IF ( WrongTransfer ) %]<div id="return2" class="dialog message"><!-- WrongTransfer --><h3>Please return <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&amp;biblionumber=[% itembiblionumber %]">[% title |html %]</a> to [% TransferWaitingAt %]</h3><h3><a href="#" onclick="Dopop('transfer-slip.pl?transferitem=[% itemnumber %]&amp;&amp;branchcode=[% homebranch %]&amp;op=slip'); return true;">Print slip</a> or <a href="/cgi-bin/koha/circ/returns.pl?itemnumber=[% itemnumber %]&amp;canceltransfer=1">Cancel transfer</a></h3>
+[% IF ( WrongTransfer ) %]<div id="return2" class="dialog message"><!-- WrongTransfer --><h3>Please return <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&amp;biblionumber=[% itembiblionumber %]">[% title |html %]</a> to [% TransferWaitingAt | $KohaBranchName %]</h3><h3><a href="#" onclick="Dopop('transfer-slip.pl?transferitem=[% itemnumber %]&amp;&amp;branchcode=[% homebranch %]&amp;op=slip'); return true;">Print slip</a> or <a href="/cgi-bin/koha/circ/returns.pl?itemnumber=[% itemnumber %]&amp;canceltransfer=1">Cancel transfer</a></h3>
 [% IF ( wborcnum ) %]<h5>Hold for:</h5>
         <ul><li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">
             [% borsurname %], [% borfirstname %]</a> ([% borcnum %])</li>