From fb4366cdad0ad96d0427810581763dc2fc189af1 Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Mon, 14 Sep 2009 15:56:13 +0200 Subject: [PATCH] User can upload a file with barcodes or with itemnumbers --- .../prog/en/modules/tools/batchMod.tmpl | 10 +++-- tools/batchMod.pl | 41 ++++++++++++------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod.tmpl index f339437497..9cee451472 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod.tmpl @@ -25,9 +25,13 @@
- Use a barcode file + Use a file
    -
  1. +
  2. +
    + +
  3. +
@@ -35,7 +39,7 @@
  1. - +
diff --git a/tools/batchMod.pl b/tools/batchMod.pl index e6e22703fa..d97921edcd 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -31,6 +31,7 @@ use C4::ClassSource; use C4::Dates; use C4::Debug; use YAML; +use Switch; use MARC::File::XML; sub find_value { @@ -112,22 +113,32 @@ if ($op eq "action") { #------------------------------------------------------------------------------- if ($op eq "show"){ - my $barcodefh = $input->upload('uploadbarcodes'); - my @barcodelist; - if ( $barcodefh){ - while (my $barcode=<$barcodefh>){ - chomp $barcode; - push @barcodelist, $barcode; + my $filefh = $input->upload('uploadfile'); + my $filecontent = $input->{'filecontent'}; + + my @contentlist; + if ($filefh){ + while (my $content=<$filefh>){ + chomp $content; + push @contentlist, $content; } - } - if ( my $list=$input->param('barcodelist')){ - push @barcodelist, split(/\s\n/, $list); - } - push @itemnumbers,map{GetItemnumberFromBarcode($_)} @barcodelist; - warn Dump(@itemnumbers); + switch ($filecontent) { + case "barcode_file" { + push @itemnumbers,map{GetItemnumberFromBarcode($_)} @contentlist; + } + + case "itemid_file" { + @itemnumbers = @contentlist; + } + } + } else { + if ( my $list=$input->param('barcodelist')){ + push my @barcodelist, split(/\s\n/, $list); + push @itemnumbers,map{GetItemnumberFromBarcode($_)} @barcodelist; + } +} $items_display_hashref=BuildItemsData(@itemnumbers); - warn Dump($items_display_hashref); # now, build the item form for entering a new item my @loop_data =(); @@ -370,7 +381,7 @@ sub BuildItemsData{ # And $tag>10 sub UpdateMarcWith($$){ my ($marcfrom,$marcto)=@_; - warn "FROM :",$marcfrom->as_formatted; + #warn "FROM :",$marcfrom->as_formatted; my ( $itemtag, $itemtagsubfield) = &GetMarcFromKohaField("items.itemnumber", ""); my $fieldfrom=$marcfrom->field($itemtag); my @fields_to=$marcto->field($itemtag); @@ -379,5 +390,5 @@ sub UpdateMarcWith($$){ $field_to_update->update($$subfield[0]=>$$subfield[1]) if ($$subfield[1]); } } - warn "TO edited:",$marcto->as_formatted; + #warn "TO edited:",$marcto->as_formatted; } -- 2.39.2