From 4dd2086deb6da3079f17ff38c033f47d92b50a25 Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Wed, 10 Mar 2010 22:26:14 +0100 Subject: [PATCH] MT 2269 : Do not display all the items if there is a large amount of items Also fix the barcode not found problem (due to empty lines) Signed-off-by: Henri-Damien LAURENT Signed-off-by: Galen Charlton --- C4/Biblio.pm | 19 +++++++++++ C4/Items.pm | 22 ++++++++++++ .../prog/en/modules/tools/batchMod-del.tmpl | 34 +++++++++++++++---- .../prog/en/modules/tools/batchMod-edit.tmpl | 25 +++++++++++++- tools/batchMod.pl | 21 +++++++++--- 5 files changed, 110 insertions(+), 11 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index e24bee893e..91e9027679 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -58,6 +58,7 @@ BEGIN { &GetBiblioItemInfosOf &GetBiblioItemByBiblioNumber &GetBiblioFromItemNumber + &GetBiblionumberFromItemnumber &GetRecordValue &GetFieldMapping @@ -716,6 +717,24 @@ sub GetBiblioItemByBiblioNumber { return @results; } +=head2 GetBiblionumberFromItemnumber + +=over 4 + +=back + +=cut + +sub GetBiblionumberFromItemnumber { + my ($itemnumber) = @_; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("Select biblionumber FROM items WHERE itemnumber = ?"); + + $sth->execute($itemnumber); + my ($result) = $sth->fetchrow; + return ($result); +} + =head2 GetBiblioFromItemNumber =over 4 diff --git a/C4/Items.pm b/C4/Items.pm index 7f31cdc745..3b2e620b90 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -66,6 +66,7 @@ BEGIN { GetItemsInfo get_itemnumbers_of GetItemnumberFromBarcode + GetBarcodeFromItemnumber DelItemCheck MoveItemFromBiblio @@ -1517,6 +1518,27 @@ sub GetItemnumberFromBarcode { return ($result); } +=head2 GetBarcodeFromItemnumber + +=over 4 + +$result = GetBarcodeFromItemnumber($itemnumber); + +=back + +=cut + +sub GetBarcodeFromItemnumber { + my ($itemnumber) = @_; + my $dbh = C4::Context->dbh; + + my $rq = + $dbh->prepare("SELECT barcode FROM items WHERE items.itemnumber=?"); + $rq->execute($itemnumber); + my ($result) = $rq->fetchrow; + return ($result); +} + =head3 get_item_authorised_values find the types and values for all authorised values assigned to this item. 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 7e7b98bbf0..1ba9b24f2f 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 @@ -30,7 +30,6 @@
Cannot Delete: item is checked out.
Cannot Delete: item has a waiting hold.
- @@ -47,11 +46,14 @@ +

The following barcodes were found :

+ -
+ +
@@ -72,10 +74,33 @@
+ + + +
    + +
  • + "> +
  • + +
+ + + + + + +

Too many items (): not displaying each one individually.

+ + " /> + + + +
" /> -

This will delete the selected items.

+

This will delete all thethe selected items.

@@ -83,9 +108,6 @@
- -

No item found

-

item(s) deleted.

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 40640cc846..acc9e12791 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 @@ -44,11 +44,13 @@ +

The following barcodes were found :

+ - +
@@ -71,7 +73,28 @@
+ + + +

The following items were modified:

+ + + + + +

Too many items (): not displaying each one individually.

+ + " /> + + +
" />

Edit Items

diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 6c3caf8382..f7e9557ef1 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -90,7 +90,6 @@ if ($op eq "action") { my $xml = TransformHtmlToXml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag, 'ITEM'); my $marcitem = MARC::Record::new_from_xml($xml, 'UTF-8'); my $localitem = TransformMarcToKoha( $dbh, $marcitem, "", 'items' ); - foreach my $itemnumber(@itemnumbers){ my $itemdata=GetItem($itemnumber); if ($input->param("del")){ @@ -107,7 +106,14 @@ if ($op eq "action") { eval{my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = ModItemFromMarc($localmarcitem,$itemdata->{biblionumber},$itemnumber)}; } } - $items_display_hashref=BuildItemsData(@itemnumbers); + # If we have a reasonable amount of items, we display them + if (scalar(@itemnumbers) <= 1000) { + $items_display_hashref=BuildItemsData(@itemnumbers); + } else { + # Else, we only display the barcode + my @simple_items_display = map {{ itemnumber => $_, barcode => GetBarcodeFromItemnumber($_), biblionumber => GetBiblionumberFromItemnumber($_) }} @itemnumbers; + $template->param("simple_items_display" => \@simple_items_display); + } } # @@ -124,7 +130,7 @@ if ($op eq "show"){ if ($filefh){ while (my $content=<$filefh>){ chomp $content; - push @contentlist, $content; + push @contentlist, $content if $content; } switch ($filecontent) { @@ -161,8 +167,15 @@ if ($op eq "show"){ } } + # Only display the items if there are no more than 1000 + if (scalar(@itemnumbers) <= 1000) { $items_display_hashref=BuildItemsData(@itemnumbers); - + } else { + $template->param("too_many_items" => scalar(@itemnumbers)); + # Even if we do not display the items, we need the itemnumbers + my @itemnumbers_hashref = map {{itemnumber => $_}} @itemnumbers; + $template->param("itemnumbers_hashref" => \@itemnumbers_hashref); + } # now, build the item form for entering a new item my @loop_data =(); my $i=0; -- 2.39.5