4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
30 use C4::BackgroundJob;
35 use List::MoreUtils qw/uniq/;
37 use Koha::AuthorisedValues;
45 my $dbh = C4::Context->dbh;
46 my $error = $input->param('error');
47 my @itemnumbers = $input->multi_param('itemnumber');
48 my $biblionumber = $input->param('biblionumber');
49 my $op = $input->param('op');
50 my $del = $input->param('del');
51 my $del_records = $input->param('del_records');
52 my $completedJobID = $input->param('completedJobID');
53 my $runinbackground = $input->param('runinbackground');
54 my $src = $input->param('src');
55 my $use_default_values = $input->param('use_default_values');
60 $template_name = "tools/batchMod.tt";
61 $template_flag = { tools => '*' };
64 $template_name = ($del) ? "tools/batchMod-del.tt" : "tools/batchMod-edit.tt";
65 $template_flag = ($del) ? { tools => 'items_batchdel' } : { tools => 'items_batchmod' };
69 my ($template, $loggedinuser, $cookie)
70 = get_template_and_user({template_name => $template_name,
73 flagsrequired => $template_flag,
76 # Does the user have a restricted item edition permission?
77 my $uid = $loggedinuser ? Koha::Patrons->find( $loggedinuser )->userid : undef;
78 my $restrictededition = $uid ? haspermission($uid, {'tools' => 'items_batchmod_restricted'}) : undef;
79 # In case user is a superlibrarian, edition is not restricted
80 $restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian());
82 $template->param(del => $del);
86 my @errors; # store errors found while checking data BEFORE saving item.
87 my $items_display_hashref;
88 our $tagslib = &GetMarcStructure(1);
90 my $deleted_items = 0; # Number of deleted items
91 my $deleted_records = 0; # Number of deleted records ( with no items attached )
92 my $not_deleted_items = 0; # Number of items that could not be deleted
93 my @not_deleted; # List of the itemnumbers that could not be deleted
94 my $modified_items = 0; # Numbers of modified items
95 my $modified_fields = 0; # Numbers of modified fields
97 my %cookies = parse CGI::Cookie($cookie);
98 my $sessionID = $cookies{'CGISESSID'}->value;
101 #--- ----------------------------------------------------------------------------
102 if ($op eq "action") {
103 #-------------------------------------------------------------------------------
104 my @tags = $input->multi_param('tag');
105 my @subfields = $input->multi_param('subfield');
106 my @values = $input->multi_param('field_value');
107 my @disabled = $input->multi_param('disable_input');
108 # build indicator hash.
109 my @ind_tag = $input->multi_param('ind_tag');
110 my @indicator = $input->multi_param('indicator');
112 # Is there something to modify ?
113 # TODO : We shall use this var to warn the user in case no modification was done to the items
114 my $values_to_modify = scalar(grep {!/^$/} @values);
115 my $values_to_blank = scalar(@disabled);
118 # Once the job is done
119 if ($completedJobID) {
120 # If we have a reasonable amount of items, we display them
121 my $max_items = $del ? C4::Context->preference("MaxItemsToDisplayForBatchDel") : C4::Context->preference("MaxItemsToDisplayForBatchMod");
122 if (scalar(@itemnumbers) <= $max_items ){
123 if (scalar(@itemnumbers) <= 1000 ) {
124 $items_display_hashref=BuildItemsData(@itemnumbers);
126 # Else, we only display the barcode
127 my @simple_items_display = map {
129 my $item = Koha::Items->find($itemnumber);
131 itemnumber => $itemnumber,
132 barcode => $item ? ( $item->barcode // q{} ) : q{},
133 biblionumber => $item ? $item->biblio->biblionumber : q{},
136 $template->param("simple_items_display" => \@simple_items_display);
139 $template->param( "too_many_items_display" => scalar(@itemnumbers) );
140 $template->param( "job_completed" => 1 );
143 # Setting the job as done
144 my $job = C4::BackgroundJob->fetch($sessionID, $completedJobID);
146 # Calling the template
147 add_saved_job_results_to_template($template, $completedJobID);
150 # While the job is getting done
152 # Job size is the number of items we have to process
153 my $job_size = scalar(@itemnumbers);
156 # If we asked for background processing
157 if ($runinbackground) {
158 $job = put_in_background($job_size);
161 #initializing values for updates
162 my ( $itemtagfield, $itemtagsubfield) = &GetMarcFromKohaField("items.itemnumber", "");
163 if ($values_to_modify){
164 my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag, 'ITEM');
165 $marcitem = MARC::Record::new_from_xml($xml, 'UTF-8');
167 if ($values_to_blank){
168 foreach my $disabledsubf (@disabled){
169 if ($marcitem && $marcitem->field($itemtagfield)){
170 $marcitem->field($itemtagfield)->update( $disabledsubf => "" );
173 $marcitem = MARC::Record->new();
174 $marcitem->append_fields( MARC::Field->new( $itemtagfield, '', '', $disabledsubf => "" ) );
181 foreach my $itemnumber(@itemnumbers){
183 $job->progress($i) if $runinbackground;
184 my $itemdata = Koha::Items->find($itemnumber);
185 next unless $itemdata; # Should have been tested earlier, but just in case...
186 $itemdata = $itemdata->unblessed;
188 my $return = DelItemCheck( $itemdata->{'biblionumber'}, $itemdata->{'itemnumber'});
192 $not_deleted_items++;
194 { biblionumber => $itemdata->{'biblionumber'},
195 itemnumber => $itemdata->{'itemnumber'},
196 barcode => $itemdata->{'barcode'},
197 title => $itemdata->{'title'},
202 # If there are no items left, delete the biblio
204 my $itemscount = Koha::Biblios->find( $itemdata->{'biblionumber'} )->items->count;
205 if ( $itemscount == 0 ) {
206 my $error = DelBiblio( $itemdata->{'biblionumber'} );
209 if ( $src eq 'CATALOGUING' ) {
210 # We are coming catalogue/detail.pl, there were items from a single bib record
211 $template->param( biblio_deleted => 1 );
217 if ($values_to_modify || $values_to_blank) {
218 my $localmarcitem = Item2Marc($itemdata);
220 my $modified = UpdateMarcWith( $marcitem, $localmarcitem );
223 if ( my $item = ModItemFromMarc( $localmarcitem, $itemdata->{biblionumber}, $itemnumber ) ) {
224 LostItem($itemnumber, 'batchmod') if $item->{itemlost} and not $itemdata->{itemlost};
228 if ( $runinbackground ) {
229 $modified_items++ if $modified;
230 $modified_fields += $modified;
232 modified_items => $modified_items,
233 modified_fields => $modified_fields,
243 #-------------------------------------------------------------------------------
244 # build screen with existing items. and "new" one
245 #-------------------------------------------------------------------------------
248 my $filefh = $input->upload('uploadfile');
249 my $filecontent = $input->param('filecontent');
250 my ( @notfoundbarcodes, @notfounditemnumbers);
254 binmode $filefh, ':encoding(UTF-8)';
255 while (my $content=<$filefh>){
256 $content =~ s/[\r\n]*$//;
257 push @contentlist, $content if $content;
260 @contentlist = uniq @contentlist;
261 if ($filecontent eq 'barcode_file') {
262 my $existing_items = Koha::Items->search({ barcode => \@contentlist });
263 @itemnumbers = $existing_items->get_column('itemnumber');
264 my %exists = map {lc($_)=>1} $existing_items->get_column('barcode');
265 # to avoid problems with case sensitivity
266 foreach my $barcode (@contentlist) {
267 $barcode = lc($barcode);
269 @notfoundbarcodes = grep { !$exists{$_} } @contentlist;
271 elsif ( $filecontent eq 'itemid_file') {
272 @itemnumbers = Koha::Items->search({ itemnumber => \@contentlist })->get_column('itemnumber');
273 my %exists = map {$_=>1} @itemnumbers;
274 @notfounditemnumbers = grep { !$exists{$_} } @contentlist;
277 if (defined $biblionumber && !@itemnumbers){
278 my @all_items = GetItemsInfo( $biblionumber );
279 foreach my $itm (@all_items) {
280 push @itemnumbers, $itm->{itemnumber};
283 if ( my $list=$input->param('barcodelist')){
284 push my @barcodelist, uniq( split(/\s\n/, $list) );
286 my $existing_items = Koha::Items->search({ barcode => \@barcodelist });
287 @itemnumbers = $existing_items->get_column('itemnumber');
288 my @barcodes = $existing_items->get_column('barcode');
289 my %exists = map {lc($_)=>1} @barcodes;
290 # to avoid problems with case sensitivity
291 foreach my $barcode (@barcodelist) {
292 $barcode = lc($barcode);
294 @notfoundbarcodes = grep { !$exists{$_} } @barcodelist;
298 # Flag to tell the template there are valid results, hidden or not
299 if(scalar(@itemnumbers) > 0){ $template->param("itemresults" => 1); }
300 # Only display the items if there are no more than pref MaxItemsToProcessForBatchMod or MaxItemsToDisplayForBatchDel
301 my $max_display_items = $del
302 ? C4::Context->preference("MaxItemsToDisplayForBatchDel")
303 : C4::Context->preference("MaxItemsToDisplayForBatchMod");
304 $template->param("too_many_items_process" => scalar(@itemnumbers)) if !$del && scalar(@itemnumbers) >= C4::Context->preference("MaxItemsToProcessForBatchMod");
305 if (scalar(@itemnumbers) <= ( $max_display_items // 1000 ) ) {
306 $items_display_hashref=BuildItemsData(@itemnumbers);
308 $template->param("too_many_items_display" => scalar(@itemnumbers));
309 # Even if we do not display the items, we need the itemnumbers
310 $template->param(itemnumbers_array => \@itemnumbers);
312 # now, build the item form for entering a new item
315 my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
317 my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;# build once ahead of time, instead of multiple times later.
319 # Adding a default choice, in case the user does not want to modify the branch
320 my $nochange_branch = { branchname => '', value => '', selected => 1 };
321 unshift (@$libraries, $nochange_branch);
323 my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
325 # Getting list of subfields to keep when restricted batchmod edit is enabled
326 my $subfieldsToAllowForBatchmod = C4::Context->preference('SubfieldsToAllowForRestrictedBatchmod');
327 my $allowAllSubfields = (
328 not defined $subfieldsToAllowForBatchmod
329 or $subfieldsToAllowForBatchmod eq q||
331 my @subfieldsToAllow = split(/ /, $subfieldsToAllowForBatchmod);
333 foreach my $tag (sort keys %{$tagslib}) {
334 # loop through each subfield
335 foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
336 next if IsMarcStructureInternal( $tagslib->{$tag}{$subfield} );
337 next if (not $allowAllSubfields and $restrictededition && !grep { $tag . '$' . $subfield eq $_ } @subfieldsToAllow );
338 next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
339 # barcode and stocknumber are not meant to be batch-modified
340 next if $tagslib->{$tag}->{$subfield}->{'kohafield'} eq 'items.barcode';
341 next if $tagslib->{$tag}->{$subfield}->{'kohafield'} eq 'items.stocknumber';
344 my $index_subfield = int(rand(1000000));
345 if ($subfield eq '@'){
346 $subfield_data{id} = "tag_".$tag."_subfield_00_".$index_subfield;
348 $subfield_data{id} = "tag_".$tag."_subfield_".$subfield."_".$index_subfield;
350 $subfield_data{tag} = $tag;
351 $subfield_data{subfield} = $subfield;
352 $subfield_data{marc_lib} ="<span id=\"error$i\" title=\"".$tagslib->{$tag}->{$subfield}->{lib}."\">".$tagslib->{$tag}->{$subfield}->{lib}."</span>";
353 $subfield_data{mandatory} = $tagslib->{$tag}->{$subfield}->{mandatory};
354 $subfield_data{repeatable} = $tagslib->{$tag}->{$subfield}->{repeatable};
356 if ( $use_default_values) {
357 $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
358 # get today date & replace YYYY, MM, DD if provided in the default value
359 my $today = dt_from_string;
360 my $year = $today->year;
361 my $month = $today->month;
362 my $day = $today->day;
363 $value =~ s/YYYY/$year/g;
364 $value =~ s/MM/$month/g;
365 $value =~ s/DD/$day/g;
367 $subfield_data{visibility} = "display:none;" if (($tagslib->{$tag}->{$subfield}->{hidden} > 4) || ($tagslib->{$tag}->{$subfield}->{hidden} < -4));
368 # testing branch value if IndependentBranches.
370 if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
371 my @authorised_values;
373 # builds list, depending on authorised value...
375 if ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "branches" ) {
376 foreach my $library (@$libraries) {
377 push @authorised_values, $library->{branchcode};
378 $authorised_lib{$library->{branchcode}} = $library->{branchname};
382 elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
383 push @authorised_values, "";
384 my $itemtypes = Koha::ItemTypes->search_with_localization;
385 while ( my $itemtype = $itemtypes->next ) {
386 push @authorised_values, $itemtype->itemtype;
387 $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
393 elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "cn_source" ) {
394 push @authorised_values, "" unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
396 my $class_sources = GetClassSources();
397 my $default_source = C4::Context->preference("DefaultClassificationSource");
399 foreach my $class_source (sort keys %$class_sources) {
400 next unless $class_sources->{$class_source}->{'used'} or
401 ($value and $class_source eq $value) or
402 ($class_source eq $default_source);
403 push @authorised_values, $class_source;
404 $authorised_lib{$class_source} = $class_sources->{$class_source}->{'description'};
408 #---- "true" authorised value
411 push @authorised_values, ""; # unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
413 my @avs = Koha::AuthorisedValues->search({ category => $tagslib->{$tag}->{$subfield}->{authorised_value}, branchcode => $branch_limit },{order_by=>'lib'});
414 for my $av ( @avs ) {
415 push @authorised_values, $av->authorised_value;
416 $authorised_lib{$av->authorised_value} = $av->lib;
420 $subfield_data{marc_value} = {
422 id => "tag_".$tag."_subfield_".$subfield."_".$index_subfield,
423 name => "field_value",
424 values => \@authorised_values,
425 labels => \%authorised_lib,
428 # it's a thesaurus / authority field
430 elsif ( $tagslib->{$tag}->{$subfield}->{authtypecode} ) {
431 $subfield_data{marc_value} = {
433 id => $subfield_data{id},
435 authtypecode => $tagslib->{$tag}->{$subfield}->{authtypecode},
438 elsif ( $tagslib->{$tag}->{$subfield}->{value_builder} ) { # plugin
439 require Koha::FrameworkPlugin;
440 my $plugin = Koha::FrameworkPlugin->new( {
441 name => $tagslib->{$tag}->{$subfield}->{'value_builder'},
445 my $pars= { dbh => $dbh, record => $temp, tagslib => $tagslib,
446 id => $subfield_data{id}, tabloop => \@loop_data };
447 $plugin->build( $pars );
448 if( !$plugin->errstr ) {
449 $subfield_data{marc_value} = {
451 id => $subfield_data{id},
453 javascript => $plugin->javascript,
454 noclick => $plugin->noclick,
457 warn $plugin->errstr;
458 $subfield_data{marc_value} = { # supply default input form
460 id => $subfield_data{id},
465 elsif ( $tag eq '' ) { # it's an hidden field
466 $subfield_data{marc_value} = {
468 id => $subfield_data{id},
472 elsif ( $tagslib->{$tag}->{$subfield}->{'hidden'} ) { # FIXME: shouldn't input type be "hidden" ?
473 $subfield_data{marc_value} = {
475 id => $subfield_data{id},
479 elsif ( length($value) > 100
480 or (C4::Context->preference("marcflavour") eq "UNIMARC" and
481 300 <= $tag && $tag < 400 && $subfield eq 'a' )
482 or (C4::Context->preference("marcflavour") eq "MARC21" and
483 500 <= $tag && $tag < 600 )
485 # oversize field (textarea)
486 $subfield_data{marc_value} = {
488 id => $subfield_data{id},
492 # it's a standard field
493 $subfield_data{marc_value} = {
495 id => $subfield_data{id},
499 # $subfield_data{marc_value}="<input type=\"text\" name=\"field_value\">";
500 push (@loop_data, \%subfield_data);
503 } # -- End foreach tag
507 # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
510 notfoundbarcodes => \@notfoundbarcodes,
511 notfounditemnumbers => \@notfounditemnumbers
514 } # -- End action="show"
516 $template->param(%$items_display_hashref) if $items_display_hashref;
520 $template->param( $op => 1 ) if $op;
522 if ($op eq "action") {
524 #my @not_deleted_loop = map{{itemnumber=>$_}}@not_deleted;
527 not_deleted_items => $not_deleted_items,
528 deleted_items => $deleted_items,
529 delete_records => $del_records,
530 deleted_records => $deleted_records,
531 not_deleted_loop => \@not_deleted
535 foreach my $error (@errors) {
536 $template->param($error => 1) if $error;
538 $template->param(src => $src);
539 $template->param(biblionumber => $biblionumber);
540 output_html_with_http_headers $input, $cookie, $template->output;
544 # ---------------- Functions
548 # now, build existiing item list
549 my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code
551 #---- finds where items.itemnumber is stored
552 my ( $itemtagfield, $itemtagsubfield) = &GetMarcFromKohaField("items.itemnumber", "");
553 my ($branchtagfield, $branchtagsubfield) = &GetMarcFromKohaField("items.homebranch", "");
554 foreach my $itemnumber (@itemnumbers){
555 my $itemdata = Koha::Items->find($itemnumber);
556 next unless $itemdata; # Should have been tested earlier, but just in case...
557 $itemdata = $itemdata->unblessed;
558 my $itemmarc=Item2Marc($itemdata);
560 foreach my $field (grep {$_->tag() eq $itemtagfield} $itemmarc->fields()) {
561 # loop through each subfield
562 my $itembranchcode=$field->subfield($branchtagsubfield);
563 if ($itembranchcode && C4::Context->preference("IndependentBranches")) {
565 my $userenv = C4::Context->userenv();
566 unless (C4::Context->IsSuperLibrarian() or (($userenv->{'branch'} eq $itembranchcode))){
567 $this_row{'nomod'}=1;
570 my $tag=$field->tag();
571 foreach my $subfield ($field->subfields) {
572 my ($subfcode,$subfvalue)=@$subfield;
573 next if ($tagslib->{$tag}->{$subfcode}->{tab} ne 10
574 && $tag ne $itemtagfield
575 && $subfcode ne $itemtagsubfield);
577 $witness{$subfcode} = $tagslib->{$tag}->{$subfcode}->{lib} if ($tagslib->{$tag}->{$subfcode}->{tab} eq 10);
578 if ($tagslib->{$tag}->{$subfcode}->{tab} eq 10) {
579 $this_row{$subfcode}=GetAuthorisedValueDesc( $tag,
580 $subfcode, $subfvalue, '', $tagslib)
584 $this_row{itemnumber} = $subfvalue if ($tag eq $itemtagfield && $subfcode eq $itemtagsubfield);
588 # grab title, author, and ISBN to identify bib that the item
589 # belongs to in the display
590 my $biblio = Koha::Biblios->find( $itemdata->{biblionumber} );
591 $this_row{title} = $biblio->title;
592 $this_row{author} = $biblio->author;
593 $this_row{isbn} = $biblio->biblioitem->isbn;
594 $this_row{biblionumber} = $biblio->biblionumber;
595 $this_row{holds} = $biblio->holds->count;
596 $this_row{item_holds} = Koha::Holds->search( { itemnumber => $itemnumber } )->count;
599 push(@big_array, \%this_row);
602 @big_array = sort {$a->{0} cmp $b->{0}} @big_array;
604 # now, construct template !
605 # First, the existing items for display
607 my @witnesscodessorted=sort keys %witness;
608 for my $row ( @big_array ) {
610 my @item_fields = map +{ field => $_ || '' }, @$row{ @witnesscodessorted };
611 $row_data{item_value} = [ @item_fields ];
612 $row_data{itemnumber} = $row->{itemnumber};
613 #reporting this_row values
614 $row_data{'nomod'} = $row->{'nomod'};
615 $row_data{bibinfo} = $row->{bibinfo};
616 $row_data{author} = $row->{author};
617 $row_data{title} = $row->{title};
618 $row_data{isbn} = $row->{isbn};
619 $row_data{biblionumber} = $row->{biblionumber};
620 $row_data{holds} = $row->{holds};
621 $row_data{item_holds} = $row->{item_holds};
622 my $is_on_loan = C4::Circulation::IsItemIssued( $row->{itemnumber} );
623 $row_data{onloan} = $is_on_loan ? 1 : 0;
624 push(@item_value_loop,\%row_data);
626 my @header_loop=map { { header_value=> $witness{$_}} } @witnesscodessorted;
628 return { item_loop => \@item_value_loop, item_header_loop => \@header_loop };
631 #BE WARN : it is not the general case
632 # This function can be OK in the item marc record special case
633 # Where subfield is not repeated
634 # And where we are sure that field should correspond
637 my ($marcfrom,$marcto)=@_;
638 my ( $itemtag, $itemtagsubfield) = &GetMarcFromKohaField("items.itemnumber", "");
639 my $fieldfrom=$marcfrom->field($itemtag);
640 my @fields_to=$marcto->field($itemtag);
642 foreach my $subfield ( $fieldfrom->subfields() ) {
643 foreach my $field_to_update ( @fields_to ) {
644 if ( $subfield->[1] ) {
645 unless ( $field_to_update->subfield($subfield->[0]) eq $subfield->[1] ) {
647 $field_to_update->update( $subfield->[0] => $subfield->[1] );
652 $field_to_update->delete_subfield( code => $subfield->[0] );
660 my ($tagfield,$insubfield,$record) = @_;
663 foreach my $field ($record->field($tagfield)) {
664 my @subfields = $field->subfields();
665 foreach my $subfield (@subfields) {
666 if (@$subfield[0] eq $insubfield) {
667 $result .= @$subfield[1];
668 $indicator = $field->indicator(1).$field->indicator(2);
672 return($indicator,$result);
675 # ----------------------------
676 # Background functions
679 sub add_results_to_template {
680 my $template = shift;
682 $template->param(map { $_ => $results->{$_} } keys %{ $results });
685 sub add_saved_job_results_to_template {
686 my $template = shift;
687 my $completedJobID = shift;
688 my $job = C4::BackgroundJob->fetch($sessionID, $completedJobID);
689 my $results = $job->results();
690 add_results_to_template($template, $results);
692 my $fields = $job->get("modified_fields");
693 my $items = $job->get("modified_items");
695 modified_items => $items,
696 modified_fields => $fields,
700 sub put_in_background {
701 my $job_size = shift;
703 my $job = C4::BackgroundJob->new($sessionID, "test", '/cgi-bin/koha/tools/batchMod.pl', $job_size);
704 my $jobID = $job->id();
707 if (my $pid = fork) {
709 # return job ID as JSON
711 # prevent parent exiting from
712 # destroying the kid's database handle
713 # FIXME: according to DBI doc, this may not work for Oracle
714 $dbh->{InactiveDestroy} = 1;
716 my $reply = CGI->new("");
717 print $reply->header(-type => 'text/html');
718 print '{"jobID":"' . $jobID . '"}';
720 } elsif (defined $pid) {
722 # close STDOUT to signal to Apache that
723 # we're now running in the background
727 # fork failed, so exit immediately
728 warn "fork failed while attempting to run tools/batchMod.pl as a background job";