From 955378882447c45ae43c69dd1aead8ebc9e38ede Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Mon, 26 Oct 2009 14:40:39 +0100 Subject: [PATCH] MT 2071, 2072 : Check that barcodes are found and that items are allowed to be deleted --- .../prog/en/modules/tools/batchMod-del.tmpl | 52 ++++++++++++++-- .../prog/en/modules/tools/batchMod-edit.tmpl | 62 ++++++------------- tools/batchMod.pl | 37 ++++++++--- 3 files changed, 92 insertions(+), 59 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl index abc3a73e83..99b817a21d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl @@ -25,10 +25,6 @@
- show :
- action :
- results :
- nextop :

Batch deletion

Error saving item: Barcode must be unique.
Error saving items: Unable to automatically determine values for barcodes. No item has been inserted.
@@ -37,6 +33,25 @@ + + +

Warning, the following barcodes were not found :

+ + + + + + + + + + + +
Barcode
+

The following barcodes were found :

+ + +
@@ -59,7 +74,7 @@
-
+
" />

This will delete the selected items.

@@ -75,7 +90,32 @@

item(s) deleted.

-

item(s) could not be deleted :

+ +

item(s) could not be deleted :

+ + + + + + + + + + + + + + + + + + + +
ItemnumberBarcodeReason
Item is checked outItem has a waiting hold
+ + + +

Back

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tmpl index ed46561864..077d5653d3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tmpl @@ -18,52 +18,36 @@
-

Batch deletionmodification

- - -
- Use a file -
    -
  1. -
    - -
  2. -
  3. -
-
-
- Or scan items one-by-one -
    -
  1. - - -
  2. -
-
- - -
- -
- -
- +

Batch modification

Error saving item: Barcode must be unique.
Error saving items: Unable to automatically determine values for barcodes. No item has been inserted.
Cannot Delete: item is checked out.
Cannot Delete: item has a waiting hold.
+ +

Warning, the following barcodes were not found :

+ + + + + + + + + + + +
Barcode
+

The following barcodes were found :

+ +
@@ -89,10 +73,6 @@
" /> - -

This will delete the selected items.

- -

Edit Items

    @@ -115,19 +95,13 @@
-
- -

item(s) deleted.

-

item(s) could not be deleted.

-

No results!

Go back -
diff --git a/tools/batchMod.pl b/tools/batchMod.pl index b2a71d4008..791d2505c6 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -94,7 +94,7 @@ if ($op eq "action") { $deleted_items++; } else { $not_deleted_items++; - push @not_deleted, $itemdata->{'itemnumber'}; + push @not_deleted, { itemnumber => $itemdata->{'itemnumber'}, barcode => $itemdata->{'barcode'}, title => $itemdata->{'title'}, $return => 1 }; } } else { my $localmarcitem=Item2Marc($itemdata); @@ -113,6 +113,7 @@ if ($op eq "action") { if ($op eq "show"){ my $filefh = $input->upload('uploadfile'); my $filecontent = $input->param('filecontent'); + my @notfoundbarcodes; my @contentlist; if ($filefh){ @@ -123,9 +124,16 @@ if ($op eq "show"){ switch ($filecontent) { case "barcode_file" { - push @itemnumbers,map{GetItemnumberFromBarcode($_)} @contentlist; - # Remove not found barcodes - @itemnumbers = grep(!/^$/, @itemnumbers); + foreach my $barcode (@contentlist) { + + my $itemnumber = GetItemnumberFromBarcode($barcode); + if ($itemnumber) { + push @itemnumbers,$itemnumber; + } else { + push @notfoundbarcodes, $barcode; + } + } + } case "itemid_file" { @@ -135,9 +143,16 @@ if ($op eq "show"){ } else { if ( my $list=$input->param('barcodelist')){ push my @barcodelist, split(/\s\n/, $list); - push @itemnumbers,map{GetItemnumberFromBarcode($_)} @barcodelist; - # Remove not found barcodes - @itemnumbers = grep(!/^$/, @itemnumbers); + + foreach my $barcode (@barcodelist) { + + my $itemnumber = GetItemnumberFromBarcode($barcode); + if ($itemnumber) { + push @itemnumbers,$itemnumber; + } else { + push @notfoundbarcodes, $barcode; + } + } } } @@ -300,6 +315,10 @@ foreach my $tag (sort keys %{$tagslib}) { # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit. $template->param(item => \@loop_data); + if (@notfoundbarcodes) { + my @notfoundbarcodesloop = map{{barcode=>$_}}@notfoundbarcodes; + $template->param(notfoundbarcodes => \@notfoundbarcodesloop); + } $nextop="action" } # -- End action="show" @@ -311,12 +330,12 @@ $template->param( if ($op eq "action") { - my @not_deleted_loop = map{{itemnumber=>$_}}@not_deleted; + #my @not_deleted_loop = map{{itemnumber=>$_}}@not_deleted; $template->param( not_deleted_items => $not_deleted_items, deleted_items => $deleted_items, - not_deleted_itemnumbers => \@not_deleted_loop + not_deleted_loop => \@not_deleted ); } -- 2.39.5