|
Lines 69-74
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Link Here
|
| 69 |
} |
69 |
} |
| 70 |
); |
70 |
); |
| 71 |
|
71 |
|
|
|
72 |
#NOTE: Turn off buffering so that keep alives go out ASAP |
| 73 |
$|++; |
| 74 |
my $keep_alive_start = time(); |
| 75 |
|
| 76 |
if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){ |
| 77 |
binmode STDOUT, ":encoding(UTF-8)"; |
| 78 |
print $input->header( |
| 79 |
-type => 'text/csv', |
| 80 |
-attachment => 'inventory.csv', |
| 81 |
); |
| 82 |
} |
| 83 |
else { |
| 84 |
output_html_with_http_headers $input, $cookie, ''; |
| 85 |
} |
| 86 |
|
| 72 |
my @authorised_value_list; |
87 |
my @authorised_value_list; |
| 73 |
my $authorisedvalue_categories = ''; |
88 |
my $authorisedvalue_categories = ''; |
| 74 |
|
89 |
|
|
Lines 192-197
if ( ($uploadbarcodes && length($uploadbarcodes) > 0) || ($barcodelist && length
Link Here
|
| 192 |
$uploadbarcodes = $barcodelist; |
207 |
$uploadbarcodes = $barcodelist; |
| 193 |
} |
208 |
} |
| 194 |
for my $barcode (@uploadedbarcodes) { |
209 |
for my $barcode (@uploadedbarcodes) { |
|
|
210 |
keep_alive(); |
| 195 |
next unless $barcode; |
211 |
next unless $barcode; |
| 196 |
|
212 |
|
| 197 |
$barcode = barcodedecode($barcode); |
213 |
$barcode = barcodedecode($barcode); |
|
Lines 219-224
if ( ($uploadbarcodes && length($uploadbarcodes) > 0) || ($barcodelist && length
Link Here
|
| 219 |
err_data => $err_data ); |
235 |
err_data => $err_data ); |
| 220 |
} |
236 |
} |
| 221 |
foreach my $barcode (@barcodes) { |
237 |
foreach my $barcode (@barcodes) { |
|
|
238 |
keep_alive(); |
| 222 |
if ( $qwithdrawn->execute($barcode) && $qwithdrawn->rows ) { |
239 |
if ( $qwithdrawn->execute($barcode) && $qwithdrawn->rows ) { |
| 223 |
push @errorloop, { 'barcode' => $barcode, 'ERR_WTHDRAWN' => 1 }; |
240 |
push @errorloop, { 'barcode' => $barcode, 'ERR_WTHDRAWN' => 1 }; |
| 224 |
} else { |
241 |
} else { |
|
Lines 299-304
if( @scanned_items ) {
Link Here
|
| 299 |
# Report scanned items that are on the wrong place, or have a wrong notforloan |
316 |
# Report scanned items that are on the wrong place, or have a wrong notforloan |
| 300 |
# status, or are still checked out. |
317 |
# status, or are still checked out. |
| 301 |
for ( my $i = 0; $i < @scanned_items; $i++ ) { |
318 |
for ( my $i = 0; $i < @scanned_items; $i++ ) { |
|
|
319 |
keep_alive(); |
| 302 |
|
320 |
|
| 303 |
my $item = $scanned_items[$i]; |
321 |
my $item = $scanned_items[$i]; |
| 304 |
|
322 |
|
|
Lines 387-397
if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){
Link Here
|
| 387 |
eval {use Text::CSV ();}; |
405 |
eval {use Text::CSV ();}; |
| 388 |
my $csv = Text::CSV->new or |
406 |
my $csv = Text::CSV->new or |
| 389 |
die Text::CSV->error_diag (); |
407 |
die Text::CSV->error_diag (); |
| 390 |
binmode STDOUT, ":encoding(UTF-8)"; |
|
|
| 391 |
print $input->header( |
| 392 |
-type => 'text/csv', |
| 393 |
-attachment => 'inventory.csv', |
| 394 |
); |
| 395 |
|
408 |
|
| 396 |
my $columns = Koha::Database::Columns->columns; |
409 |
my $columns = Koha::Database::Columns->columns; |
| 397 |
my @translated_keys; |
410 |
my @translated_keys; |
|
Lines 448-454
if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){
Link Here
|
| 448 |
exit; |
461 |
exit; |
| 449 |
} |
462 |
} |
| 450 |
|
463 |
|
| 451 |
output_html_with_http_headers $input, $cookie, $template->output; |
464 |
#NOTE: This is a workaround until we can refactor inventory to run in the background |
|
|
465 |
#NOTE: Output headers earlier so that we can send data out progressively to keep alive |
| 466 |
#long running operations |
| 467 |
#output_html_with_http_headers $input, $cookie, $template->output; |
| 468 |
my $data = $template->output; |
| 469 |
$data =~ s/\&\;amp\; /\&\; /g; |
| 470 |
print $data; |
| 452 |
|
471 |
|
| 453 |
sub additemtoresults { |
472 |
sub additemtoresults { |
| 454 |
my ( $item, $results ) = @_; |
473 |
my ( $item, $results ) = @_; |
|
Lines 456-458
sub additemtoresults {
Link Here
|
| 456 |
# since the script appends to $item, we can just overwrite the hash entry |
475 |
# since the script appends to $item, we can just overwrite the hash entry |
| 457 |
$results->{$itemno} = $item; |
476 |
$results->{$itemno} = $item; |
| 458 |
} |
477 |
} |
| 459 |
- |
478 |
|
|
|
479 |
#NOTE: Print data to client so proxies don't time out |
| 480 |
sub keep_alive { |
| 481 |
my $current_time = time(); |
| 482 |
my $elapsed = $current_time - $keep_alive_start; |
| 483 |
#Only print a keep alive once every 5 seconds |
| 484 |
if ( $elapsed >= 5 ){ |
| 485 |
print chr(0); |
| 486 |
#Reset variable for comparing time elapsed |
| 487 |
$keep_alive_start = $current_time; |
| 488 |
} |
| 489 |
} |