3 # Script for testing progressbar, part 2 - json submit handler
6 # Koha library project www.koha-community.org
8 # Licensed under the GPL
10 # Copyright 2010 Catalyst IT, Ltd
12 # This file is part of Koha.
14 # Koha is free software; you can redistribute it and/or modify it
15 # under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 3 of the License, or
17 # (at your option) any later version.
19 # Koha is distributed in the hope that it will be useful, but
20 # WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with Koha; if not, see <http://www.gnu.org/licenses>.
30 # standard or CPAN modules used
38 use C4
::BackgroundJob
;
42 my $submitted=$input->param('submitted');
43 my $runinbackground = $input->param('runinbackground');
44 my $jobID = $input->param('jobID');
45 my $completedJobID = $input->param('completedJobID');
47 my ($template, $loggedinuser, $cookie)
48 = get_template_and_user
({template_name
=> "test/progressbar.tt",
54 my %cookies = parse CGI
::Cookie
($cookie);
55 my $sessionID = $cookies{'CGISESSID'}->value;
56 if ($completedJobID) {
57 } elsif ($submitted) {
59 if ($runinbackground) {
61 $job = C4
::BackgroundJob
->new($sessionID, undef, $ENV{'SCRIPT_NAME'}, $job_size);
67 # return job ID as JSON
69 # prevent parent exiting from
70 # destroying the kid's database handle
71 # FIXME: according to DBI doc, this may not work for Oracle
73 my $reply = CGI
->new("");
74 print $reply->header(-type
=> 'text/html');
75 print '{"jobID":"' . $jobID . '"}';
77 } elsif (defined $pid) {
78 # if we get here, we're a child that has detached
81 # close STDOUT to signal to Apache that
82 # we're now running in the background
92 # fork failed, so exit immediately
93 die "fork failed while attempting to run $ENV{'SCRIPT_NAME'} as a background job";
99 die "We should not be here";