Bugzilla – Attachment 8768 Details for
Bug 7255
Information on Holds Transfer Slips is Inconsistent
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7255 - Information on Holds Transfer Slips is Inconsistent
Bug-7255---Information-on-Holds-Transfer-Slips-is-.patch (text/plain), 14.31 KB, created by
Kyle M Hall
on 2012-04-02 12:51:32 UTC
(
hide
)
Description:
Bug 7255 - Information on Holds Transfer Slips is Inconsistent
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2012-04-02 12:51:32 UTC
Size:
14.31 KB
patch
obsolete
>From 0e1876eb61ac453bc4b4d66d97bd34e9108e0577 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 2 Apr 2012 08:41:29 -0400 >Subject: [PATCH] Bug 7255 - Information on Holds Transfer Slips is Inconsistent > >We've discovered that they've got a race condition in the code. >When you click "confirm and print slip", you're both submitting >the form that confirms the hold, as well as opening the transfer >slip page. If this is a title-level hold originally, the item >information (barcode and callnumber) isn't filled in until the >form you've submitted completes it's action. So, depending on >all kinds of server-level variables, the transfer slip process >will either complete first, and not show item information, or >complete second, and include barcode/callnumber. There is no >way to tell which process will win the race ahead of time. > >This commit adds a new 'tool' to allow any popup to be loaded >with a delay. A new javascript function has been added to allow >this script to be used easily. Use the function as follows: >delayPopup( url, message, delay ) where url is the url of the >page to load ( supports GET variables ), message is an optional >message to display, and delay is the amount of time in seconds >to delay the loading of this new url. > >This tools is put into use in returns.tt to delay those slips >that have a race condition. >--- > koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js | 10 ++- > .../intranet-tmpl/prog/en/modules/circ/returns.tt | 21 +++-- > .../prog/en/modules/tools/delay-load.tt | 36 +++++++++ > tools/delay-load.pl | 83 ++++++++++++++++++++ > 4 files changed, 140 insertions(+), 10 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/tools/delay-load.tt > create mode 100755 tools/delay-load.pl > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js >index 24b785d..06986ee 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js >@@ -101,4 +101,12 @@ jQuery.fn.preventDoubleFormSubmit = function() { > else > this.beenSubmitted = true; > }); >-}; >\ No newline at end of file >+}; >+ >+function delayPopup( link, title, delay ) { >+ link = "/cgi-bin/koha/tools/delay-load.pl?url=" + escape( link ) + "&message=" + encodeURI( title ) + "&delay=" + delay; >+ alert( link ); >+ var childWindow = window.open(link,'popup','width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top'); >+ return childWindow; >+} >+ >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >index c51fed1..989734d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >@@ -4,9 +4,12 @@ > [% INCLUDE 'doc-head-close.inc' %] > <script type="text/javascript"> > //<![CDATA[ >-function Dopop(link) { >+function doPopUp(link) { > var newin=window.open(link,'popup','width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top'); > } >+function doDelayedPopUp( link ) { >+ var newin = delayPopup( link, "Loading Slip", 5 ); >+} > $(document).ready(function() { > $("#exemptcheck").change(function(){ > if(this.checked == true) { >@@ -87,7 +90,7 @@ function Dopop(link) { > </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&biblionumber=[% itembiblionumber %]">[% title |html %]</a> to [% TransferWaitingAt %]</h3><h3><a href="#" onclick="Dopop('transfer-slip.pl?transferitem=[% itemnumber %]&&branchcode=[% homebranch %]&op=slip'); return true;">Print Slip</a> or <a href="/cgi-bin/koha/circ/returns.pl?itemnumber=[% itemnumber %]&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&biblionumber=[% itembiblionumber %]">[% title |html %]</a> to [% TransferWaitingAt %]</h3><h3><a href="#" onclick="doPopUp('/cgi-bin/koha/circ/transfer-slip.pl?transferitem=[% itemnumber %]&&branchcode=[% homebranch %]&op=slip'); return true;">Print Slip</a> or <a href="/cgi-bin/koha/circ/returns.pl?itemnumber=[% itemnumber %]&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> >@@ -103,7 +106,7 @@ function Dopop(link) { > <input type="hidden" name="WT-waitingAt" value="[% TransferWaitingAt %]" /> > <input type="hidden" name="WT-From" value="[% wtransfertFrom %]" /> > <input type="submit" class="approve" value="Confirm" /> >- <input type="submit" value="Print Slip and Confirm" class="print" onclick="Dopop('hold-transfer-slip.pl?transfer=1&borrowernumber=[% borrowernumber %]&biblionumber=[% itembiblionumber %]&op=slip'); this.form.submit();" /> >+ <input type="submit" value="Print Slip and Confirm" class="print" onclick="doDelayedPopUp('/cgi-bin/koha/circ/hold-transfer-slip.pl?transfer=1&borrowernumber=[% borrowernumber %]&biblionumber=[% itembiblionumber %]&op=slip'); this.form.submit();" /> > </form> > [% END %]</div> > [% END %] >@@ -139,7 +142,7 @@ function Dopop(link) { > <form method="post" action="returns.pl" class="confirm"> > <input type="submit" class="approve" value="Confirm" /> > >- <input type="submit" value="Print and Confirm" class="print" onclick="Dopop('hold-transfer-slip.pl?borrowernumber=[% borrowernumber %]&biblionumber=[% itembiblionumber %]&op=slip'); this.form.submit();" /> >+ <input type="submit" value="Print and Confirm" class="print" onclick="doDelayedPopUp('/cgi-bin/koha/circ/hold-transfer-slip.pl?borrowernumber=[% borrowernumber %]&biblionumber=[% itembiblionumber %]&op=slip'); this.form.submit();" /> > [% FOREACH inputloo IN inputloop %] > <input type="hidden" name="ri-[% inputloo.counter %]" value="[% inputloo.barcode %]" /> > <input type="hidden" name="dd-[% inputloo.counter %]" value="[% inputloo.duedate %]" /> >@@ -181,7 +184,7 @@ function Dopop(link) { > > <form method="post" action="returns.pl" class="confirm"> > <input type="submit" class="approve" value="Confirm" /> >- <input type="submit" value="Print Slip and Confirm" class="print" onclick="Dopop('hold-transfer-slip.pl?transfer=1&borrowernumber=[% borrowernumber %]&biblionumber=[% itembiblionumber %]&op=slip'); this.form.submit();" /> >+ <input type="submit" value="Print Slip and Confirm" class="print" onclick="doDelayedPopUp('/cgi-bin/koha/circ/hold-transfer-slip.pl?transfer=1&borrowernumber=[% borrowernumber %]&biblionumber=[% itembiblionumber %]&op=slip'); this.form.submit();" /> > [% FOREACH inputloo IN inputloop %] > <input type="hidden" name="ri-[% inputloo.counter %]" value="[% inputloo.barcode %]" /> > <input type="hidden" name="dd-[% inputloo.counter %]" value="[% inputloo.duedate %]" /> >@@ -198,7 +201,7 @@ function Dopop(link) { > [% IF ( transfer ) %] > <!-- transfer: item with no reservation, must be returned to its home library --> > <div id="return1" class="dialog message"> >- <h3>Please return <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&biblionumber=[% itembiblionumber %]">[% title or "item" |html %]</a> to [% homebranchname %]<br/>( <a href="#" onclick="Dopop('transfer-slip.pl?transferitem=[% itemnumber %]&branchcode=[% homebranch %]&op=slip'); return true;">Print Slip</a> )</h3> >+ <h3>Please return <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&biblionumber=[% itembiblionumber %]">[% title or "item" |html %]</a> to [% homebranchname %]<br/>( <a href="#" onclick="doPopUp('/cgi-bin/koha/circ/transfer-slip.pl?transferitem=[% itemnumber %]&branchcode=[% homebranch %]&op=slip'); return true;">Print Slip</a> )</h3> > </div> > [% IF ( soundon ) %] > <audio src="/intranet-tmpl/prog/sound/opening.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio> >@@ -214,7 +217,7 @@ function Dopop(link) { > Transfer Now?<br /> > <form method="post" action="returns.pl" name="mainform" id="mainform"> > [% IF itemnumber %] >- <input type="submit" name="dotransfer" value="Yes, Print slip" class="print" onclick="Dopop('transfer-slip.pl?transferitem=[% itemnumber %]&&branchcode=[% homebranch %]&op=slip'); return true;" /> >+ <input type="submit" name="dotransfer" value="Yes, Print slip" class="print" onclick="doPopUp('/cgi-bin/koha/circ/transfer-slip.pl?transferitem=[% itemnumber %]&&branchcode=[% homebranch %]&op=slip'); return true;" /> > [% END %] > <input type="submit" name="dotransfer" value="Yes" class="submit" /> > <input type="submit" name="notransfer" value="No" class="submit" /> >@@ -289,10 +292,10 @@ function Dopop(link) { > <form method="post" action="returns.pl" class="confirm"> > [% IF ( transfertodo ) %] > <input type="submit" class="approve" value="Confirm hold and Transfer" /> >- <input type="submit" value="Print slip, Transfer, and Confirm" class="print" onclick="Dopop('hold-transfer-slip.pl?transfer=1&borrowernumber=[% borrowernumber %]&biblionumber=[% itembiblionumber %]&op=slip'); this.form.submit();" /> >+ <input type="submit" value="Print slip, Transfer, and Confirm" class="print" onclick="doDelayedPopUp('/cgi-bin/koha/circ/hold-transfer-slip.pl?transfer=1&borrowernumber=[% borrowernumber %]&biblionumber=[% itembiblionumber %]&op=slip'); this.form.submit();" /> > [% ELSE %] > <input type="submit" class="approve" value="Confirm hold" /> >- <input type="submit" value="Print Slip and Confirm" class="print" onclick="Dopop('hold-transfer-slip.pl?borrowernumber=[% borrowernumber %]&biblionumber=[% itembiblionumber %]&op=slip'); this.form.submit();" /> >+ <input type="submit" value="Print Slip and Confirm" class="print" onclick="doDelayedPopUp('/cgi-bin/koha/circ/hold-transfer-slip.pl?borrowernumber=[% borrowernumber %]&biblionumber=[% itembiblionumber %]&op=slip'); this.form.submit();" /> > [% END %] > <input type="submit" class="deny" value="Ignore" onclick="$('.dialog:visible').hide('slow'); $('#barcode').focus(); return false;" /> > [% FOREACH inputloo IN inputloop %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/delay-load.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/delay-load.tt >new file mode 100644 >index 0000000..7b93f54 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/delay-load.tt >@@ -0,0 +1,36 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha - Please Wait While Your Page Is Loaded</title> >+[% INCLUDE 'doc-head-close.inc' %] >+ >+</head> >+ >+<script type="text/javascript" language="javascript"> >+ >+function forwardToUrl() { >+ window.location.replace("[% url %]"); >+}; >+ >+$(document).ready(function() { >+ var i = [% delay %]; >+ var j = 0; >+ >+ while ( i > 0 ) { >+ setTimeout("document.getElementById('counter').innerHTML='" + i + "'", j * 1000 ); >+ i--; >+ j++; >+ } >+ >+ setTimeout("forwardToUrl()", [% delay %] * 1000 ); >+}); >+ >+</script> >+<body> >+ >+<div class="center" style="text-align:center"> >+ <p>[% message %]</p> >+ >+ <p><img src="/intranet-tmpl/prog/img/loading.gif" alt="Loading, Please Wait"/></p> >+ >+ <div id="counter"></div> >+</div> >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/tools/delay-load.pl b/tools/delay-load.pl >new file mode 100755 >index 0000000..b4d8f44 >--- /dev/null >+++ b/tools/delay-load.pl >@@ -0,0 +1,83 @@ >+#!/usr/bin/perl >+ >+# Copyright 2012 Bywater Solutions >+# >+# 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. >+ >+=pod >+ >+The purpose of this script is simply to >+delay the loading of another page. This is >+useful to ensure race conditions are avoided >+for items such as pop-up windows for printing >+slips. >+ >+This script accepts the following cgi parameters: >+url - The url to forward to >+message - An optional message to display during the delay >+delay - The amount of time in seconds the delay should last >+ >+A javascript function has been added to the staff functions js >+file to facility easy use of this script. Use the function as follows: >+ >+delayPopup( url, message, delay ); >+ >+where url is the url of the >+page to load ( supports GET variables ), message is an optional >+message to display, and delay is the amount of time in seconds >+to delay the loading of this new url. This function will automatically >+urlencode the passed url and message. If you use this script directly, >+you will need to urlencode your data manually. >+ >+=cut >+ >+use strict; >+use warnings; >+ >+use C4::Auth; >+use C4::Context; >+use C4::Output; >+use CGI; >+ >+use vars qw($debug); >+ >+BEGIN { >+ $debug = $ENV{DEBUG} || 0; >+} >+ >+my $input = new CGI; >+ >+my $url = $input->param('url'); >+my $message = $input->param('message'); >+my $delay = $input->param('delay'); >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "tools/delay-load.tmpl", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ debug => $debug, >+ } >+); >+ >+$template->param( >+ url => $url, >+ message => $message, >+ delay => $delay, >+); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7255
:
8767
|
8768
|
8769