User can upload a file with barcodes or with itemnumbers

This commit is contained in:
Matthias Meusburger 2009-09-14 15:56:13 +02:00 committed by Henri-Damien LAURENT
parent 0659caf40f
commit fb4366cdad
2 changed files with 34 additions and 19 deletions

View file

@ -25,9 +25,13 @@
<!-- TMPL_UNLESS name="op" -->
<form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batchMod.pl">
<fieldset class="rows">
<legend>Use a barcode file</legend>
<legend>Use a file</legend>
<ol>
<li><label for="uploadbarcodes">Barcode file: </label> <input type="file" id="uploadbarcodes" name="uploadbarcodes"></input></li>
<li>
<label for="barcode_file">Barcodes file</label><input type="radio" name="filecontent" value="barcode_file" id="barcode_file" checked="checked" /><br />
<label for="itemid_file">Item Id's file</label><input type="radio" name="filecontent" value="itemid_file" id="itemid_file" />
</li>
<li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile"></input></li>
</ol>
</fieldset>
<fieldset class="rows">
@ -35,7 +39,7 @@
<ol>
<li>
<label for="barcodelist">Barcodes list (one barcode per line): </label>
<textarea rows="10" cols="30" name="barcodelist"></textarea>
<textarea rows="10" cols="30" id="barcodelist" name="barcodelist"></textarea>
</li>
</ol>
</fieldset>

View file

@ -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;
}
}
if ( my $list=$input->param('barcodelist')){
push @barcodelist, split(/\s\n/, $list);
}
push @itemnumbers,map{GetItemnumberFromBarcode($_)} @barcodelist;
my $filefh = $input->upload('uploadfile');
my $filecontent = $input->{'filecontent'};
warn Dump(@itemnumbers);
my @contentlist;
if ($filefh){
while (my $content=<$filefh>){
chomp $content;
push @contentlist, $content;
}
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;
}