From 17bfed2b8d098348a48c3e1e31c490c4c0ef2156 Mon Sep 17 00:00:00 2001 From: Kyle M Hall 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 | 9 ++- .../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, 139 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..013b7f9 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,11 @@ 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; + 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' %] + + +
+

[% message %]

+ +

Loading, Please Wait

+ +
+
+[% 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